/* ============================================================
   BOYZ IN MOTION — Main CSS
   Tokens, reset, typography, layout, nav, footer.
   Every value here comes from DESIGN.md.
   ============================================================ */

/* ─── Design Tokens ────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg-primary:    #f6f5f4;
  --bg-surface:    #ffffff;
  --bg-surface-2:  #fafaf9;
  --bg-surface-3:  #efedea;   /* legacy name: recessed chips, empty cells */
  --bg-feature:    #f5e3c7;
  --bg-inverse:    #141413;
  --bg-inverse-2:  #292d30;
  --bg-nav:        #ffffff;

  /* Text */
  --text-primary:   #0c0a09;
  --text-secondary: #615d59;
  --text-muted:     #78716c;
  --text-faint:     #a8a29e;
  --text-inverse:   #faf9f5;

  /* Borders */
  --border:        #e8e6e5;
  --border-mid:    #d6d3d1;

  /* Accent */
  --accent:        #A8192A;
  --accent-hover:  #8C1423;
  --accent-wash:   #f6dfe1;

  /* Data */
  --win:           #15803d;
  --loss:          #78716c;
  --tie:           #b45309;

  /* Position tints */
  --pos-qb:        #fde2e1;
  --pos-rb:        #dcf3e3;
  --pos-wr:        #dbeefd;
  --pos-te:        #fde8d3;
  --pos-flex:      #fdf1c7;
  --pos-k:         #e3eef0;
  --pos-def:       #ebe2fb;
  --pos-bench:     #efedea;

  /* Legacy aliases kept so older markup and inline styles still resolve */
  --accent-dim:    var(--accent-wash);
  --accent-glow:   transparent;
  --border-accent: var(--border-mid);
  --silver:        var(--text-muted);
  --silver-bright: var(--text-primary);
  --silver-dim:    var(--bg-surface-2);
  --win-dim:       transparent;
  --loss-dim:      transparent;

  /* Typography */
  --font-display:  'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --font-heading:  'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body:     'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-data:     'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Spacing — 4px grid */
  --sp-4: 4px;   --sp-8: 8px;   --sp-12: 12px; --sp-16: 16px;
  --sp-20: 20px; --sp-24: 24px; --sp-32: 32px; --sp-40: 40px;
  --sp-48: 48px; --sp-64: 64px; --sp-80: 80px; --sp-96: 96px;

  /* Radius */
  --radius:        6px;
  --radius-lg:     12px;
  --radius-xl:     20px;
  --radius-pill:   9999px;

  /* Elevation — floating elements only */
  --shadow-float:  0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow:        none;
  --shadow-lg:     none;
  --shadow-accent: none;

  /* Layout */
  --nav-height:    64px;
  --max-width:     1200px;
  --gutter:        24px;
  --section-gap:   80px;
  --card-pad:      24px;
  --transition:    150ms ease-out;
  --transition-slow: 300ms ease-out;
}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
    --section-gap: 48px;
    --card-pad: 16px;
  }
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main { flex: 1; }

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--text-primary); text-decoration: underline; text-underline-offset: 3px; }

img { max-width: 100%; display: block; }

button {
  cursor: pointer;
  font-family: var(--font-body);
  border: none;
  background: none;
  color: inherit;
}

ul, ol { list-style: none; }

table { border-collapse: collapse; width: 100%; }

strong { font-weight: 600; color: var(--text-primary); }

:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

/* ─── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 { font-family: var(--font-display); font-weight: 400; font-size: 48px; line-height: 1.1; letter-spacing: -0.015em; }
h2 { font-size: 32px; line-height: 1.2; letter-spacing: -0.025em; }
h3 { font-size: 24px; }
h4 { font-size: 20px; font-weight: 500; line-height: 1.3; letter-spacing: -0.01em; }
h5 { font-size: 16px; }

p { color: var(--text-secondary); }

.text-accent    { color: var(--text-primary); }
.text-silver    { color: var(--text-primary); }
.text-win       { color: var(--win); }
.text-loss      { color: var(--loss); }
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.uppercase { text-transform: uppercase; letter-spacing: 0.06em; }

/* The single highlight allowed per page headline */
.hl {
  color: var(--accent);
  background: var(--accent-wash);
  border-radius: var(--radius-pill);
  padding: 0 0.28em 0.04em;
  margin: 0 -0.06em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.page {
  min-height: calc(100vh - var(--nav-height));
  padding-top: var(--nav-height);
  animation: fadeInPage var(--transition-slow) both;
}

.page-inner {
  padding: var(--sp-64) var(--gutter) var(--section-gap);
}

/* Page headline block */
.section-header {
  margin-bottom: var(--sp-40);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* The h1 that opens a page is the page title: display serif */
h1.section-title {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

/* Sub-sections set their own size inline in older markup; hold them to the scale */
h2.section-title { font-size: 24px !important; }

.section-subtitle {
  color: var(--text-muted);
  margin-top: var(--sp-12);
  font-size: 16px !important;
  line-height: 1.6;
  max-width: 62ch;
}

h2.section-title + .section-subtitle {
  font-size: 14px !important;
  margin-top: var(--sp-8);
}

/* ─── Grid helpers ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-16); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-16); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-16); }

@media (max-width: 960px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 34px; }
  .page-inner { padding-top: var(--sp-40); }
  .section-header { margin-bottom: var(--sp-24); }
}

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes fadeInPage {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Kept by name for older markup; no overshoot */
@keyframes trophy-entrance {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger-children > * {
  animation: fadeInUp 300ms ease-out both;
}
.stagger-children > *:nth-child(1)  { animation-delay: 0ms; }
.stagger-children > *:nth-child(2)  { animation-delay: 30ms; }
.stagger-children > *:nth-child(3)  { animation-delay: 60ms; }
.stagger-children > *:nth-child(4)  { animation-delay: 90ms; }
.stagger-children > *:nth-child(5)  { animation-delay: 120ms; }
.stagger-children > *:nth-child(6)  { animation-delay: 150ms; }
.stagger-children > *:nth-child(7)  { animation-delay: 180ms; }
.stagger-children > *:nth-child(8)  { animation-delay: 210ms; }
.stagger-children > *:nth-child(9)  { animation-delay: 240ms; }
.stagger-children > *:nth-child(n+10) { animation-delay: 270ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}

/* ─── Loading & Error states ─────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  gap: var(--sp-16);
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--border-mid);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; }

.loading-text {
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  gap: var(--sp-12);
  text-align: center;
  padding: var(--sp-32);
}

.error-state .error-icon { font-size: 32px; }
.error-state h2, .error-state h3 { font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.error-state p  { color: var(--text-muted); max-width: 420px; }

/* ─── Navigation ─────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--nav-height);
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--transition);
}

.nav.is-scrolled { box-shadow: var(--shadow-float); }

.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-32);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; }

.nav-logo { font-size: 16px; line-height: 1; }

.nav-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  white-space: nowrap;
}

.nav-title span { color: inherit; }

.nav-links {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  flex: 1;
  height: 100%;
}

.nav-links li { display: flex; }

.nav-links a {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0 var(--sp-12);
  display: flex;
  align-items: center;
  /* 2px underline sits on the bar's bottom hairline */
  box-shadow: inset 0 -2px 0 transparent;
  transition: color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.nav-links a.active {
  color: var(--text-primary);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 10px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--bg-surface);
}

.nav-toggle span {
  display: block;
  height: 1.5px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

.nav-toggle.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

@media (max-width: 960px) {
  .nav-toggle { display: flex; }

  /* Menu sheet */
  .nav-links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-float);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    height: auto;
    max-height: calc(100vh - var(--nav-height));
    overflow-y: auto;
    padding: var(--sp-8) 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition), visibility 0s linear 150ms;
    z-index: 999;
  }
  .nav-links.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--transition), visibility 0s linear 0s;
  }
  .nav-links a {
    flex: 1;
    padding: var(--sp-12) var(--gutter);
    font-size: 16px;
    box-shadow: inset 2px 0 0 transparent;
  }
  .nav-links a:hover { background: var(--bg-surface-2); }
  .nav-links a.active { box-shadow: inset 2px 0 0 var(--accent); }
}

/* ─── Footer ─────────────────────────────────────────────────── */
footer {
  background: var(--bg-inverse);
  color: var(--text-inverse);
  font-size: 12px;
  line-height: 1.5;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--sp-48) var(--gutter) var(--sp-32);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-48);
  align-items: start;
}

.footer-brand {
  font-family: var(--font-data);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-inverse);
}

.footer-brand .footer-mark { margin-right: var(--sp-8); }

.footer-legal {
  margin-top: var(--sp-12);
  font-family: var(--font-data);
  color: var(--text-faint);
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, auto));
  grid-auto-flow: row;
  column-gap: var(--sp-64);
  row-gap: var(--sp-8);
}

.footer-links a { color: var(--text-faint); }
.footer-links a:hover { color: var(--text-inverse); }

.footer-base {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--sp-16) var(--gutter) var(--sp-24);
  border-top: 1px solid var(--bg-inverse-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-16);
  flex-wrap: wrap;
  color: var(--text-faint);
}

footer p { color: inherit; }
.footer-base a { color: var(--text-faint); text-decoration: underline; text-underline-offset: 3px; }
.footer-base a:hover { color: var(--text-inverse); }

footer .btn-ghost {
  background: transparent;
  color: var(--text-faint);
  border-color: var(--bg-inverse-2);
  font-size: 12px;
  padding: 4px 10px;
}
footer .btn-ghost:hover {
  background: transparent;
  color: var(--text-inverse);
  border-color: var(--text-faint);
}

@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; gap: var(--sp-32); }
  .footer-links { column-gap: var(--sp-32); }
}

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ─── Selection ───────────────────────────────────────────────── */
::selection {
  background: var(--accent-wash);
  color: var(--text-primary);
}
