/* v0 reader — vanilla CSS scroll-snap 2D deck.
   Horizontal axis = stories (swipe left/right). Vertical axis = depth within a
   story (swipe up = deeper). svh (not vh/dvh) so things don't resize as the iOS
   toolbar collapses mid-snap; safe-area insets keep content clear of notch/home. */

:root {
  --bg: #0f1115;
  --fg: #f2f4f7;
  --muted: #9aa4b2;
  --accent: #6ea8fe;
  --rule: #2a313b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ---- the deck: horizontal rail of full-viewport story columns ---- */
.deck {
  display: flex;
  height: 100svh;
  width: 100vw;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  touch-action: pan-x;
  outline: none;
}
.deck::-webkit-scrollbar { display: none; }
.deck { scrollbar-width: none; }

/* ---- a story: fixed header + scrolling ladder ---- */
.story {
  flex: 0 0 100vw;
  height: 100svh;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  overflow: hidden;            /* header stays put; the cards scroll in the child */
  position: relative;          /* anchor for the left depth rail */
}

/* depth rail: full-height vertical strip on the left, segments top->bottom =
   gist->deepest, in the true per-rung card colors. */
.story__rail {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 9px;
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.rail-seg { flex: 1 1 0; }     /* background set inline by app.js */

/* fixed header: row 1 = section + label on the FIRST card's color (constant);
   row 2 = a short strip of the per-rung colors, the active one taller. */
.shead {
  position: relative;
  flex: 0 0 auto;
  padding-top: env(safe-area-inset-top);
}
.shead__title {
  position: relative;
  padding: 20px 14px 21px;   /* ~150% of the prior band height — more room to breathe */
  text-align: center;
  /* background + color set inline by app.js = shade(hue, 0) */
}
.shead__section {
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.78;
}
.shead__label {
  font-size: 1.02rem;
  font-weight: 700;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shead__count {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.7;             /* inherits the title's contrasting color */
}

/* ---- the ladder: vertical scroll-snap of cards ---- */
.story__scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y proximity;
  touch-action: pan-y;
}
.story__scroll::-webkit-scrollbar { display: none; }
.story__scroll { scrollbar-width: none; }

/* ---- a card: one comfortable eyeful; bg + text set per-card by app.js ---- */
.card {
  min-height: 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 1.6rem calc(env(safe-area-inset-bottom) + 4.8rem);
  position: relative;
}
.card__text {
  margin: 0;
  font-weight: 500;
  line-height: 1.35;
  text-wrap: balance;
  color: inherit;
}
.card--gist .card__text { font-size: clamp(1.5rem, 6vw, 2.2rem); font-weight: 650; }
.card--deep .card__text { font-size: clamp(1.1rem, 4.5vw, 1.4rem); }

/* centered source pills (no "Source" label) */
.chips {
  position: absolute;
  left: 1.2rem; right: 1.2rem;
  bottom: calc(env(safe-area-inset-bottom) + 1.2rem);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}
.chip {
  font-size: 0.74rem;
  color: var(--chip-fg, var(--fg));
  background: var(--chip-bg, rgba(0, 0, 0, 0.07));
  border: 1px solid var(--chip-border, var(--rule));
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  text-decoration: none;
}
.chip:active { opacity: 0.7; }

/* ---- terminus + state screens (neutral, dark) ---- */
.story--end { align-items: center; justify-content: center; }
.terminus, .state {
  min-height: 100svh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
  padding: 2rem;
}
.state { position: fixed; inset: 0; background: var(--bg); }
.state[hidden], .deck[hidden] { display: none; }
.terminus h2, .state h2 { font-size: 1.6rem; margin: 0; }
.terminus p, .state p { color: var(--muted); margin: 0; max-width: 28ch; }
.btn {
  margin-top: 0.5rem;
  background: var(--accent);
  color: #0b1020;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
}
