/* RHABDOM: the interface as a compound eye. See the direction contract at the top of index.html. */

@font-face {
  font-family: "Tektur";
  src: url("/fonts/tektur.woff2") format("woff2");
  font-weight: 400 900;
  font-stretch: 75% 100%;
  font-display: swap;
}

@property --sheen-angle {
  syntax: "<angle>";
  inherits: true;
  initial-value: 24deg;
}

:root {
  --ground: #0a0f0c;
  --cell: #111814;
  --cell-2: #17221c;
  --well: #0c120f;
  --line: #24332b;
  --text: #ecebe2;
  --muted: #a9b5ab;
  --faint: #83918a;
  --emerald: #4fd39a;
  --teal: #37b9c9;
  --amethyst: #8f73f2;
  --orchid: #cf72e6;
  --gold: #e8b64f;
  --a: #64f4ff;
  --b: #ff7ad9;
  --good: #7fe0a0;
  --bad: #ff8a8a;

  --display: "Tektur", "Bahnschrift", "Arial Narrow", sans-serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  --sheen: conic-gradient(from var(--sheen-angle), var(--emerald), var(--teal) 20%, var(--amethyst) 40%,
           var(--orchid) 58%, var(--gold) 78%, var(--emerald));
  --cut-x: 14px;
  --cut-y: 24px;
  --cell-clip: polygon(var(--cut-x) 0, calc(100% - var(--cut-x)) 0, 100% var(--cut-y), 100% calc(100% - var(--cut-y)),
               calc(100% - var(--cut-x)) 100%, var(--cut-x) 100%, 0 calc(100% - var(--cut-y)), 0 var(--cut-y));
  --pill-clip: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%);
  --hex-shape: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  --hex-lattice: none;

  color-scheme: dark;
  accent-color: var(--emerald);
  scrollbar-color: #33463c var(--ground);
  transition: --sheen-angle 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html { background: var(--ground); }

body {
  margin: 0 auto;
  max-width: 1480px;
  padding-inline: clamp(16px, 3vw, 40px);
  padding-block: 0 56px;
  background: var(--ground);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  caret-color: var(--gold);
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(143, 115, 242, 0.5); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb { background: #33463c; border-radius: 5px; border: 2px solid var(--ground); }
::-webkit-scrollbar-thumb:hover { background: #4b6457; }

#facets {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: block;
  pointer-events: none;
}

a { color: var(--gold); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: #f5cf7f; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; }
h2 {
  font-size: 15px;
  font-weight: 700;
  font-stretch: 85%;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--gold);
}
h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text);
  margin-top: 22px;
  margin-bottom: 6px;
}
p { margin: 6px 0; }
.note { color: var(--muted); font-size: 13px; }
.status { color: var(--muted); font-size: 13px; min-height: 1.55em; font-variant-numeric: tabular-nums; }
button { font: inherit; }

.banner {
  margin-inline: calc(-1 * clamp(16px, 3vw, 40px));
  padding: 10px clamp(16px, 3vw, 40px);
  font-weight: 600;
  font-size: 14px;
}
.banner.warn { background: #3b2d0c; color: #ffd98f; }
.banner.bad { background: #3f1418; color: #ffc2c2; }

/* ---- the facet band ---------------------------------------------------- */
.band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 28px;
  padding-block: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 14px; color: var(--text); text-decoration: none; }
.mark { width: 46px; height: 46px; flex: none; overflow: visible; }
.mark use { fill: url(#chitin); }
.mark use.core { fill: var(--gold); }
.wordmark {
  font-family: var(--display);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 800;
  font-stretch: 100%;
  letter-spacing: 0.3em;
  line-height: 1;
}

.live { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.chip {
  position: relative;
  isolation: isolate;
  min-width: 108px;
  padding: 7px 22px 8px;
  clip-path: var(--pill-clip);
  background: var(--sheen);
}
.chip::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -1;
  clip-path: var(--pill-clip);
  background: var(--cell);
}
.live dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); font-family: var(--display); }
.live dd { margin: 0; font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.conn::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 10px;
  margin-right: 7px;
  vertical-align: -1px;
  clip-path: var(--hex-shape);
  background: var(--faint);
}
.conn[data-state="live"]::before { background: var(--emerald); }
.conn[data-state="offline"]::before { background: var(--bad); }
.conn[data-state="connecting"]::before { background: var(--gold); }

/* ---- thesis ------------------------------------------------------------- */
.thesis { padding-block: 26px 10px; max-width: 980px; }
.thesis h1 {
  font-size: clamp(34px, 5.4vw, 72px);
  font-weight: 800;
  font-stretch: 78%;
  line-height: 0.98;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.lede { font-size: clamp(17px, 1.8vw, 21px); line-height: 1.45; margin: 0 0 8px; max-width: 64ch; }
.lede strong { color: #fff; font-weight: 650; }
.lede-sub { color: var(--muted); font-size: 15px; margin: 0; max-width: 72ch; }

/* ---- cells: hexagonal panels with an iridescent membrane ---------------- */
.cell {
  position: relative;
  isolation: isolate;
  margin-top: 16px;
  padding: 22px 24px 26px;
  min-width: 0;
  clip-path: var(--cell-clip);
  background: var(--sheen);
}
.cell::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -2;
  clip-path: var(--cell-clip);
  background: linear-gradient(162deg, var(--cell-2), var(--cell) 38%, #0e1511 100%);
}
/* the fracture: under the pointer the cell breaks into lit facets */
.cell::after {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -1;
  pointer-events: none;
  background: var(--sheen);
  opacity: 0;
  -webkit-mask-image: var(--hex-lattice), radial-gradient(circle 170px at var(--mx, 50%) var(--my, 50%), #000 0%, transparent 72%);
  -webkit-mask-composite: source-in;
  mask-image: var(--hex-lattice), radial-gradient(circle 170px at var(--mx, 50%) var(--my, 50%), #000 0%, transparent 72%);
  mask-composite: intersect;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (hover: hover) {
  .cell:hover::after { opacity: 0.42; }
}
.cell-head { margin-bottom: 12px; }
.cell-head p { color: var(--muted); font-size: 13px; margin-top: 6px; max-width: 72ch; }

.hive {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(0, 0.92fr);
  gap: 0 16px;
  align-items: start;
}
.hive > .eyes-cell { margin-top: 58px; }   /* honeycomb stagger */
.side { display: flex; flex-direction: column; min-width: 0; }

@media (max-width: 1150px) {
  .hive { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hive > .eyes-cell { margin-top: 16px; }
  .side { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; }
  .side .cell:last-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  :root { --cut-x: 10px; --cut-y: 17px; }
  .hive, .side { grid-template-columns: minmax(0, 1fr); }
  .cell { padding: 20px 18px 22px; }
}

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- ring ----------------------------------------------------------------- */
.ring-cell { padding-bottom: 20px; }
.stack { position: relative; margin-inline: auto; }
.stack canvas { position: absolute; inset: 0; display: block; }
#ring-over { cursor: none; touch-action: pan-x pan-y; }

.ring-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 14px; }
.palette { display: flex; gap: 3px; flex-wrap: wrap; }
.swatch {
  width: 36px;
  height: 40px;
  padding: 3px;
  border: 0;
  background: transparent;
  clip-path: var(--hex-shape);
  cursor: pointer;
  transition: background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.swatch span { display: block; width: 100%; height: 100%; clip-path: var(--hex-shape); }
.swatch:hover { background: #3a4d43; }
.swatch[aria-checked="true"] { background: var(--sheen); }
.swatch:focus-visible { outline: none; background: var(--gold); }

.cooldown { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 13px; }
.cd-bar {
  width: 132px;
  height: 10px;
  background: #1d2923;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 9px, transparent 9px 11px);
  mask-image: repeating-linear-gradient(90deg, #000 0 9px, transparent 9px 11px);
}
.cd-bar span { display: block; height: 100%; width: 100%; background: var(--emerald); transition: background-color 0.3s; }
.cd-bar span.wait { background: var(--gold); }

/* ---- arena ---------------------------------------------------------------- */
#arena-wrap { display: flex; justify-content: center; }
#arena { display: block; max-width: 100%; }
.flystats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; font-size: 13px; }
.flystat { position: relative; padding-left: 20px; font-variant-numeric: tabular-nums; }
.flystat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 12px;
  height: 14px;
  clip-path: var(--hex-shape);
  background: var(--faint);
}
.flystat.A::before { background: var(--a); }
.flystat.B::before { background: var(--b); }
.flystat b { font-family: var(--mono); }
.flystat span { color: var(--muted); display: block; }

/* ---- eyes ----------------------------------------------------------------- */
.eyes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.eye { min-width: 0; }
.eye canvas { display: block; width: 100%; cursor: crosshair; }
.eye .cap { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 6px; }
.eye .cap b { font-family: var(--mono); }
.eye.A .cap b { color: var(--a); }
.eye.B .cap b { color: var(--b); }

.motor { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.motor-fly h4 { margin: 0 0 6px; font-family: var(--mono); font-size: 13px; }
.motor-fly.A h4 { color: var(--a); }
.motor-fly.B h4 { color: var(--b); }
.mrow { display: grid; grid-template-columns: 64px 1fr 42px; align-items: center; gap: 6px; font-size: 12px; height: 22px; }
.mrow .lab { color: var(--muted); white-space: nowrap; }
.mrow .val { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.mbar { position: relative; height: 10px; background: #18231e; }
.mbar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--faint); }
.mbar span {
  position: absolute;
  top: 0;
  bottom: 0;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px);
  mask-image: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px);
}
.motor-fly.A .mbar span { background: var(--a); }
.motor-fly.B .mbar span { background: var(--b); }

/* ---- the turk ---------------------------------------------------------------- */
.turk-cell h2 { margin-bottom: 6px; }
.progress { height: 8px; background: #1d2923; margin-top: 14px; }
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--sheen);
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 7px, transparent 7px 9px);
  mask-image: repeating-linear-gradient(90deg, #000 0 7px, transparent 7px 9px);
}
.guess { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btn {
  position: relative;
  isolation: isolate;
  padding: 13px 18px;
  border: 0;
  clip-path: var(--pill-clip);
  background: #33463c;
  color: var(--text);
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -1;
  clip-path: var(--pill-clip);
  background: var(--cell-2);
  transition: background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn.fly-a { color: var(--a); }
.btn.fly-b { color: var(--b); }
.btn:hover:not(:disabled) { background: currentColor; }
.btn:focus-visible { outline: none; background: var(--gold); }
.btn:disabled { cursor: default; opacity: 0.42; }
.btn.chosen { opacity: 1; background: currentColor; }
.btn.chosen::before { background: currentColor; }
.btn.chosen span { color: var(--ground); }
.btn.chosen::after { content: "your call"; display: block; font-size: 11px; font-weight: 600; color: var(--ground); letter-spacing: 0.1em; text-transform: uppercase; }

.result { margin-top: 14px; }
.result:empty { display: none; }
.result .big { font-family: var(--display); font-size: 24px; font-weight: 800; line-height: 1.1; margin: 0 0 6px; }
.result .big .A { color: var(--a); }
.result .big .B { color: var(--b); }
.result p { font-size: 13px; margin: 3px 0; }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* ---- teams ---------------------------------------------------------------- */
.teams { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 4px; }
.team {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px 4px 8px 0;
  border-bottom: 1px solid var(--line);
}
.team:last-child { border-bottom: 0; }
.team .chip { width: 18px; height: 20px; min-width: 0; padding: 0; clip-path: var(--hex-shape); }
.team .chip::before { display: none; }
.team.mine .chip { outline: none; box-shadow: none; }
.team .name { font-family: var(--display); font-weight: 700; letter-spacing: 0.04em; }
.team.mine .name { color: var(--gold); }
.team .score { font-family: var(--mono); font-size: 12px; color: var(--muted); display: block; }
.team .score b { color: var(--text); font-size: 15px; }
.team .why { grid-column: 2 / 4; font-size: 12px; color: var(--muted); margin: 0; }
.team button {
  padding: 5px 14px;
  border: 0;
  clip-path: var(--pill-clip);
  background: #22302a;
  color: var(--text);
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.team button:hover { background: #33463c; }
.team button:focus-visible { outline: none; background: var(--gold); color: var(--ground); }
.team button[aria-pressed="true"] { background: var(--gold); color: var(--ground); }

/* ---- feed ------------------------------------------------------------------- */
.feed { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; max-height: 260px; overflow-y: auto; }
.feed:empty::before { content: "Paint, jumps and walls show up here."; color: var(--faint); }
.feed li { padding: 5px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.feed li:last-child { border-bottom: 0; }
.feed time { font-family: var(--mono); color: var(--faint); margin-right: 8px; font-size: 12px; }
.feed .A { color: var(--a); }
.feed .B { color: var(--b); }

/* ---- record, tables, facts -------------------------------------------------------- */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin: 14px 0; }
.stat {
  position: relative;
  isolation: isolate;
  padding: 12px 18px 14px;
  clip-path: var(--pill-clip);
  background: var(--line);
}
.stat::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  clip-path: var(--pill-clip);
  background: var(--well);
}
.stat .k { font-family: var(--display); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .s { font-size: 12px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th, .table td { text-align: left; padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-family: var(--display); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
.table td.num { font-family: var(--mono); }
.table tbody tr:hover td { background: rgba(79, 211, 154, 0.05); }

.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; margin-top: 8px; }
@media (max-width: 960px) { .cols3 { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.chosen, .plain { margin: 0; padding-left: 0; list-style: none; font-size: 13px; }
.chosen li, .plain li { position: relative; margin-bottom: 10px; padding-left: 18px; max-width: 70ch; }
.chosen li::before, .plain li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 8px;
  height: 9px;
  clip-path: var(--hex-shape);
  background: var(--amethyst);
}
.plain li::before { background: var(--gold); }
.chosen .why { display: block; color: var(--muted); }

/* ---- history: a comb of facets --------------------------------------------------- */
.history { margin-top: 40px; }
.comb { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.comb li { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.comb li:nth-child(3n + 2) { transform: translateY(28px); }
.comb p { margin: 0; }
.comb strong { color: var(--text); }
.year { font-family: var(--display); font-size: 22px; font-weight: 800; font-stretch: 80%; color: var(--gold); line-height: 1; }
@media (max-width: 960px) {
  .comb { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .comb li:nth-child(3n + 2) { transform: none; }
  .comb li:nth-child(2n) { transform: translateY(24px); }
}
@media (max-width: 600px) {
  .comb { grid-template-columns: minmax(0, 1fr); }
  .comb li:nth-child(2n) { transform: none; }
}

footer { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  :root { transition: none; }
  *, *::before, *::after { transition: none !important; }
  .cell::after { display: none; }
}
