/* Cable Turf
   ------------------------------------------------------------------
   One stylesheet, no build step, no webfonts. Tokens, base, masthead and
   footer follow the shared publicworks.nyc chrome; the reference is
   paygap.publicworks.nyc. The front page is a story that scrolls beside a
   pinned map and ends in the map itself. */

/* ---- Tokens ---------------------------------------------------- */

:root {
  --paper:        #fbfaf7;
  --paper-raised: #ffffff;
  --paper-sunken: #f2f0eb;
  --ink:          #16181d;
  --ink-soft:     #4a4f5a;
  --ink-faint:    #6b7280;
  --rule:         #e0ddd6;
  --rule-strong:  #c9c5bb;

  --accent:       #0b5a70;   /* deep cyan; 7.4:1 on the paper */
  --on-accent:    #ffffff;
  --accent-soft:  #e2eef1;
  --accent-ink:   #08465a;

  /* Map fills, one per cable company. Matches FILL in map.js. */
  --spectrum:     #a6c4ef;
  --optimum:      #96d4c6;
  --both:         #c4b5ea;
  --open:         #e5e8ec;
  --hatch:        rgba(20, 32, 56, .6);
  --spectrum-tag: #5a8ed8;
  --optimum-tag:  #3aa58f;
  --stage:        #f0f2f5;
  --astound:      #8b6fd0;

  /* "Other options" view: share of a block's buildings with no other option.
     Matches RAMP in map.js. --wire is the ramp's step used for bars. */
  --ramp: linear-gradient(90deg, #eef3fb 0%, #c3d3ee 25%, #88a3d6 50%, #4f70b4 75%, #22407e 100%);
  --wire: #4f70b4;

  --shadow-tight: 0 1px 2px rgba(20,22,28,.06);
  --shadow-card: 0 2px 10px rgba(20,22,28,.08);

  --glass:      rgba(251, 250, 247, .82);
  --glass-blur: saturate(140%) blur(14px);
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, .9);

  --measure: 34rem;
  --wide:    72rem;
  --masthead-h: 3.3rem;
  --story-w: 28rem;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

/* ---- Base ------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.12; letter-spacing: -.022em; font-weight: 700; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 5.2vw, 3.6rem); letter-spacing: -.03em; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-top: 2.5em; }
h3 { font-size: 1.1rem; letter-spacing: -.01em; margin-top: 2em; }

p { margin: 0 0 1em; max-width: var(--measure); }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: .07em; }
a:hover { color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--accent); color: #fff; padding: .6rem 1rem; z-index: 100;
}
.skip:focus { left: .5rem; top: .5rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { width: min(100% - 2.5rem, var(--wide)); margin-inline: auto; }
main { padding-bottom: 5rem; }

/* ---- Masthead --------------------------------------------------- */
/* The shared portfolio header. Only --accent may differ between sites.
   Do not retune the sizes below. */

.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); }

@media (min-width: 60rem) and (hover: hover) {
  .masthead {
    position: sticky; top: 0; z-index: 30;
    background: var(--glass);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-edge);
  }
  :root { scroll-padding-top: calc(var(--masthead-h) + 1rem); }
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .masthead { background: var(--paper-raised); }
  }
  @media (prefers-reduced-transparency: reduce) {
    .masthead {
      background: var(--paper-raised);
      -webkit-backdrop-filter: none; backdrop-filter: none;
    }
  }
  @media (max-height: 34rem) {
    .masthead { position: static; }
    :root { scroll-padding-top: 0; }
  }
}

.masthead-inner {
  display: flex; align-items: center; gap: 1.25rem;
  padding: .55rem 0; flex-wrap: wrap;
}
.wordmark {
  font-weight: 700; letter-spacing: -.03em; font-size: 1.25rem;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.nav { display: flex; gap: .15rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a {
  color: var(--ink-soft); text-decoration: none;
  padding: .35rem .6rem; border-radius: 6px;
  font-size: .9rem; font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--paper-sunken); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* ---- Notes ------------------------------------------------------ */

.note-box {
  border-left: 3px solid var(--rule-strong);
  background: var(--paper-sunken);
  padding: .85rem 1rem;
  border-radius: 0 8px 8px 0;
  font-size: .89rem;
  color: var(--ink-soft);
  margin: 1.5rem 0;
  max-width: 46rem;
}
.note-box p { max-width: none; }
.note-box p:last-child { margin-bottom: 0; }

/* ---- Footer ----------------------------------------------------- */

.footer {
  border-top: 1px solid var(--rule);
  margin-top: 4rem; padding: 2rem 0 3rem;
  font-size: .87rem; color: var(--ink-faint);
}
.footer p { max-width: 40rem; }
.footer a { color: var(--ink-soft); }
.footer a:hover { color: var(--accent); }
.footer-grid {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.footer .footer-head {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-faint); margin: 0 0 .5rem; line-height: 1.6;
}
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer li { margin-bottom: .25rem; }

.colophon { margin-top: 1.5rem; font-size: .82rem; }
.portfolio {
  margin: 1.75rem 0 0; padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: .8rem; letter-spacing: .02em; color: var(--ink-faint);
}
.portfolio a { color: var(--ink-soft); text-decoration: none; font-weight: 600; }
.portfolio a:hover { color: var(--accent); text-decoration: underline; }

.footer-compact { margin: 1.25rem 0 0; padding: 1rem 0 0; font-size: .8rem; }
.footer-compact p { margin: 0; }
.footer-compact .colophon { margin-top: 0; font-size: .76rem; line-height: 1.5; }
.footer-compact .portfolio { margin-top: .8rem; padding-top: .7rem; }

/* ---- About and Data --------------------------------------------- */

.document { padding-top: clamp(2rem, 5vw, 3.5rem); }
.document h1 { margin-bottom: .3em; }
.document h2 { margin-top: 2.2em; }
.document ul, .document ol { max-width: var(--measure); padding-left: 1.2rem; margin: 0 0 1em; }
.document li { margin-bottom: .45rem; }
.document .lead { font-size: 1.2rem; line-height: 1.45; color: var(--ink-soft); max-width: 36rem; }

.downloads {
  display: grid; gap: 1rem; margin: 1rem 0; max-width: 48rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}
.download {
  display: block; background: var(--paper-raised);
  border: 1px solid var(--rule); border-radius: 10px; padding: 1rem 1.2rem;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-tight);
  transition: border-color .15s ease;
}
.download:hover { border-color: var(--accent); color: inherit; }
.download h3 { margin: 0 0 .25rem; font-size: 1.02rem; }
.download p { margin: 0; font-size: .89rem; color: var(--ink-soft); max-width: none; }

details { max-width: 48rem; margin: 1rem 0; }
details > summary { cursor: pointer; font-weight: 600; font-size: .95rem; }
details[open] > summary { margin-bottom: .75rem; }
.data-note { font-size: .85rem; color: var(--ink-faint); margin-top: .75rem; }
.fine { font-size: .85rem; color: var(--ink-faint); }

.table-wrap {
  overflow-x: auto; max-width: 48rem; margin: 1rem 0;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--paper-raised);
}
.document table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.document th, .document td { padding: .5rem .8rem; text-align: left; vertical-align: top; }
.document thead th {
  background: var(--paper-sunken); border-bottom: 1px solid var(--rule-strong);
  font-size: .78rem; letter-spacing: .02em; color: var(--ink-soft); font-weight: 700;
}
.document tbody tr + tr td { border-top: 1px solid var(--rule); }
.document code { font-family: var(--mono); font-size: .88em; }

.process { list-style: none; margin: 1rem 0 0; padding: 0; counter-reset: step; max-width: var(--measure); }
.document .process { padding-left: 0; }
.process > li { position: relative; counter-increment: step; padding: 0 0 1.25rem 2.6rem; margin: 0; }
.process > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--paper);
  font-size: .8rem; font-weight: 700;
}
.process > li:not(:last-child)::after {
  content: ""; position: absolute; left: .8rem; top: 1.9rem; bottom: .25rem;
  border-left: 2px solid var(--rule-strong);
}
.process h3 { margin: 0 0 .2rem; font-size: 1rem; }
.process p { margin: 0; color: var(--ink-soft); }

/* ---- Front page ------------------------------------------------- */
/* Wide: the story scrolls on the left and the map stays pinned on the
   right. Narrow: the map stays pinned on top and the story scrolls under
   it. The last step is the panel, whose sections follow Chopper Noise's
   readout. */

.app-page main { padding-bottom: 0; }

/* The masthead spans the window, in line with the story and the map. */
@media (min-width: 60rem) {
  body.app-page .masthead .wrap { width: calc(100% - 2.5rem); }
}

.story {
  display: grid;
  grid-template-columns: var(--story-w) 1fr;
}

/* First in the page so it can stick on a phone; placed right when wide. */
.story-stage {
  grid-column: 2; grid-row: 1; align-self: start;
  position: sticky; top: 0;
  height: 100dvh;
  background: var(--stage);
}
@media (min-width: 60rem) and (hover: hover) {
  .story-stage { top: var(--masthead-h); height: calc(100dvh - var(--masthead-h)); }
}

.story-text {
  grid-column: 1; grid-row: 1;
  border-right: 1px solid var(--rule);
  background: var(--paper);
}

.step {
  min-height: 78vh;
  padding: 16vh 1.75rem 4rem 1.6rem;
  border-left: 3px solid transparent;
  font-size: 1rem; line-height: 1.6;
  transition: border-color .3s ease;
}
.step:first-child { padding-top: 2.25rem; }
.step.is-active { border-left-color: var(--accent); }
.step p { max-width: none; margin: 0 0 .9rem; }
.step h1 { font-size: 1.9rem; line-height: 1.12; margin: 0 0 1rem; }
.step h2 { font-size: 1.45rem; margin: 0 0 .8rem; }
.step-count {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint);
}
.step p.step-count { margin-bottom: .45rem; }
.step .figure { margin-bottom: 1.1rem; }
.step-key { margin-top: 1.2rem; max-width: 20rem; }
.step .key-ramp-label { margin-bottom: .3rem; line-height: 1.4; }
.step-skip { font-size: .9rem; font-weight: 600; }
.step-skip a { text-decoration: none; }
.step-skip a:hover { text-decoration: underline; }

/* The last step is the panel, at the panel's type size. */
.step-live {
  display: flex; flex-direction: column;
  min-height: calc(100dvh - var(--masthead-h));
  padding-top: 2rem; padding-bottom: .9rem;
  font-size: .92rem; line-height: 1.5;
}
.step-live:focus { outline: none; }
.step-live p { margin: 0; }
.step-live > div > p:not([class]) { margin-bottom: .6rem; }
.step-live .seg { margin: .4rem 0 .2rem; }
.step-live .footer-compact { margin-top: auto; padding-bottom: 0; }

/* Segmented buttons: one choice from a short set, as on Chopper Noise. */
.seg {
  display: flex; padding: 2px; gap: 2px;
  background: var(--paper-sunken); border: 1px solid var(--rule); border-radius: 8px;
}
.seg button {
  flex: 1; min-width: 0; font: inherit; font-size: .84rem; font-weight: 500;
  color: var(--ink-soft); background: none; border: 0; border-radius: 6px;
  padding: .32rem .4rem; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--ink); background: rgba(255, 255, 255, .6); }
.seg button[aria-pressed="true"] {
  background: var(--paper-raised); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 22, 28, .12);
}

.readout { padding: .8rem 0; border-bottom: 1px solid var(--rule); }
.readout:last-child { border-bottom: 0; }
.readout > p + p { margin-top: .4rem; }
.readout p:not([class]) { font-size: .86rem; color: var(--ink-soft); line-height: 1.45; }

.section-h {
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; line-height: 1.4; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 .45rem;
}

.figure .num {
  display: block;
  font-size: 2.1rem; font-weight: 700; line-height: 1.05; letter-spacing: -.03em;
}
.figure .cap { display: block; margin-top: .2rem; color: var(--ink-soft); font-size: .86rem; line-height: 1.4; }
.step-live .fine { font-size: .78rem; color: var(--ink-faint); line-height: 1.4; }

/* Rows: a label, a bar on a shared track, a value. */
.rows { list-style: none; margin: .2rem 0 0; padding: 0; display: grid; gap: .3rem; }
.rows li {
  display: grid; grid-template-columns: 7.4rem 1fr 4.8rem; gap: .55rem; align-items: center;
  font-size: .84rem; color: var(--ink-soft);
}
.rows .bar { height: .5rem; background: var(--paper-sunken); border-radius: 2px; overflow: hidden; }
.rows .bar i { display: block; width: 0; height: 100%; border-radius: 0 3px 3px 0; background: var(--wire); transition: width .4s ease; }
.rows .v { text-align: right; color: var(--ink); font-weight: 600; white-space: nowrap; }

.verdict { margin-top: .55rem !important; font-size: .9rem; color: var(--ink); line-height: 1.4; }

.key-line { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .8rem; color: var(--ink-soft); }
.key-line > span { display: inline-flex; align-items: center; gap: .35rem; }
.readout .key-line + .key-line, [data-key] + .key-line { margin-top: .4rem; }
.key-ramp-label { font-size: .8rem; color: var(--ink-soft); margin-bottom: .3rem; }
.key-ramp { display: grid; gap: .15rem; margin-bottom: .45rem; }
.ramp-bar { height: .7rem; border-radius: 2px; background: var(--ramp); border: 1px solid rgba(0, 0, 0, .08); }
.ramp-ends { display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-faint); }

.swatch {
  flex: none; width: 1.15rem; height: .85rem;
  border: 1px solid rgba(0, 0, 0, .12); border-radius: 2px;
}
.swatch.spectrum { background: var(--spectrum); }
.swatch.optimum { background: var(--optimum); }
.swatch.both { background: var(--both); }
.swatch.open { background: var(--open); }
/* Lines in the map pattern's 45° rhythm. */
.swatch.hatch {
  background: repeating-linear-gradient(135deg, var(--hatch) 0 1.1px, transparent 1.1px 3.5px), var(--paper-raised);
}
/* Dashes in the map line's 3:1.5 rhythm. */
.swatch.line {
  height: 2.5px; border: 0; border-radius: 0;
  background: repeating-linear-gradient(90deg, var(--ink) 0 5px, transparent 5px 7.5px);
}

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  font: inherit; font-size: .8rem; color: var(--ink-soft); cursor: pointer;
  background: var(--paper-raised); border: 1px solid var(--rule);
  border-radius: 999px; padding: .2rem .65rem;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* Block readout. */
.back {
  font: inherit; font-size: .8rem; font-weight: 600; color: var(--accent); cursor: pointer;
  background: none; border: 0; padding: 0; margin: .85rem 0 .1rem;
}
.back:hover { text-decoration: underline; }
.holder { display: flex; align-items: center; gap: .55rem; font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.holder .swatch { width: 1.1rem; height: 1.1rem; border-radius: 3px; }
.step-live .sub { margin-top: .15rem; font-size: .86rem; color: var(--ink-soft); }

.out { font-size: .86rem; font-weight: 600; }

/* ---- Map stage -------------------------------------------------- */

.map { position: absolute; inset: 0; }

.map-message {
  position: absolute; top: 50%; left: 50%; translate: -50% -50%;
  padding: .45rem .85rem;
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 6px;
  font-size: .88rem; color: var(--ink-soft);
}

/* One line at the pointer: the block's cable company and its rivals' claims. */
.map-tip {
  position: absolute; z-index: 5; pointer-events: none;
  max-width: calc(100% - 1rem);
  padding: .3rem .55rem;
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 6px;
  box-shadow: var(--shadow-card);
  font-size: .8rem; line-height: 1.35; color: var(--ink-soft); white-space: nowrap;
}
.map-tip[hidden] { display: none; }
.map-tip b { color: var(--ink); font-weight: 600; }


/* Company tags, so they never read as a street or neighborhood. */
.turf-name {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .22rem .55rem .22rem .4rem;
  background: rgba(255, 255, 255, .94); border-radius: 999px;
  box-shadow: 0 1px 3px rgba(20, 22, 28, .22);
  font-size: .72rem; font-weight: 700; line-height: 1.2; letter-spacing: .02em;
  color: var(--ink); white-space: nowrap; pointer-events: none;
}
.turf-name::before {
  content: ""; width: .7rem; height: .7rem; border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, .18);
}
.turf-S::before { background: var(--spectrum-tag); }
.turf-O::before { background: var(--optimum-tag); }
.turf-name { transition: opacity .6s ease; }
.names-off .turf-name, .names-hidden .turf-name { opacity: 0; }

/* Places the story names, shown once the camera lands on them. */
.place-tag {
  display: inline-block; opacity: 0; transition: opacity .5s ease;
  padding: .2rem .55rem;
  background: var(--ink); color: var(--paper); border-radius: 4px;
  box-shadow: 0 1px 3px rgba(20, 22, 28, .25);
  font-size: .76rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  pointer-events: none;
}
.place-tag.is-shown { opacity: 1; }

.map-attrib {
  position: absolute; right: 0; bottom: 0; z-index: 1;
  padding: 0 .4rem; border-radius: 4px 0 0 0;
  background: rgba(251, 250, 247, .8);
  font-size: .68rem; color: var(--ink-faint);
}
.map-attrib a { display: inline-flex; align-items: center; min-height: 24px; color: var(--ink-soft); }

.maplibregl-ctrl-group { box-shadow: none !important; border: 1px solid var(--rule); }

@media (max-width: 60rem) {
  .story { display: block; }
  .story-stage { z-index: 3; height: 46svh; border-bottom: 1px solid var(--rule); }
  .story-text { border-right: 0; }
  .step {
    max-width: 42rem; margin-inline: auto;
    min-height: 62svh; padding: 1.6rem 1.25rem 3rem; border-left-width: 0; border-top: 3px solid transparent;
  }
  .step.is-active { border-top-color: var(--accent); }
  .step:first-child { padding-top: 1.4rem; }
  .step h1 { font-size: 1.6rem; }
  .step-live { min-height: 54svh; padding-top: 1.4rem; }
}

/* ---- Stable first paint ---------------------------------------- */
/* The masthead is drawn by script. Until it is, its slot holds the height it
   will have at that width: one row, or the nav wrapping to two. Cable Turf's
   nav wraps at 315px and below. */
header[data-chrome="masthead"]:empty { display: block; min-height: 52.83px; }
@media (max-width: 19.6875rem) { header[data-chrome="masthead"]:empty { min-height: 104.83px; } }
