/* Duo SF — mobile-first dark theme, legibility-first. iPhone ~390px first. */
@import url("https://fonts.googleapis.com/css2?family=Gloock&family=Schibsted+Grotesk:wght@400;500;600;700&family=Martian+Mono:wght@400;500;600&display=swap");

:root {
  --night: #05060a;
  --panel: #10141f;
  /* text — tuned for WCAG AA on near-black */
  --star: #f4f2ec;        /* primary text / headings  (~17:1) */
  --star-dim: #c7c3b8;    /* secondary / body         (~9.6:1) */
  --star-faint: #9d998e;  /* labels, min 12px         (~5.2:1) */
  --ember: #ffc87a;       /* in-stock / live accent    */
  --ember-deep: #f0a94a;  /* buy button gradient       */
  --ember-glow: #ffc87a4d;
  --alert: #ff9a86;       /* degraded / error          */
  --ok: #7fe0a8;
  --hair: #ece8de1f;
  --hair-strong: #ece8de36;
  --font-display: "Gloock", "Times New Roman", serif;
  --font-sans: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "Martian Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--night); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--star);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  background:
    radial-gradient(120% 70% at 78% -14%, #2a386a3d, transparent 58%),
    radial-gradient(85% 55% at -12% 22%, #3f2b5526, transparent 70%),
    var(--night);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* quiet starfield (decorative, reduced) */
body::before {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image:
    radial-gradient(1.5px 1.5px at 22% 28%, #ece8de55, transparent),
    radial-gradient(1px 1px at 68% 14%, #ece8de40, transparent),
    radial-gradient(1.3px 1.3px at 82% 62%, #ece8de3a, transparent),
    radial-gradient(1px 1px at 38% 82%, #ece8de30, transparent);
  background-size: 300px 300px;
  animation: drift 260s linear infinite;
}

main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding:
    max(env(safe-area-inset-top), 14px)
    max(env(safe-area-inset-right), 18px)
    max(env(safe-area-inset-bottom), 40px)
    max(env(safe-area-inset-left), 18px);
}
@media (min-width: 640px) { main { padding-left: 32px; padding-right: 32px; } }

/* ── typography helpers ─────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;              /* 12px min */
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--star-faint);
  margin: 0;
}
.mono { font-family: var(--font-mono); }
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.015em; }
.dim { color: var(--star-dim); }
.faint { color: var(--star-faint); }
.tnum { font-variant-numeric: tabular-nums; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

/* ── header ─────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 18px; height: 18px; }
.brand span {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--star);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--star-dim);
  background: #ece8de0f;
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 6px 12px;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--star-faint); }
.status-pill.live { color: var(--ember); border-color: #ffc87a3d; background: #ffc87a12; }
.status-pill.live .dot { background: var(--ember); box-shadow: 0 0 0 0 var(--ember-glow); animation: breathe 2.2s ease-in-out infinite; }
.status-pill.blind, .status-pill.paused { color: var(--alert); border-color: #ff9a8640; background: #ff9a8610; }
.status-pill.blind .dot, .status-pill.paused .dot { background: var(--alert); }
.badge-preview {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border: 1px solid var(--hair-strong);
  border-radius: 999px;
  color: var(--ember);
}

/* ── degraded banner ────────────────────────────────────────────── */
.banner {
  margin-top: 12px;
  border: 1px solid #ff9a8647;
  background: linear-gradient(#ff9a8614, #ff9a8608);
  border-radius: 16px;
  padding: 14px 16px;
}
.banner h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--alert); }
.banner p { margin: 6px 0 0; font-size: 14px; color: var(--star-dim); line-height: 1.5; }

/* ── top section layout ─────────────────────────────────────────── */
.top { margin-top: 18px; display: grid; gap: 28px; }
.top > .rise, .top > .map, .top > .hero, .top > .ready-slot, .top > .stats-slot { min-width: 0; }
.stats-slot .stats { margin-top: 0; }   /* the grid gap already separates it from the hero */

/* In-stock: hoist the ready card directly under the headline (and push the 3-stat
   row below it) so the first "Open in Apple Store" / "Buy in Safari" button is on the
   first screen of a 390×844 phone. Empty state keeps hero → stats → ready source order. */
.top.instock > .hero       { order: 1; }
.top.instock > #readycard  { order: 2; }
.top.instock > #statsrow   { order: 3; }
.top.instock > .radar-wrap { order: 4; }
.top.instock > #pushcard   { order: 5; }
.top.instock > #fastcard   { order: 6; }

@media (min-width: 1024px) {
  .top {
    margin-top: 28px;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 32px 48px;
    align-items: start;
    grid-template-areas:
      "hero  ready"
      "stats push"
      "map   push"
      "map   fast";
  }
  /* grid-area placement overrides `order`, so the desktop two-column layout is
     unchanged by the in-stock reorder above. */
  .hero { grid-area: hero; }
  #statsrow { grid-area: stats; }
  .ready-slot { grid-area: ready; }
  .map { grid-area: map; }
  #pushcard { grid-area: push; }
  #fastcard { grid-area: fast; }
}

/* ── hero ───────────────────────────────────────────────────────── */
.hero { min-width: 0; }
.hero-eyebrow { margin-top: 2px; }
/* each phrase stays whole, so the eyebrow only ever breaks at the " · " separators
   (never mid-word like "SF Bay / Area") — one clean line, or two if it must wrap. */
.hero-eyebrow .nb { white-space: nowrap; }
.hero h1 {
  margin: 14px 0 0;
  font-size: clamp(2.6rem, 12vw, 5rem);
  line-height: 0.95;
}
.hero.instock h1 { color: var(--star); }
.hero .sub { margin: 14px 0 0; max-width: 34rem; font-size: 1.0625rem; line-height: 1.55; color: var(--star-dim); }
.hero.instock .sub { color: var(--star); }

/* stats dl */
.stats {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
}
.stats > div { padding: 14px 10px 14px 14px; border-left: 1px solid var(--hair); }
.stats > div:first-child { padding-left: 0; border-left: 0; }
.stats dt { margin: 0; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--star-faint); }
.stats dd { margin: 7px 0 0; font-family: var(--font-mono); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--star); }

/* ── radar map ──────────────────────────────────────────────────── */
.radar-wrap { position: relative; }
.radar-wrap svg { display: block; width: 100%; height: auto; user-select: none; }
.legend {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--star-dim);
}
.legend span { display: flex; align-items: center; gap: 8px; }
.legend .d-ready { width: 11px; height: 11px; border-radius: 999px; background: var(--star); box-shadow: 0 0 9px 2px #ece8de99; }
.legend .d-recent { width: 9px; height: 9px; border-radius: 999px; background: var(--ember); }
.legend .d-sold { width: 8px; height: 8px; border-radius: 999px; background: #ece8de70; }
.inspect {
  margin-top: 14px;
  min-height: 2.6rem;
  border-top: 1px solid var(--hair);
  padding-top: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--star-dim);
}
.inspect .on { color: var(--ember); font-weight: 500; }

/* ── cards ──────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--hair-strong);
  border-radius: 22px;
  padding: 20px;
  background: linear-gradient(#141926c2, #0b0f19a6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.card.dashed { border-style: dashed; background: #0b0f1966; backdrop-filter: none; -webkit-backdrop-filter: none; }
@media (min-width: 640px) { .card { padding: 26px; } }
.card h2 { margin: 10px 0 0; font-family: var(--font-display); font-weight: 400; font-size: 1.9rem; line-height: 1.05; }
.card .lead { margin: 10px 0 0; font-size: 15px; line-height: 1.55; color: var(--star-dim); max-width: 26rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.on-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ember); border: 1px solid #ffc87a4d; background: #ffc87a14; border-radius: 999px; padding: 6px 11px;
}
.on-pill .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--ember); box-shadow: 0 0 0 0 var(--ember-glow); animation: breathe 2.2s ease-in-out infinite; }

/* ── ready-for-pickup (the in-stock answer) ─────────────────────── */
.ready-slot { min-width: 0; }
.ready-live {
  border-color: #ffc87a5c;
  background:
    radial-gradient(120% 80% at 50% -10%, #ffc87a1f, transparent 60%),
    linear-gradient(#171a23, #0f1017);
  box-shadow: 0 0 0 1px #ffc87a26, 0 18px 50px -24px #ffc87a4d;
}
.ready-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ready-head .eyebrow { color: var(--ember); }
.ready-count {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--night); background: var(--ember); border-radius: 999px; padding: 6px 12px;
}
.ready-empty { margin: 12px 0 0; font-family: var(--font-display); font-size: 1.7rem; line-height: 1.15; color: var(--star); }
.ready-last { margin-top: 12px; font-size: 13.5px; color: var(--star-dim); line-height: 1.55; }
.ready-nudge { margin-top: 14px; font-size: 14px; color: var(--star-faint); line-height: 1.55; }

.store-card {
  position: relative; overflow: hidden;
  border: 1px solid #ffc87a3d; border-radius: 18px; padding: 16px; margin-top: 14px;
  background: linear-gradient(#1a1d26, #121420);
}
.store-card.focus { box-shadow: 0 0 0 2px #ffc87a85; }
.store-card .sc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.store-card h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.store-card .sc-dist { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--ember); white-space: nowrap; }
.store-card .sc-city { margin: 3px 0 0; font-size: 13px; color: var(--star-faint); }

.sc-item {
  margin-top: 12px; padding: 12px; border-radius: 14px;
  border: 1px solid var(--hair); background: #ece8de08;
}
.sc-item-top { display: flex; align-items: center; gap: 10px; }
.sc-item .dot { width: 14px; height: 14px; border-radius: 999px; flex: none; }
.sc-item .dot.night { background: #27304d; box-shadow: inset 0 0 0 1px #ffffff26; }
.sc-item .dot.white { background: #efebe1; box-shadow: inset 0 0 0 1px #0003; }
.sc-item .sc-model { font-size: 15.5px; font-weight: 600; flex: 1; min-width: 0; }
.sc-item .sc-price { font-family: var(--font-mono); font-size: 13px; color: var(--star-dim); white-space: nowrap; }
.sc-item .sc-since { margin-top: 7px; font-family: var(--font-mono); font-size: 12px; color: var(--ember); }
.sc-item .buy {
  margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; border-radius: 13px; text-decoration: none;
  font-family: var(--font-sans); font-size: 15px; font-weight: 700; letter-spacing: 0.01em;
  background: linear-gradient(180deg, var(--ember), var(--ember-deep)); color: #1a1205;
  box-shadow: 0 6px 20px -8px #ffc87a99;
}
.sc-item .buy:active { transform: translateY(1px); }

/* ── filters / chips ────────────────────────────────────────────── */
fieldset { border: 0; margin: 0; padding: 0; }
.filter-group { margin-top: 18px; }
.filter-group legend { padding: 0; }
.chips { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--hair-strong); background: #ece8de08;
  color: var(--star-dim);
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 9px;
  cursor: pointer; transition: border-color .2s, background .2s, color .2s;
}
.chip:hover { color: var(--star); }
.chip[aria-pressed="true"] {
  border-color: var(--star); background: #ece8de1a; color: var(--star); font-weight: 600;
}
.swatch { width: 16px; height: 16px; border-radius: 999px; display: inline-block; }
.swatch.night { background: linear-gradient(to bottom right, #2b3350, #0b0e19); box-shadow: inset 0 0 0 1px #ffffff26; }
.swatch.white { background: linear-gradient(to bottom right, #fbf9f3, #d9d3c4); box-shadow: inset 0 0 0 1px #0003; }

/* ── buttons ────────────────────────────────────────────────────── */
.btn {
  min-height: 52px; width: 100%; border-radius: 14px; border: 1px solid transparent;
  background: var(--star); color: var(--night);
  font-family: var(--font-sans); font-size: 15px; letter-spacing: 0.01em; font-weight: 700;
  cursor: pointer; transition: filter .15s, opacity .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn.ghost { background: none; border-color: var(--hair-strong); color: var(--star-dim); font-weight: 600; }
.btn.ghost:hover { color: var(--star); border-color: #ece8de80; }
.btn-row { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.btn-sub {
  margin-top: 12px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55;
  color: var(--star-faint);
}
.btn-sub.err { color: var(--alert); }

/* install / denied / unsupported guides */
.guide { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.guide-step { display: flex; gap: 13px; align-items: flex-start; }
.guide-step .num {
  flex: none; width: 28px; height: 28px; border-radius: 999px;
  border: 1px solid #ffc87a59; background: #ffc87a14; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--ember);
}
.guide-step p { margin: 3px 0 0; font-size: 15px; line-height: 1.5; color: var(--star-dim); }
.guide-step strong { color: var(--star); font-weight: 700; }
.note { margin-top: 16px; font-size: 13px; line-height: 1.6; color: var(--star-faint); }
.skeleton { margin-top: 20px; height: 96px; border-radius: 16px; background: #ece8de0d; animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite; }

/* ── fast checkout ──────────────────────────────────────────────── */
.toggle {
  margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  border: 1px solid var(--hair-strong); border-radius: 14px; padding: 4px;
}
.toggle button {
  min-height: 48px; border: 0; border-radius: 10px; background: none; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600; color: var(--star-dim); transition: background .2s, color .2s;
}
.toggle button[aria-pressed="true"] { background: var(--star); color: var(--night); }
.setup {
  margin-top: 18px; border: 1px solid var(--hair); border-radius: 16px; padding: 16px;
  background: #05060a66; font-size: 15px; line-height: 1.55; color: var(--star-dim);
}
.setup strong { color: var(--star); font-weight: 700; }
.setup p { margin: 12px 0 0; }
.setup p:first-of-type { margin-top: 0; }
.copy-btn {
  margin-top: 14px; min-height: 48px; width: 100%; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--hair-strong); background: #ece8de0d; color: var(--star);
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
}
.after-note { margin-top: 16px; font-size: 15px; line-height: 1.55; color: var(--star-dim); }

/* ── drop history ───────────────────────────────────────────────── */
.history { margin-top: 72px; border-top: 1px solid var(--hair); padding-top: 44px; }
.history-grid { display: grid; gap: 40px; }
@media (min-width: 1024px) {
  .history-grid { grid-template-columns: minmax(0,1fr) minmax(0,1.3fr); gap: 56px; align-items: start; }
}
.history h2 { margin: 14px 0 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(2.1rem, 7vw, 3.2rem); line-height: 1; }
.history .lead { margin: 14px 0 0; max-width: 28rem; font-size: 15px; line-height: 1.55; color: var(--star-dim); }

.histogram { margin-top: 28px; }
.histo-cap { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.histo-cap .ht { font-size: 13px; font-weight: 600; color: var(--star); }
.histo-cap .hm { font-family: var(--font-mono); font-size: 12px; color: var(--star-faint); white-space: nowrap; }
.bars { margin-top: 14px; display: flex; height: 108px; align-items: flex-end; gap: 3px; }
.bars .col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bars .bar { width: 100%; border-radius: 3px 3px 0 0; transition: height 0.6s ease; background: #ece8de1f; }
.bars .bar.nz { background: #ece8de66; }
.bars .bar.peak { background: var(--ember); box-shadow: 0 0 12px -2px var(--ember-glow); }
.bars .col.current .bar { outline: 1.5px solid var(--star); outline-offset: 1px; }
.axis { margin-top: 8px; display: flex; font-family: var(--font-mono); font-size: 11px; color: var(--star-faint); }
.axis span { flex: 1; }

.drops { min-width: 0; }
.group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 22px 0 4px; font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--star-faint);
}
.group-head:first-child { margin-top: 0; }
.drop-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--hair);
}
.drop-row .dr-main { min-width: 0; }
.drop-row .name { font-size: 15px; font-weight: 600; }
.drop-row .sub { margin-top: 3px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; font-size: 13px; color: var(--star-dim); }
.drop-row .sub .t { font-family: var(--font-mono); font-size: 12px; color: var(--star-faint); white-space: nowrap; }
.drop-row .sub .dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }
.drop-row .sub .dot.night { background: #27304d; box-shadow: inset 0 0 0 1px #ffffff26; }
.drop-row .sub .dot.white { background: #efebe1; box-shadow: inset 0 0 0 1px #0003; }
.drop-row .sub .city { color: var(--star-faint); }
.drop-row .right { font-family: var(--font-mono); font-size: 12.5px; color: var(--star-dim); white-space: nowrap; padding-top: 1px; }
.drop-row .right.live { color: var(--ember); display: flex; align-items: center; gap: 6px; }
.drop-row .right.live .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--ember); box-shadow: 0 0 0 0 var(--ember-glow); animation: breathe 2.2s ease-in-out infinite; }
.load-older { margin-top: 20px; }
.empty-drops { font-size: 14px; color: var(--star-dim); line-height: 1.7; }

/* ── footer ─────────────────────────────────────────────────────── */
footer {
  margin-top: 64px; border-top: 1px solid var(--hair); padding-top: 22px;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 12.5px; line-height: 1.55; color: var(--star-faint);
}
@media (min-width: 640px) { footer { flex-direction: row; justify-content: space-between; gap: 24px; } }
footer p { margin: 0; }

/* ── animations ─────────────────────────────────────────────────── */
.rise { animation: rise 0.8s cubic-bezier(.2,.7,.1,1) both; }
@keyframes rise { 0% { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 var(--ember-glow); } 50% { box-shadow: 0 0 0 7px #0000; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes drift { to { transform: translate(-300px, -150px); } }
@keyframes appear { 0% { opacity: 0; } }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.pulse-ring { transform-origin: center; animation: pulse-ring 2.4s cubic-bezier(.4,0,.6,1) infinite; }
@keyframes pulse-ring { 0% { opacity: 0.9; transform: scale(.4); } to { opacity: 0; transform: scale(3.2); } }
.radar-sweep { transform-origin: center; }
@keyframes radar { 0% { opacity: 0; transform: rotate(0); } 10% { opacity: 1; } to { opacity: 0; transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  body::before { animation: none; }
}
