/*
 * v7 buttons, style B "Spring" (Esslam picked "b", 21 Nov 2026; design/decisions.md, "Button options").
 * One file for every button on the site. It is linked LAST in base.html and maps the existing classes
 * (.btn, -gold, -outline, -ghost, -danger, -sm, -lg, .btn--ghost, .btn--soft, .btn--big, .btn--join, .btn--signin)
 * to the B look, so the template call sites stay as they are.
 * A soft pill with a round arrow tile. Hover and press are springs from Motion (js/v7/buttons.js);
 * Flat: no drop shadow, no gold hover, no pulse ring (Esslam, 21 Nov 2026: "I don't like the gold depth effect on the buttons remove it").
 * with no script, plain CSS hover still works. Reduced motion: no movement at all.
 * Arabic first: logical properties; --dir (shell.css) flips the arrow and the slide.
 * Look to port: .work/ui-audit-21nov/buttons/css/b.css. Colours are tokens only.
 */

/* --- base: size set by three numbers, colours by four variables --- */
.btn {
  --bg: var(--color-ground); --ink: var(--color-on-ground);
  --chipbg: var(--color-on-ground); --chipink: var(--color-ground);
  --tile: 42px; --ps: 26px; --pe: 8px; --gap: 16px; --rs: calc(var(--tile) + var(--gap));
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--gap);
  /* --rs is the room kept free at the end for the tile, so the label can never run under it (fix 5, H1) */
  min-height: 58px; padding-block: 0; padding-inline: var(--ps) calc(var(--pe) + var(--rs));
  border: 0; border-radius: 999px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: var(--text-label); font-weight: 600; line-height: 1.1; letter-spacing: var(--tracking-label);
  text-decoration: none; cursor: pointer; transform-origin: 50% 50%;
  transition: background-color 180ms var(--ease-out);
}
.btn:hover, .btn:focus-visible { color: var(--ink); }
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }

/* the arrow tile: ::after is the circle, ::before is the arrow drawn on it (mask); both slide on hover.
   Both are pinned to the end edge, so a full-width button keeps the arrow inside its circle (fix 5, H1) */
.btn:not(.btn-ghost, :has(> svg))::after {
  content: ''; position: absolute; inset-inline-end: var(--pe); inset-block: 0; margin-block: auto;
  inline-size: var(--tile); block-size: var(--tile); border-radius: 50%; pointer-events: none;
  background: var(--chipbg); transition: transform 520ms var(--spring);
}
.btn:not(.btn-ghost, :has(> svg))::before {
  --arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10h14M11 4l6 6-6 6'/%3E%3C/svg%3E");
  content: ''; position: absolute; inset-inline-end: var(--pe); inset-block: 0; margin-block: auto;
  inline-size: var(--tile); block-size: var(--tile); z-index: 1; background: var(--chipink);
  -webkit-mask: var(--arrow) center / 20px 20px no-repeat; mask: var(--arrow) center / 20px 20px no-repeat;
  transform: scaleX(var(--dir)); transition: transform 520ms var(--spring); pointer-events: none;
}
.btn:not(:disabled, .disabled, [aria-disabled='true']):hover:not(.btn-ghost, :has(> svg))::after { transform: translateX(calc(4px * var(--dir))); }
.btn:not(:disabled, .disabled, [aria-disabled='true']):hover:not(.btn-ghost, :has(> svg))::before { transform: translateX(calc(4px * var(--dir))) scaleX(var(--dir)); }
/* a button that already carries its own icon, and the quiet text button, have no tile */
.btn:is(.btn-ghost, :has(> svg)) { --pe: var(--ps); --gap: 10px; --rs: 0px; }

/* --- sizes --- */
.btn-sm { --tile: 32px; --ps: 18px; --pe: 6px; --gap: 12px; min-height: 44px; font-size: 0.9375rem; box-shadow: none; }
.btn-lg, .btn--big, .btn--join { --tile: 46px; --ps: 28px; --pe: 10px; min-height: 64px; font-size: 1.1875rem; }
.btn--signin { --tile: 34px; --ps: 18px; --pe: 6px; --gap: 10px; min-height: 48px; }
.formcard .btn { justify-content: space-between; min-height: 60px; }
/* a button that carries its own icon keeps icon and label together, centred (fix 5, M3) */
.formcard .btn:is(.btn-ghost, :has(> svg)), .btn-row .btn:has(> svg) { justify-content: center; }

/* --- colours --- */
/* second: a tonal pill (outline, soft and the double-dash ghost) */
.btn-outline, .btn--ghost, .btn--soft { --bg: var(--color-tint); --ink: var(--color-link); --chipbg: var(--color-green); --chipink: var(--color-on-green); }
/* on a Ground panel: a cream pill with a dark tile; second is a dark pill with an edge */
:is(.on-ground, .sp-hero) .btn, .btn--join {
  --bg: var(--color-btn-ground-bg); --ink: var(--color-btn-ground-ink); --chipbg: var(--color-ground); --chipink: var(--color-on-ground);
}
:is(.on-ground, .sp-hero) .btn:is(.btn-outline, .btn--ghost, .btn--soft), .btn--signin {
  --bg: var(--color-ground-2); --ink: var(--color-on-ground); --chipbg: var(--color-on-ground); --chipink: var(--color-ground);
  box-shadow: inset 0 0 0 1.5px var(--hero-control-edge);
}
:is(.on-ground, .sp-hero) .btn:not(:disabled, .disabled, .btn-outline, .btn--ghost, .btn--soft, .btn-ghost, .btn-danger):hover,
.btn--join:hover { --bg: color-mix(in srgb, var(--color-btn-ground-bg) 90%, var(--color-ground)); }
/* danger: dark ink on the light red in dark mode (design audit, 21 Nov) */
.btn.btn-danger { --bg: var(--danger); --ink: var(--on-danger); --chipbg: var(--on-danger); --chipink: var(--danger); }
/* quiet text button: a rest line and a line that sweeps in from the reading side */
.btn.btn-ghost {
  --bg: transparent; --ink: var(--color-link); min-height: 44px; min-inline-size: 44px; padding-inline: 6px; border-radius: 8px; box-shadow: none; font-size: 0.9375rem;
}
:is(.on-ground, .sp-hero) .btn.btn-ghost { --ink: var(--color-on-ground); --bg: transparent; box-shadow: none; }
.btn.btn-ghost::before, .btn.btn-ghost::after {
  content: ''; position: absolute; inset-inline: 6px; inset-block-end: 6px; block-size: 2px; border-radius: 2px;
}
.btn.btn-ghost::before { background: color-mix(in srgb, var(--ink) 32%, transparent); }
.btn.btn-ghost::after { background: var(--ink); transform: scaleX(0); transform-origin: var(--o) center; transition: transform 420ms var(--spring); }
.btn.btn-ghost:hover::after { transform: scaleX(1); }
.btn:disabled, .btn.disabled, .btn[aria-disabled='true'] {
  --bg: var(--color-panel); --ink: var(--color-ink-soft); --chipbg: var(--color-edge); --chipink: var(--color-ink-soft);
  box-shadow: none; pointer-events: none; cursor: not-allowed;
}
.btn.btn-ghost:disabled, .btn.btn-ghost.disabled { --bg: transparent; }

/* --- keyboard focus --- */
.btn:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
:is(.on-ground, .sp-hero, .bar) .btn:focus-visible { outline-color: var(--color-focus-on-ground); }

/* --- layout helpers --- */
@media (max-width: 520px) { .btn-row .btn { flex: 1 1 auto; justify-content: space-between; } .btn-row .btn.btn-ghost { justify-content: center; } }

/* --- no script: plain CSS hover and press (with the springs running, Motion drives the scale instead) --- */
@media (prefers-reduced-motion: no-preference) {
  html:not(.has-springs) .btn { transition: background-color 180ms var(--ease-out), transform 200ms var(--ease-out); }
  html:not(.has-springs) .btn:not(:disabled, .disabled, .btn-ghost):hover { transform: scale(1.03); }
  html:not(.has-springs) .btn:not(:disabled, .disabled, .btn-ghost):active { transform: scale(0.96); }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .btn::before, .btn::after { transition: none !important; }
}

/* --- the top bar: the Create account pill stays on one row (desktop only, it leaves the row below 1160; v7-shell.css owns the phone and tablet Sign in) --- */
.bar .btn--join { flex: none; white-space: nowrap; align-self: center; min-inline-size: 44px; }
.bar .btn--signin { flex: none; white-space: nowrap; }
@media (max-width: 560px) {
  .bar .btn--join::before, .bar .btn--join::after { display: none; }
  .bar .btn--join { --rs: 0px; --ps: 14px; --pe: 14px; min-height: 48px; font-size: 1rem; }
}
@media (max-width: 400px) { .bar .btn--join { --ps: 10px; --pe: 10px; font-size: 0.9375rem; } }
@media (max-width: 340px) { .bar .btn--join { --ps: 7px; --pe: 7px; font-size: 0.875rem; } }

/* fix 5, L19: on the smallest phones (320 to 360) the arrow tile and the side room are one step smaller, so a button label of two or three words stays on one line */
@media (max-width: 360px) {
  .btn:not(.btn-sm, .btn-ghost, :has(> svg), .bar .btn) { --tile: 36px; --ps: 18px; --pe: 6px; --gap: 10px; font-size: 0.9375rem; min-height: 56px; }
  .btn-lg:not(.bar .btn), .btn--big:not(.bar .btn) { --tile: 38px; --ps: 20px; --pe: 7px; font-size: 1.0625rem; min-height: 58px; }
}
