/* stocks.css — stylesheet for the programmatic /stocks pages (site/stocks/render.js).
   Static asset (Assets fast path; never run_worker_first). The token block, chrome, and the band-row /
   range-col rules are COPIED from returns.html (single source of truth there; keep in sync — no build
   step). Page-specific additions are at the bottom (.crumbs, .stock-*, .hz-*). */

/* Self-hosted fonts — cloned from returns.html / history.html. */
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 700; font-display: optional; src: url('/vendor/jetbrains-mono-700.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/vendor/jetbrains-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/vendor/jetbrains-mono-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter Tight'; font-style: normal; font-weight: 400; font-display: swap; src: url('/vendor/inter-tight-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter Tight'; font-style: normal; font-weight: 500; font-display: swap; src: url('/vendor/inter-tight-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter Tight'; font-style: normal; font-weight: 600; font-display: swap; src: url('/vendor/inter-tight-600.woff2') format('woff2'); }

/* Tokens — cloned verbatim from returns.html :root (itself cloned from history.html). */
:root {
  --bg: #08090b; --bg2: #11131a; --bg3: #181b24;
  --border: #1f2330; --border2: #2a2f3d;
  --text: #e8ecf5; --text2: #a8b0c0; --text3: #7a8395;
  --accent: #c9d3e8;
  --red: #c44848; --amber: #c89545; --green: #5a9a48; --green-deep: #2a6b3a;
  --gray-mid: #484f58; --red-deep: #8b1f1f; --blue-muted: #4a6a8a;
  --orange: #e8842a; --orange-deep: #a8551a;
  --regime-risk-off: #d05d5d; --regime-mildly-off: var(--amber); --regime-neutral: var(--text2);
  --regime-mildly-on: var(--green); --regime-risk-on: #6db85a;
  --regime-sw-risk-off: var(--red-deep); --regime-sw-mildly-off: var(--amber); --regime-sw-neutral: var(--gray-mid);
  --regime-sw-mildly-on: var(--green); --regime-sw-risk-on: var(--green-deep);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--text);
  font-family: 'Inter Tight', -apple-system, sans-serif; font-weight: 400;
  min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden;
}
html { scroll-behavior: smooth; }
/* Grid texture overlay — institutional terminal feel (0.018 alpha; do not raise). */
body::before {
  content: ''; position: fixed; inset: 0;
  background-image: linear-gradient(rgba(232,236,245,0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(232,236,245,0.018) 1px, transparent 1px);
  background-size: 48px 48px; pointer-events: none; z-index: 0;
}
main {
  position: relative; z-index: 1; max-width: 920px; margin: 0 auto;
  padding: 28px max(32px, env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left));
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}

/* ── Top bar ── */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text3); letter-spacing: 0.14em;
}
.brand-logo { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-logo img { height: 20px; width: auto; display: block; }
.brand-wordmark { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 13px; letter-spacing: 0.14em; word-spacing: -0.3em; text-transform: uppercase; color: var(--text); }
.brand-logo:focus-visible { outline: 1px solid var(--border2); outline-offset: 3px; border-radius: 3px; }
.topbar-back { color: var(--text2); text-decoration: none; letter-spacing: 0.12em; transition: color 0.2s; }
.topbar-back:hover, .topbar-back:focus-visible { color: var(--text); }
.topbar-back:focus-visible { outline: 1px solid var(--border2); outline-offset: 3px; }

/* ── Page header — accent hairline + mono descriptor ── */
.hist-head { margin: 32px 0 26px; }
.page-title {
  padding-left: 16px; border-left: 3px solid var(--green);
  font-family: 'Inter Tight', sans-serif; font-weight: 600; font-size: clamp(26px, 3.4vw, 38px);
  letter-spacing: -0.02em; line-height: 1.05; color: var(--text);
}
.page-descriptor {
  margin-top: 11px; padding-left: 19px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; letter-spacing: 0.04em; color: var(--text2);
}
.page-descriptor a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }

/* Regime WORD color tier (AA on --bg). */
.b-risk_off { color: var(--regime-risk-off); }
.b-mildly_off { color: var(--regime-mildly-off); }
.b-neutral { color: var(--regime-neutral); }
.b-mildly_on { color: var(--regime-mildly-on); }
.b-risk_on { color: var(--regime-risk-on); }

/* ── Band rows (copied from returns.html) ── */
.tk-figure { margin-top: 44px; }
.bandmap { display: flex; flex-direction: column; gap: 6px; }
.band-row {
  display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 14px;
  padding: 9px 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg2);
}
.band-row.is-here { border-color: var(--border2); box-shadow: inset 0 0 0 1px var(--border2); }
.band-row.is-insufficient { opacity: 0.45; }
.band-head { display: flex; flex-direction: column; gap: 4px; }
.band-name { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; }
.band-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.flag { font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.06em; line-height: 1.3; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.flag-here { color: var(--text); border: 1px solid var(--border2); background: var(--bg3); }
.flag-thin { color: var(--text3); border: 1px solid var(--border); }
.range-col { position: relative; height: 48px; }
.range-zero { position: absolute; top: 18px; bottom: 14px; width: 1px; background: rgba(168, 180, 200, 0.85); z-index: 2; }
.range-band { position: absolute; top: 22px; height: 8px; border-radius: 4px; min-width: 3px; }
.range-tick { position: absolute; top: 19px; height: 14px; width: 2.5px; border-radius: 1px; transform: translateX(-50%); background: #e8ecf5; z-index: 3; }
.range-typical { position: absolute; top: 0; transform: translateX(-50%); font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--text); white-space: nowrap; }
.range-lo, .range-hi { position: absolute; top: 34px; transform: translateX(-50%); font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.02em; color: var(--text3); white-space: nowrap; }
.range-na { position: absolute; top: 18px; left: 0; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-style: italic; color: var(--text3); }
.band-pos { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.02em; color: var(--text3); }
.tk-empty { font-family: 'JetBrains Mono', monospace; font-size: 12px; letter-spacing: 0.04em; color: var(--text3); padding: 30px 4px; text-align: center; }
.tk-hero-line { font-family: 'JetBrains Mono', monospace; font-size: 13px; letter-spacing: 0.04em; line-height: 1.5; color: var(--text2); }
.tk-hero-line strong { color: var(--text); font-weight: 700; }
.tk-hero-line .here-band { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 13px; letter-spacing: 0.06em; }
.tk-foot { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.04em; line-height: 1.6; color: var(--text3); margin-top: 18px; }
.tk-foot a { color: var(--text2); text-decoration: underline; text-underline-offset: 2px; }
.tk-foot a:hover, .tk-foot a:focus-visible { color: var(--text); }

/* ── Methodology / section labels / footer (copied from returns.html) ── */
.methodology { margin-top: 44px; }
.section-label {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 400; letter-spacing: 0.22em;
  color: var(--text3); text-transform: uppercase; margin-bottom: 24px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px;
}
.section-label::before { content: ''; display: inline-block; width: 4px; height: 4px; background: var(--amber); border-radius: 50%; }
.method-prose { font-family: 'Inter Tight', sans-serif; font-size: 15px; line-height: 1.6; color: var(--text2); max-width: 70ch; margin-bottom: 14px; }
.method-prose a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.method-prose a:hover, .method-prose a:focus-visible { color: var(--green); }
footer {
  margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text3); letter-spacing: 0.14em;
}
footer a { color: var(--text2); text-decoration: none; transition: color 0.2s; }
footer a:hover { color: var(--text); }
.footer-disclaimer strong { color: var(--text2); font-weight: 700; letter-spacing: 0.1em; }

/* ── /stocks-specific additions ── */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3); }
.crumbs a { color: var(--text2); text-decoration: none; transition: color 0.2s; }
.crumbs a:hover, .crumbs a:focus-visible { color: var(--text); }
.crumbs a:focus-visible { outline: 1px solid var(--border2); outline-offset: 2px; }
.stock-live { margin: 0 0 14px; }
.stock-live a { color: inherit; text-decoration: none; }
.stock-live a:hover .here-band, .stock-live a:focus-visible .here-band { text-decoration: underline; text-underline-offset: 3px; }
.stock-profile { font-family: 'Inter Tight', sans-serif; font-size: 15px; line-height: 1.6; color: var(--text2); max-width: 70ch; margin: 0 0 8px; }
/* main is a flex column: its children default to min-width:auto, so a wide table would push the
   whole page past the viewport on mobile. Pin the sections to min-width:0 so only the .hz-wrap scrolls. */
main > section, main > p, main > nav { min-width: 0; }
/* All-horizons table */
.hz-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.hz-table { width: 100%; min-width: 560px; border-collapse: collapse; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.hz-table caption { caption-side: top; text-align: left; font-size: 10px; letter-spacing: 0.06em; color: var(--text3); padding-bottom: 10px; }
.hz-table th, .hz-table td { padding: 8px 10px; border: 1px solid var(--border); background: var(--bg2); text-align: left; vertical-align: top; }
.hz-table thead th { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text3); font-weight: 400; }
.hz-table tbody th { font-weight: 700; letter-spacing: 0.06em; white-space: nowrap; }
.hz-table tbody th .flag { margin-left: 6px; vertical-align: middle; }
.hz-table tr.is-here th, .hz-table tr.is-here td { border-color: var(--border2); }
.hz-med { display: block; font-weight: 700; color: var(--text); }
.hz-sub { display: block; font-size: 9.5px; letter-spacing: 0.02em; color: var(--text3); margin-top: 2px; white-space: nowrap; }
.hz-sub + .hz-sub { margin-top: 0; }
.hz-na { color: var(--text3); font-style: italic; font-size: 10px; }
.hz-thin .hz-med { color: var(--text2); }
.hz-all th, .hz-all td { background: var(--bg3); }
.hz-all th { color: var(--text2); }
/* Ticker search on /stocks (copied from returns.html .tk-search / .tk-input / .tk-btn / .tk-msg) */
.tk-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.stock-search { margin: 4px 0 18px; }
.tk-input {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 9px 12px; width: 170px; max-width: 100%;
  border: 1px solid var(--border2); border-radius: 4px; background: var(--bg2); color: var(--text);
  -webkit-appearance: none; appearance: none; transition: border-color 0.2s;
}
.tk-input::placeholder { color: var(--text3); text-transform: none; letter-spacing: 0.02em; }
.tk-input:focus { outline: none; border-color: var(--text3); }
.tk-input:focus-visible { outline: 1px solid var(--border2); outline-offset: 2px; }
.tk-btn {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 9px 18px; border: 1px solid var(--border2); border-radius: 4px; background: var(--bg3); color: var(--text);
  cursor: pointer; -webkit-appearance: none; appearance: none; transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.tk-btn:hover, .tk-btn:focus-visible { border-color: var(--text3); }
.tk-btn:focus-visible { outline: 1px solid var(--border2); outline-offset: 2px; }
.tk-msg { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.04em; color: var(--regime-risk-off); }
/* Ticker grids (related tickers on a page; the full universe on /stocks) */
.stock-more { margin-top: 44px; }
.stock-index { margin-top: 8px; }
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.stock-grid a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg2); text-decoration: none; color: var(--text2); font-family: 'JetBrains Mono', monospace; font-size: 11px; transition: border-color 0.2s, background 0.2s; }
.stock-grid a strong { color: var(--text); letter-spacing: 0.06em; }
.stock-grid a span { font-family: 'Inter Tight', sans-serif; font-size: 12px; color: var(--text3); }
.stock-grid a:hover, .stock-grid a:focus-visible { border-color: var(--text3); background: var(--bg3); }
.stock-grid a:focus-visible { outline: 1px solid var(--border2); outline-offset: 2px; }
.stock-cta { margin-top: 16px; }

@media (max-width: 600px) {
  main { padding: 20px max(20px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  /* Range-band rows — tightened for mobile (copied from returns.html). */
  .band-row { grid-template-columns: 1fr; gap: 4px; padding: 5px 12px; }
  .band-head { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
  .bandmap { gap: 4px; }
  .band-name { font-size: 10.5px; }
  .band-pos { font-size: 9px; flex-basis: 100%; }
  .range-col { height: 38px; }
  .range-typical { font-size: 10px; }
  .range-zero { top: 14px; bottom: 11px; }
  .range-band { top: 17px; height: 7px; }
  .range-tick { top: 15px; height: 11px; }
  .range-lo, .range-hi { top: 27px; font-size: 8.5px; }
  .stock-grid { grid-template-columns: repeat(2, 1fr); }
  .tk-input { width: 100%; } .tk-btn { flex: 1 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
