/* Phoenix Evolution — shared design system.
   Livery-derived palette: iridescent teal/green/purple with a gold crest.
   Visual grammar is the pit wall: condensed uppercase headings, tabular
   numerals for every figure, sector bars as rules, position badges.
   Every page links this; page-specific CSS stays inline on that page. */

:root {
  color-scheme: dark;
  --bg: #14131A; --surface: #1E1C25; --surface2: #272430; --raised: #302C3B;
  --ink: #EAE9F1; --ink2: #ACA9BB; --muted: #767386;
  --line: rgba(234,233,241,.14); --grid: rgba(234,233,241,.07);
  --accent: #2FC1B5; --accent-ink: #06201D; --gold: #D9A544;
  --c1: #0AA99B; --c2: #7A59C3; --c3: #BD8B29; --c4: #3072C1;
  --c5: #629B3E; --c6: #AA4D75; --c7: #0095B6; --c8: #B46B40;
  --p1: #D9A544; --p2: #B8BDC9; --p3: #B4753F;
  --display: "Avenir Next Condensed", "Helvetica Neue Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --data: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --livery: linear-gradient(90deg, var(--c1), var(--c5), var(--c2));
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #F4F4F7; --surface: #FFFFFF; --surface2: #EDEDF3; --raised: #E3E2EB;
    --ink: #211F28; --ink2: #565364; --muted: #837F92;
    --line: rgba(33,31,40,.16); --grid: rgba(33,31,40,.08);
    --accent: #0A8F84; --accent-ink: #FFFFFF; --gold: #A87712;
    --c1: #059488; --c2: #7250BA; --c3: #9C7220; --c4: #2A62A6;
    --c5: #538C2D; --c6: #94425F; --c7: #087E9B; --c8: #9A5A34;
    --p1: #A87712; --p2: #6C7381; --p3: #8A5124;
    --shadow: 0 10px 30px rgba(33,31,40,.10);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* Without this Chrome renders native dropdown popups light-on-dark. The
   `color-scheme` above is half the fix; option backgrounds are the other half. */
select option { background: var(--surface); color: var(--ink); }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---------- chrome ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: 54px; background: var(--surface);
  border-bottom: 2px solid; border-image: var(--livery) 1;
  position: sticky; top: 0; z-index: 20;
}
.brand {
  font-family: var(--display); text-transform: uppercase; font-weight: 700;
  font-size: 19px; letter-spacing: .04em; white-space: nowrap;
  color: inherit; text-decoration: none; display: flex; align-items: center; gap: 9px;
}
.brand em { color: var(--gold); font-style: normal; }
.brand img { height: 26px; width: auto; display: block; }
.pnav { display: flex; gap: 4px; flex-wrap: wrap; }
.pnav a {
  text-decoration: none; color: var(--ink2); font-size: 12.5px; padding: 5px 14px;
  border: 1px solid var(--line); border-radius: 5px; white-space: nowrap;
}
.pnav a.on { background: var(--surface2); color: var(--ink); border-color: var(--accent); }
.pnav a:hover { color: var(--ink); }
.pnav a.cta { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.pnav a.cta:hover { filter: brightness(1.08); color: var(--accent-ink); }
.fresh { margin-left: auto; color: var(--muted); font-size: 12px; font-family: var(--data); }
.navtoggle { display: none; }

@media (max-width: 860px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .fresh { margin-left: auto; order: 2; }
  .pnav { order: 3; width: 100%; }
  .pnav a { flex: 1 1 auto; text-align: center; }
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }
.wrap.wide { max-width: 1240px; }

/* ---------- section headers ---------- */
h2 {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .14em;
  font-size: 12px; color: var(--muted); margin: 26px 0 10px; font-weight: 600;
}
h2:first-child { margin-top: 0; }
.sect { margin: 54px 0 0; }
.sect:first-of-type { margin-top: 34px; }
.sect-h {
  display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.sect-h h3 {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .06em;
  font-size: 25px; margin: 0; font-weight: 700;
}
.sect-h .sub { color: var(--muted); font-size: 12.5px; font-family: var(--data); }
.sect-h .more { margin-left: auto; font-size: 12.5px; text-decoration: none; white-space: nowrap; }
.sect-h .more:hover { text-decoration: underline; }

/* sector bar — three livery segments, used as a rule/accent */
.sector { display: flex; height: 3px; width: 82px; border-radius: 2px; overflow: hidden; }
.sector i { flex: 1; }
.sector i:nth-child(1) { background: var(--c1); }
.sector i:nth-child(2) { background: var(--c5); }
.sector i:nth-child(3) { background: var(--c2); }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.hero-in {
  position: relative; z-index: 2; max-width: 1080px; margin: 0 auto;
  padding: 76px 18px 30px;
}
/* layered backdrop: faint grid + a slow livery sweep. No gradient blobs. */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 46px 46px, 46px 46px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 78%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 78%);
}
.hero::after {
  content: ""; position: absolute; top: 0; left: -30%; z-index: 1;
  width: 30%; height: 100%;
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--accent) 12%, transparent), transparent);
  transform: skewX(-18deg);
  animation: sweep 9s ease-in-out infinite;
}
@keyframes sweep {
  0%   { left: -30%; }
  55%  { left: 118%; }
  100% { left: 118%; }
}
.hero .eyebrow {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
  font-family: var(--display); text-transform: uppercase; letter-spacing: .22em;
  font-size: 11.5px; color: var(--accent); font-weight: 600;
}
.hero h1 {
  font-family: var(--display); text-transform: uppercase; font-weight: 700;
  font-size: clamp(46px, 9vw, 104px); line-height: .92; letter-spacing: .01em;
  margin: 0 0 18px;
}
.hero h1 em { font-style: normal; color: var(--gold); }
.hero .lede {
  max-width: 62ch; font-size: 16px; color: var(--ink2); margin: 0 0 26px;
  line-height: 1.55;
}
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: var(--display); text-transform: uppercase; letter-spacing: .1em;
  font-size: 12.5px; font-weight: 700; padding: 11px 20px; border-radius: 5px;
  text-decoration: none; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
  transition: transform .14s ease, filter .14s ease;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- stats ---------- */
.statrow {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; margin-top: 34px;
}
.stat { background: var(--surface); padding: 16px 16px 14px; }
.stat .v {
  font-family: var(--data); font-size: clamp(26px, 4vw, 34px); font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1; color: var(--ink);
}
.stat .k {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .13em;
  font-size: 10.5px; color: var(--muted); margin-top: 8px; font-weight: 600;
}
.stat.hi .v { color: var(--gold); }

/* generic tiles (record book) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 12px 14px;
}
.tile .lbl { font-family: var(--display); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; color: var(--muted); }
.tile .val { font-family: var(--data); font-size: 26px; font-weight: 700; color: var(--ink); margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile .who { font-size: 13px; color: var(--ink2); font-weight: 600; }
.tile .det { font-size: 12px; color: var(--muted); }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px; transition: transform .16s ease, border-color .16s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

/* driver card */
.dcard { position: relative; overflow: hidden; }
.dcard::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--livery);
}
.dcard .nm {
  font-family: var(--display); text-transform: uppercase; font-weight: 700;
  font-size: 19px; letter-spacing: .02em; line-height: 1.1;
}
.dcard .handle { font-family: var(--data); font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.dcard .role {
  display: inline-block; font-family: var(--display); text-transform: uppercase;
  letter-spacing: .1em; font-size: 10px; font-weight: 700; color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 50%, transparent);
  border-radius: 3px; padding: 1px 6px; margin-left: 8px; vertical-align: middle;
}
.dcard .kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.dcard .kv div { border-top: 1px solid var(--grid); padding-top: 7px; }
.dcard .kv b {
  display: block; font-family: var(--data); font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dcard .kv span {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .1em;
  font-size: 9.5px; color: var(--muted);
}

.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 12px; }
.tag {
  font-size: 10.5px; font-family: var(--display); text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink2); background: var(--surface2);
  border: 1px solid var(--line); border-radius: 3px; padding: 2px 7px;
}
.tag.acc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tag.gold { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }

/* form sparkline — taller bar = better finish, so the shape reads like form */
.form { display: flex; align-items: flex-end; gap: 3px; height: 28px; margin-top: 12px; }
.form i {
  flex: 1; background: color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 2px 2px 0 0; min-height: 2px;
}
.form i.p1 { background: var(--p1); }
.form i.p3 { background: color-mix(in srgb, var(--p1) 55%, var(--accent)); }

/* ---------- results ---------- */
.rlist { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.rrow {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 14px; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid var(--grid);
}
.rrow:last-child { border-bottom: none; }
.rrow:hover { background: var(--surface2); }
.rrow .who { font-weight: 600; font-size: 13.5px; }
.rrow .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.rrow .meta .sep { opacity: .5; margin: 0 5px; }
.rrow .when { font-family: var(--data); font-size: 11.5px; color: var(--muted); text-align: right; white-space: nowrap; }
.rrow .sof { font-family: var(--data); font-size: 11px; color: var(--muted); }

.pos {
  font-family: var(--data); font-weight: 700; font-size: 16px; text-align: center;
  font-variant-numeric: tabular-nums; padding: 6px 0; border-radius: 4px;
  background: var(--surface2); color: var(--ink2); border: 1px solid var(--line);
}
.pos.p1 { background: color-mix(in srgb, var(--p1) 18%, var(--surface2)); color: var(--p1); border-color: color-mix(in srgb, var(--p1) 45%, transparent); }
.pos.p2 { background: color-mix(in srgb, var(--p2) 16%, var(--surface2)); color: var(--p2); border-color: color-mix(in srgb, var(--p2) 40%, transparent); }
.pos.p3 { background: color-mix(in srgb, var(--p3) 16%, var(--surface2)); color: var(--p3); border-color: color-mix(in srgb, var(--p3) 40%, transparent); }

@media (max-width: 560px) {
  .rrow { grid-template-columns: 46px 1fr; }
  .rrow .when { grid-column: 2; text-align: left; margin-top: 2px; }
}

/* ---------- tables ---------- */
.bar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.bar input[type=search], .bar select {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 5px;
  padding: 6px 10px; font-size: 13px; color: var(--ink);
}
.bar input[type=search] { width: 240px; }
.bar input:focus-visible, .bar select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.bar .n { font-family: var(--data); color: var(--muted); font-size: 12.5px; }

.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .08em; font-size: 11px;
  color: var(--muted); text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--line);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap;
}
thead th.num { text-align: right; }
tbody td { padding: 7px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tbody td.num { text-align: right; font-family: var(--data); font-variant-numeric: tabular-nums; font-size: 12.5px; }
tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--accent) 5%, transparent); }
tbody tr:last-child td { border-bottom: none; }
td.rec { color: var(--gold); font-weight: 700; }
.note { color: var(--muted); font-size: 12px; margin-top: 10px; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- forms ---------- */
.ffield { margin-bottom: 15px; }
.ffield label {
  display: block; font-family: var(--display); text-transform: uppercase;
  letter-spacing: .11em; font-size: 10.5px; color: var(--muted);
  font-weight: 600; margin-bottom: 5px;
}
.ffield input, .ffield textarea, .ffield select {
  width: 100%; background: var(--surface2); border: 1px solid var(--line);
  border-radius: 5px; padding: 9px 11px; font-size: 14px; color: var(--ink);
}
.ffield textarea { min-height: 92px; resize: vertical; }
.ffield input:focus-visible, .ffield textarea:focus-visible, .ffield select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.ffield .hint { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.msg { border-radius: 6px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 14px; }
.msg.ok { background: color-mix(in srgb, var(--c5) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c5) 45%, transparent); }
.msg.err { background: color-mix(in srgb, var(--c6) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c6) 45%, transparent); }

/* ---------- misc ---------- */
.prose { max-width: 68ch; }
.prose p { color: var(--ink2); line-height: 1.65; }
.prose h4 {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .08em;
  font-size: 16px; margin: 26px 0 6px;
}
.footer {
  border-top: 1px solid var(--line); margin-top: 60px; padding: 26px 18px 40px;
  color: var(--muted); font-size: 12.5px;
}
.footer .in { max-width: 1080px; margin: 0 auto; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer a { color: var(--ink2); text-decoration: none; }
.footer a:hover { color: var(--accent); }
.footer .right { margin-left: auto; font-family: var(--data); font-size: 11.5px; }

/* ---------- motion ----------
   Reveal only hides content once JS has confirmed it can un-hide it: the .js
   class is set by an inline script in <head>. Without JS everything renders. */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .hero::after { animation: none; display: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn:hover, .card:hover { transform: none; }
  * { scroll-behavior: auto !important; }
}
