/* City Chroma - delivery page: home and city views (version 3, docs/web_reveal_spec.md); work pages (version 4, docs/web_explained_spec.md).
   Figure-ground palette from urban-morphology plans: white paper, black ink, thin rules in black with transparency.
   The city colour is the only hue; it appears only after the reveal (set per view as --city-a / --city-b from the data).
   IBM Plex Mono for data and labels, Source Serif 4 for city names and sentences. Every view fits one screen. */
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/SourceSerif4Display-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/SourceSerif4Display-It.otf") format("opentype"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --paper: #FFFFFF; --ink: #000000; --ink-2: rgba(0, 0, 0, 0.62); --rule: rgba(0, 0, 0, 0.16);
  --city-a: #000000; --city-b: #000000;   /* replaced per city view from the data bundle */
  --mono: "IBM Plex Mono", "Source Serif 4", monospace;
  --serif: "Source Serif 4", "IBM Plex Mono", serif;
  --m: 48px; --gap: 32px;
}
* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--mono); font-size: 13px; line-height: 1.5; font-variant-numeric: tabular-nums; }
h1, h2, h3, p, ul, ol, table, figure { margin: 0; }
ul, ol { list-style: none; padding: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--ink); text-decoration: none; }
a:hover, button:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.k { color: var(--ink-2); }
.serif { font-family: var(--serif); }

/* ---------- one view = one screen ---------- */
.view { height: 100vh; height: 100dvh; padding: 28px var(--m); display: grid; row-gap: 20px; overflow: hidden; }
.view.fade { animation: fade 220ms ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.bar { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; min-width: 0; }
.bar .links { display: flex; gap: 28px; white-space: nowrap; }
.site { font-family: var(--serif); font-size: 17px; }

/* ---------- home ---------- */
.home { grid-template-rows: minmax(0, 1fr) auto auto; }
.pair { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--gap); align-items: end; align-self: center; min-height: 0; }
.city-link { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.city-link:hover { text-decoration: none; }
.city-link canvas { display: block; }
.city-link .name { font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1.1; margin-top: 22px; }
.city-link:hover .name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
.city-link .count { color: var(--ink-2); font-size: 12px; margin-top: 4px; }
.legend .what { flex-basis: 100%; max-width: 80ch; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; color: var(--ink-2); font-size: 12px; }
.legend .dots { display: inline-flex; align-items: center; gap: 14px; }
.legend .dots span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; border-radius: 50%; background: var(--ink); }
.legend .bar-scale { display: inline-flex; align-items: center; gap: 8px; }
.legend .bar-scale b { display: inline-block; height: 5px; border: 1px solid var(--ink); border-top: 0; }

/* ---------- city ---------- */
.city { grid-template-rows: auto minmax(0, 1fr) auto; }
.ident { display: flex; align-items: flex-end; gap: 28px; min-width: 0; }
.ident canvas { display: block; flex: none; }
.ident h1 { font-family: var(--serif); font-weight: 400; font-size: 52px; line-height: 1; }
.ident .work { font-family: var(--serif); font-size: 20px; color: var(--ink-2); margin-top: 8px; }
.entries { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--gap); min-height: 0; }
.entry { display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--ink); padding: 36px 40px; min-height: 0; }
.entry:hover { text-decoration: none; }
.entry h2 { font-family: var(--serif); font-weight: 400; font-size: 64px; line-height: 1; }
.entry:hover h2 { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 8px; }
.entry p { font-family: var(--serif); font-size: 21px; margin-top: 12px; }
.entry .scale { display: grid; grid-template-columns: repeat(9, 1fr); height: 26%; }
.entry canvas { display: block; width: 100%; height: 30%; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.3fr); column-gap: var(--gap); border-top: 1px solid var(--rule); padding-top: 14px; }
.facts .v { font-size: 26px; line-height: 1.2; }
.facts .v small { font-size: 13px; color: var(--ink-2); }
.facts .l { display: block; }
.facts .p { display: block; color: var(--ink-2); font-size: 12px; }
.facts .words { font-size: 13px; }
.facts .words { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
.facts .words li { display: flex; justify-content: space-between; }

/* ---------- work pages (docs/web_explained_spec.md): a fixed header, three parts, one screen each ---------- */
.work { grid-template-rows: auto minmax(0, 1fr); row-gap: 14px; padding-top: 18px; padding-bottom: 18px; }
.work .bar { border-bottom: 1px solid var(--rule); gap: 28px; }
.work .title { display: flex; align-items: baseline; gap: 18px; min-width: 0; white-space: nowrap; }
.work .bar h1 { font-family: var(--serif); font-weight: 400; font-size: 23px; line-height: 1.1; padding-bottom: 9px; }
.transport { display: flex; gap: 18px; align-items: baseline; white-space: nowrap; font-size: 12px; }
.transport .time { color: var(--ink-2); min-width: 9ch; text-align: right; }
.parts-tabs { display: flex; gap: 26px; margin-right: auto; white-space: nowrap; }
.parts-tabs a { padding: 0 0 10px; color: var(--ink-2); font-family: var(--serif); font-size: 15px; }
.parts-tabs a .n { font-family: var(--mono); font-size: 13px; margin-right: 4px; }
.parts-tabs a[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.parts-tabs a:hover { text-decoration: none; color: var(--ink); }
.part { display: none; min-height: 0; overflow: auto; }
.part.on { display: grid; row-gap: 18px; align-content: start; }
.lead { font-family: var(--serif); font-size: 21px; line-height: 1.3; max-width: 80ch; }
.points p, .sub p, .wdetail p { max-width: 80ch; }
details.why { margin-top: 1px; }
.anchors details.why:not([open]), .decs details.why:not([open]), .card details.why:not([open]) { display: inline-block; margin-left: 8px; }
details.why summary, details.all summary { cursor: pointer; color: var(--ink-2); font-size: 12px; width: max-content; }
details.why[open] summary { color: var(--ink); }
.why-body { border-left: 1px solid var(--ink); padding: 4px 0 4px 12px; margin-top: 6px; font-size: 12px; }
.why-body p + p, .why-body .pcard + .pcard, .why-body p + .pcard, .why-body .pcard + p { margin-top: 8px; }
.pcard .t { font-family: var(--serif); font-size: 15px; }
.pcard blockquote { margin: 4px 0; font-family: var(--serif); font-style: italic; font-size: 14px; line-height: 1.4; }
.pcard .ev { color: var(--ink-2); }
.tl { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tl .rd { border: 1px solid var(--rule); padding: 0 6px; white-space: nowrap; }
.tl .rd.pass { border-color: var(--ink); }

/* part 0: the flow */
.flow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); column-gap: 28px; border-top: 1px solid var(--ink); padding-top: 18px; }
.flow li { position: relative; min-width: 0; }
.flow li + li::before { content: "→"; position: absolute; left: -22px; top: 40px; color: var(--ink); }
.flow .fig { height: 190px; display: flex; align-items: center; margin-bottom: 18px; }
.flow h3 { font-family: var(--serif); font-weight: 400; font-size: 20px; line-height: 1.2; margin-bottom: 8px; }
.flow p { font-size: 13px; color: var(--ink-2); }
.fig-pattern { display: block; width: 100%; height: 190px; }
.fig-scale-w { display: block; width: 100%; }
.fig-scale-w .cap { display: block; font-size: 11px; text-align: center; }
.fig-pattern canvas { display: block; }
.fig-scale { width: 100%; height: 40px; font-family: var(--mono); }
.fig-words { display: grid; width: 100%; row-gap: 7px; }
.fig-words .dv { height: 8px; }
.fig .fig-brief { font-family: var(--serif); font-style: italic; font-size: 15px; line-height: 1.3; color: var(--ink); }
.fig .fig-kb { font-size: 13px; line-height: 1.7; color: var(--ink); }
.fig-work { position: relative; display: block; width: 100%; height: 190px; }
.fig-work canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.fig-work .field { position: absolute; inset: 0; opacity: 0; }
.fig-work.done .field { opacity: 1; }
.points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 40px; border-top: 1px solid var(--rule); padding-top: 16px; }
.points p { font-family: var(--serif); font-size: 17px; line-height: 1.4; }
.dv { position: relative; display: block; height: 8px; }
.dv::before { content: ""; position: absolute; left: 50%; top: -1px; bottom: -1px; border-left: 1px solid var(--rule); }
.dv i { position: absolute; top: 0; bottom: 0; }
.dv.prominent i { background: var(--ink); }
.dv.moderate i { background: rgba(0, 0, 0, 0.4); }
.dv.typical i { border: 1px solid var(--ink); }

/* part 1: 36 measurements → 12 words */
.words-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); column-gap: 48px; min-height: 0; }
.compo { display: grid; grid-template-columns: 280px minmax(80px, 1fr) 330px; min-height: 0; }
.ms .grp { display: grid; grid-template-columns: 92px 1fr; border-top: 1px solid var(--rule); padding: 2px 0; }
.ms .grp:first-child { border-top: 0; }
.ms .gname { color: var(--ink-2); font-size: 11px; line-height: 15px; }
.ms li { font-size: 11px; line-height: 15px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms li.on { color: var(--ink); }
.compo svg.links { width: 100%; height: 100%; }
.ws { display: flex; flex-direction: column; justify-content: space-around; }
.ws button { display: grid; grid-template-columns: 180px 1fr 34px; align-items: center; column-gap: 8px; text-align: left; padding: 3px 4px; font-size: 12px; }
.ws button .sc { text-align: right; }
.ws button.typical .wl { color: var(--ink-2); }
.ws button[aria-pressed="true"] { box-shadow: inset 2px 0 0 var(--ink); }
.ws button:hover { text-decoration: none; }
.side { display: grid; grid-template-rows: auto auto; row-gap: 14px; align-content: start; min-height: 0; }
.wdetail { font-size: 12px; border-bottom: 1px solid var(--rule); padding-bottom: 10px; }
.wdetail .def { font-family: var(--serif); font-size: 15px; margin: 4px 0 6px; }
.wm li { display: grid; grid-template-columns: minmax(0, 1fr) 44px 170px; column-gap: 8px; }
.wm li span:nth-child(2) { text-align: right; }
.side .points { grid-template-columns: 1fr; row-gap: 10px; border-top: 0; padding-top: 0; }
.side .points p { font-family: var(--mono); font-size: 12px; line-height: 1.45; }
.side .points b { font-weight: 500; }
.foot { font-size: 12px; max-width: 120ch; }

/* part 2: the work itself */
.work-main.colour { display: grid; grid-template-columns: 17% minmax(0, 1fr); column-gap: 28px; min-height: 0; }
.part.on:has(.work-main) { grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; row-gap: 10px; }
.closing { border-top: 1px solid var(--rule); padding-top: 8px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); column-gap: 32px; }
.closing p { font-family: var(--serif); font-size: 14px; line-height: 1.35; }
.closing .limits { margin-top: 0; }
.hero { display: grid; grid-template-rows: minmax(0, 1fr) auto; row-gap: 10px; min-height: 0; }
.block { position: relative; min-height: 0; overflow: hidden; }
.block .field { position: absolute; inset: 0; }
.block .field h1 { position: absolute; left: 20px; bottom: 18px; font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1; color: var(--on); }
.block .field h1 span { display: block; }
.vals { font-size: 11px; line-height: 1.55; }
.subs { display: grid; grid-template-columns: 0.75fr 1.75fr 1fr 0.9fr; column-gap: 24px; min-height: 0; }
.sub { min-height: 0; overflow: auto; font-size: 11.5px; line-height: 1.4; }
.sub h3 { font-family: var(--serif); font-weight: 400; font-size: 18px; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--ink); }
.sub .concept { font-family: var(--serif); font-size: 14px; line-height: 1.3; margin-bottom: 6px; }
.anchors li { padding: 3px 0; border-top: 1px solid var(--rule); }
.anchors b, .rules b { font-weight: 500; }
.sub .note { margin-bottom: 8px; }
.rules { border-collapse: collapse; width: 100%; font-size: 11px; line-height: 1.35; }
.rules th { text-align: left; font-weight: 400; color: var(--ink-2); border-bottom: 1px solid var(--ink); padding: 2px 6px 2px 0; }
.rules td { border-bottom: 1px solid var(--rule); padding: 3px 6px 3px 0; vertical-align: top; }
.rules .num { white-space: nowrap; }
.rules td .k { white-space: nowrap; }
.rules tr.na td { border-bottom: 0; }
.rules tr.why-na td { color: var(--ink-2); font-style: italic; font-family: var(--serif); font-size: 12.5px; padding-top: 0; }
.conflict { margin-top: 8px; }
details.all { margin-top: 3px; }
.cands { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.cands li { width: 18px; height: 26px; }
.cands li.sel { outline: 2px solid var(--ink); outline-offset: 2px; }
.cands li.fin { margin-left: 10px; }
.thumbs { display: flex; gap: 6px; margin: 6px 0 8px; align-items: flex-end; }
.thumbs button img { display: block; height: 32px; width: auto; border: 1px solid var(--rule); }
.decs li { padding: 3px 0; border-top: 1px solid var(--rule); }
.tag { color: var(--ink-2); white-space: nowrap; }
.tag::before { content: "· "; }
.meas li { display: grid; grid-template-columns: minmax(0, 1fr) 76px; column-gap: 10px; row-gap: 1px; align-items: center; padding: 3px 0; border-top: 1px solid var(--rule); }
.meas li:first-child { border-top: 0; }
.meas .rg { grid-column: 1 / -1; }
.meas .val { text-align: right; white-space: nowrap; }
.meas .oor { display: block; font-size: 11px; }
.rg { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; align-items: center; }
.rg svg { display: block; width: 100%; height: 14px; }
.rg .lab { color: var(--ink-2); font-size: 11px; }
.chk { margin: 4px 0; }
.card { border-top: 1px solid var(--rule); padding-top: 6px; }
.card .ql { color: var(--ink-2); }
.card blockquote { margin: 2px 0 4px; font-family: var(--serif); font-size: 12.5px; line-height: 1.3; }
.card .ba { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-top: 4px; }
.card .ba .x { font-size: 16px; }
.card .ba .before { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1px; }
.seg { display: inline-flex; border: 1px solid var(--ink); margin: 8px 0 2px; }
.seg button { padding: 2px 10px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.limits { color: var(--ink-2); font-size: 11px; margin-top: 6px; }
.limits li + li { margin-top: 3px; }
.limits b { color: var(--ink); font-weight: 500; }
.work-main.music { display: grid; grid-template-rows: minmax(0, 15vh) auto minmax(0, 1fr); row-gap: 6px; min-height: 0; }
.meas.line li { grid-template-columns: minmax(0, 1fr) 78px 76px; padding: 1px 0; }
.meas.line li > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meas.line .rg { grid-column: auto; grid-template-columns: 1fr; }
.meas.line .rg .lab { display: none; }
.roll { position: relative; min-height: 0; cursor: pointer; }
.roll canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.roll .head { position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--ink); opacity: 0; }
.roll .frame { position: absolute; top: 0; bottom: 0; border: 1px solid var(--ink); pointer-events: none; opacity: 0; }
.carries { position: relative; height: 16px; font-size: 11px; line-height: 1.35; overflow: hidden; }
.carries span { position: absolute; top: 0; padding-right: 8px; color: var(--ink-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.carries span.on { color: var(--ink); }
.music .subs { grid-template-columns: 0.58fr 1.9fr 0.88fr 1.38fr; column-gap: 20px; }

dialog { border: 1px solid var(--ink); padding: 20px; background: var(--paper); color: var(--ink); max-width: 92vw; max-height: 92vh; }
dialog::backdrop { background: rgba(255, 255, 255, 0.92); }
dialog img { display: block; max-width: 86vw; max-height: 76vh; }
dialog .cap { margin-top: 10px; color: var(--ink-2); }
dialog .close { margin-top: 8px; }

/* ---------- narrow screens (390 × 844): same views, stacked; long step content scrolls inside its panel ---------- */
@media (max-width: 700px) {
  :root { --m: 20px; --gap: 16px; }
  .view { padding: 16px var(--m); row-gap: 12px; }
  .site { font-size: 15px; }
  .pair { grid-template-columns: 1fr; row-gap: 22px; align-content: center; align-items: start; }
  .city-link .name { font-size: 30px; margin-top: 10px; }
  .legend { font-size: 11px; gap: 6px 14px; }
  .legend .dots { gap: 9px; }
  .ident { gap: 14px; }
  .city .bar { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .city .bar .links { justify-content: space-between; }
  .ident h1 { font-size: 34px; }
  .ident .work { font-size: 16px; margin-top: 4px; }
  .entries { grid-template-columns: 1fr; row-gap: 12px; }
  .entry { padding: 16px 18px; }
  .entry h2 { font-size: 38px; }
  .entry p { font-size: 16px; margin-top: 6px; }
  .entry .scale { height: 20px; }
  .entry canvas { height: 40px; }
  .facts { grid-template-columns: 1fr 1fr 1fr; row-gap: 8px; padding-top: 10px; column-gap: 12px; }
  .facts .v { font-size: 18px; }
  .facts .l, .facts .p { font-size: 11px; }
  .facts .wordsc { grid-column: 1 / -1; }
  .facts .words { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 12px; }
  .facts .words li { max-width: none; gap: 6px; }
  /* work pages: same parts; a part scrolls inside itself on a narrow screen */
  .work .bar { flex-direction: column; align-items: flex-start; gap: 6px; border-bottom: 0; }
  .parts-tabs { order: 3; width: 100%; border-bottom: 1px solid var(--rule); }
  .parts-tabs a { padding-bottom: 6px; }
  .work .title { flex-direction: column; gap: 2px; }
  .work .bar h1 { font-size: 22px; }
  .transport { gap: 14px; }
  .parts-tabs { gap: 18px; }
  .parts-tabs a { font-size: 13px; }
  .parts-tabs a .t { display: none; }
  .lead { font-size: 17px; }
  .flow { grid-template-columns: 1fr 1fr; row-gap: 16px; column-gap: 20px; }
  .flow li + li::before { display: none; }
  .flow .fig { height: 70px; margin-bottom: 8px; }
  .part.on:has(.work-main) { overflow: auto; display: block; }
  .closing { grid-template-columns: 1fr; row-gap: 8px; margin-top: 16px; }
  .fig-pattern, .fig-work { height: 70px; }
  .points { grid-template-columns: 1fr; row-gap: 12px; }
  .words-main { grid-template-columns: 1fr; row-gap: 16px; }
  .compo { grid-template-columns: 1fr; }
  .compo .ms, .compo svg.links { display: none; }
  .ws button { grid-template-columns: 150px 1fr 34px; }
  .wm li { grid-template-columns: minmax(0, 1fr) 40px; }
  .wm li span:nth-child(3) { grid-column: 1 / -1; }
  .work-main.colour { grid-template-columns: 1fr; grid-template-rows: 160px auto auto; row-gap: 10px; }
  .hero { display: contents; }
  .block .field h1 { font-size: 34px; left: 14px; bottom: 12px; }
  .subs, .music .subs { grid-template-columns: 1fr; row-gap: 18px; }
  .sub { overflow: visible; }
  .work-main.music { grid-template-rows: 170px auto auto; }
  .carries { display: none; }
}
