/* Shared Predict Sports design system. Tokens mirror the hub's psl.css; extend, don't fork. */

@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("/fonts/public-sans-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --brand: #D92D20;
  --on-brand: #FFFFFF;
  --radius: 10px;
  --radius-sm: 8px;
  --gutter: 24px;
  --measure: 68ch;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Dark is the default; light follows prefers-color-scheme or the toggle. */
  color-scheme: dark;
  --bg: #0E1117;
  --surface: #151A23;
  --surface-2: #1B2230;
  --border: #263041;
  --text: #E6EAF2;
  --muted: #9AA6B8;
  --link: #7AA2FF;
  --focus: #7AA2FF;
  --gain: #34D399;
  --loss: #FBBF24;
  --skeleton-a: #1B2230;
  --skeleton-b: #263041;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #FFFFFF;
    --surface: #F6F7F9;
    --surface-2: #EDEFF3;
    --border: #E1E5EA;
    --text: #0B1220;
    --muted: #4B5565;
    --link: #1D4ED8;
    --focus: #1D4ED8;
    --gain: #0F766E;
    --loss: #B45309;
    --skeleton-a: #EDEFF3;
    --skeleton-b: #E1E5EA;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #FFFFFF;
  --surface: #F6F7F9;
  --surface-2: #EDEFF3;
  --border: #E1E5EA;
  --text: #0B1220;
  --muted: #4B5565;
  --link: #1D4ED8;
  --focus: #1D4ED8;
  --gain: #0F766E;
  --loss: #B45309;
  --skeleton-a: #EDEFF3;
  --skeleton-b: #E1E5EA;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: clamp(2.25rem, 5.2vw, 3.5rem); }
h2 { font-size: clamp(1.625rem, 3.2vw, 2.125rem); }
h3 { font-size: 1.25rem; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 0.18em; }
::selection { background: var(--link); color: var(--bg); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.num, table, .stat-value { font-variant-numeric: tabular-nums; }

.skip-link {
  position: absolute; left: var(--gutter); top: -48px; z-index: 100;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: var(--radius-sm); transition: top 0.15s var(--ease);
}
.skip-link:focus { top: 12px; }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-sm { width: 16px; height: 16px; }

.container { width: min(100% - 2 * var(--gutter), 1120px); margin-inline: auto; }
.section { padding-block: clamp(48px, 7vw, 88px); border-top: 1px solid var(--border); }
.section-head { display: grid; gap: 8px; margin-bottom: 28px; max-width: var(--measure); }
.section-head p { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 94%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px); }
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--brand); color: var(--on-brand); font-size: 1.125rem; line-height: 1; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.site-nav a { color: var(--text); text-decoration: none; padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 500; font-size: 0.9375rem; min-height: 44px; display: inline-flex; align-items: center; }
.site-nav a:hover { background: var(--surface); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface); }
.menu-btn { display: none; margin-left: auto; }
.header-tools { display: flex; gap: 8px; }
.theme-btn .icon-sun, .theme-btn .icon-moon, .theme-btn .icon-auto { display: none; }
.theme-btn[data-mode="light"] .icon-sun, .theme-btn[data-mode="dark"] .icon-moon, .theme-btn[data-mode="system"] .icon-auto { display: block; }

@media (max-width: 860px) {
  .menu-btn { display: inline-grid; }
  .site-nav {
    position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border); padding: 8px var(--gutter) 16px; margin: 0;
    visibility: hidden; opacity: 0; transform: translateY(-6px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0s 0.2s;
  }
  .site-nav.open { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
  .site-nav a { padding: 12px 8px; }
  .header-tools { margin-left: 0; }
}

/* Buttons and links: red is for the one primary action per view. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 1rem var(--font-body); text-decoration: none; cursor: pointer; transition: background 0.15s var(--ease), transform 0.15s var(--ease); }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--link); padding-inline: 8px; }
.btn-quiet:hover { background: var(--surface); }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-height: 44px; }

/* Hero */
.hero { padding-block: clamp(40px, 7vw, 88px); }
.hero-grid { display: grid; gap: 40px; align-items: start; grid-template-columns: 1fr; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 11fr 9fr; gap: 56px; } }
.hero-copy { display: grid; gap: 20px; }
.hero-copy .lede { color: var(--muted); font-size: 1.125rem; max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 4px; }
.season-line { color: var(--muted); font-size: 0.9375rem; min-height: 1.5em; }

/* Tag: status never relies on color alone. */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; min-height: 24px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.8125rem; font-weight: 600; color: var(--muted); background: var(--surface); white-space: nowrap; }
.tag-gain { color: var(--gain); border-color: color-mix(in srgb, var(--gain) 45%, transparent); }
.tag-loss { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 45%, transparent); }
.tag-solid { background: var(--text); color: var(--bg); border-color: var(--text); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }

/* Pick panel */
.pick { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; display: grid; gap: 16px; min-height: 360px; align-content: start; }
.pick-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; }
.pick-race { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.pick-when { color: var(--muted); font-size: 0.9375rem; }
.pick-horse { display: flex; align-items: baseline; gap: 12px; padding-block: 16px; border-block: 1px solid var(--border); }
.pick-number { font-family: var(--font-display); font-size: 2.25rem; font-weight: 700; min-width: 2ch; color: var(--muted); }
.pick-name { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.pick-meta { display: flex; gap: 24px; flex-wrap: wrap; }
.pick-meta dt { color: var(--muted); font-size: 0.8125rem; }
.pick-meta dd { margin: 0; font-weight: 600; font-size: 1.125rem; }
.pick-why { color: var(--text); max-width: var(--measure); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.pick-note { color: var(--muted); font-size: 0.8125rem; }

/* Stats: numbers carry the weight, not decoration. */
.stat-row { display: grid; gap: 0; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--border); margin-bottom: 32px; }
.stat { padding: 20px 16px 20px 0; display: grid; gap: 4px; align-content: start; }
.stat + .stat { padding-left: 20px; border-left: 1px solid var(--border); }
.stat-value { font-family: var(--font-display); font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.875rem; }
.stat-note { color: var(--muted); font-size: 0.8125rem; }
@media (max-width: 560px) {
  .stat-row { grid-template-columns: 1fr; }
  .stat, .stat + .stat { padding: 14px 0; border-left: 0; }
  .stat + .stat { border-top: 1px solid var(--border); }
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border-block: 1px solid var(--border); margin-bottom: 28px; }
.stat-grid .stat { padding: 16px 16px 16px 0; }
.stat-grid .stat + .stat { padding-left: 16px; }
.bankroll { font-family: var(--font-display); font-size: clamp(2.5rem, 7vw, 4rem); font-weight: 700; line-height: 1.05; }

/* Tables read like a racing form: thin rules, right-aligned figures. */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background:
  linear-gradient(to right, var(--bg) 30%, transparent) left center / 28px 100% no-repeat local,
  linear-gradient(to left, var(--bg) 30%, transparent) right center / 28px 100% no-repeat local,
  linear-gradient(to right, rgba(0,0,0,0.35), transparent) left center / 10px 100% no-repeat scroll,
  linear-gradient(to left, rgba(0,0,0,0.35), transparent) right center / 10px 100% no-repeat scroll; }
.table-wrap:focus-visible { outline-offset: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
caption { text-align: left; padding: 12px 16px; color: var(--muted); font-size: 0.875rem; caption-side: bottom; }
th, td { padding: 12px 16px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); background: var(--surface); }
tbody tr[hidden] { display: none; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface) 55%, transparent); }
td .sub { display: block; color: var(--muted); font-size: 0.8125rem; font-weight: 400; }
.scroll-hint { display: none; color: var(--muted); font-size: 0.8125rem; margin-top: 8px; }
@media (max-width: 860px) { .scroll-hint { display: block; } }

/* Data states */
.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--skeleton-a), var(--skeleton-b), var(--skeleton-a)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.state { display: grid; gap: 10px; justify-items: start; padding: 20px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.state strong { color: var(--text); font-weight: 600; }
.state-row td { padding: 24px 16px; text-align: left; color: var(--muted); white-space: normal; }
.fade-in { animation: fade-in 0.2s var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.freshness { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.875rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gain); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding-block: 40px; color: var(--muted); font-size: 0.875rem; }
.footer-grid { display: grid; gap: 24px; }
@media (min-width: 760px) { .footer-grid { grid-template-columns: 2fr 1fr; } }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.footer-links a { color: var(--text); display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
.site-footer p + p { margin-top: 8px; }
.site-footer a { color: var(--link); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .skeleton { animation: none; }
}
