/* Shell layout: left column (brand, mode, topics, page), map controls, slots. Phone: top bar + bottom sheet. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 13px/1.4 var(--font); color: var(--ink); background: #e4e9ea; overflow: hidden; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
#c { position: absolute; inset: 0; }
.cesium-widget-credits, .cesium-viewer-bottom { display: none !important; }
button { font: inherit; color: inherit; }
h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ---- column */
#col { position: absolute; top: var(--s4); left: var(--s4); bottom: var(--s4); width: 336px; z-index: 3; display: flex; flex-direction: column; pointer-events: none; }
#col > .ir-panel { pointer-events: auto; display: flex; flex-direction: column; min-height: 0; max-height: 100%; overflow: hidden; }
#brand { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 var(--s4); flex: none; }
#brand img { height: 18px; display: block; }
#brand .where { font-size: 12px; color: var(--mut); letter-spacing: .02em; }
#sheet-h { display: none; }

/* mode switch: same place and size in both modes */
#mode { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin: 0 var(--s4); padding: 2px; height: 36px; background: var(--subtle); border: 1px solid var(--line); border-radius: var(--r2); flex: none; }
#mode button { display: flex; align-items: center; justify-content: center; gap: var(--s2); border: 0; border-radius: var(--r1); background: transparent; font-weight: 500; font-size: 13px; color: var(--ink-2); cursor: pointer; }
#mode button:hover { color: var(--ink); }
#mode button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(20, 38, 41, .12), 0 0 0 1px var(--line); }
#mode .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px rgba(214, 69, 43, .16); }
#mode .sm { display: none; }
#mode .hr { font-variant-numeric: tabular-nums; color: var(--mut); font-weight: 500; }

/* topic tabs */
#topics { display: grid; grid-template-columns: repeat(4, 1fr); margin: var(--s3) var(--s4) 0; border-bottom: 1px solid var(--line); flex: none; }
#topics button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s1); height: 56px; border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 12px; font-weight: 500; }
#topics button .ic { width: 20px; height: 20px; }
#topics button:hover { color: var(--ink); }
#topics button.on { color: var(--teal); font-weight: 600; }
#topics button.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--teal); }
#live-head { margin: var(--s3) var(--s4) 0; border-bottom: 1px solid var(--line); padding-bottom: var(--s3); flex: none; }
body:not([data-mode="live"]) #live-head, body[data-mode="live"] #topics { display: none; }

/* pages: one at a time */
#pages { overflow-y: auto; overscroll-behavior: contain; min-height: 0; scrollbar-width: thin; }
.page { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s5); }
.group { display: flex; flex-direction: column; gap: var(--s2); }
.rule { height: 1px; background: var(--line); margin: 0 calc(-1 * var(--s4)); }
.backbar { display: flex; align-items: center; gap: var(--s1); margin: calc(-1 * var(--s2)) 0 calc(-1 * var(--s3)) calc(-1 * var(--s2)); }
.backbar .btn { padding: 0 var(--s2) 0 var(--s1); color: var(--ink-2); font-weight: 500; }
.backbar .btn .ic { width: 16px; height: 16px; }
.page-title { font-size: 18px; line-height: 24px; font-weight: 600; letter-spacing: -.01em; }

/* menu rows */
.menu { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.menu button { display: grid; grid-template-columns: 20px 1fr auto 16px; align-items: center; gap: var(--s3); height: var(--h-row); padding: 0 var(--s3); border: 0; border-top: 1px solid var(--line); background: #fff; text-align: left; cursor: pointer; font-size: 13px; font-weight: 500; }
.menu button:first-child { border-top: 0; }
.menu button:hover { background: var(--subtle); }
.menu button .ic { color: var(--ink-2); }
.menu button .chev { width: 16px; height: 16px; color: var(--mut); }
.menu .meta { font-size: 12px; color: var(--mut); font-weight: 400; font-variant-numeric: tabular-nums; }

/* map controls: one joined group, bottom right */
#mapctl { position: absolute; right: var(--s4); bottom: var(--s5); z-index: 3; display: flex; flex-direction: column; padding: 0; overflow: visible; }
#mapctl button { width: 36px; height: 36px; border: 0; border-top: 1px solid var(--line); background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); font: 600 11px/1 var(--font); letter-spacing: .02em; }
#mapctl button:first-child { border-top: 0; border-radius: var(--r3) var(--r3) 0 0; }
#mapctl button:last-child { border-radius: 0 0 var(--r3) var(--r3); }
#mapctl button:hover { background: var(--subtle); color: var(--ink); }
#mapctl button.on { color: var(--teal); background: var(--teal-t); }
#mapctl .sep { height: 6px; border-top: 1px solid var(--line); background: var(--subtle); }

/* credits: one quiet line under the map, right of the column */
#foot { position: absolute; left: 368px; right: 72px; bottom: 6px; z-index: 2; font-size: 10px; line-height: 14px; color: #4c5f62; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }

/* slots */
#timeline { position: absolute; left: 368px; right: 80px; bottom: var(--s5); margin: 0 auto; max-width: 720px; z-index: 3; padding: var(--s3) var(--s4); }
#toast { position: absolute; top: var(--s4); left: 50%; transform: translateX(-50%); z-index: 8; padding: var(--s2) var(--s4); font-weight: 500; background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---- phone: top bar + bottom sheet */
@media (max-width: 700px) {
  #col { top: auto; left: 0; right: 0; bottom: 0; width: auto; }
  #col > .ir-panel { -webkit-backdrop-filter: none; backdrop-filter: none; background: #fff; border-radius: 16px 16px 0 0; border-bottom: 0; max-height: 64vh; transition: max-height .25s ease; }
  body:not(.sheet-open) #col > .ir-panel { max-height: 262px; }
  /* peek: question, number, legend; the rest when the sheet is open */
  body:not(.sheet-open) #topic p, body:not(.sheet-open) #topic .bigl, body:not(.sheet-open) #topic .seg2, body:not(.sheet-open) #topic .eyebrow, body:not(.sheet-open) #topic .lg-ends + .lg-ends { display: none; }
  body:not(.sheet-open) #pages { overflow: hidden; }
  #brand { position: fixed; top: 8px; left: 8px; right: 8px; height: 44px; padding: 0 4px 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); box-shadow: var(--shadow); pointer-events: auto; gap: var(--s2); }
  #brand .where { display: none; }
  #brand img { height: 16px; }
  #mode { position: fixed; top: 14px; right: 12px; width: 212px; height: 32px; margin: 0; z-index: 4; pointer-events: auto; }
  #mode button { font-size: 12px; gap: 6px; white-space: nowrap; }
  #mode .lg { display: none; } #mode .sm { display: inline; }
  #sheet-h { display: block; flex: none; height: 20px; border: 0; background: none; cursor: pointer; padding: 0; }
  #sheet-h i { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto; }
  #topics { margin-top: 0; }
  #topics button { height: 48px; }
  .page { gap: var(--s4); }
  #mapctl { top: 64px; bottom: auto; right: 8px; }
  #mapctl button { width: 34px; height: 34px; }
  #foot { display: none; }
  /* story on the phone: a fixed sheet height; the map canvas ends above it, so the camera frames the visible part */
  body.story-on #col > .ir-panel { max-height: 420px; }
  body.story-on #c { bottom: 420px; }
  body.story-on .story { height: 312px; }
  body.story-on #pg-stories .backbar, body.story-on #pg-stories .page-title { display: none; }
  #timeline { left: 8px; right: 8px; bottom: calc(64vh + 8px); }
  #toast { top: 60px; }
}

/* ---- live mode: the column keeps brand + mode + live status; the live bundle's rail and panels sit under it */
body[data-mode="live"] #pages { display: none; }
body[data-mode="live"] #live-head { border-bottom: 0; padding-bottom: var(--s4); }
.cesium-host .panel { background: var(--surface) !important; -webkit-backdrop-filter: blur(8px) !important; backdrop-filter: blur(8px) !important; border: 1px solid var(--line) !important; border-radius: var(--r3) !important; box-shadow: var(--shadow) !important; }
@media (max-width: 700px) {
  body[data-mode="live"] #col > .ir-panel { max-height: 0; border: 0; box-shadow: none; overflow: visible; }
  body[data-mode="live"] #sheet-h, body[data-mode="live"] #live-head { display: none; }
}
/* pedestrian network legend (left of the map buttons) and its credit in the footer */
#pn-legend { position: absolute; right: 68px; bottom: var(--s5); z-index: 3; width: 196px; padding: var(--s2) var(--s3); font-size: 12px; color: var(--ink-2); }
#pn-legend .pn-row { display: flex; align-items: center; gap: var(--s2); line-height: 20px; }
#pn-legend .pn-row i { width: 16px; height: 4px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba(20,38,41,.15); }
#pn-legend .pn-row i.dash { background: repeating-linear-gradient(90deg, var(--ink-2) 0 4px, #fff 4px 7px); }
#pn-legend .pn-cr { margin-top: var(--s1); font-size: 10px; line-height: 13px; color: var(--mut); }
#foot .pn-foot { display: none; } #foot.pn .pn-foot { display: inline; }
@media (max-width: 700px) { #pn-legend { right: 56px; bottom: auto; top: 60px; width: 170px; font-size: 11px; } body.sheet-open #pn-legend, body.story-on #pn-legend { display: none; } }
