/* variant.css—page-specific styles for /variant/.
   Extends styles.css tokens; doesn't redefine them. */

.variant-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 32px 60px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.variant-header { margin-bottom: 24px; }
.variant-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.015em;
}
.variant-sub {
  color: var(--t-2);
  margin: 0 0 14px;
  max-width: 780px;
}

.variant-quota { display: flex; gap: 8px; flex-wrap: wrap; }
.quota-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--t-2);
}
.quota-pill.danger { border-color: var(--skip-line); background: var(--skip-bg); color: var(--skip); }
.quota-pill.warn   { border-color: var(--test-line); background: var(--test-bg); color: var(--test); }

/* ── Form ──────────────────────────────────────────────────────────────── */
.variant-form-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 32px;
}
.form-row { margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--t-2);
  margin-bottom: 6px;
}
.form-required { color: var(--skip); }
/* Trend Stage Signal Test opt-in badge — marks the headline-type control as
   experimental so writers consciously choose. Amber, distinct from the form palette. */
.form-test-badge { font-size: 0.7rem; font-weight: 700; color: #b45309; background: rgba(245,158,11,.10); border: 1px solid #f59e0b; border-radius: 3px; padding: 0 4px; margin-right: 6px; }
/* Set the test control off from the advanced-options disclosure above it (spacing
   in CSS, not an inline style, to match every other .form-row). */
#headline-type-row { margin-top: 0.75rem; }
/* Expert-signal checkbox row. The control lives inside its <label> so the whole
   sentence is a click target; override the uppercase .form-label treatment since
   this is a sentence, not a field name, and lay the box + text out inline. */
.expert-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--t-1);
  cursor: pointer;
  margin-bottom: 0;
}
.expert-check-input {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--news-accent);
  cursor: pointer;
}
.form-meta { color: var(--t-3); font-weight: 400; text-transform: none; letter-spacing: 0; font-family: var(--font-mono); margin-left: 6px; }
.form-hint { color: var(--t-3); font-size: 11.5px; margin-top: 4px; display: block; }

.variant-form-card textarea,
.variant-form-card select,
.variant-form-card input[type="text"] {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--line-2);
  color: var(--t-1);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 13.5px;
  resize: vertical;
}

.form-advanced {
  margin: 16px 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.form-advanced summary {
  cursor: pointer;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--t-3);
  font-weight: 600;
  user-select: none;
  padding: 4px 0;
}
.form-advanced summary:hover { color: var(--t-2); }
.form-advanced[open] summary { color: var(--t-2); margin-bottom: 8px; }
.variant-form-card textarea:focus,
.variant-form-card select:focus { outline: none; border-color: var(--line-bright); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

/* Audit fix R13: prefers-reduced-motion respect for users with vestibular
   sensitivity (WCAG 2.3.3). Disables transition + animation duration. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration:  0.01ms !important;
  }
}

.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.btn-primary {
  background: var(--news-accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  letter-spacing: -0.005em;
}
/* R14: hover gated behind @media (hover: hover) so touch devices (where
   :hover sticks after a tap) don't keep the brightened state until the
   user taps elsewhere. */
@media (hover: hover) { .btn-primary:hover { filter: brightness(1.1); } }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.form-status { color: var(--t-3); font-size: 12.5px; font-family: var(--font-mono); }
.form-status.warn  { color: var(--test); }
.form-status.error { color: var(--skip); }

/* Async-dispatch progress indicator. Sits next to the form-status text while
   a /generate-async job is polling. Stage label + filled bar that advances
   per stage and tweens between stages via elapsed-time interpolation. */
/* :not([hidden]) so the HTML `hidden` attribute wins over our display:flex
  —without this, the progress block shows on page load with no job running. */
.form-progress:not([hidden]) { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }
.form-progress-label { color: var(--t-3); font-size: 12.5px; font-family: var(--font-mono); }
.form-progress-bar { height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; }
.form-progress-bar-fill { height: 100%; background: #3b82f6; border-radius: 2px; transition: width 0.4s ease-out; }

.results-pipeline .stat.warn { color: var(--test); }

/* ── Results ────────────────────────────────────────────────────────────── */
.variant-results { margin-bottom: 24px; }
.results-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; gap: 16px; }
.results-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.results-meta { color: var(--t-3); font-size: 12px; font-family: var(--font-mono); }
.results-pipeline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--t-3);
}
.results-pipeline .stat { background: var(--bg-1); padding: 3px 8px; border-radius: var(--radius); border: 1px solid var(--line); }

.variant-list { display: flex; flex-direction: column; gap: 10px; }

.variant-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  transition: border-color 0.15s;
}
.variant-card:hover { border-color: var(--line-bright); }
.variant-card.is-wildcard { border-color: var(--ent-accent); background: linear-gradient(180deg, var(--ent-bg) 0%, var(--bg-1) 80%); }
.variant-card.is-kept { border-color: var(--go); background: var(--go-bg); }

.variant-text {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  margin: 0 0 8px;
  color: var(--t-1);
}
.variant-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--t-3);
}
.variant-meta .chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 6px;
}
.chip.wildcard {
  background: var(--ent-bg);
  border-color: rgba(168, 85, 247, 0.4);
  color: var(--ent-accent);
  font-weight: 600;
}
.chip.score { color: var(--go); border-color: var(--go-line); background: var(--go-bg); font-weight: 600; }
.chip.cosine { color: var(--conf-mod); }
/* Trend-stage framing conformance readout (test-arm generations only).
   VALIDATED-NOT-SCORED — never enters grader_score; a publish-time signal
   of whether the variant carries the chosen CTRL/EMG/FWD framing. */
.chip.framing-ok   { color: var(--go); border-color: var(--go-line); background: var(--go-bg); font-weight: 600; }
/* framing-warn (amber ⚠) removed 2026-06-16: off-pattern is now a neutral study
   tag (framing-info), not an alarm. The editorial-flag chip below owns amber. */
/* Off-pattern framing is a neutral study tag, not an alarm — muted, no amber. */
.chip.framing-info { color: var(--t-2); border-color: var(--line); background: var(--bg-2); }
/* Editorial-judgment flag: cleared every hard check but trips a relaxable
   preference (e.g. a few chars over target). Amber = "your call," noticeable
   but not a defect (red is reserved for failures, which never reach the card). */
.chip.editorial-flag { color: #fbbf24; border-color: rgba(251,191,36,.40); background: rgba(251,191,36,.10); font-weight: 600; }
/* Operator/experiment notes (debug-only) — dimmed below writer-facing warnings. */
.results-pipeline .stat.warn.operator-note { color: var(--t-2); opacity: .85; }

.variant-actions { display: flex; flex-direction: column; gap: 6px; }
.btn-action {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--t-1);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-action:hover { background: var(--bg-3); border-color: var(--line-bright); }
.btn-action.btn-kept { color: var(--go); border-color: var(--go-line); }
.btn-action.btn-kept:hover { background: var(--go-bg); }
.btn-action.btn-kept.is-kept { background: var(--go); color: var(--bg-0); border-color: var(--go); font-weight: 600; }
@media (hover: hover) { .btn-action.btn-kept.is-kept:hover { background: var(--go); filter: brightness(0.92); } }
.btn-action:disabled { opacity: 0.5; cursor: not-allowed; }

/* Grader-breakdown drawer (collapsed by default) */
.variant-breakdown { grid-column: 1 / -1; margin-top: 4px; }
.variant-breakdown summary {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--t-3);
  cursor: pointer;
  padding: 4px 0;
}
.variant-breakdown summary:hover { color: var(--t-2); }
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 12px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.breakdown-row { display: grid; grid-template-columns: auto 1fr; gap: 6px; }
.breakdown-row .pass-yes { color: var(--go); }
.breakdown-row .pass-no  { color: var(--skip); }
.breakdown-row .pass-na  { color: var(--t-4); }
.breakdown-row .name     { color: var(--t-2); }

/* ── Reference accordion ────────────────────────────────────────────────── */
.variant-reference {
  margin-top: 32px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.variant-reference summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--t-2);
  font-size: 13px;
  padding: 4px 0;
}
.variant-reference summary:hover { color: var(--t-1); }
.reference-body { padding-top: 10px; color: var(--t-2); font-size: 13px; line-height: 1.55; }
.reference-body p { margin: 8px 0; }
.reference-body ul { padding-left: 20px; margin: 8px 0; }
.reference-body li { margin: 3px 0; }

/* ── Hardening 2026-05-07 ─────────────────────────────────────────────── */

/* Mode badge in results header */
.chip.mode-article  { background: rgba(59,130,246,.10); color: #93c5fd; border: 1px solid rgba(59,130,246,.35); }
.chip.mode-default  { background: rgba(148,163,184,.08); color: #94a3b8; border: 1px solid rgba(148,163,184,.30); }

/* Recovery-advice panel—surfaces actionable guidance when a /generate
   call returns 0 / partial / errors. Distinct from the variant cards. */
.recovery-advice {
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid rgba(245,158,11,.30);
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  background: rgba(245,158,11,.05);
  color: var(--t-2);
}
.recovery-advice h3 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--t-1);
}
.recovery-advice p { margin: 6px 0 10px 0; font-size: 13px; line-height: 1.5; }
.recovery-advice ul { margin: 6px 0; padding-left: 20px; font-size: 13px; line-height: 1.55; }
.recovery-advice li { margin: 4px 0; }

.results-tools {
  margin: 12px 0 6px 0;
  display: flex;
  justify-content: flex-end;
}
.btn-regenerate {
  background: rgba(59,130,246,.08);
  color: #93c5fd;
  border: 1px solid rgba(59,130,246,.35);
}
.btn-regenerate:hover:not(:disabled) {
  background: rgba(59,130,246,.15);
}

/* Length-warning indicator on the headline char counter */
.form-hint.warn { color: #f59e0b; font-weight: 600; }

/* ── How-to-use primer ────────────────────────────────────────────────── */
.variant-howto {
  margin: 0 0 18px 0;
  border: 1px solid rgba(59,130,246,.40);
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
  background: rgba(59,130,246,.06);
  transition: background .15s, border-color .15s;
}
.variant-howto:hover { background: rgba(59,130,246,.10); border-color: rgba(59,130,246,.55); }
.variant-howto[open] { background: rgba(59,130,246,.05); }

.variant-howto > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-weight: 600;
  color: #bfdbfe;
  font-size: 13px;
}
.variant-howto > summary::-webkit-details-marker { display: none; }
.variant-howto > summary::marker { display: none; }
.howto-icon  { font-size: 16px; line-height: 1; }
.howto-label { flex: 1; }
.howto-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: #93c5fd;
  background: rgba(59,130,246,.18);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(59,130,246,.40);
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.variant-howto:hover .howto-toggle { background: rgba(59,130,246,.30); color: #dbeafe; }
.variant-howto[open] .howto-toggle::before { content: '▴ '; }
.variant-howto[open] .howto-toggle { color: #94a3b8; }
.variant-howto:not([open]) .howto-toggle::before { content: '▾ '; }

.howto-body {
  padding: 0 14px 14px 38px;
  color: var(--t-2);
  font-size: 13px;
  line-height: 1.55;
  border-top: 1px dashed rgba(59,130,246,.20);
  margin-top: 0;
  padding-top: 12px;
}
.howto-body ol { padding-left: 22px; margin: 8px 0; }
.howto-body ol li { margin: 6px 0; }
.howto-body p { margin: 10px 0 4px 0; }
.howto-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(148,163,184,.10);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--t-1);
}

/* ── Help bubbles (?)—inline circular tooltip trigger ───────────────── */
.help-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: rgba(148,163,184,.12);
  color: var(--t-2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  cursor: help;
  user-select: none;
  vertical-align: 2px;
  border: 1px solid rgba(148,163,184,.25);
  position: relative;
}
/* Audit fix R13: :hover gated behind @media (hover: hover) so touch devices
   (where :hover sticks after a tap) don't compete with the JS data-open
   tap-toggle, leaving two help bubbles visible at once. Keyboard :focus
   still surfaces help on tab; data-open handles tap. */
.help-bubble:focus {
  background: rgba(59,130,246,.20);
  color: #bfdbfe;
  border-color: rgba(59,130,246,.45);
  outline: none;
}
@media (hover: hover) {
  .help-bubble:hover {
    background: rgba(59,130,246,.20);
    color: #bfdbfe;
    border-color: rgba(59,130,246,.45);
    outline: none;
  }
}

/* Tooltip ::after—keyboard-focused / data-open trigger always; hover only
   on pointer-fine devices via the @media block immediately following. */
.help-bubble[data-open="true"]::after,
.help-bubble:focus::after {
  content: attr(data-help);
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  width: 320px;
  max-width: 90vw;
  padding: 10px 12px;
  background: rgba(15,23,42,.98);
  border: 1px solid rgba(148,163,184,.30);
  border-radius: 4px;
  color: var(--t-1);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  pointer-events: none;
}
@media (hover: hover) {
  .help-bubble:hover::after {
    content: attr(data-help);
    position: absolute;
    left: 50%;
    top: calc(100% + 6px);
    transform: translateX(-50%);
    width: 320px;
    max-width: 90vw;
    padding: 10px 12px;
    background: rgba(15,23,42,.98);
    border: 1px solid rgba(148,163,184,.30);
    border-radius: 4px;
    color: var(--t-1);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
    pointer-events: none;
  }
}

/* ── Usage history button + log panel ─────────────────────────────────── */
.quota-history-btn {
  margin-left: 8px;
  background: rgba(148,163,184,.10);
  border: 1px solid rgba(148,163,184,.30);
  color: var(--t-2);
  padding: 4px 10px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.quota-history-btn:hover {
  background: rgba(59,130,246,.15);
  border-color: rgba(59,130,246,.40);
  color: #bfdbfe;
}

.my-usage {
  margin: 12px 0 18px 0;
  border: 1px solid rgba(148,163,184,.20);
  border-left: 3px solid rgba(148,163,184,.60);
  border-radius: 4px;
  background: rgba(148,163,184,.04);
}
.my-usage > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--t-2);
  font-size: 13px;
}
.my-usage > summary::-webkit-details-marker { display: none; }
.my-usage > summary::marker { display: none; }
.my-usage-icon { font-size: 16px; }
.my-usage-label { flex: 1; }
.my-usage-meta { color: var(--t-3); font-weight: 400; font-family: var(--font-mono); font-size: 11px; margin-left: 8px; }
.my-usage-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--t-3);
  background: rgba(148,163,184,.10);
  padding: 3px 8px;
  border-radius: 3px;
}
.my-usage-body { padding: 4px 14px 14px 14px; border-top: 1px dashed rgba(148,163,184,.18); }
.my-usage-section { margin: 12px 0; }
.my-usage-section h3 { margin: 6px 0 8px 0; font-size: 12px; color: var(--t-2); font-weight: 600; }
/* R14: visually-hidden utility for heading-hierarchy bridging (WCAG 1.3.1).
   Element is read by screen readers but invisible to sighted users. */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
  white-space: nowrap;
}
.my-usage-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 11.5px; }
.my-usage-table th, .my-usage-table td {
  text-align: left; padding: 5px 8px; border-bottom: 1px solid rgba(148,163,184,.12);
  color: var(--t-2);
}
.my-usage-table th { color: var(--t-3); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.my-usage-table td.hl { font-family: var(--font-sans); color: var(--t-1); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-usage-table code { font-size: 10.5px; color: var(--t-3); background: rgba(148,163,184,.10); padding: 1px 4px; border-radius: 3px; }
.my-usage-empty { color: var(--t-3); font-style: italic; font-size: 12px; padding: 4px 0; }
.my-usage-footer { color: var(--t-3); font-size: 11px; font-style: italic; margin: 14px 0 0 0; padding-top: 10px; border-top: 1px dashed rgba(148,163,184,.15); }

/* Unlimited-user pill—distinguishes the no-cap state from the
   bounded-cap state. Subtle purple to signal "exception, not generic". */
.quota-pill.unlimited {
  background: rgba(168,85,247,.08);
  border-color: rgba(168,85,247,.40);
  color: #c084fc;
  font-weight: 600;
}

/* Required-field gate: Generate button stays disabled (and visually muted)
   until both required fields are filled. Native :disabled handling already
   blocks click, but the explicit class lets us style differently from
   "in-flight" disabled (where the spinner state has its own treatment). */
.btn-primary.btn-blocked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

/* Style the (required) tag—softer than a bright red asterisk; clear
   without being alarming. Pairs visually with the optional pill style. */
.form-required {
  color: var(--skip);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
  background: rgba(248,113,113,.08);
  border: 1px solid rgba(248,113,113,.30);
  padding: 1px 7px;
  border-radius: 3px;
  vertical-align: 1px;
}

/* ── Focus-visible indicators ────────────────────────────────────────────────
   WCAG 2.4.7 (Focus Visible). Round 7 audit fix: keyboard-only users couldn't
   tell which element had focus—outlines were stripped by `outline: none`
   and replaced with low-contrast border swaps. Restore visible focus rings on
   every interactive element using :focus-visible (only fires for keyboard
   navigation, never on mouse clicks—so no extra noise for mouse users). */
.btn-primary:focus-visible,
.btn-action:focus-visible,
.btn-action.btn-regenerate:focus-visible,
.quota-history-btn:focus-visible,
.help-bubble:focus-visible,
/* R14: .variant-card:focus-visible removed—<article> elements are not
   focusable and never receive focus (no tabindex). The selector was dead. */
#variant-form input:focus-visible,
#variant-form textarea:focus-visible,
#variant-form select:focus-visible,
.subnav a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--news-accent);
  outline-offset: 2px;
}
