/* ─────────────────────────────────────────────────────────────────────────
   RunTheBook — design-tokens.css
   Single source of truth for the visual system. Lifted directly from the
   Tweaks panel: every --rtb-* below is what the panel writes at runtime.
   ───────────────────────────────────────────────────────────────────────── */

.rtb-root {
  /* Surfaces (evolved from existing brand tokens) ------------------------ */
  --rtb-bg:        #0A0D11;
  --rtb-panel:     #11151c;
  --rtb-panel-2:   #0d1117;
  --rtb-line:      #1f2530;
  --rtb-line-2:    #2a3142;

  /* Ink ----------------------------------------------------------------- */
  --rtb-ink:       #E8ECF4;
  --rtb-ink-2:     #b6bfd0;
  --rtb-dim:       #7A8499;
  --rtb-mute:      #4a5263;

  /* Signal -------------------------------------------------------------- */
  --rtb-accent:    #C8102E;   /* hot accent — used sparingly, like an ON-AIR light */
  --rtb-accent-ink:#ffffff;
  --rtb-ok:        #2cae67;
  --rtb-warn:      #f0a020;

  /* Alignment chips (face/heel/tweener) -------------------------------- */
  --rtb-face:      #4fb6e8;
  --rtb-heel:      #C8102E;
  --rtb-tweener:   #b59a55;

  /* Geometry ----------------------------------------------------------- */
  --rtb-radius:    10px;
  --rtb-radius-sm: 6px;
  --rtb-radius-lg: 14px;
  --rtb-tap:       46px;

  /* Type --------------------------------------------------------------- */
  --rtb-font-display: "Oswald", "Impact", "Arial Narrow", sans-serif;
  --rtb-font-body:    "Inter", system-ui, -apple-system, sans-serif;
  --rtb-font-mono:    "JetBrains Mono", "SF Mono", ui-monospace, monospace;
  --rtb-type-scale:   1;

  --rtb-fs-12: calc(12px * var(--rtb-type-scale));
  --rtb-fs-13: calc(13px * var(--rtb-type-scale));
  --rtb-fs-14: calc(14px * var(--rtb-type-scale));
  --rtb-fs-16: calc(16px * var(--rtb-type-scale));
  --rtb-fs-18: calc(18px * var(--rtb-type-scale));
  --rtb-fs-22: calc(22px * var(--rtb-type-scale));
  --rtb-fs-28: calc(28px * var(--rtb-type-scale));
  --rtb-fs-40: calc(40px * var(--rtb-type-scale));
  --rtb-fs-56: calc(56px * var(--rtb-type-scale));

  /* Density — drives row/pad scale ----------------------------------- */
  --rtb-density:   1;            /* 0.85 compact · 1 regular · 1.15 comfy */
  --rtb-pad-1:     calc(6px  * var(--rtb-density));
  --rtb-pad-2:     calc(10px * var(--rtb-density));
  --rtb-pad-3:     calc(14px * var(--rtb-density));
  --rtb-pad-4:     calc(20px * var(--rtb-density));
  --rtb-pad-5:     calc(28px * var(--rtb-density));

  /* Motion — flip to 0 for reduced-motion ---------------------------- */
  --rtb-motion:    1;
  --rtb-dur-fast:  calc(120ms * var(--rtb-motion));
  --rtb-dur:       calc(220ms * var(--rtb-motion));
  --rtb-dur-slow:  calc(420ms * var(--rtb-motion));

  /* Surface depth — how lifted panels feel above bg ------------------ */
  --rtb-depth:     1;
  --rtb-shadow-1:  0 1px 0 rgba(255,255,255,0.02), 0 calc(6px * var(--rtb-depth)) calc(18px * var(--rtb-depth)) rgba(0,0,0,calc(0.35 * var(--rtb-depth)));
  --rtb-shadow-2:  0 calc(12px * var(--rtb-depth)) calc(40px * var(--rtb-depth)) rgba(0,0,0,calc(0.5 * var(--rtb-depth)));

  /* Broadcast — derived ---------------------------------------------- */
  --rtb-skew:      -12deg;
  --rtb-strap-h:   28px;

  background: var(--rtb-bg);
  color: var(--rtb-ink);
  font-family: var(--rtb-font-body);
  font-size: var(--rtb-fs-14);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  .rtb-root { --rtb-motion: 0; }
}

/* Mobile frame ---------------------------------------------------------- */
.rtb-frame {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--rtb-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}
.rtb-frame::before {
  /* Subtle vignette to lift the broadcast feel */
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 0%, rgba(200,16,46,0.04), transparent 55%);
  pointer-events: none;
  z-index: 0;
}
.rtb-frame > * { position: relative; z-index: 1; }

/* Top bar — broadcast chrome -------------------------------------------- */
.rtb-topbar {
  display: flex;
  align-items: center;
  gap: var(--rtb-pad-2);
  padding: 14px var(--rtb-pad-4) 10px;
  background: linear-gradient(180deg, var(--rtb-panel-2) 0%, transparent 100%);
  border-bottom: 1px solid var(--rtb-line);
}
.rtb-topbar-title {
  font-family: var(--rtb-font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  font-size: var(--rtb-fs-18);
  line-height: 1;
  flex: 1;
}
.rtb-iconbtn {
  width: var(--rtb-tap);
  height: var(--rtb-tap);
  border-radius: var(--rtb-radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--rtb-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  margin-left: calc(var(--rtb-pad-3) * -1);
  transition: background var(--rtb-dur-fast), border-color var(--rtb-dur-fast);
}
.rtb-iconbtn:hover { background: var(--rtb-panel); border-color: var(--rtb-line); }
.rtb-iconbtn:focus-visible { outline: 2px solid var(--rtb-accent); outline-offset: 2px; }

/* ON-AIR pip ----------------------------------------------------------- */
.rtb-onair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--rtb-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--rtb-ink-2);
}
.rtb-onair .dot {
  width: 7px; height: 7px;
  background: var(--rtb-accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(200,16,46,0.18);
  animation: rtb-pulse calc(1400ms * var(--rtb-motion, 1)) ease-in-out infinite;
}
@keyframes rtb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Lower-third strap — angled broadcast cut ------------------------------ */
.rtb-strap {
  position: relative;
  padding: 6px var(--rtb-pad-3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--rtb-font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  font-size: var(--rtb-fs-12);
  line-height: 1;
  color: var(--rtb-accent-ink);
  background: var(--rtb-accent);
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  padding-right: calc(var(--rtb-pad-3) + 10px);
}
.rtb-strap--ghost {
  background: var(--rtb-panel);
  color: var(--rtb-ink-2);
  border: 1px solid var(--rtb-line);
}

/* Panel ---------------------------------------------------------------- */
.rtb-panel {
  background: var(--rtb-panel);
  border: 1px solid var(--rtb-line);
  border-radius: var(--rtb-radius);
  box-shadow: var(--rtb-shadow-1);
}
.rtb-panel--sunk { background: var(--rtb-panel-2); }

/* Section eyebrow ------------------------------------------------------ */
.rtb-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--rtb-font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--rtb-dim);
}
.rtb-eyebrow::before {
  content: "";
  width: 12px; height: 2px;
  background: var(--rtb-accent);
}

/* Buttons -------------------------------------------------------------- */
.rtb-btn {
  min-height: var(--rtb-tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 var(--rtb-pad-4);
  font-family: var(--rtb-font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: var(--rtb-fs-14);
  font-weight: 600;
  border-radius: var(--rtb-radius);
  border: 1px solid var(--rtb-line);
  background: var(--rtb-panel);
  color: var(--rtb-ink);
  cursor: pointer;
  transition: background var(--rtb-dur-fast), border-color var(--rtb-dur-fast), transform var(--rtb-dur-fast);
}
.rtb-btn:hover { border-color: var(--rtb-line-2); background: var(--rtb-panel-2); }
.rtb-btn:active { transform: translateY(1px); }
.rtb-btn:focus-visible { outline: 2px solid var(--rtb-accent); outline-offset: 2px; }
.rtb-btn--primary {
  background: var(--rtb-accent);
  border-color: var(--rtb-accent);
  color: var(--rtb-accent-ink);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04) inset, var(--rtb-shadow-1);
}
.rtb-btn--primary:hover { background: #d92b48; border-color: #d92b48; }
.rtb-btn--ghost { background: transparent; }

/* Chips ---------------------------------------------------------------- */
.rtb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  font-family: var(--rtb-font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rtb-ink-2);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--rtb-line);
}
.rtb-chip--face    { color: var(--rtb-face);    border-color: rgba(79,182,232,0.45); background: rgba(79,182,232,0.08); }
.rtb-chip--heel    { color: var(--rtb-heel);    border-color: rgba(200,16,46,0.45); background: rgba(200,16,46,0.10); }
.rtb-chip--tweener { color: var(--rtb-tweener); border-color: rgba(181,154,85,0.45); background: rgba(181,154,85,0.10); }

/* Numeric readout ------------------------------------------------------- */
.rtb-num {
  font-family: var(--rtb-font-display);
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
}
.rtb-mono {
  font-family: var(--rtb-font-mono);
  font-variant-numeric: tabular-nums;
}

/* Stat bar ------------------------------------------------------------- */
.rtb-bar {
  height: 4px;
  background: var(--rtb-line);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.rtb-bar > i {
  display: block;
  height: 100%;
  background: var(--rtb-ink);
  border-radius: 2px;
  transition: width var(--rtb-dur) cubic-bezier(.2,.7,.2,1);
}
.rtb-bar--accent > i { background: var(--rtb-accent); }
.rtb-bar--ok > i { background: var(--rtb-ok); }

/* Pip row -------------------------------------------------------------- */
.rtb-pips { display: inline-flex; gap: 3px; }
.rtb-pip {
  width: 10px; height: 10px;
  border-radius: 2px;
  background: var(--rtb-line);
}
.rtb-pip--on { background: var(--rtb-ink); }
.rtb-pip--accent.rtb-pip--on { background: var(--rtb-accent); }

/* Bottom nav (nav-v2 · DH#261) ---------------------------------------- */
/* Frosted broadcast strip. Active tab lights up like a selected channel:
   accent icon + a lower-third "tick" cut at the top edge of the cell.
   Safe-area aware so it floats above the iOS home indicator. */
.rtb-tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--rtb-panel-2) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--rtb-line);
  position: relative;
  z-index: 40;
}
.rtb-tab {
  position: relative;
  min-height: var(--rtb-tap);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 2px 6px;
  background: transparent;
  border: 0;
  color: var(--rtb-dim);
  font-family: var(--rtb-font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--rtb-radius-sm);
  -webkit-tap-highlight-color: transparent;
  transition: color calc(var(--rtb-dur-fast) * var(--rtb-motion, 1)),
              transform calc(140ms * var(--rtb-motion, 1)) cubic-bezier(.2,.7,.3,1);
}
.rtb-tab:active { transform: scale(0.92); }
.rtb-tab svg {
  width: 22px; height: 22px;
  transition: transform calc(220ms * var(--rtb-motion, 1)) cubic-bezier(.2,.7,.3,1);
}

/* icon shell — anchors the badge */
.rtb-tab__ico {
  position: relative;
  display: grid; place-items: center;
  width: 28px; height: 26px;
}
.rtb-tab__label { font-weight: 500; white-space: nowrap; line-height: 1; }

/* lower-third tick at the top edge of the active cell */
.rtb-tab__tick {
  position: absolute; top: -1px; left: 50%;
  width: 28px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--rtb-accent);
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  transition: transform calc(220ms * var(--rtb-motion, 1)) cubic-bezier(.2,.7,.3,1);
}

/* active state */
.rtb-tab[aria-current="page"] { color: var(--rtb-ink); }
.rtb-tab[aria-current="page"] .rtb-tab__ico { color: var(--rtb-accent); }
.rtb-tab[aria-current="page"] svg {
  transform: translateY(-1px);
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--rtb-accent) 55%, transparent));
}
.rtb-tab[aria-current="page"] .rtb-tab__label { color: var(--rtb-ink); font-weight: 600; }
.rtb-tab[aria-current="page"] .rtb-tab__tick { transform: translateX(-50%) scaleX(1); }
.rtb-tab:focus-visible { outline: 2px solid var(--rtb-accent); outline-offset: 2px; }

/* MARKET "new" badge */
.rtb-tab__badge {
  position: absolute; top: -1px; right: 2px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rtb-accent);
  box-shadow: 0 0 0 2px var(--rtb-panel-2),
              0 0 8px color-mix(in srgb, var(--rtb-accent) 75%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .rtb-tab__badge { animation: rtb-badge-pulse 2.4s ease-in-out infinite; }
}
@keyframes rtb-badge-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Stripey placeholder (for portraits / asset slots) -------------------- */
.rtb-placeholder {
  background:
    repeating-linear-gradient(135deg,
      rgba(255,255,255,0.03) 0 6px,
      transparent 6px 12px),
    var(--rtb-panel-2);
  border: 1px dashed var(--rtb-line-2);
  display: grid;
  place-items: center;
  color: var(--rtb-dim);
  font-family: var(--rtb-font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Ticker --------------------------------------------------------------- */
.rtb-ticker {
  display: flex;
  align-items: center;
  height: 24px;
  border-top: 1px solid var(--rtb-line);
  border-bottom: 1px solid var(--rtb-line);
  overflow: hidden;
  background: var(--rtb-panel-2);
}
.rtb-ticker .tag {
  flex: 0 0 auto;
  background: var(--rtb-accent);
  color: var(--rtb-accent-ink);
  font-family: var(--rtb-font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  padding: 0 10px;
  height: 100%;
  display: grid; place-items: center;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  padding-right: 16px;
}
.rtb-ticker .scroll {
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}
.rtb-ticker .scroll-inner {
  display: inline-block;
  padding-left: 100%;
  animation: rtb-ticker-scroll calc(28s / var(--rtb-motion, 1)) linear infinite;
  font-family: var(--rtb-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--rtb-ink-2);
}
.rtb-ticker .scroll-inner span { color: var(--rtb-dim); margin: 0 18px; }
.rtb-ticker .scroll-inner em {
  font-style: normal;
  color: var(--rtb-accent);
  margin-right: 4px;
}
@keyframes rtb-ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* Match-card --------------------------------------------------------- */
.rtb-matchcard {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: var(--rtb-pad-2) var(--rtb-pad-3);
  background: var(--rtb-panel);
  border: 1px solid var(--rtb-line);
  border-radius: var(--rtb-radius);
  min-height: var(--rtb-tap);
}
.rtb-matchcard__num {
  font-family: var(--rtb-font-display);
  font-size: var(--rtb-fs-18);
  color: var(--rtb-dim);
  text-align: center;
}
.rtb-matchcard__type {
  font-family: var(--rtb-font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rtb-dim);
  margin-bottom: 2px;
}
.rtb-matchcard__line {
  font-family: var(--rtb-font-display);
  text-transform: uppercase;
  font-size: var(--rtb-fs-14);
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.rtb-matchcard--seg .rtb-matchcard__line {
  font-family: var(--rtb-font-body);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--rtb-ink-2);
}
.rtb-matchcard__handle {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--rtb-dim);
  cursor: grab;
}
.rtb-matchcard__handle:active { cursor: grabbing; }

/* Telecast diagonal mask used in headers ------------------------------ */
.rtb-cut {
  background: linear-gradient(180deg, var(--rtb-panel) 0%, transparent 100%);
  position: relative;
}
.rtb-cut::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 6px;
  background:
    linear-gradient(90deg, var(--rtb-accent) 0, var(--rtb-accent) 30%, transparent 30%, transparent 33%, var(--rtb-line) 33%, var(--rtb-line) 100%);
  clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 100%, 0 100%);
}

/* a11y ---------------------------------------------------------------- */
.rtb-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
