/* ============================================================
   ApexAtlas · design system
   Palette is taken from the track maps themselves so the UI and
   the artwork share one language.
   ============================================================ */
:root {
  --ink:        #0d0d14;
  --ink-2:      #12121c;
  --panel:      #181824;
  --panel-2:    #1f1f2e;
  --line:       rgba(247, 244, 241, .12);
  --line-2:     rgba(247, 244, 241, .22);
  --paper:      #f7f4f1;
  --text:       #f7f4f1;
  --muted:      rgba(247, 244, 241, .62);
  --muted-2:    rgba(247, 244, 241, .40);

  --s1:         #e51073;   /* Sector 1 magenta  */
  --s2:         #ffd100;   /* Sector 2 yellow   */
  --s3:         #4098d9;   /* Sector 3 blue     */
  --straight:   #e62b00;   /* straight-mode red */
  --overtake:   #71cc98;   /* overtake green    */

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 22px;
  --pad:  clamp(16px, 3.2vw, 34px);
  --maxw: 1240px;
  --head-h: 62px;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, .8);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 82% -8%, rgba(229, 16, 115, .16), transparent 60%),
    radial-gradient(900px 520px at 6% 4%, rgba(64, 152, 217, .14), transparent 62%),
    var(--ink);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.68;
  letter-spacing: .012em;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4.4vw, 46px); }
h2 { font-size: clamp(21px, 2.6vw, 29px); }
h3 { font-size: clamp(17px, 1.9vw, 21px); }
p { margin: 0 0 .9em; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible { outline: 2px solid var(--s2); outline-offset: 3px; border-radius: 4px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--s2); color: #000; padding: 10px 16px; border-radius: 0 0 var(--r-sm) 0; font-weight: 600;
}
.skip:focus { left: 0; }

/* ---------------- header ---------------- */
.site-head {
  position: sticky; top: 0; z-index: 40;
  background: rgba(13, 13, 20, .82);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.head-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad);
  height: var(--head-h); display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 11px; margin-right: auto; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: url("../assets/favicon.svg") center / contain no-repeat;
  box-shadow: 0 0 0 1px rgba(247, 244, 241, .22);
  position: relative;
}
.brand-mark::after { display: none; }

/* season switcher (2026 / 2027) */
.season-switch { display: flex; gap: 2px; align-items: center; background: rgba(247,244,241,.06);
  border: 1px solid rgba(247,244,241,.14); border-radius: 999px; padding: 2px; margin-left: 10px; flex: none; }
.season-switch button { border: 0; background: transparent; color: var(--muted); font: inherit;
  font-size: 13px; padding: 4px 11px; border-radius: 999px; cursor: pointer; }
.season-switch button[aria-pressed="true"] { background: var(--s1); color: #fff; }
.season-switch button:focus-visible { outline: 2px solid var(--s2); outline-offset: 1px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 17px; letter-spacing: .02em; }
.brand-text small { font-size: 11px; color: var(--muted-2); letter-spacing: .14em; }

.site-nav { display: flex; gap: 4px; }
.site-nav a {
  padding: 8px 14px; border-radius: 999px; font-size: 14.5px; color: var(--muted);
  transition: color .2s, background .2s;
}
.site-nav a:hover { color: var(--text); background: rgba(247, 244, 241, .06); }
.site-nav a.on { color: #0d0d14; background: var(--text); font-weight: 600; }
.nav-toggle {
  display: none; width: 40px; height: 36px; border: 1px solid var(--line-2);
  background: transparent; border-radius: var(--r-sm); position: relative;
}
.nav-toggle span[aria-hidden] {
  position: absolute; left: 10px; right: 10px; top: 17px; height: 2px; background: var(--text);
  box-shadow: 0 -6px 0 var(--text), 0 6px 0 var(--text);
}

/* ---------------- layout ---------------- */
.view { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad) 90px; min-height: 60vh; }
.view:focus { outline: none; }
section { margin-top: clamp(40px, 6vw, 72px); }
.sec-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.sec-head h2 { margin-right: auto; }
.eyebrow {
  font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted-2);
  display: block; margin-bottom: 10px;
}
.lede { color: var(--muted); max-width: 68ch; font-size: 16.5px; }

/* ---------------- hero ---------------- */
.hero { padding-top: clamp(34px, 6vw, 66px); position: relative; }
.hero h1 { max-width: 20ch; }
.hero h1 em { font-style: normal; color: var(--s2); }
.hero-top { display: grid; gap: 26px; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); align-items: end; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.stat {
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px; background: rgba(24, 24, 36, .6);
  min-width: 108px;
}
.stat b { display: block; font-size: 22px; line-height: 1.2; }
.stat span { font-size: 12.5px; color: var(--muted-2); }
.hero-strip {
  height: 4px; border-radius: 999px; margin: 34px 0 0;
  background: linear-gradient(90deg, var(--s1) 0 33.3%, var(--s2) 0 66.6%, var(--s3) 0 100%);
  opacity: .85;
}

/* ---------------- cards / chips ---------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  font-size: 12.5px; border: 1px solid var(--line-2); color: var(--muted); background: rgba(255, 255, 255, .03);
  white-space: nowrap;
}
.chip.solid { color: #0d0d14; border-color: transparent; font-weight: 650; }
.chip.sprint { background: var(--s2); }
.chip.round { background: rgba(247, 244, 241, .1); color: var(--text); font-variant-numeric: tabular-nums; }
.chip.s1 { background: var(--s1); color: #fff; }
.chip.s2 { background: var(--s2); }
.chip.s3 { background: var(--s3); color: #06121c; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.fchip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent;
  font-size: 14px; color: var(--muted); transition: all .18s var(--ease);
}
.fchip:hover { color: var(--text); border-color: var(--line-2); background: rgba(255, 255, 255, .05); }
.fchip[aria-pressed="true"] { background: var(--text); color: #0d0d14; border-color: var(--text); font-weight: 620; }
.search {
  margin-left: auto; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2);
  border-radius: 999px; padding: 6px 14px; background: rgba(255, 255, 255, .04);
}
.search input {
  border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; width: 170px; outline: none;
}
.search input::placeholder { color: var(--muted-2); }
.search svg { opacity: .55; flex: none; }

/* calendar grid */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.tcard {
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--panel);
  display: flex; flex-direction: column; transition: transform .22s var(--ease), border-color .22s, box-shadow .22s;
}
.tcard:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: var(--shadow); }
.tcard-map { background: var(--paper); padding: 10px 12px; position: relative; }
.tcard-map img { width: 100%; height: 118px; object-fit: contain; }
.tcard-map .rn {
  position: absolute; left: 12px; top: 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  color: rgba(13, 13, 20, .55); font-variant-numeric: tabular-nums;
}
.tcard-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tcard-body h3 { font-size: 16.5px; }
.tcard-sub { font-size: 12.5px; color: var(--muted-2); }
.tcard-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 10px; }
.tcard-note { font-size: 13px; color: var(--muted); line-height: 1.6; }
.tagline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------------- track detail ---------------- */
.crumb { display: inline-flex; align-items: center; gap: 8px; margin-top: 26px; color: var(--muted); font-size: 14px; }
.crumb:hover { color: var(--text); }
.td-head { padding-top: 14px; display: grid; gap: 16px; }
.td-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.td-flag { font-size: 34px; line-height: 1; }
.td-title h1 { font-size: clamp(24px, 3.4vw, 36px); }
.td-names { color: var(--muted); font-size: 15px; }
.td-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.td-intro { max-width: 74ch; color: var(--muted); font-size: 16px; margin-top: 4px; }

/* map + panel */
.td-main { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.map-card {
  background: var(--paper); border-radius: var(--r-lg); padding: 10px; border: 1px solid var(--line-2);
  box-shadow: var(--shadow); position: relative;
}
.map-stage { position: relative; }
.map-stage img.base { width: 100%; height: auto; }
.map-stage img.dim {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
  transition: opacity .3s var(--ease); pointer-events: none;
}
.map-stage.dimmed img.dim { opacity: 1; }
.hs {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent;
  background: transparent; color: transparent; font-size: 0; padding: 0;
  transition: background .18s, border-color .18s, transform .18s, box-shadow .18s;
}
.hs::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 1px dashed rgba(13, 13, 20, .22);
}
.hs:hover { background: rgba(229, 16, 115, .22); border-color: var(--s1); transform: translate(-50%, -50%) scale(1.18); }
.hs:hover::after { border-color: transparent; }
.hs.on { background: var(--s1); border-color: #fff; box-shadow: 0 0 0 4px rgba(229, 16, 115, .28); transform: translate(-50%, -50%) scale(1.22); }
.hs.in-group { background: rgba(255, 209, 0, .4); border-color: #0d0d14; }
.hs.off { opacity: .1; pointer-events: none; }
.map-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 12px)); background: #0d0d14; color: var(--text);
  border: 1px solid var(--line-2); padding: 4px 9px; border-radius: var(--r-sm); font-size: 12.5px;
  pointer-events: none; white-space: nowrap; opacity: 0; transition: opacity .15s; font-weight: 600;
}
.map-tip.on { opacity: 1; }

.map-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.map-tools .fchip { padding: 6px 12px; font-size: 13px; }
/* controls live on the paper card, so they need ink-on-paper colours */
.map-card .fchip { color: rgba(13, 13, 20, .72); border-color: rgba(13, 13, 20, .22); background: rgba(13, 13, 20, .04); }
.map-card .fchip:hover { background: rgba(13, 13, 20, .09); color: #0d0d14; }
.map-card .fchip[aria-pressed="true"] { background: #0d0d14; color: var(--paper); border-color: #0d0d14; }
.map-card .dot { box-shadow: 0 0 0 1px rgba(13, 13, 20, .25); }
.legend-toggle { margin-left: auto; }

.legend {
  border-top: 1px dashed rgba(13, 13, 20, .22); margin-top: 12px; padding-top: 12px; display: grid; gap: 8px;
  font-size: 13px; color: rgba(13, 13, 20, .78);
}
.legend[hidden] { display: none; }
.legend b { color: #0d0d14; }
.legend li { display: flex; gap: 10px; align-items: flex-start; }
.legend .k { flex: none; width: 30px; text-align: center; }
.legend-mark { width: 30px; height: 14px; display: inline-block; position: relative; }

.panel {
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); padding: 20px;
  position: sticky; top: calc(var(--head-h) + 16px);
}
.panel-kicker { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted-2); }
.panel h3 { margin: 6px 0 2px; }
.panel .codes { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 12px; }
.panel p { font-size: 15px; color: rgba(247, 244, 241, .86); }
.panel-hint { font-size: 13.5px; color: var(--muted-2); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.panel-nav { display: flex; gap: 8px; margin-top: 14px; }
.panel-nav button {
  flex: 1; padding: 8px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: transparent;
  font-size: 13px; color: var(--muted);
}
.panel-nav button:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, .06); }
.panel-nav button:disabled { opacity: .35; cursor: not-allowed; }

/* metrics */
.spec-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.spec {
  border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--panel);
}
.spec .lab { font-size: 12.5px; color: var(--muted-2); }
.spec .val { font-size: 21px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.spec .val small { font-size: 13px; font-weight: 400; color: var(--muted); }
.spec .sub { font-size: 12px; color: var(--muted-2); margin-top: 2px; }

.meters { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.meter .lab { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--muted); margin-bottom: 7px; }
.bar { height: 8px; border-radius: 999px; background: rgba(247, 244, 241, .1); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--text); transition: width .8s var(--ease); }
.bar.s1 i { background: var(--s1); } .bar.s2 i { background: var(--s2); }
.bar.s3 i { background: var(--s3); } .bar.acc i { background: var(--straight); }
.pips { display: flex; gap: 5px; }
.pip { width: 20px; height: 8px; border-radius: 3px; background: rgba(247, 244, 241, .13); }
.pip.on { background: var(--text); }

/* sector + corner lists */
.sectors { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.sector {
  border: 1px solid var(--line); border-left: 3px solid var(--sc, var(--line-2));
  border-radius: var(--r); padding: 16px 18px; background: var(--panel);
}
.sector h3 { font-size: 16.5px; }
.sector .rng { font-size: 12.5px; color: var(--muted-2); margin-bottom: 8px; }
.sector p { font-size: 14.5px; color: rgba(247, 244, 241, .84); margin: 0; }

.clist { display: grid; gap: 10px; }
.crow {
  width: 100%; text-align: left; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); padding: 14px 16px; display: flex; gap: 14px; align-items: flex-start;
  transition: border-color .18s, background .18s, transform .18s;
}
.crow:hover { border-color: var(--line-2); background: var(--panel-2); }
.crow.on { border-color: var(--s1); background: rgba(229, 16, 115, .1); }
.crow .code {
  flex: none; min-width: 62px; font-weight: 700; font-size: 14px; letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.crow .code i { display: block; font-style: normal; font-size: 11px; color: var(--muted-2); font-weight: 400; }
.crow h4 { margin: 0 0 3px; font-size: 15.5px; }
.crow p { margin: 0; font-size: 14px; color: var(--muted); }

/* generic callouts */
.note {
  border: 1px solid var(--line); border-left: 3px solid var(--s2); border-radius: var(--r);
  padding: 16px 18px; background: var(--panel); font-size: 15px; color: rgba(247, 244, 241, .86);
}
.note.green { border-left-color: var(--overtake); }
.note.blue { border-left-color: var(--s3); }
.note b { color: var(--text); }

.cols-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* accordion (guide) */
.acc { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.acc + .acc { margin-top: 10px; }
.acc > button {
  width: 100%; text-align: left; background: transparent; border: 0; padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
}
.acc > button:hover { background: rgba(255, 255, 255, .04); }
.acc .t { font-weight: 620; font-size: 16px; margin-right: auto; }
.acc .s { font-size: 13px; color: var(--muted-2); }
.acc .caret { transition: transform .2s var(--ease); color: var(--muted); }
.acc[data-open="true"] .caret { transform: rotate(90deg); }
.acc .body { padding: 0 18px 16px; color: var(--muted); font-size: 15px; display: none; }
.acc[data-open="true"] .body { display: block; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted-2); font-weight: 600; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; }
.tbl tbody tr:hover { background: rgba(255, 255, 255, .03); }
.tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }

/* compare */
.picker { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; }
.picker select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 9px 12px; font: inherit; font-size: 14.5px;
}
.cmp { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.cmp-col { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); overflow: hidden; }
.cmp-col .top { background: var(--paper); padding: 10px; }
.cmp-col .top img { height: 96px; width: 100%; object-fit: contain; }
.cmp-col .nm { padding: 14px 16px 0; }
.cmp-col dl { margin: 0; padding: 10px 16px 16px; display: grid; gap: 8px; }
.cmp-col .row { display: grid; grid-template-columns: 74px 1fr; gap: 10px; align-items: center; font-size: 13.5px; }
.cmp-col .row dt { color: var(--muted-2); }
.cmp-col .row dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

/* prev/next */
.pager { display: flex; gap: 12px; margin-top: 34px; flex-wrap: wrap; }
.pager a {
  flex: 1; min-width: 220px; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px;
  background: var(--panel); transition: border-color .2s, transform .2s;
}
.pager a:hover { border-color: var(--line-2); transform: translateY(-2px); }
.pager span { display: block; font-size: 12px; color: var(--muted-2); }
.pager b { font-size: 15.5px; font-weight: 600; }
.pager .next { text-align: right; }

/* footer */
.site-foot { border-top: 1px solid var(--line); background: rgba(18, 18, 28, .7); }
.foot-inner { max-width: var(--maxw); margin: 0 auto; padding: 26px var(--pad); font-size: 13.5px; color: var(--muted-2); }
.foot-inner strong { color: var(--text); }
.foot-links a { color: var(--muted); border-bottom: 1px solid var(--line-2); }

/* states */
.loading { padding: 80px 0; text-align: center; color: var(--muted-2); }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 14px; border-radius: 50%;
  border: 2px solid rgba(247, 244, 241, .18); border-top-color: var(--s1); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.err { border: 1px solid var(--straight); border-radius: var(--r); padding: 18px; background: rgba(230, 43, 0, .08); }
.err code { background: rgba(0, 0, 0, .35); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

.fade { animation: fade .32s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- responsive ---------------- */
@media (max-width: 1080px) {
  .td-main { grid-template-columns: 1fr; }
  .panel { position: static; }
  .hero-top { grid-template-columns: 1fr; align-items: start; }
}
@media (max-width: 760px) {
  :root { --head-h: 58px; }
  .nav-toggle { display: block; }
  .site-nav {
    position: absolute; left: 0; right: 0; top: var(--head-h); flex-direction: column; gap: 0;
    background: rgba(13, 13, 20, .97); border-bottom: 1px solid var(--line);
    padding: 6px var(--pad) 14px; display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 4px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .site-nav a.on { background: transparent; color: var(--s2); padding-left: 4px; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; }
  .hs { width: 34px; height: 34px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .tcard-map img { height: 88px; }
  .tcard-body { padding: 12px 13px 14px; }
  .tcard-body h3 { font-size: 15px; }
  .tcard-note { display: none; }
  .td-flag { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
