/* Reset and page shell: fixture bar, left rail, header strip, grid. Every size, gap, radius and duration is a token. */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--fx-h) + var(--head-h) + var(--sp-4));
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: var(--fw-text) var(--fs-13)/var(--lh-13) var(--sans);
  letter-spacing: var(--tr-13);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--brand); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--brand-tint); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* one focus ring everywhere: 2px brand, 2px out; inside a clipping box it is drawn inset (offset -2px) */
:focus { outline: none; }
:focus-visible { outline: var(--ring); outline-offset: var(--ring-off); }
:where(a, [role="link"]):focus-visible { border-radius: var(--r-sm); }

.mono { font-family: var(--mono); font-variant-numeric: var(--nums); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- fixture bar ---------- */
.fixture-bar {
  position: sticky; top: 0; z-index: 70;
  height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: #d92b3a;
  color: #fff;
  font: 700 var(--fs-11)/1 var(--sans);
  letter-spacing: 0.16em;
}

/* ---------- left rail (drawn from the nav config) ---------- */
/* the lockup: mark, then one logotype in two weights */
.lockup { display: flex; align-items: center; color: var(--text); }
.lockup:hover { color: var(--text); text-decoration: none; }
.lk { display: inline-flex; align-items: baseline; white-space: nowrap; font: 600 var(--fs-13)/1 var(--wordmark); letter-spacing: -0.01em; color: var(--text); }
.lk .mark { width: 19.3px; height: 14px; margin-right: 7px; flex: none; color: var(--brand); }
.lk .mo { margin-left: 0.3em; font-weight: 400; letter-spacing: 0; color: var(--brand); }
/* the two words join the mark once their face is in (html.has-mark); it loads after the first screen's own (app.js) */
html:not(.has-mark) .lk > span { display: none; }

.rail {
  position: fixed; top: var(--fx-h); left: 0; bottom: 0; z-index: 60;
  width: var(--rail-w);
  display: flex; flex-direction: column;
  padding: 0 var(--sp-3);
  /* a separate plane: a faint light falling from the top */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012) 45%, rgba(255, 255, 255, 0)) var(--bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > .lockup { height: var(--row-h); flex: none; margin: 0 -12px 10px; padding: 0 20px; } /* as on main */
.nav { display: flex; flex-direction: column; padding-bottom: var(--sp-4); }
.nav-h { margin: var(--sp-6) 0 var(--sp-1); padding: 0 var(--sp-2); font: var(--fw-label) var(--fs-11)/var(--lh-11) var(--sans); letter-spacing: var(--tr-11); color: var(--text-3); }
/* an item is its label, 32px tall, so the list keeps a 4px rhythm */
.nav-a, .nav-p {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  height: 32px; flex: none; padding: 0 var(--sp-2);
  border-radius: var(--r-ctl);
  font: var(--fw-label) var(--fs-13)/1 var(--sans);
  letter-spacing: var(--tr-13);
  color: var(--text-2);
  white-space: nowrap;
}
.nav-l { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-a { transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
a.nav-a:hover { color: var(--text); background: var(--fill); text-decoration: none; }
a.nav-a:active { background: var(--fill-hover); }
.nav-a[aria-current="page"] { color: var(--text); background: var(--fill-hover); }
/* the selected page carries a 2px brand bar on its left edge (on the guide, for a product's page) */
.nav-a[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: var(--sp-2); bottom: var(--sp-2); width: 2px; border-radius: var(--r-mark); background: var(--accent-v); }
.nav-a:focus-visible { outline-offset: calc(-1 * var(--ring-off)); }
/* a product label is not a link; it turns strong only while one of its pages is open */
.nav-p.is-cur { color: var(--text); }
.nav-p.is-off { color: var(--text-3); }
/* a product's pages sit in, beside a hairline guide (main's indentation); the selected page's bar rides the guide */
.nav-g { position: relative; display: flex; flex-direction: column; margin: 0 0 0 14px; padding-left: 7px; }
.nav-g::before { content: ""; position: absolute; left: 0; top: var(--sp-1); bottom: var(--sp-1); width: 1px; background: var(--line-strong); }
.nav-g .nav-a { padding-left: 10px; }
.nav-g .nav-a[aria-current="page"]::before { left: -8px; }
.nav-tag { flex: none; font: var(--fw-label) var(--fs-11)/1 var(--sans); letter-spacing: var(--tr-11); color: var(--text-3); }
.rail-foot { flex: none; display: flex; align-items: center; height: 64px; margin: auto calc(-1 * var(--sp-3)) 0; padding: 0 var(--sp-3); border-top: 1px solid var(--line); }
.rail-foot .nav-a { flex: 1; }
.scrim { position: fixed; inset: 0; z-index: 55; background: rgba(1, 6, 18, 0.72); }
.mbar { display: none; }

/* ---------- page header ---------- */
/* the content column carries the page's one signature: a soft brand light along its top */
.shell { margin-left: var(--rail-w); display: flex; flex-direction: column; min-height: calc(100vh - var(--fx-h)); background: var(--glow); background-repeat: no-repeat; }
/* Nothing moves once it is visible (app.js, present): a page's title block waits for its first screen, each card for
   every card of its row, the foot for the last row. Meanwhile the page is kept taller than the window, so a scrollbar
   that takes room does so before anything shows. */
html:not(.is-shown) .shell > *, .page > .is-held, html:not(.is-done) .foot { visibility: hidden; }
html:not(.is-done) main { min-height: calc(100vh + 1px); }
/* the phone bar's menu button sits at the right edge, which a scrollbar coming or going moves: it shows once the
   first page has its final height (html.has-page) */
html:not(.has-page) .menu-btn { visibility: hidden; }
/* One block, stuck to the top: the as-of time top right; beneath it the title, with the Range control at the right
   end of its line. Once the page scrolls, the as-of line slides under the top edge (--hd-tuck), the time rides beside
   the Range and the block takes its frosted surface (.is-stuck, set by the shell); at rest it lies on the page's light. */
.head {
  position: sticky; top: calc(var(--fx-h) - var(--hd-tuck)); z-index: 40;
  height: var(--hd-h); flex: none;
  padding: var(--sp-4) var(--pad) 0;
  /* at rest it lies on the page's light with no edge at all: no line, no band */
  background: transparent;
}
/* The stuck surfaces (the title block, the tabs row, the phone bar) carry no line. Once content passes beneath them
   they take a frosted surface that fades out over 24px below their box, so the page goes under a soft edge rather
   than a straight one; the lowest of them carries the fade. */
.head::before, .subhead::before, .mbar::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: -24px; z-index: -1; pointer-events: none;
  background: rgba(1, 6, 18, 0.8);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  opacity: 0;
  transition: opacity var(--t-mid) var(--ease);
}
.head.has-sub::before { bottom: 0; -webkit-mask-image: none; mask-image: none; }
.head.is-stuck::before, .head.is-stuck + .subhead::before { opacity: 1; }
.head-in, .page, .foot-in, .subhead-in { width: 100%; max-width: 1240px; margin: 0 auto; }
.head-in { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-rows: 16px 32px; gap: var(--sp-3) var(--sp-4); align-items: center; }
.page-title { grid-column: 1; grid-row: 2; display: flex; align-items: baseline; min-width: 0; font: var(--fw-strong) var(--fs-20)/32px var(--sans); letter-spacing: var(--tr-20); white-space: nowrap; }
/* a sub-page is titled by its trail: the parent page, then the key, then its plain name */
.crumb { font-weight: var(--fw-label); color: var(--text-3); transition: color var(--t-fast) var(--ease); }
.crumb:hover { color: var(--text); text-decoration: none; }
.crumb-s { margin: 0 var(--sp-2); font-weight: var(--fw-text); color: var(--text-3); }
.crumb-n { margin-left: var(--sp-3); font: var(--fw-text) var(--fs-13)/var(--lh-13) var(--sans); letter-spacing: var(--tr-13); color: var(--text-3); }
.crumb-n:empty { display: none; }
/* the market's name, then its listing date, set apart by space alone */
.crumb-n > span + span { margin-left: var(--sp-3); }
/* a long name gives way before the header does; the 4px is room for the crumb's focus ring inside the clip */
.page-title.is-trail { overflow: hidden; margin-left: calc(-1 * var(--sp-1)); padding-left: var(--sp-1); }
.page-title.is-trail > * { flex: none; }
.page-title.is-trail > .crumb-n { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.asof { grid-column: 2 / 4; grid-row: 1; justify-self: end; font: var(--fw-text) var(--fs-12)/var(--lh-12) var(--sans); letter-spacing: var(--tr-12); font-variant-numeric: var(--nums); color: var(--text-3); white-space: nowrap; }
.asof b { font-weight: var(--fw-label); color: var(--text-2); }
.asof.is-stale, .asof.is-stale b { color: var(--down); }
.asof .short { display: none; }
.head #range { grid-column: 3; grid-row: 2; justify-self: end; }
/* scrolled: the as-of line has slid under the top edge, so the time rides beside the Range */
.head.is-stuck .asof { grid-column: 2; grid-row: 2; animation: fade-in var(--t-mid) var(--ease); }
@keyframes fade-in { from { opacity: 0; } }
/* a page without a Range (Research Library, Data): the as-of time sits on the title's own line, baselines aligned */
.head.no-range .head-in { align-items: baseline; }
.head.no-range .asof { grid-column: 2 / 4; grid-row: 2; animation: none; }

/* segmented control: a quiet track (control radius), the pressed option one step lighter (small radius) */
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--fill); border-radius: var(--r-ctl); }
.seg button {
  height: 24px; min-width: 32px; padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  font: var(--fw-label) var(--fs-12)/1 var(--sans);
  letter-spacing: var(--tr-12);
  color: var(--text-2);
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.seg button:hover:not(:disabled):not([aria-pressed="true"]) { color: var(--text); background: var(--fill-hover); }
.seg button:active:not(:disabled):not([aria-pressed="true"]) { background: var(--fill-press); }
.seg button[aria-pressed="true"] { background: var(--fill-press); color: var(--text); }
.seg button:disabled { color: var(--text-off); cursor: default; }
.seg button:focus-visible { outline-offset: calc(-1 * var(--ring-off)); }
.seg.is-off { display: none; }
/* the Range control decides what every chart on the page shows, so it is the one control with the brand tint */
.seg.is-range button { height: 28px; min-width: 44px; padding: 0 var(--sp-3); font-size: var(--fs-13); letter-spacing: var(--tr-13); font-variant-numeric: var(--nums); }
.seg.is-range button[aria-pressed="true"] { background: var(--accent-fill); box-shadow: inset 0 0 0 1px rgba(92, 178, 246, 0.45); color: var(--brand-tint); }

/* ---------- the row beneath the title block: the page's tabs (Markets); on a phone it also holds the Range control ---------- */
.subhead {
  position: sticky; top: calc(var(--fx-h) + var(--hd-h) - var(--hd-tuck)); z-index: 39;
  flex: none; padding: 0 var(--pad);
}
.subhead-in { display: flex; align-items: flex-end; min-height: 40px; }
.sub-l { display: flex; align-items: flex-end; min-width: 0; }
/* page tabs (Markets): the hit area reaches 8px past the label on each side; the underline is the label's width */
.tabs { display: flex; gap: var(--sp-6); }
.tabs button { position: relative; height: 40px; margin: 0 calc(-1 * var(--sp-2)); padding: 0 var(--sp-2); font: var(--fw-label) var(--fs-13)/1 var(--sans); letter-spacing: var(--tr-13); color: var(--text-3); white-space: nowrap; transition: color var(--t-fast) var(--ease); }
.tabs button::after { content: ""; position: absolute; left: var(--sp-2); right: var(--sp-2); bottom: 0; height: 2px; border-radius: var(--r-mark) var(--r-mark) 0 0; background: transparent; transition: background-color var(--t-fast) var(--ease); }
.tabs button:hover { color: var(--text); }
.tabs button:hover::after { background: var(--line-hover); }
.tabs button:active { color: var(--text-2); }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after { background: var(--accent); }
.tabs button:focus-visible { outline-offset: calc(-1 * var(--sp-1)); border-radius: var(--r-ctl); }

main { flex: 1; padding: var(--sp-5) var(--pad) var(--sp-8); }
.page { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
/* a tall card may take two rows, with two short cards stacked beside it */
.rows-2 { grid-row: span 2; }

/* ---------- foot: the credit, at the end of the content (the viewport's bottom on a short page) ---------- */
.foot { flex: none; padding: 0 var(--pad); border-top: 1px solid var(--line); }
.foot-in { height: 64px; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: var(--sp-2); }
.foot .by { font: var(--fw-label) var(--fs-12)/1 var(--sans); letter-spacing: var(--tr-12); color: var(--text-3); }
.foot .by span { color: var(--text-2); }
.foot .no { font: var(--fw-text) var(--fs-11)/1 var(--sans); letter-spacing: var(--tr-11); color: var(--text-3); }

/* ---------- floating layer ---------- */
#layer { position: absolute; top: 0; left: 0; width: 0; height: 0; z-index: 80; }
/* every floating layer shares one surface: --pop, a hairline, a highlight along its top edge, one shadow */
.toast, .pop, .tip {
  background: var(--pop);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  box-shadow: var(--hi-pop), var(--shadow);
}
.toast {
  position: fixed; left: 50%; bottom: var(--sp-8); transform: translateX(-50%);
  padding: var(--sp-2) var(--sp-3);
  font: var(--fw-label) var(--fs-12)/var(--lh-12) var(--sans); letter-spacing: var(--tr-12); color: var(--text);
  z-index: 90;
  animation: rise-in var(--t-mid) var(--ease);
}
@keyframes rise-in { from { opacity: 0; transform: translate(-50%, 4px); } }

/* ---------- responsive ---------- */
@media (max-width: 1279px) {
  .span-3 { grid-column: span 6; }
}
@media (max-width: 1180px) {
  .span-8 { grid-column: span 12; }
  .span-4, .span-3 { grid-column: span 6; }
  .span-4:last-child:nth-child(even) { grid-column: span 12; }
}
@media (max-width: 1000px) {
  .span-6, .span-4 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
  .rows-2 { grid-row: auto; }
}

@media (min-width: 761px) and (max-width: 1100px) {
  /* not enough room on the title line for the stuck as-of time beside a long trail */
  .head.is-stuck .asof { display: none; }
}
@media (min-width: 761px) and (max-width: 900px) {
  /* a narrow window beside the rail: the Range tightens, the market's name gives way */
  .head-in { column-gap: var(--sp-3); }
  .crumb-n { display: none; }
  .seg.is-range button { min-width: 36px; padding: 0 var(--sp-2); }
}
@media (max-width: 760px) {
  /* the rail becomes a top bar; its menu button opens the full rail as a drawer on the floating surface */
  .mbar {
    position: sticky; top: var(--fx-h); z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    height: var(--row-h); padding: 0 var(--sp-1) 0 var(--pad);
  }
  /* on a phone the page's light starts behind the top bar, so the bar has no edge at rest either */
  body { background: var(--glow) no-repeat, var(--bg); }
  .shell { background: none; }
  /* scrolled: the bar and the Range row take the frosted surface; the lower of the two carries the fade */
  html:has(.subhead:not([hidden])) .mbar::before { bottom: 0; -webkit-mask-image: none; mask-image: none; }
  html.is-scrolled .mbar::before, html.is-scrolled .subhead::before { opacity: 1; }
  .menu-btn { width: 40px; height: 40px; color: var(--text-2); }
  .rail {
    width: min(84vw, 300px); background: var(--pop); border-right-color: var(--line-strong); box-shadow: var(--hi-pop), var(--shadow);
    transform: translateX(-100%); visibility: hidden; transition: transform var(--t-mid) var(--ease), visibility 0s var(--t-mid);
  }
  .rail.is-open { transform: none; visibility: visible; transition: transform var(--t-mid) var(--ease); }
  .rail-open body { overflow: hidden; }
  .scrim { animation: fade-in var(--t-mid) var(--ease); }
  .shell { margin-left: 0; min-height: calc(100vh - var(--fx-h) - var(--row-h)); }
  /* the title scrolls away with the page; the row beneath it (tabs, then the Range control) sticks under the top bar */
  .head, .head.is-stuck { position: static; height: auto; padding: var(--sp-4) var(--pad) var(--sp-2); background: none; }
  .head::before { display: none; }
  /* one line: the title (it may wrap inside its column) and the short as-of time on its first baseline */
  .head-in { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto; gap: 0 var(--sp-3); align-items: baseline; }
  .page-title, .page-title.is-trail { grid-row: 1; flex-wrap: wrap; white-space: normal; overflow: visible; margin-left: 0; padding-left: 0; line-height: var(--lh-20); }
  .page-title.is-trail > .crumb-n { flex: 0 1 100%; margin-left: 0; white-space: normal; }
  .asof, .head.no-range .asof { grid-column: 2; grid-row: 1; }
  .asof .long { display: none; }
  .asof .short { display: inline; }
  .subhead { top: calc(var(--fx-h) + var(--row-h)); padding: 0; }
  .subhead-in { display: block; min-height: 0; }
  .sub-l { padding: 0 var(--pad); overflow-x: auto; scrollbar-width: none; }
  .sub-l::-webkit-scrollbar { display: none; }
  .sub-l:empty { display: none; }
  .sub-l .tabs { flex: none; }
  .tabs button { margin-bottom: 0; }
  .subhead #range:not(.is-off) { display: flex; margin: var(--sp-2) var(--pad); }
  .subhead #range button { flex: 1 1 0; min-width: 0; padding: 0; height: 32px; }
  main { padding-top: var(--sp-3); padding-bottom: var(--sp-6); }
  .foot-in { align-items: flex-start; }
  .page { gap: var(--sp-3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
