/* Habib interface: tokens, base, shell, plates.
   Gold is treated as light, never paint: hairlines, glows, and the few numbers that matter. */

:root {
  color-scheme: dark;

  --void: #000;
  --basalt: #0c0c0d;
  --slate: #151516;
  --slate-2: #1e1e20;
  --hair: #26241f;
  --hair-2: #3a362e;
  --edge: #625c4c;                 /* borders of controls: 3:1 against the panel */

  --gold: #d9b24c;
  --gold-hi: #ffd978;
  --gold-lo: #8a6d22;
  --gold-ink: #17120a;
  --glow: 255, 217, 120;           /* rgb triplet of --gold-hi, for alpha washes */

  --ink: #efe9d8;
  --ink-2: #b0a999;
  --ink-3: #8d8777;

  --up: #62d19b;
  --down: #ff6f61;
  --warn: #f2a33a;
  --info: #8fb0d1;

  --f-display: "Big Shoulders Display", "Avenir Next Condensed", "DIN Condensed", "Arial Narrow", "TeX Gyre Heros Cn", sans-serif;
  --f-text: "Hanken Grotesk", "Avenir Next", system-ui, -apple-system, "Segoe UI", Inter, sans-serif;

  --rail: 86px;
  --gap: 18px;
  --cut: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--void); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--void);
  color: var(--ink);
  font: 400 15px/1.55 var(--f-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
/* the only atmosphere: one warm light above the desk, one faint one in the corner */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1100px 460px at 58% -140px, rgba(var(--glow), .10), transparent 70%),
    radial-gradient(640px 420px at -4% 108%, rgba(var(--glow), .045), transparent 70%);
}

h1, h2, h3, h4, p, ul, ol, figure, dl { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-hi); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
::selection { background: rgba(var(--glow), .28); color: #fff; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--gold); color: var(--gold-ink); padding: 8px 14px; font-weight: 600; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* scrollbars: thin, dark */
* { scrollbar-width: thin; scrollbar-color: var(--hair-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--hair-2); border-radius: 10px; border: 2px solid var(--void); }

/* ───────────── type ───────────── */
.display { font-family: var(--f-display); font-weight: 700; letter-spacing: .01em; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.big-num { font-weight: 600; font-variant-numeric: lining-nums; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.gold { color: var(--gold); }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

/* ───────────── shell ───────────── */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; position: relative; z-index: 1; }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; align-items: stretch;
  padding: 20px 0 16px;
  background: var(--void);
  border-right: 1px solid var(--hair);
}
.rail .home { align-self: center; margin-bottom: 26px; color: var(--gold-hi); filter: drop-shadow(0 0 10px rgba(var(--glow), .45)); line-height: 0; }
.rail .home:hover { color: #fff3c9; }
.rail nav { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.rail nav::-webkit-scrollbar { display: none; }
.rail a.nav, .rail button.nav {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 11px 0 10px;
  color: var(--ink-3);
  font: 500 11.5px/1 var(--f-text);
  background: none; border: 0; border-radius: 0;
  transition: color .18s var(--ease);
}
.rail button.nav.more { display: none; }
.rail a.nav svg, .rail button.nav svg { width: 22px; height: 22px; transition: filter .18s var(--ease); }
.rail a.nav:hover, .rail button.nav:hover { color: var(--ink); }
.rail a.nav[aria-current="page"], .rail button.nav[aria-current="true"] { color: var(--gold-hi); }
.rail a.nav[aria-current="page"]::before, .rail button.nav[aria-current="true"]::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px;
  background: var(--gold-hi); box-shadow: 0 0 14px 1px rgba(var(--glow), .75);
}
.rail a.nav[aria-current="page"] svg, .rail button.nav[aria-current="true"] svg { filter: drop-shadow(0 0 6px rgba(var(--glow), .6)); }
@media (max-height: 780px) and (min-width: 821px) { .rail a.nav { padding: 8px 0 7px; gap: 4px; } .rail .home { margin-bottom: 16px; } }

/* a small count on a page that has something waiting */
.nbadge { display: none; font-style: normal; }
.nbadge.on {
  display: inline-grid; place-items: center; position: absolute; top: 5px; left: calc(50% + 7px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--gold-hi); color: var(--gold-ink);
  font: 700 10.5px/1 var(--f-text); font-variant-numeric: tabular-nums; box-shadow: 0 0 10px rgba(var(--glow), .6);
}
.rail .rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--ink-3); font-size: 11px; }

.stage { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 68px; padding: 10px 32px;
  background: rgba(0, 0, 0, .86);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hair);
}
.topbar.live { border-bottom-color: rgba(255, 111, 97, .7); box-shadow: 0 1px 24px -6px rgba(255, 111, 97, .45); }
.topbar .where { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.topbar h1 { font: 700 30px/1 var(--f-display); letter-spacing: .02em; white-space: nowrap; }
.topbar .where .sub { color: var(--ink-3); font-size: 13px; }
.topbar .status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.topbar .status .chips { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

#view { width: 100%; max-width: 1380px; margin: 0 auto; padding: 22px 32px 90px; outline: none; }

.demo-flag {
  position: fixed; right: 0; bottom: 18px; z-index: 60;
  background: var(--gold); color: var(--gold-ink);
  font: 700 12px/1 var(--f-text); letter-spacing: .08em;
  padding: 8px 14px 8px 18px; pointer-events: none;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%);
}

/* ───────────── the plate: cut-corner armour panel whose hairline catches the cursor ───────────── */
.plate {
  --hairline: var(--hair);
  position: relative;
  padding: 1px;
  background:
    radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), rgba(var(--glow), .95), rgba(var(--glow), 0) 72%),
    var(--hairline);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  min-width: 0;
}
.plate > .pb {
  position: relative;
  height: 100%;
  background:
    radial-gradient(420px circle at var(--mx, -999px) var(--my, -999px), rgba(var(--glow), .035), transparent 70%),
    var(--basalt);
  padding: 20px 22px 22px;
  clip-path: polygon(calc(var(--cut) - .586px) 0, 100% 0, 100% calc(100% - var(--cut) + .586px), calc(100% - var(--cut) + .586px) 100%, 0 100%, 0 calc(var(--cut) - .586px));
}
/* rim light along the top edge */
.plate > .pb::before {
  content: ""; position: absolute; left: var(--cut); right: 0; top: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, rgba(var(--glow), .0), rgba(var(--glow), .30) 28%, rgba(var(--glow), 0) 92%);
}
.plate.lift > .pb { background-color: var(--slate); }
.plate.hot { --hairline: var(--gold-lo); }
.plate.danger { --hairline: rgba(255, 111, 97, .55); }
.plate.tight > .pb { padding: 14px 16px 16px; }
.plate.link { cursor: pointer; transition: --hairline .2s; }
.plate.link:hover { --hairline: var(--hair-2); }
.plate.link:focus-visible { outline: none; --hairline: var(--gold-hi); }
.plate.static-cut { --cut: 10px; }

.plate-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; min-height: 24px; }
.plate-title { font: 600 14px/1.2 var(--f-text); color: var(--ink-2); letter-spacing: .01em; }
.plate-title b { color: var(--ink); font-weight: 600; }
.plate-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ───────────── layout helpers ───────────── */
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-s { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { margin-left: auto; }
hr.rule { border: 0; height: 1px; background: var(--hair); margin: 16px 0; }

.page-head { margin: 4px 0 22px; }
.page-head h2 { font: 700 clamp(32px, 3.6vw, 48px)/1 var(--f-display); letter-spacing: .01em; }
.page-head p { margin-top: 10px; color: var(--ink-2); max-width: 66ch; font-size: 16px; }

@media (max-width: 1080px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
}
@media (max-width: 820px) {
  :root { --rail: 0px; --gap: 14px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 50;
    flex-direction: row; padding: 0 0 env(safe-area-inset-bottom);
    border-right: 0; border-top: 1px solid var(--hair); background: rgba(0, 0, 0, .94);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  .rail .home, .rail .rail-foot { display: none; }
  .rail nav { flex-direction: row; width: 100%; justify-content: space-around; overflow: visible; }
  .rail a.nav, .rail button.nav { flex: 1; padding: 10px 0 9px; font-size: 10.5px; }
  .rail a.nav.sec { display: none; }
  .rail button.nav.more { display: flex; }
  .rail a.nav[aria-current="page"]::before, .rail button.nav[aria-current="true"]::before { left: 20%; right: 20%; top: 0; bottom: auto; width: auto; height: 2px; }
  .nbadge.on { top: 4px; left: calc(50% + 6px); }
  .topbar {
    position: static; padding: 12px 16px; min-height: 0;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "where halt" "chips chips"; gap: 10px 12px; align-items: center;
  }
  .topbar .where { grid-area: where; }
  .topbar .where .sub { display: none; }
  .topbar .status { display: contents; }
  .topbar .status .chips { grid-area: chips; justify-content: flex-start; gap: 8px; }
  .topbar .status > .btn { grid-area: halt; }
  .topbar h1 { font-size: 28px; }
  #view { padding: 16px 16px 110px; }
  .span-3 { grid-column: span 12; }
  .demo-flag { bottom: 76px; font-size: 10.5px; padding: 6px 10px 6px 15px; opacity: .92; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .plate { background: CanvasText; }
  .plate > .pb { background: Canvas; }
}

@property --hairline { syntax: "<color>"; inherits: true; initial-value: #26241f; }
