/*
 * The product pages' stylesheet. The tokens it reads (colours, type
 * scale) and the appearance control are in theme.css, which every shell
 * links first.
 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

main {
  max-width: 32rem;
  margin: 3rem auto;
  padding: 0 1.25rem;
}

h1 {
  font-size: var(--text-xl);
  margin-bottom: 0.5rem;
}

/* The landing's heading is its tagline (the header's lockup names the
   product): a sentence rather than a title, so a step down from the other
   screens' headings, or it runs four lines on a phone. */
h1.tagline {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.35;
}

/* Every screen's h1 takes focus by script when the stage changes, so a
   screen reader lands on it. It is not a tab stop and nothing on it can
   be activated, so the ring the browser draws for a focused element would
   only read as a fault. */
h1:focus {
  outline: none;
}

/* Off the page, in the accessibility tree: the shell's one live region.
   What it says is already on the page as the status line, the confirmed
   banner or the result headline; the region exists so a screen reader is
   told when that text changes, which an element inserted with the new
   screen cannot reliably do. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* One step under h1's --text-xl. */
h2 {
  font-size: var(--text-lg);
}

/* The answer is the hero of the result screen. */
.result-headline {
  font-size: var(--text-2xl);
  line-height: 1.25;
}

.hint {
  color: var(--quiet);
  font-size: var(--text-base);
}

.hint.private {
  font-style: italic;
}

/* Arabic and Hebrew have no italic face to slant into — a browser fakes one
   by shearing the glyphs, which reads as a rendering fault rather than as
   emphasis. The hint keeps its quieter
   colour there and drops the slant. */
.hint.private:lang(ar),
.hint.private:lang(he) {
  font-style: normal;
}

.status {
  font-size: var(--text-base);
}

.warning {
  color: var(--error);
  font-size: var(--text-sm);
}

.error {
  color: var(--error);
  min-height: 1.2em;
  font-size: var(--text-sm);
}

button {
  font-size: var(--text-base);
  padding: 0.5rem 1rem;
  min-height: 2.75rem; /* ≥44px touch target */
  border-radius: 0.35rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  /*
   * The text takes the page colour in dark, where the accent is a light blue
   * that white sits on at 2.3:1; in light the accent is deep enough for
   * white. Measured in web-rs/prefs/tests/contrast.rs, hover included.
   */
  color: light-dark(#fff, var(--bg));
  cursor: pointer;
  margin: 0.5rem 0;
  margin-inline-end: 0.5rem; /* the gap follows the row's direction, not the left edge */
}

button:hover {
  filter: brightness(1.08);
}

/* Secondary actions (Decline): present, not competing with the primary. */
.button-quiet {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}

.button-quiet:hover {
  filter: none;
  background: var(--row-hover);
}

input[type="text"],
input[type="number"],
input[type="email"],
textarea {
  font-size: var(--text-base);
  padding: 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  width: 100%;
}

textarea {
  font-family: inherit;
  min-height: 5.5rem;
  resize: vertical;
}

/*
 * The check words are the anti-MITM centrepiece (docs/product.md §2.6) and the
 * one editable object a happy-path user is asked to look at — they get a
 * typographic identity nothing else in the app shares (the SAS words echo
 * it at receipt size).
 */
input.code-input {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  letter-spacing: 0.04em;
  text-align: center;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.invite-link {
  margin: 0.75rem 0;
}

.bound-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 20rem;
}

/*
 * Standalone and in-sentence links keep their quiet visual size but carry a
 * ≥44px hit area: the padding grows the touch box, the negative margins give
 * the space back to the layout.
 */
.restart {
  display: inline-block;
  margin: 0.25rem 0 -0.75rem;
  padding: 0.75rem 0;
  color: var(--accent);
}

.hint a {
  display: inline-block;
  padding: 0.75rem 0;
  margin: -0.75rem 0;
}

.fine-print {
  font-size: var(--text-sm);
}

.countdown {
  font-variant-numeric: tabular-nums;
}

/*
 * The SAS is a receipt, not the anti-MITM defence (docs/product.md §2.7) — no
 * box, quiet, mono at body size, so the answer above it competes with
 * nothing.
 */
.sas {
  margin: 1.25rem 0;
}

.banner {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 0.35rem;
  font-size: var(--text-sm);
}

/* Action banners (resume, zero-credits) are a <div> holding a line and its
 * buttons: one compact strip, wrapping on narrow screens. The confirmed-words
 * banner is a bare <p class="banner"> and keeps the base box above. */
div.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
}

div.banner p {
  margin: 0;
  flex: 1 1 12rem;
}

div.banner button {
  margin: 0;
  flex-shrink: 0;
}

.sas-words {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--quiet);
  margin: 0 0 0.25rem;
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
}

.create-form fieldset,
.joiner-options fieldset {
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.create-form label,
.joiner-options label {
  font-size: var(--text-sm);
}

/* The form's fold: a native <details>
   whose summary is the one control that shows, and whose contents stack
   with the form's own gap once it is open. The stacking lives on an inner
   block, not the <details> itself, so the closed state stays the
   browser's. */
.create-form summary,
.joiner-options summary {
  cursor: pointer;
}

.joiner-options {
  margin-bottom: 0.75rem;
}

.create-form .more-options,
.joiner-options .more-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

select {
  font-size: var(--text-base);
  padding: 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
}

/* ── the accounting checkout ── */

/*
 * The session chrome above the out-of-credits block: whose account the
 * screen is acting on, and the way out of it. Quiet and small — the approved
 * copy below it is the screen's voice, this row is furniture.
 */
.account-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--quiet);
  font-size: var(--text-sm);
  margin-bottom: 1.5rem;
}

.account-line .button-quiet {
  margin: 0;
  flex-shrink: 0;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
  margin-top: 1.75rem;
}

.account-form p {
  margin: 0;
}

.account-form label {
  font-size: var(--text-sm);
}

/* "How many more do you want?" is a small number; the field says so. */
.account-form input[type="number"] {
  max-width: 8rem;
}

/* ── the protocol trace drawer ── */

.trace-drawer {
  margin-top: 0.75rem;
}

/*
 * The disclosure control: quiet by design. Not a
 * call-to-action — quiet, small, text-only, so the closed state adds
 * near-zero visual weight next to the screen's real controls. Only on
 * hover/focus does it read as interactive, the same way .restart's plain
 * link does elsewhere.
 */
.trace-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  color: var(--quiet);
  font-size: var(--text-sm);
  padding: 0.25rem 0;
  margin: 0;
  border: none;
  border-radius: 0;
}

.trace-toggle:hover,
.trace-toggle:focus-visible {
  color: var(--accent);
}

.trace-caret {
  font-size: 0.7em;
}

.trace-hint {
  margin-top: 0.5rem;
}

.trace-log {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--trace-bg);
  max-height: 22rem;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
}

.trace-phase {
  color: var(--dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: var(--text-sm);
  margin: 0.75rem 0 0.25rem;
}

/* Tracking is a Latin-script device: Arabic's letters join, so spacing them
   apart breaks the word, and Hebrew reads the gaps as a spacing error. The
   headers keep everything else and lose the tracking. */
.trace-phase:lang(ar),
.trace-phase:lang(he) {
  letter-spacing: normal;
}

.trace-phase::before {
  content: "── ";
  color: var(--faint);
}

.trace-phase::after {
  content: " ──";
  color: var(--faint);
}

.trace-row {
  display: grid;
  grid-template-columns: 4.25rem 6.25rem 1fr 4.5rem;
  gap: 0.5rem;
  align-items: baseline;
  border-radius: 0.25rem;
  padding: 0 0.25rem;
  margin: 0 -0.25rem;
}

@media (prefers-reduced-motion: no-preference) {
  .trace-row {
    animation: trace-row-in 180ms ease-out;
  }
}

@keyframes trace-row-in {
  from {
    opacity: 0;
    transform: translateY(0.25rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.trace-row-clickable {
  cursor: pointer;
}

/* A row that opens is a <button>, so it
   is reachable from the keyboard and read as a control; it keeps the row's
   look, not the CTA's — the grid, the mono font and the hover tint come
   from the rules around it, and the outline on focus from the shared
   focus-visible rule. */
button.trace-row {
  width: 100%;
  min-height: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
}

button.trace-row:hover {
  filter: none;
}

.trace-row-clickable:hover {
  background: var(--row-hover);
}

.trace-t {
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.trace-dir {
  white-space: pre;
}

.trace-dir-send {
  color: var(--accent);
}

.trace-dir-recv {
  color: var(--ok);
}

.trace-dir-ctl {
  color: var(--dim);
}

.trace-note {
  color: var(--dim);
}

.trace-size {
  text-align: end;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.trace-row-local .trace-label {
  color: var(--dim);
  font-style: italic;
}

.trace-bar {
  color: var(--accent);
}

.trace-detail {
  margin-block: 0.25rem 0.5rem;
  margin-inline: 4.75rem 0;
  padding: 0.5rem 0.75rem;
  border-inline-start: 2px solid var(--border);
  color: var(--dim);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.trace-hex {
  color: var(--fg);
  word-break: break-all;
  opacity: 0.8;
  margin: 0 0 0.5rem;
}

.trace-k {
  color: var(--accent);
}

.trace-layer {
  color: var(--fg);
  margin-top: 0.25rem;
}

.trace-tag {
  color: var(--accent);
  font-weight: 600;
}

.trace-layer-innermost .trace-tag {
  color: var(--ok);
}

.trace-prose {
  margin-top: 0.5rem;
}

.trace-tally {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
  font-size: var(--text-sm);
}

.trace-tally-box {
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.5rem 1rem;
}

.trace-tally-box h3 {
  font-size: var(--text-sm);
  margin: 0 0 0.25rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dim);
}

.trace-tally-box ul {
  margin: 0;
  padding-inline-start: 1rem;
}

.trace-never {
  color: var(--error);
}

.trace-never::marker {
  content: "✕ ";
}

@media (max-width: 30rem) {
  /*
   * Action buttons stack full-width on a phone. `main > button` catches the
   * screens that render controls at the top level (consent, checkout, link
   * page, confirm step); the trace toggle sits inside .trace-drawer and
   * keeps its quiet inline shape.
   */
  main > button,
  .bound-form button {
    display: block;
    width: 100%;
    margin: 0.25rem 0;
  }
  .trace-tally {
    grid-template-columns: 1fr;
  }
  .trace-row {
    grid-template-columns: 3.5rem 4.75rem 1fr 3.75rem;
    gap: 0.25rem;
  }
}

/* The header the shells carry above <main>: the lockup, then the controls
   that belong to the page rather than to any one screen — appearance and
   language. It shares <main>'s column and inline padding, so the row lines
   up with the text it sits above instead of with the window's corners. */
#page-header {
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 0;
}

/* One row: the lockup at its left edge, the controls against its right;
   both controls take their quiet size and colour from it.

   This row is the page's one deliberate exception to the sheet's logical
   properties (see the direction note at the foot of this file): it is
   `direction: ltr` so it does *not* mirror with <html dir>. These controls
   are the things a person reaches for while changing language, and picking
   a right-to-left language reloads the page — mirroring would send the
   language select to the opposite edge, out from under the pointer that
   just used it, and swap it with the appearance control on the way. The
   lockup stays at the left with them: it is the domain, which reads left to
   right in every language. The text inside each control still reads in its
   own direction; only the row's geometry is pinned.

   One row at every width, in every language: the appearance control is
   icons and the language control shows a tag, so the controls are as
   narrow in Spanish as in English, and the lockup steps down to make room
   (theme.css) rather than the row wrapping and pushing the page down. */
.header-controls {
  display: flex;
  direction: ltr;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  font-size: var(--text-sm);
  color: var(--quiet);
}

.header-controls .lockup {
  margin-right: auto;
}

/* On a phone the row closes up a little, which lets the mark and "sounding"
   stay on a 375 px screen (theme.css's step-down measurements count it). */
@media (max-width: 30rem) {
  .header-controls {
    gap: 0.5rem;
  }
}

/* The language control: a globe, the current language's tag and a chevron,
   set as quiet text, with the native select lying over all three,
   transparent — so a press anywhere on the control opens the browser's own
   list, which names every language in full (and marks the unreviewed ones),
   and the keyboard and a screen reader meet the select itself. The closed
   control shows the tag rather than the name so it is as narrow in every
   language. It renders nothing while only one language is offered. */
.locale-switch {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.75rem; /* ≥44px touch target */
  padding: 0 0.375rem;
  border: 1px solid transparent;
  border-radius: 0.35rem;
}

.locale-globe {
  opacity: 0.8;
}

.locale-chevron {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.locale-switch select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.locale-switch:hover {
  color: var(--fg);
  border-color: var(--border);
}

/* The select is invisible, so the control shows its focus and its held
   state for it. */
.locale-switch:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.locale-switch:has(select:disabled) {
  opacity: 0.5;
}

.locale-switch select:disabled {
  cursor: not-allowed;
}

/* A dropdown is the browser's, drawn from the page's `color-scheme`;
   naming its colours keeps it on this palette rather than the platform's
   default light list — the language control's and any other select's
   alike, so the rule is global rather than scoped to the header. */
option {
  background: var(--bg);
  color: var(--fg);
}

/* The caveat with the reader: one
   line under the controls while the page speaks an offered-but-unreviewed
   catalog, in the page's language, set like the row it follows. Physical
   `right` rather than `end`, for the same reason the row above is pinned —
   and it is the natural alignment either way: `end` in a left-to-right
   page, `start` in a right-to-left one. The text itself still flows in the
   page's own direction. */
.locale-notice {
  margin: 0;
  padding: 0.25rem 0 0;
  font-size: var(--text-sm);
  color: var(--quiet);
  text-align: right;
}

/* Direction: the sheet is written in logical
   properties — inline-start/end, not left/right — so a right-to-left
   locale mirrors from <html dir> alone. The three rules above that were
   physical (trace-size, trace-detail, trace-tally-box ul) were the whole
   audit; grid and flex mirror on their own.

   One deliberate exception: the header
   row, `.header-controls` and the `.locale-notice` under it. Page content
   mirrors because that is how it is read; the controls that *change* the
   page do not, because a person reaching for the language select should
   find it in the same place whatever language the page is currently in —
   and the switch reloads, so the jump would land mid-reach. Text inside
   them still reads in its own direction. Nothing else in this sheet
   should acquire a physical property to match. */

/* The shared footer's mount point below <main> (theme.css styles what goes
   in it): <main>'s column, like #page-header above. */
#page-footer {
  max-width: 32rem;
  margin: 0 auto;
  padding: 0 1.25rem 1.5rem;
}

/* The logo while the result is computed (run-ui's Computing screen; decided
   2026-11-27). It plays out the logo's own story: the lower bowl draws, the
   ping leaves its dot with waves, and the upper bowl swings up from folded
   over the lower one into place; the ping then repeats while the parties
   compute. When the result is in, the session adds `logo-arrived`: the echo
   runs up the top arcs into the top dot, which sends waves of its own, and
   only then does the result show. The timings here are run-ui's echo
   constants (INTRO_MS, ECHO_MS): change them together. The viewBox starts at
   0 0 so the swing's origin, 32px 33px, is the bowls' own pivot. Hidden from
   a screen reader, which hears the status line; still for anyone who asks
   for reduced motion. */
.computing-logo {
  display: flex;
  justify-content: center;
  padding-block: 2.5rem 1.5rem;
}
.logo-hero {
  height: 8rem;
  width: auto;
  overflow: visible;
}
.logo-hero .logo-upper {
  transform-box: view-box;
  transform-origin: 32px 33px;
}
@keyframes logo-draw {
  from {
    stroke-dasharray: 1 1;
    stroke-dashoffset: 1;
  }
  to {
    stroke-dasharray: 1 1;
    stroke-dashoffset: 0;
  }
}
@keyframes logo-appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes logo-swing {
  from {
    transform: rotate(205deg);
  }
  to {
    transform: rotate(22deg);
  }
}
@keyframes logo-ping-loop {
  0% {
    opacity: 0.3;
  }
  5% {
    opacity: 1;
  }
  45%,
  100% {
    opacity: 0.3;
  }
}
@keyframes logo-dot-loop {
  0% {
    transform: scale(1);
  }
  15% {
    transform: scale(1.6);
  }
  35%,
  100% {
    transform: scale(1);
  }
}
@keyframes logo-wave-loop {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  1% {
    opacity: 0.9;
  }
  30%,
  100% {
    opacity: 0;
    transform: scale(17);
  }
}
.logo-hero .logo-echo-arc {
  opacity: 0.12;
}
.logo-hero .logo-echo-dot {
  opacity: 0.35;
}
@media (prefers-reduced-motion: no-preference) {
  /* the introduction, 0 to INTRO_MS (1150 ms) */
  .logo-hero .logo-lower-ink {
    animation: logo-draw 400ms ease-in-out both;
  }
  .logo-hero .logo-upper {
    animation:
      logo-appear 1ms 550ms both,
      logo-swing 600ms cubic-bezier(0.34, 1.4, 0.64, 1) 550ms both;
  }
  .logo-hero .logo-ping-dot {
    animation:
      logo-dot-pulse 400ms ease-out 420ms both,
      logo-dot-loop 2400ms ease-out 2400ms infinite;
  }
  .logo-hero .logo-ping-arc {
    animation:
      logo-arc-light 120ms ease-out both,
      logo-ping-loop 2400ms ease-out infinite;
  }
  .logo-hero .logo-ping-1 {
    animation-delay: 440ms, 2400ms;
  }
  .logo-hero .logo-ping-2 {
    animation-delay: 500ms, 2460ms;
  }
  .logo-hero .logo-ping-3 {
    animation-delay: 560ms, 2520ms;
  }
  .logo-hero .logo-ping-wave-1,
  .logo-hero .logo-ping-wave-2,
  .logo-hero .logo-ping-wave-3 {
    animation:
      logo-wave-out 700ms ease-out both,
      logo-wave-loop 2400ms ease-out infinite;
  }
  .logo-hero .logo-ping-wave-1 {
    animation-delay: 420ms, 2400ms;
  }
  .logo-hero .logo-ping-wave-2 {
    animation-delay: 540ms, 2520ms;
  }
  .logo-hero .logo-ping-wave-3 {
    animation-delay: 660ms, 2640ms;
  }
  .logo-hero .logo-echo-wave-1,
  .logo-hero .logo-echo-wave-2,
  .logo-hero .logo-echo-wave-3 {
    animation: none;
  }

  /* the echo, 0 to ECHO_MS (1000 ms) after `logo-arrived` */
  .logo-hero.logo-arrived .logo-ping-arc,
  .logo-hero.logo-arrived .logo-ping-dot {
    animation: none;
  }
  .logo-hero.logo-arrived .logo-echo-arc {
    animation: logo-arc-light 120ms ease-out both;
  }
  .logo-hero.logo-arrived .logo-echo-1 {
    animation-delay: 0ms;
  }
  .logo-hero.logo-arrived .logo-echo-2 {
    animation-delay: 60ms;
  }
  .logo-hero.logo-arrived .logo-echo-3 {
    animation-delay: 120ms;
  }
  .logo-hero.logo-arrived .logo-echo-dot {
    animation: logo-dot-pulse 400ms ease-out 180ms both;
  }
  .logo-hero.logo-arrived .logo-echo-wave-1,
  .logo-hero.logo-arrived .logo-echo-wave-2,
  .logo-hero.logo-arrived .logo-echo-wave-3 {
    animation: logo-wave-out 600ms ease-out both;
  }
  .logo-hero.logo-arrived .logo-echo-wave-1 {
    animation-delay: 180ms;
  }
  .logo-hero.logo-arrived .logo-echo-wave-2 {
    animation-delay: 280ms;
  }
  .logo-hero.logo-arrived .logo-echo-wave-3 {
    animation-delay: 380ms;
  }
}
