/* ===== Stay Frosty — base: reset, document, type utilities, layout, the frost ground and the glass recipes
   (DESIGN.md §4.1–4.2, §10; design/reskin/SPEC.md §2, §4.2) ===== */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4, h5, h6 { font: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, canvas, video { vertical-align: middle; }
svg { flex-shrink: 0; }
img, canvas, video { max-width: 100%; }
b, strong { font-weight: 600; }
small { font-size: inherit; }
a { color: var(--blue); text-decoration: none; }
/* the menu layer is shown by class as well as by the attribute, so it is left out here */
[hidden]:not(.menu-layer) { display: none !important; }

button {
  font: inherit; color: inherit; background: none; border: 0; border-radius: 0; padding: 0; margin: 0;
  text-align: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: manipulation;
}
button:disabled, button[disabled] { cursor: default; }
input, select, textarea { font: inherit; font-size: max(17px, 1rem); color: var(--ink); margin: 0; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }

/* ---------- document and Dynamic Type (§4.1) ---------- */
html { font-size: 17px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
@media (hover: none) and (pointer: coarse) { @supports (font: -apple-system-body) { html { font: -apple-system-body; } } }
body {
  font-family: var(--font-ui); font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 400;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow: hidden; overscroll-behavior: none;
}

/* ---------- focus (§5.10) ---------- */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
/* full-width rows and tiles clip an outside ring at the screen edge or under overflow: draw it inside */
/* (shelf tiles sit in a scroll box; the nav bar's buttons touch the top of the screen) */
:is(.wrow, .grow, .xs-act, .mfit-row, .tabbar button, .chip, .ltile, .shelf > button, .dr-row):focus-visible { outline-offset: -2px; }
/* glass discs and capsules: the ring hugs the visible disc (the 44pt hit box is larger than what you see) */
.gbtn:focus-visible, .tabbar-mini:focus-visible { outline: none; }
.gbtn:focus-visible::before, .tabbar-mini:focus-visible { box-shadow: 0 0 0 2px var(--blue), var(--spec); }
:focus:not(:focus-visible) { outline: none; }
/* a sheet's heading takes focus when the sheet opens (so VoiceOver starts there); it is not a control */
:is(h1, h2, h3, .sh-ctitle)[tabindex="-1"]:focus { outline: none; }

/* ---------- type utilities (§2 scale, §3 families) ---------- */
.t-hero     { font: 800 var(--fs-hero)/var(--lh-hero) var(--font-ui); font-stretch: var(--wd-cond); letter-spacing: -0.4px; }
.t-large    { font: 800 var(--fs-large)/var(--lh-large) var(--font-ui); font-stretch: var(--wd-cond); letter-spacing: -0.2px; }
.t-title1   { font: 800 var(--fs-title1)/var(--lh-title1) var(--font-ui); font-stretch: var(--wd-cond); }
.t-title2   { font: 700 var(--fs-title2)/var(--lh-title2) var(--font-ui); font-stretch: 100%; }
.t-title3   { font: 700 var(--fs-title3)/var(--lh-title3) var(--font-ui); font-stretch: 100%; }
.t-headline { font: 600 var(--fs-headline)/var(--lh-headline) var(--font-ui); font-stretch: 100%; }
.t-body     { font: 400 var(--fs-body)/var(--lh-body) var(--font-ui); font-stretch: 100%; }
.t-callout  { font: 400 var(--fs-callout)/var(--lh-callout) var(--font-ui); font-stretch: 100%; }
.t-subhead  { font: 400 var(--fs-subhead)/var(--lh-subhead) var(--font-ui); font-stretch: 100%; }
.t-footnote { font: 400 var(--fs-footnote)/var(--lh-footnote) var(--font-ui); font-stretch: 100%; }
.t-caption  { font: 500 var(--fs-caption)/var(--lh-caption) var(--font-ui); font-stretch: 100%; }

.d-xl { font: 700 var(--fs-dxl)/var(--lh-dxl) var(--font-data); }
.d-l  { font: 600 var(--fs-dl)/var(--lh-dl) var(--font-data); }
.d-m  { font: 500 var(--fs-dm)/var(--lh-dm) var(--font-data); }
.d-s  { font: 500 var(--fs-ds)/var(--lh-ds) var(--font-data); }
.d-xs { font: 500 var(--fs-dxs)/var(--lh-dxs) var(--font-data); }
/* catalogue line ("AR-01 · Assault rifle · 14.2% picked"): words are Archivo; only the code is Martian Mono */
.serial { font: 500 var(--fs-footnote)/var(--lh-footnote) var(--font-ui); color: var(--ink-3); }
/* the font shorthand resets font-stretch and font-variant-numeric, so they come after it */
.d-xl, .d-l, .d-m, .d-s, .d-xs, .serial { font-variant-numeric: tabular-nums; font-stretch: var(--wd-semi); }
.serial { font-stretch: 100%; }
.serial .code { font-family: var(--font-data); font-stretch: var(--wd-cond); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
/* keeps a date and time on one line ("Nov 22, 5:38 AM" never orphans "AM") */
.nowrap { white-space: nowrap; }

/* ---------- layout (§4.2) ---------- */
#app {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto;
  /* 100% of body, not 100vh/100dvh: a host can pad the root (the Claude phone app pads :root by the safe-area
     insets), and a viewport-tall #app would then push the tab bar off the bottom of the screen */
  height: 100%; overflow: hidden;
  overflow: clip;   /* not a scroll container (WebKit 16+), so neither script nor iOS focus scrolling can offset it */
  background: var(--stage-under); isolation: isolate;
  --stick-col: var(--stick);   /* sticky column heads; Meta moves them under the docked style bar */
}
/* Meta: column heads ride under the docked style bar (4 + 44) */
#app[data-tab="meta"] { --stick-col: calc(var(--stick) + 48px); }
@media (min-width: 561px) { #app { box-shadow: 0 0 0 var(--hair) var(--rule); } }

/* ---------- the frost ground (SPEC §2): painted once on #stage, never moves ---------- */
#stage {
  position: absolute; inset: 0; z-index: 0; transform-origin: 50% 0;
  background:
    var(--aura),                                   /* blue ambient glow under the brand */
    var(--frost-corners),                          /* rime in the two bottom corners */
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 38%, var(--bg) 100%);
  timeline-scope: --sf-scroll;                     /* the brand bar collapses on #scroller's scroll (chrome.css) */
}
/* frost speckle at the edges: a 180px tile, decoded once, masked to the screen edges (text never sits on it) */
#stage::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: var(--frost-noise) 0 0 / 180px 180px;
  opacity: .55;
  -webkit-mask-image: radial-gradient(140% 95% at 50% 45%, transparent 52%, #000 100%);
          mask-image: radial-gradient(140% 95% at 50% 45%, transparent 52%, #000 100%);
}

#scroller {
  position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  /* content runs under the floating tab capsule and through the gaps beside and below it */
  padding: 0 var(--g) var(--tab-space);
  /* keyboard focus lands clear of the sticky chrome: the compact brand bar (and on Meta the docked style bar), the
     column head under it (+36) and the tab capsule */
  scroll-padding: calc(var(--stick-col) + 36px) 0 var(--tab-space);
  scroll-timeline: --sf-scroll block;
}
/* The top inset (safe area + the 56pt brand bar) is a spacer rather than padding-top: browsers measure sticky
   offsets from inside a scroller's padding, and every sticky `top` (--stick, --stick-col) is measured from the top
   of the screen. Visually identical to padding-top. */
#scroller::before { content: ''; display: block; height: calc(var(--safe-t) + var(--bar-h)); }
#view { position: relative; min-width: 0; }

/* full-bleed ledger lists */
.list { margin-inline: calc(var(--g) * -1); }
.list > * { padding-inline: var(--g); }

/* ---------- sections ---------- */
.sec { min-width: 0; }
.sec + .sec { margin-top: var(--sec-gap); }
/* The title never shrinks below its own width: when title and qualifier don't fit on one line,
   the qualifier drops to its own right-aligned line instead of squeezing or overprinting the title. */
.sec-h {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px;
  padding-bottom: 8px; border-bottom: var(--hair) solid var(--rule);
  font: 700 var(--fs-title3)/var(--lh-title3) var(--font-ui); color: var(--ink);
}
.sec-h > :is(h2, h3) { flex: 1 1 auto; margin: 0; min-width: min(100%, max-content); font: inherit; }
.sec-q {
  flex: 0 1 auto; margin-left: auto; min-width: 0; white-space: normal; text-align: right;
  font: 500 var(--fs-footnote)/var(--lh-footnote) var(--font-ui);
  font-variant-numeric: tabular-nums; color: var(--ink-2);
}
.sec-h > :is(.link, button) { flex: none; margin-left: auto; white-space: nowrap; }
.foot {
  margin-top: 12px; text-align: left;
  font: 400 var(--fs-footnote)/var(--lh-footnote) var(--font-ui); color: var(--ink-3);
}

/* ---------- data glyphs and icons ---------- */
/* 7px filled triangle: inline SVG from Art.icon('tri-up|tri-down'), or drawn here when the element is empty */
.tri { display: inline-block; width: 7px; height: 7px; margin-inline: 2px; vertical-align: 0; flex: none; fill: currentColor; stroke: none; }
.tri.up { color: var(--green); }
.tri.down { color: var(--red); }
.tri:empty { background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tri.down:empty { clip-path: polygon(0 0, 100% 0, 50% 100%); }

.ico {
  display: inline-block; flex: none; vertical-align: -0.125em; overflow: visible;
  fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round;
}

/* legacy safety net: any old .card renders as an inset group */
.card {
  display: block; width: 100%; padding: 16px; overflow: hidden;
  background: var(--surface); border-radius: var(--r-group); --eyelet: var(--surface);
}
.card + .card { margin-top: 12px; }

/* ---------- liquid glass recipes (SPEC §4.2). Floating chrome only: never inside a scrolling list ---------- */
/* floating glass (tab bar, mini button, drawer panel, menus, toast) */
.glass { background: var(--glass-regular); -webkit-backdrop-filter: var(--blur-regular); backdrop-filter: var(--blur-regular);
         box-shadow: var(--spec), var(--sh-float); }
.glass.thick { background: var(--glass-thick); -webkit-backdrop-filter: var(--blur-thick); backdrop-filter: var(--blur-thick); }
.glass.thin  { background: var(--glass-thin);  -webkit-backdrop-filter: var(--blur-thin);  backdrop-filter: var(--blur-thin); }
/* refractive rim: a 1px gradient ring, bright top-left and bottom-right (the "specular edge") */
.rim { position: relative; isolation: isolate; }
.rim::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: var(--rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
}
/* in-flow glass look, no blur (segmented tracks, secondary buttons, the stepper) */
.faux { background: var(--glass-faux); box-shadow: var(--spec); }
/* solid frost panel (content): text inside still starts at --g from the screen edge */
.panel {
  position: relative; margin-inline: calc(var(--panel-x) - var(--g)); padding: 12px var(--pad) 14px;
  border-radius: var(--r-panel); background: linear-gradient(180deg, var(--panel-top), var(--panel-bot));
  box-shadow: var(--edge-frost);
}
.panel + .panel, .sec + .sec { margin-top: var(--sec-gap); }
