/* Gimbal — an instrument panel.
   Every colour below was measured off this project's own X banner and PFP with PIL; the hexes and
   the places they were sampled are in SPEC.md §2. There is no page here, there is a panel: a
   12-column mosaic of tiles, each one a single reading or a single control. No hero, no sections,
   no three.js, and no animation that runs on its own. */

:root {
  /* measured off the banner crop */
  --ground: #091315;      /* most common pixel of the crop */
  --ground-2: #0a1515;    /* the corners */
  --bezel: #0c181c;       /* mid field */
  --bezel-hi: #101e23;    /* upper field */
  --hair: #66a1a5;        /* brightest hairline of the wave envelope */
  --hair-hi: #70adb1;
  --pinch: #366c77;       /* the glow at the centre waist */
  --level: #9be8f8;       /* the bright horizontal line, row y=124 */
  --level-core: #e0fefe;  /* brightest pixel, banner and PFP both */
  --ring: #a6ced6;        /* the PFP's ring highlight */

  --read: #dcf2f6;
  --text: #c3d8dd;
  --muted: #90a8b0;
  --dim: #7e959d;
  --amber: #e4a95c;
  --red: #f2695c;

  --edge: rgba(54, 108, 119, .42);
  --edge-hi: rgba(112, 173, 177, .55);
  --rule: rgba(102, 161, 165, .18);

  --ui: "Saira", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --gut: clamp(14px, 2.2vw, 28px);
  --gap: 10px;
  --maxw: 1480px;
  --t: 140ms cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--ground); }
body {
  font-family: var(--ui);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.58;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100%;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; color: inherit; font-size: inherit; }
table { border-collapse: collapse; }

/* --- the plate ------------------------------------------------------------------------------
   A generated image on near-black reads as a lighter rectangle, so it gets BOTH a screen blend
   and a radial mask — one of the two is not enough. */
.plate {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-repeat: no-repeat;
  background-position: 50% 38%;
  background-size: cover;
  mix-blend-mode: screen;
  -webkit-mask-image: radial-gradient(142% 108% at 50% 40%, #000 0%, #000 46%, transparent 92%);
          mask-image: radial-gradient(142% 108% at 50% 40%, #000 0%, #000 46%, transparent 92%);
  pointer-events: none;
}
body[data-plate="wave"] .plate { background-image: url("/img/plate-wave.webp"); opacity: .66; }
body[data-plate="rings"] .plate { background-image: url("/img/plate-rings.webp"); opacity: .46; }
body[data-plate="grazing"] .plate { background-image: url("/img/plate-grazing.webp"); opacity: .42; }

/* --- the rail: not a nav bar with a hero under it, the panel's own label strip --------------- */
.rail {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px var(--gut) 10px;
}
.rail .mk { display: flex; align-items: center; gap: 9px; }
.rail .mk img { display: block; width: 22px; height: 22px; }
.rail .mk b {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: lowercase;
  color: var(--read);
}
.rail nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.rail nav a {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: 3px;
  transition: color var(--t), border-color var(--t), background var(--t);
}
.rail nav a:hover, .rail nav a:focus-visible { color: var(--read); border-color: var(--edge); }
.rail nav a[aria-current="page"] {
  color: var(--level);
  border-color: var(--edge);
  background: rgba(12, 24, 28, .7);
}
.rail .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--edge);
  border-radius: 3px;
  padding: 5px 10px;
  background: rgba(12, 24, 28, .62);
}
.rail .chip i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--dim); font-style: normal; flex: none;
}
.rail .chip i.on { background: var(--level); }

/* --- the panel ------------------------------------------------------------------------------ */
.panel {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gut) calc(var(--gut) + 18px);
  display: grid;
  /* minmax(0, 1fr), never 1fr: a `1fr` track is minmax(auto, 1fr) and floors on a table's
     min-content width, which is exactly how a tile grid overflows at 390px. */
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-content: start;
}

.tile {
  min-width: 0;
  position: relative;
  grid-column: span 12;
  border: 1px solid var(--edge);
  border-radius: 3px;
  background: rgba(12, 24, 28, .82);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--t);
}
.tile:hover, .tile:focus-within { border-color: var(--edge-hi); }
.tile.raised { background: rgba(16, 30, 35, .86); }
.tile.flat { background: rgba(9, 19, 21, .88); }

.lab {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
}
.val {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.2;
  color: var(--read);
  margin-top: 10px;
  overflow-wrap: anywhere;
}
.val small { font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: .02em; }
.val.big {
  font-family: var(--ui);
  font-weight: 600;
  font-size: clamp(34px, 5.2vw, 56px);
  letter-spacing: -.02em;
  text-transform: lowercase;
  line-height: 1.02;
}
.val.ok { color: var(--level); }
.val.half { color: var(--amber); }
.val.shut { color: var(--red); }
.prov {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .02em;
  line-height: 1.5;
  color: var(--dim);
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px solid var(--rule);
}
.prov b { color: var(--muted); font-weight: 500; }
.tile > .prov:last-child { margin-top: auto; }

.tile h2 {
  font-family: var(--ui);
  font-weight: 600;
  font-size: clamp(19px, 2.1vw, 26px);
  letter-spacing: -.012em;
  line-height: 1.18;
  color: var(--read);
  margin-top: 10px;
}
.tile p { margin-top: 10px; color: var(--text); }
.tile p + p { margin-top: 9px; }
.tile p b, .tile h2 b { color: var(--read); font-weight: 600; }
.tile code, .mono { font-family: var(--mono); font-size: .92em; color: var(--ring); }
.tile ul { margin-top: 10px; padding-left: 0; list-style: none; }
.tile li { position: relative; padding-left: 16px; margin-top: 7px; }
.tile li::before {
  content: ""; position: absolute; left: 0; top: .72em;
  width: 7px; height: 1px; background: var(--hair);
}

/* spans — 12 columns at ≥1120px */
.s2 { grid-column: span 2; } .s3 { grid-column: span 3; } .s4 { grid-column: span 4; }
.s5 { grid-column: span 5; } .s6 { grid-column: span 6; } .s8 { grid-column: span 8; }
.s12 { grid-column: span 12; }

/* --- the quoted figure: a strip of readings inside one tile ---------------------------------- */
.cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 1px; margin-top: 12px; background: var(--rule); }
.cells > div { background: rgba(12, 24, 28, .92); padding: 11px 12px; min-width: 0; }
.cells .val { font-size: 16px; margin-top: 7px; }

/* --- tables --------------------------------------------------------------------------------- */
.tw { margin-top: 12px; overflow-x: auto; min-width: 0; }
table.t { width: 100%; font-family: var(--mono); font-size: 13px; }
table.t th {
  font-weight: 500; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); text-align: right; padding: 0 0 8px; white-space: nowrap;
  border-bottom: 1px solid var(--rule);
}
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td {
  text-align: right; padding: 7px 0; color: var(--read); white-space: nowrap;
  border-bottom: 1px solid rgba(102, 161, 165, .08);
}
table.t td + td, table.t th + th { padding-left: 16px; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.wrap { white-space: normal; font-family: var(--ui); color: var(--text); min-width: 220px; }
table.t td.dim, .dim { color: var(--dim); }
table.t td.bid { color: var(--level); }
table.t td.ask { color: var(--ring); }
table.t td a { color: var(--level); border-bottom: 1px solid var(--edge); }

.tag {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  border: 1px solid var(--edge); border-radius: 2px; padding: 2px 7px; color: var(--muted);
  white-space: nowrap;
}
.tag.ok { color: var(--level); border-color: rgba(155, 232, 248, .42); }
.tag.no { color: var(--red); border-color: rgba(242, 105, 92, .45); }

/* --- the rule table (eight rows, the product) ------------------------------------------------ */
.rules { margin-top: 12px; display: flex; flex-direction: column; }
.rrow {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid rgba(102, 161, 165, .08);
}
.rrow:last-child { border-bottom: 0; }
.rrow .n { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.rrow .w { font-size: 14px; line-height: 1.5; color: var(--text); }
.rrow .w b { color: var(--read); font-weight: 600; }
.rrow .w code { font-size: 12.5px; }
.rrow .v {
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-align: right;
  white-space: nowrap;
}
.rrow .v.shut { color: var(--red); }
.rrow .v.half { color: var(--amber); }

/* --- controls -------------------------------------------------------------------------------- */
.ctl { margin-top: 12px; }
.ctl .row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ctl .row .v { font-family: var(--mono); font-size: 17px; color: var(--read); }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin-top: 12px; background: transparent; cursor: ew-resize;
  display: block;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: var(--rule); border-radius: 1px;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); border-radius: 1px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; margin-top: -5px; border-radius: 50%;
  background: var(--level-core); border: 0;
  box-shadow: 0 0 0 1px rgba(9, 19, 21, .9), 0 0 10px rgba(155, 232, 248, .5);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; border: 0;
  background: var(--level-core); box-shadow: 0 0 10px rgba(155, 232, 248, .5);
}
input[type="range"]:focus-visible { outline: 1px solid var(--edge-hi); outline-offset: 4px; }

.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.btn {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em;
  color: var(--text); background: rgba(9, 19, 21, .72);
  border: 1px solid var(--edge); border-radius: 3px; padding: 7px 12px; cursor: pointer;
  transition: color var(--t), border-color var(--t), background var(--t);
}
.btn:hover, .btn:focus-visible { color: var(--read); border-color: var(--edge-hi); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--edge-hi); }
.btn[aria-pressed="true"] {
  color: var(--level); border-color: rgba(155, 232, 248, .5);
  background: rgba(16, 30, 35, .9);
}
.btn.alarm[aria-pressed="true"] { color: var(--red); border-color: rgba(242, 105, 92, .5); }

/* --- the spirit level: the tilt, drawn the way the instrument draws it ------------------------ */
.vial {
  position: relative;
  margin-top: 14px;
  height: 34px;
  border: 1px solid var(--edge);
  border-radius: 17px;
  background: rgba(9, 19, 21, .7);
  overflow: hidden;
}
.vial .mid { position: absolute; left: 50%; top: 5px; bottom: 5px; width: 1px; background: rgba(155, 232, 248, .45); }
.vial .gate { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(228, 169, 92, .5); }
.vial .bub {
  position: absolute; top: 50%; left: 50%;
  width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, var(--level-core), rgba(155, 232, 248, .5) 62%, rgba(155, 232, 248, .08) 100%);
  transition: transform 420ms cubic-bezier(.2, .7, .2, 1), background 220ms linear;
}
.vial .bub.over { background: radial-gradient(circle at 38% 34%, #fff0ec, rgba(242, 105, 92, .6) 62%, rgba(242, 105, 92, .1) 100%); }
.vial .hairs { position: absolute; inset: 0; }
.vial .hairs i { position: absolute; top: 11px; bottom: 11px; width: 1px; background: rgba(102, 161, 165, .3); }

/* a side of the book going dark is a state change, not a loop */
.sideoff { opacity: .44; transition: opacity 220ms linear; }
.flash { animation: flash 300ms linear 1; }
@keyframes flash { 0% { color: var(--level); } 100% { color: inherit; } }

/* --- the identity tile ------------------------------------------------------------------------ */
.ident { display: flex; align-items: center; gap: 14px; }
.ident img { width: 54px; height: 54px; display: block; flex: none; }
.ident .n {
  font-family: var(--ui); font-weight: 600; font-size: 30px; letter-spacing: -.015em;
  text-transform: lowercase; color: var(--read); line-height: 1;
}
.ident .h { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .06em; margin-top: 5px; }
.bio { font-size: 16px; line-height: 1.5; color: var(--text); margin-top: 12px; }
.bio b { color: var(--read); font-weight: 600; }

.skel {
  height: 13px; border-radius: 2px; margin: 9px 0;
  background: linear-gradient(90deg, rgba(102, 161, 165, .16), rgba(102, 161, 165, .05));
}

/* --- responsive: 12 → 6 → 2 → 1 ----------------------------------------------------------------- */
@media (max-width: 1119px) {
  .panel { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .s8, .s12 { grid-column: span 6; }
  .s5, .s6 { grid-column: span 6; }
  .s4 { grid-column: span 3; }
  .s3 { grid-column: span 3; }
  .s2 { grid-column: span 3; }
}
@media (max-width: 719px) {
  .panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .s3, .s4, .s5, .s6, .s8, .s12 { grid-column: span 2; }
  .s2 { grid-column: span 1; }
}
@media (max-width: 479px) {
  .panel { grid-template-columns: minmax(0, 1fr); }
  .s2, .s3, .s4, .s5, .s6, .s8, .s12 { grid-column: span 1; }
}
@media (max-width: 560px) {
  .tile { padding: 14px 15px; }
  .val { font-size: 20px; }
  .ident .n { font-size: 26px; }
  .ident img { width: 44px; height: 44px; }
  .rail { gap: 10px; padding-bottom: 8px; }
  .rail nav { margin-left: 0; width: 100%; order: 3; }
  .rail nav a { padding: 6px 9px; }
}

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

/* the OG card renders this page's own tiles at 1200x630; no hosting URL appears anywhere in it */
body.og { width: 1200px; height: 630px; overflow: hidden; }
body.og .panel { padding-top: 6px; }

/* --- the rule strip: which of the eight rules decided, drawn as an instrument reads it -------- */
.rstrip { display: flex; gap: 3px; margin-top: 14px; }
.rstrip span {
  flex: 1 1 0; min-width: 0; height: 26px; border: 1px solid var(--rule); border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10.5px; color: var(--dim);
  transition: color 220ms linear, border-color 220ms linear, background 220ms linear;
}
.rstrip span.lit { color: var(--red); border-color: rgba(242, 105, 92, .55); background: rgba(242, 105, 92, .1); }
.rstrip span.lit.half { color: var(--amber); border-color: rgba(228, 169, 92, .55); background: rgba(228, 169, 92, .1); }

/* --- diagrams: a hairline drawing of the mechanism, never an illustration -------------------- */
svg.diag { display: block; width: 100%; height: auto; margin-top: 14px; }
svg.diag .bx { fill: rgba(9, 19, 21, .8); stroke: var(--pinch); stroke-width: 1; }
svg.diag .ln { stroke: var(--hair); stroke-width: 1; fill: none; }
svg.diag .hot { stroke: var(--level); stroke-width: 1.4; fill: none; }
svg.diag .dot { fill: rgba(9, 19, 21, .9); stroke: var(--hair); stroke-width: 1; }
svg.diag .dot.hot { fill: rgba(155, 232, 248, .18); stroke: var(--level); }
svg.diag .cut { stroke: var(--red); stroke-width: 1.3; }
svg.diag text { font-family: var(--mono); font-size: 9px; letter-spacing: .08em; fill: var(--muted); }
svg.diag text.k { fill: var(--read); font-size: 10px; }
svg.diag text.c { fill: var(--level); }
svg.diag text.x { fill: var(--red); }

/* --- a scale with a marker: the half-spread read the way a gauge reads it --------------------- */
.scale { position: relative; height: 30px; margin-top: 14px; }
.scale::before {
  content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 1px; background: var(--rule);
}
.scale i {
  position: absolute; top: 3px; left: 0; width: 2px; height: 13px; margin-left: -1px;
  background: var(--level-core); box-shadow: 0 0 9px rgba(155, 232, 248, .6);
  transition: left 420ms cubic-bezier(.2, .7, .2, 1), opacity 220ms linear;
}
.scale b, .scale u {
  position: absolute; top: 15px; font-family: var(--mono); font-size: 10px; font-weight: 400;
  color: var(--dim); text-decoration: none; letter-spacing: .06em;
}
.scale b { left: 0; }
.scale u { right: 0; }

/* --- the wave band: this project's own banner, inside the tile that carries its name ---------- */
.band {
  flex: 1 1 68px; min-height: 68px; margin-top: 14px; border-radius: 2px;
  background: url("/img/plate-wave.webp") 50% 50% / cover no-repeat;
  mix-blend-mode: screen; opacity: .8;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}

/* --- a status readout: four facts, each one a no ---------------------------------------------- */
.facts { margin-top: 12px; font-family: var(--mono); font-size: 12px; }
.facts div {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid rgba(102, 161, 165, .08);
}
.facts div:last-child { border-bottom: 0; }
.facts span:first-child { color: var(--muted); }
.facts span:last-child { color: var(--read); }
