/* [MODULE] client/components.css | Shared platform components harvested from the scaffold: chrome chip, wallet, screen stack, notice bar, code input
 * [IFACE]  layer: view | in: (static) → out: `components` layer rules | crosses: []
 * [GRAPH]  needs: [client/core.css] | feeds: [client/shell.js, modules/auth, modules/account, modules/billing] | group: platform-app.client
 * [STATE]  stateless | persists: nothing | raises: nothing
 *
 * Everything here sits in the `components` layer declared in index.html, so it beats `core`
 * and yields to `modules`. Tokens come from core.css and nothing is redefined. Rules are
 * harvested from `Experiments/platform_scaffold/client/scaffold.css` (the one file that tree
 * was allowed to design in) — only the components a production surface now renders. */

@layer components {

  /* ── topbar chrome: sign-in chip, wallet, sign-out ─────────────────────────────── */
  .chrome {
    display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap;
    justify-content: flex-end;
  }

  .wallet {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 16px; border-radius: var(--r-pill);
    background: var(--surface); border: 1px solid var(--line);
    font-size: calc(13px * var(--fs-scale-ui)); font-weight: 800;
    color: var(--ink); text-decoration: none; cursor: pointer;
    font-family: inherit;
  }
  .wallet:hover { background: var(--tint); }
  .wallet .w-num { color: var(--brand-700); font-variant-numeric: tabular-nums; }
  .wallet .w-unit { color: var(--ink-soft); font-weight: 700; }
  /* Low balance is a warning, not an error — the user has not done anything wrong. It is
     the moment the product asks for money, so it speaks in the Pro voice (`--pro*`). */
  .wallet.is-low { border-color: var(--pro-line); background: var(--pro-fill); }
  .wallet.is-low .w-num { color: var(--pro); }
  .wallet.is-empty { border-color: rgba(217, 83, 79, .45); background: rgba(217, 83, 79, .08); }
  .wallet.is-empty .w-num { color: var(--sig-red); }

  /* ── the billing notice bar under the topbar ───────────────────────────────────── */
  .notice-bar {
    display: flex; align-items: center; gap: 12px;
    margin: 0 0 18px; padding: 12px 16px;
    border-radius: var(--r-md); border: 1px solid var(--pro-line); background: var(--pro-fill);
    color: var(--ink); font-size: calc(14px * var(--fs-scale-body));
  }
  .notice-bar.is-empty { border-color: rgba(217, 83, 79, .45); background: rgba(217, 83, 79, .08); }
  .notice-bar .nb-text { flex: 1; min-width: 0; }
  .notice-bar .nb-close {
    border: 0; background: transparent; color: var(--ink-soft); font-size: 20px; line-height: 1;
    cursor: pointer; padding: 0 4px; font-family: inherit;
  }

  /* ── one vertical stack per surface ────────────────────────────────────────────── */
  .screen { display: grid; gap: 18px; }
  .screen > * { margin: 0; }

  /* ── the six-digit code field on sign-in ───────────────────────────────────────── */
  .code-input {
    font-size: 28px; letter-spacing: .35em; text-align: center;
    font-variant-numeric: tabular-nums; font-weight: 800;
  }

  /* ── definition rows on the account screen ─────────────────────────────────────── */
  .kv { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 8px 16px; }
  .kv dt { color: var(--ink-soft); font-size: calc(12px * var(--fs-scale-ui)); font-weight: 800;
           text-transform: uppercase; letter-spacing: .06em; align-self: center; }
  .kv dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
}

/* ── drills: harvested from onboarding_app/static/organic.css (2026-09-17) ─────────── */
/* Tokens come from core.css; the four keyword-role hues are the one addition, because
   more than one drill (Read-Ahead's reveal, later ones' evidence) speaks that vocabulary. */
@layer components {
  :root {
    --role-q:    #5a8a3a;  /* question word — the answer type */
    --role-subj: #2f6f8f;  /* subject       — what it's about */
    --role-act:  #b5731f;  /* action        — what happens    */
    --role-trap: #b03a5b;  /* catch         — the distractor filter */
    --role-q-fill:    rgba(90, 138, 58, .16);
    --role-subj-fill: rgba(47, 111, 143, .16);
    --role-act-fill:  rgba(181, 115, 31, .18);
    --role-trap-fill: rgba(176, 58, 91, .16);
  }
  html[data-theme="dark"] {
    --role-q:    #8bb36a;
    --role-subj: #6fb0cf;
    --role-act:  #dda155;
    --role-trap: #dd7a97;
    --role-q-fill:    rgba(139, 179, 106, .20);
    --role-subj-fill: rgba(111, 176, 207, .20);
    --role-act-fill:  rgba(221, 161, 85, .22);
    --role-trap-fill: rgba(221, 122, 151, .20);
  }

  .reveal-out { display: flex; flex-direction: column; gap: 18px; }
  .reveal-out:empty { display: none; }

  .screen-lead { margin: 8px 0 20px; }
  .screen-lead h2 { font-family: 'Fraunces', serif; font-size: calc(30px * var(--fs-scale-title)); font-weight: 600; line-height: 1.12; margin-bottom: 10px; letter-spacing: -.02em; }
  .screen-lead p { font-size: calc(16px * var(--fs-scale-body)); color: var(--ink-soft); margin: 10px 0; }

  .mini-steps { list-style: none; padding: 0; margin: 14px 0 2px; display: grid; gap: 10px; counter-reset: step; }
  .mini-steps li { display: flex; align-items: center; gap: 10px; font-size: calc(15px * var(--fs-scale-body)); color: var(--ink-soft); counter-increment: step; }
  .mini-steps li::before {
    content: counter(step); flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center; font-size: calc(12px * var(--fs-scale-ui)); font-weight: 800;
    background: var(--tint-2); color: var(--brand-600);
  }

  .timer { font-family: 'Fraunces', serif; font-weight: 600; color: var(--sig-red); }

  /* the pass/fail evidence badges */
  .badge-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
  .badge-row.stack { display: block; }
  .badge-row.stack .signal-badge { margin: 8px 0; width: fit-content; }
  .signal-badge {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 18px; border-radius: 16px 26px 16px 26px; border: 2px solid var(--line);
    background: var(--surface-2);
  }
  .signal-badge.ok { border-color: var(--sig-green); background: var(--tint); }
  .signal-badge.no { border-color: var(--sig-red); background: rgba(217,83,79,.10); }
  .signal-badge .sb-label { font-size: calc(11px * var(--fs-scale-ui)); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
  .signal-badge .sb-value { font-weight: 800; font-size: calc(15px * var(--fs-scale-ui)); }
  .signal-badge.ok .sb-value { color: var(--brand-600); }
  .signal-badge.no .sb-value { color: var(--sig-red); }
  .signal-badge .sb-note { font-size: calc(14px * var(--fs-scale-body)); font-weight: 400; color: var(--ink-soft); line-height: 1.5; }
  .signal-badge .sb-note b.good { color: var(--brand-700); }
  .signal-badge .sb-note b.bad { color: var(--sig-red); }

  /* every result lives in one bordered surface: verdict · evidence · coach */
  .result-panel {
    overflow: hidden; background: var(--surface); border: 1px solid var(--line);
    border-left: 6px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
  }
  .result-panel.pass { border-left-color: var(--sig-green); }
  .result-panel.fail { border-left-color: var(--sig-red); }
  .result-panel.warn { border-left-color: var(--sig-amber); }
  .rp-verdict {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 18px 24px; font-size: calc(15px * var(--fs-scale-body)); line-height: 1.5;
    border-bottom: 1px solid var(--line-soft);
  }
  .rp-verdict .rp-icon {
    flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 900; font-size: calc(15px * var(--fs-scale-ui));
    color: var(--on-brand);
  }
  .result-panel.pass .rp-verdict { background: var(--tint-2); }
  .result-panel.fail .rp-verdict { background: rgba(217,83,79,.12); }
  .result-panel.warn .rp-verdict { background: rgba(224,165,58,.14); }
  .result-panel.pass .rp-icon { background: var(--sig-green); }
  .result-panel.fail .rp-icon { background: var(--sig-red); }
  .result-panel.warn .rp-icon { background: var(--sig-amber); }
  .rp-verdict .rp-vtext b { font-weight: 800; }
  .result-panel.pass .rp-verdict .rp-vtext b { color: var(--brand-700); }
  .result-panel.fail .rp-verdict .rp-vtext b { color: var(--sig-red); }
  .result-panel.warn .rp-verdict .rp-vtext b { color: var(--sig-amber); }
  .rp-body { padding: 20px 24px; display: grid; gap: 14px; }
  .rp-body h4 { margin: 6px 0 0; }
  .rp-coach { display: flex; gap: 14px; padding: 18px 24px; border-top: 1px solid var(--line-soft); background: var(--tint); }
  .rp-coach .emoji { font-size: 28px; line-height: 1; }
  .rp-coach h4 { margin: 0 0 4px; }
  .rp-coach p { margin: 0; color: var(--ink-soft); }

  /* the action row under every result: new question · same again · back */
  .drill-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
  .drill-actions .spacer { flex: 1; }
  .drill-note { font-size: calc(13px * var(--fs-scale-ui)); color: var(--ink-soft); }

  /* the catalogue home */
  .cat-section { margin-top: 26px; }
  .cat-section h2 { font-family: 'Fraunces', serif; font-size: calc(24px * var(--fs-scale-title)); font-weight: 600; margin-bottom: 12px; }
  .cat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .cat-card { display: grid; gap: 8px; align-content: start; padding: 18px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
  .cat-card h3 { margin: 0; }
  .cat-card p { margin: 0; color: var(--ink-soft); font-size: calc(14px * var(--fs-scale-body)); }
  .cat-card .cat-meta { font-size: calc(12px * var(--fs-scale-ui)); color: var(--ink-soft); font-weight: 700; }
  .cat-card .btn { margin-top: 4px; justify-self: start; }
  .continue-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-md); border: 1px dashed var(--pro-line); background: var(--pro-fill); }
  .continue-row .cr-text { flex: 1; min-width: 0; }
}

/* ── listening drills: the play bar and the choice rows ─────────────────────────────── */
@layer components {
  .audio-bar {
    display: flex; align-items: center; gap: 14px; padding: 14px 18px;
    border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 14px;
  }
  .play {
    width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; border: none; cursor: pointer;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-400)); color: var(--on-brand);
    font-size: 15px; display: grid; place-items: center; font-family: inherit;
  }
  .play:disabled { opacity: .7; cursor: default; }
  .wavebars { display: flex; align-items: center; gap: 3px; height: 24px; flex: 1; }
  .wavebars i { width: 3px; background: var(--brand-400); border-radius: 2px; animation: wv 1.1s ease-in-out infinite; animation-play-state: paused; }
  .wavebars i:nth-child(2n) { animation-delay: -.4s; } .wavebars i:nth-child(3n) { animation-delay: -.7s; }
  .audio-bar.playing .wavebars i { animation-play-state: running; }
  @keyframes wv { 0%,100% { height: 6px; } 50% { height: 22px; } }

  .choices { display: grid; gap: 10px; }
  .choice {
    display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer;
    border-radius: 16px 26px 16px 26px; background: var(--surface-2);
    border: 2px solid var(--line-soft); transition: all .2s ease; font-size: calc(15px * var(--fs-scale-body));
    width: 100%; text-align: left; font-family: inherit; color: inherit;
  }
  .choice:hover { border-color: var(--brand-400); }
  .choice[disabled] { cursor: default; }
  .choice .mk { width: 22px; height: 22px; flex-shrink: 0; border-radius: 7px; border: 2px solid var(--line); }
  .choice.picked .mk { background: var(--brand-400); border-color: var(--brand-400); }
  .choice.correct { border-color: var(--sig-green); background: var(--tint); }
  .choice.correct .mk { background: var(--sig-green); border-color: var(--sig-green); }
  .choice.wrong { border-color: var(--sig-red); background: rgba(217,83,79,.08); }
  .choice.wrong .mk { background: var(--sig-red); border-color: var(--sig-red); }

  .transcript-replay {
    background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
    padding: 18px 20px; font-family: 'Fraunces', serif; font-size: calc(17px * var(--fs-scale-body)); line-height: 1.65; color: var(--ink);
  }
  .transcript-replay .hit { background: var(--tint-2); color: var(--brand-700); font-weight: 700; border-radius: 5px; padding: 1px 4px; box-shadow: inset 0 -2px 0 var(--sig-green); }
  .transcript-replay .bait { color: var(--sig-red); font-weight: 700; border-radius: 5px; padding: 1px 4px; background: rgba(217,83,79,.10); box-shadow: inset 0 -2px 0 var(--sig-red); }
  .answer-chip { display: inline-flex; align-items: center; gap: 8px; font-size: calc(13px * var(--fs-scale-ui)); font-weight: 800; color: var(--brand-700); background: var(--tint); border-radius: 20px; padding: 6px 14px; width: fit-content; }

  @keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-7px); } 40%,80% { transform: translateX(7px); } }
  .shake { animation: shake .4s ease; border-color: var(--sig-red) !important; }
}
