/* THE DESK, public — a reading page, not an app shell. Same voice as the
   Feed next door: void ground, serif for the ideas, mono for the numbers.
   The one page-specific accent is the desk gold (#f0cd75) on the chrome;
   green/red stay reserved for the numbers themselves so color always means
   direction, never decoration. */
* { box-sizing: border-box; }
html { background: #07090e; }
body {
  margin: 0;
  background: transparent;
  color: #eef2f7;
  font-family: 'Jost', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── the ambient layer (Visual Doctrine, phase 5) ──────────────────────────
   The market's sky: a green nebula in one low corner, a red one in the
   other — the board's two directions as weather — scrimmed back toward the
   void so the numbers keep their contrast. position:fixed (iOS ignores
   background-attachment:fixed) — the page scrolls over a still sky.
   z-index:-1 paints under content but over the html ground; body must
   stay transparent. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(7,9,14,0.5), rgba(7,9,14,0.78) 82%),
    url('/img/ambient/market.webp') center / cover no-repeat,
    #07090e;
}
@media (prefers-reduced-data: reduce) {
  body::before { background: #07090e; }
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 18px calc(40px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }

/* top chrome */
#bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(rgba(7,9,14,0.92), rgba(7,9,14,0.75));
  backdrop-filter: blur(6px);
}
#homeLink {
  color: #aeb8c7;
  text-decoration: none;
  font-size: 20px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(140,160,190,0.25);
  border-radius: 10px;
}
.bar-title {
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.28em;
  color: #f0cd75;
}
.bar-spacer { flex: 1; }

/* masthead */
#masthead { padding: 22px 0 6px; }
#masthead h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.15;
  margin: 0 0 14px;
  text-wrap: balance;
}
#chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid rgba(140,160,190,0.3);
  color: #8b96a6;
}
.chip.on { color: #62d6a4; border-color: rgba(98,214,164,0.45); }
.chip.off { color: #8b96a6; }
.chip.live { color: #aeb8c7; }
.chip.live.sample { color: #e6bd5c; border-color: rgba(230,189,92,0.45); }

/* section labels */
.sec {
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.26em;
  color: #f0cd75;
  margin: 34px 0 10px;
}

/* the brief — generated prose, set like prose */
#brief {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: clamp(16.5px, 4.4vw, 19px);
  line-height: 1.55;
  color: #dde4ee;
  margin: 0;
}

/* the spread — center-anchored bars, one per asset class */
.sp-row {
  display: grid;
  grid-template-columns: minmax(96px, 128px) 1fr 64px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}
.sp-name {
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #aeb8c7;
}
.sp-track {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: rgba(140,160,190,0.12);
}
.sp-track::before {
  content: '';
  position: absolute;
  left: 50%; top: -2px; bottom: -2px;
  width: 1px;
  background: rgba(140,160,190,0.35);
}
.sp-track i {
  position: absolute;
  top: 2px; bottom: 2px;
  border-radius: 3px;
}
.sp-track i.up { background: #62d6a4; }
.sp-track i.dn { background: #e0716d; }
.sp-val {
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  text-align: right;
}
.sp-note {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #8b96a6;
}
.up { color: #62d6a4; }
.dn { color: #e0716d; }

/* the board — one section per asset class */
.cls { margin: 0 0 26px; }
.cls header { margin: 0 0 4px; }
.cls header h2 { margin: 0; font-size: inherit; }
.cls header h2 .term {
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: #eef2f7;
}
.cls header p {
  margin: 2px 0 6px;
  font-size: 13.5px;
  color: #8b96a6;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid rgba(140,160,190,0.12);
  /* rows are buttons now — tap one, see its candle tape */
  appearance: none;
  width: 100%;
  background: none;
  border-left: none; border-right: none; border-bottom: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.row:active { background: rgba(140,160,190,0.06); }

/* the tape sheet */
#chart {
  border: 1px solid rgba(240,205,117,0.3);
  border-radius: 16px;
  background: #0b0e15;
  color: #eef2f7;
  padding: 20px 20px 16px;
  width: min(560px, calc(100vw - 32px));
  font-family: 'Jost', system-ui, sans-serif;
}
#chart::backdrop { background: rgba(4,5,8,0.72); backdrop-filter: blur(3px); }
#chartTitle {
  margin: 0 0 2px;
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: #eef2f7;
}
#chartSub {
  margin: 0 0 12px;
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: #8b96a6;
}
.chart-box { height: 230px; }
.chart-box svg { display: block; }
.chart-note { margin: 10px 0 0; font-size: 13px; line-height: 1.5; color: #8b96a6; }
#chartLesson {
  display: inline-block;
  margin: 12px 0 14px;
  font-size: 14px;
  color: #62d6a4;
  text-decoration: none;
  border-bottom: 1px solid rgba(98,214,164,0.4);
  padding-bottom: 1px;
}
#chartClose {
  display: block;
  width: 100%;
  appearance: none;
  border: 1px solid rgba(140,160,190,0.3);
  border-radius: 10px;
  background: none;
  color: #aeb8c7;
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  padding: 10px;
  cursor: pointer;
}
.who b { font-weight: 500; font-size: 15.5px; }
.who i {
  display: block;
  font-style: normal;
  font-size: 12.5px;
  color: #8b96a6;
  margin-top: 1px;
}
.num {
  text-align: right;
  white-space: nowrap;
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.num b { font-weight: 600; font-size: 15px; }
.num .pct {
  display: block;
  font-size: 12px;
  margin-top: 1px;
}
.pct.always { color: #8b96a6; letter-spacing: 0.08em; }

/* the row sparkline — the day as a shape before its number */
.spk { flex: 0 0 84px; height: 26px; display: flex; align-items: center; }
.spark { width: 84px; height: 26px; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spark.up { stroke: #62d6a4; } .spark.up circle { fill: #62d6a4; }
.spark.dn { stroke: #e0716d; } .spark.dn circle { fill: #e0716d; }
@media (max-width: 419px) { .spk { flex-basis: 64px; } .spark { width: 64px; } }

/* the widest gap, drawn — twin bars diverging from one zero line */
#gapFig { margin: 12px 0 0; }
#gapFig:empty { display: none; }
.gf-row { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.gf-name {
  flex: 0 0 96px; font-size: 12.5px; color: #ccd5e0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gf-track { flex: 1; position: relative; height: 10px; border-radius: 5px; background: rgba(140,160,190,0.12); overflow: hidden; }
.gf-track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.gf-track i.up { background: #62d6a4; }
.gf-track i.dn { background: #e0716d; }
.gf-val { flex: 0 0 56px; text-align: right; font-family: 'Spline Sans Mono', ui-monospace, monospace; font-size: 12px; font-variant-numeric: tabular-nums; }
.gf-val.up { color: #62d6a4; } .gf-val.dn { color: #e0716d; }
.gf-note { margin: 4px 0 0; font-size: 11.5px; color: #8b96a6; font-family: 'Spline Sans Mono', ui-monospace, monospace; letter-spacing: 0.04em; }

/* tap-to-define terms — dotted underline, real buttons, finger-sized */
.term {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted rgba(240,205,117,0.65);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  position: relative;
}
.term::after {
  /* an invisible 44px hit area without disturbing the text layout */
  content: '';
  position: absolute;
  inset: -12px -6px;
}

/* the glossary popover */
#gloss {
  border: 1px solid rgba(240,205,117,0.3);
  border-radius: 16px;
  background: #0b0e15;
  color: #eef2f7;
  padding: 22px 22px 18px;
  max-width: min(420px, calc(100vw - 48px));
  font-family: 'Jost', system-ui, sans-serif;
}
#gloss::backdrop { background: rgba(4,5,8,0.72); backdrop-filter: blur(3px); }
#glossTerm {
  margin: 0 0 8px;
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.24em;
  color: #f0cd75;
}
#glossDef { margin: 0 0 14px; font-size: 15.5px; line-height: 1.55; color: #dde4ee; }
#glossLink {
  display: inline-block;
  margin: 0 0 16px;
  font-size: 14px;
  color: #62d6a4;
  text-decoration: none;
  border-bottom: 1px solid rgba(98,214,164,0.4);
  padding-bottom: 1px;
}
#glossClose {
  display: block;
  width: 100%;
  appearance: none;
  border: 1px solid rgba(140,160,190,0.3);
  border-radius: 10px;
  background: none;
  color: #aeb8c7;
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  padding: 10px;
  cursor: pointer;
}

/* fineprint + doors */
#fine { margin-top: 40px; border-top: 1px solid rgba(140,160,190,0.15); padding-top: 18px; }
#fine p { font-size: 13px; line-height: 1.55; color: #8b96a6; margin: 0 0 16px; }
#fine .term { text-decoration-color: rgba(140,160,190,0.5); }
#doors { display: flex; flex-direction: column; gap: 8px; }
#doors a {
  color: #62d6a4;
  text-decoration: none;
  font-size: 14.5px;
}
