/* TickTalk — base styles.
 *
 * Editorial-broadcast register, post-Phase-A. Type families self-hosted
 * under /static/fonts/ (see fonts/LICENSE-NOTICE.md for attribution).
 * Palette tokens are intentionally warm and accent-disciplined: only ONE
 * accent paint (--accent) is allowed on any given screen, reserved for the
 * primary CTA, active progress step, and the latest-take highlight.
 */

/* --- Type families --------------------------------------------------------
 *
 * Three variable woff2s, each ≈ 25-65 KB. font-display: swap renders body
 * text in the fallback first, then upgrades — no FOIT. unicode-range is
 * the latin subset only; if non-latin copy lands, re-fetch from gfonts.
 */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/fraunces-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/manrope-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/jbmono-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Design tokens --------------------------------------------------------
 *
 * Phase A: only colors + typography are new. Layout tokens stay where they
 * were so the structural pass in Phases D-F can replace them in isolation.
 *
 * Accent discipline: --accent is reserved for the primary CTA, active step
 * in the progress nav, the latest-take highlight, and the "saved" tick.
 * Default buttons use ink-on-paper outline.
 */

:root {
  /* Editorial-broadcast palette */
  --ink: #1a1814;              /* warm near-black for body + headings */
  --ink-soft: #3a342c;         /* secondary text + body emphasis */
  --paper: #fbf8f3;            /* warm cream; page background */
  --panel: #ffffff;            /* card / panel surface above paper */
  --rule: #e9e3d6;             /* warm hairline — borders + dividers */
  --muted: #7a756a;            /* warm muted grey — meta + hints */
  --accent: #c5363a;           /* deep magenta-red — single accent */
  --accent-quiet: #f4dfd9;     /* 8% tinted accent — hover/active background */
  --gold: #a47c3a;             /* warning + info affordances */
  --warn-bg: #fdf3d6;
  --warn-border: #c0951f;
  --err-bg: #f7dad6;
  --err-border: #a8302c;
  --ok-bg: #e3efd9;
  --ok-border: #3f7d4b;
  --info-bg: #f0e7df;
  --info-border: #7a756a;

  /* Backwards-compat shims — old token names still referenced by beta.css,
   * coach.css, rank.css, record.css. Phase A keeps them aliased; the
   * follow-up CSS audit (Phase A step 5) replaces direct refs.
   */
  --bg: var(--paper);
  --border: var(--rule);

  /* Type families */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body:    "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale — 1.25 ratio, 16 px base */
  --type-display: 40px;        /* hero h1 (display serif) */
  --type-h1:      28px;        /* page h1 (display serif) */
  --type-h2:      20px;        /* section h2 (sans semibold) */
  --type-body:    16px;        /* default body */
  --type-small:   14px;        /* meta + hints */
  --type-mono:    14px;        /* numerals + slugs in admin */
  --leading-display: 1.1;
  --leading-body:    1.6;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  font-size: var(--type-body);
  line-height: var(--leading-body);
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: var(--leading-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: var(--type-h1); }
h2 { font-size: var(--type-h2); font-family: var(--font-body); font-weight: 600; letter-spacing: 0; }
h3 { font-size: var(--type-body); font-family: var(--font-body); font-weight: 600; letter-spacing: 0; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
}

header h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

.pill {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 4px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.pill:hover { color: var(--ink); border-color: var(--ink-soft); }
.pill.ok  { color: var(--ok-border);  border-color: var(--ok-border); }
.pill.err { color: var(--err-border); border-color: var(--err-border); }

main {
  max-width: 880px;
  margin: 32px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

input[type="url"], input[type="text"], input[type="number"], select, textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
input[type="url"], input[type="text"] { min-width: 240px; }
input[type="number"] { width: 100px; font-family: var(--font-mono); }

textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

button {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
button:hover { background: var(--accent-quiet); border-color: var(--accent); }
button.primary {
  background: var(--accent);
  color: var(--panel);
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover { filter: brightness(0.95); }
button.secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--rule);
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--rule);
  background: var(--paper);
}
.status:empty { display: none; }
.status.info { background: var(--info-bg); border-color: var(--info-border); }
.status.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--gold); }
.status.err  { background: var(--err-bg);  border-color: var(--err-border); color: var(--err-border); }
.status.ok   { background: var(--ok-bg);   border-color: var(--ok-border); color: var(--ok-border); }

.meta {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--muted);
}
.hint {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--muted);
}

/* Numerals + slugs (admin tables, version strings) render mono */
code, .mono { font-family: var(--font-mono); }

#player { width: 100%; aspect-ratio: 16 / 9; background: #000; }
#audio-preview { display: block; width: 100%; margin: 8px 0; }

/* --- Phase H: global responsive + accessibility base --------------------- */

/* Never allow horizontal scroll on a phone. Media elements cap to container. */
html, body { max-width: 100%; overflow-x: hidden; }
audio, img, canvas, video, svg { max-width: 100%; }

/* Visible keyboard focus ring on every interactive element. Mouse users keep
 * the clean look (:focus-visible only fires for keyboard / programmatic focus). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Respect reduced-motion: kill transitions, animations, smooth scroll. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Single-column main padding tightens on small screens. */
@media (max-width: 768px) {
  main { padding: 0 14px; margin: 20px auto; gap: 16px; }
  .panel { padding: 16px; }
}

/* Screen-reader-only utility for labels we don't want shown visually. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Phase H: mobile overflow fixes (≤480px) ----------------------------- */
@media (max-width: 480px) {
  /* Text inputs shouldn't force their 240px min-width on a phone. */
  input[type="url"], input[type="text"] { min-width: 0; width: 100%; }
  /* Side-by-side audio / chart rows stack vertically. */
  .audio-row { grid-template-columns: 1fr !important; }
  .chart-row { grid-template-columns: 1fr !important; }
}
