/* Mid-City diorama: four risograph inks (fluorescent pink, yellow, blue, federal-blue key) on cream stock. */
:root {
  --paper: #f6f0e1;
  --paper-hi: #faf6ea;
  --pink: #ff48b0;
  --yellow: #ffe800;
  --blue: #0078bf;
  --key: #232f6b;
  --key-soft: #5b6395;
  --pink-tint: #fbc3dd;
  --blue-tint: #b9d5e6;
  --yellow-tint: #f9ea8c;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .14 0 0 0 0 .18 0 0 0 0 .42 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --dots: radial-gradient(circle, rgba(35, 47, 107, 0.2) 0.9px, transparent 1.3px) 0 0 / 5px 5px;
  --display: "Bricolage Grotesque", "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--grain), var(--paper);
  color: var(--key);
  font: 15px/1.42 var(--display);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }
#map:focus-visible { box-shadow: inset 0 0 0 3px var(--pink); }

/* Misregistered heading: key-blue type with a pink pass printed a hair off. */
.mis { position: relative; color: var(--blue); isolation: isolate; }
.mis::after {
  content: attr(data-text);
  content: attr(data-text) / "";
  position: absolute;
  inset: 0;
  transform: translate(2px, 1.5px);
  color: var(--pink);
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* Crop marks in the page corners. */
.marks i { position: fixed; z-index: 1; width: 18px; height: 18px; pointer-events: none; }
.marks i::before, .marks i::after { content: ""; position: absolute; background: var(--key); opacity: 0.55; }
.marks i::before { width: 18px; height: 1px; top: 8px; }
.marks i::after { width: 1px; height: 18px; left: 8px; }
.marks i:nth-child(1) { top: 4px; left: 4px; }
.marks i:nth-child(2) { top: 4px; right: 4px; }
.marks i:nth-child(3) { bottom: 4px; left: 4px; }
.marks i:nth-child(4) { bottom: 4px; right: 4px; }

/* Panels are flat printed sheets with an offset pink pass as their shadow. */
.zine {
  position: fixed;
  z-index: 2;
  background: var(--grain), var(--paper-hi);
  border: 1.5px solid var(--key);
  box-shadow: 5px 5px 0 var(--pink);
}

.mast { top: 18px; left: 18px; width: min(350px, calc(100vw - 36px)); padding: 12px 18px 16px; z-index: 3; }
.masthead-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-bottom: 1.5px solid var(--key); padding-bottom: 6px; }
.home { font: 600 13px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; color: var(--key); }
.home:hover { color: var(--pink); }
.issue { font: 500 10.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--key-soft); }
.mast h1 { font: 800 40px/0.9 var(--display); letter-spacing: -0.02em; margin: 12px 0 8px; text-transform: uppercase; font-stretch: condensed; }
.dek { margin: 0 0 12px; font-size: 14.5px; color: var(--key); }
/* The way out of a neighborhood: up to the county map, or next door. */
.nav { margin: -4px 0 12px; font: 500 11.5px/1.5 var(--mono); color: var(--key-soft); }
.nav a { color: var(--key); text-decoration-color: var(--pink); text-underline-offset: 2px; }
.nav a:hover { color: var(--pink); }
.nav .up { display: inline-block; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; margin-right: 10px; }
.nav .next { display: block; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1.5px solid var(--key);
  background: var(--paper);
}
.search:focus-within { box-shadow: 3px 3px 0 var(--yellow), 3px 3px 0 1.5px var(--key); }
.search span { font: 600 18px/1 var(--mono); color: var(--blue); }
.search input { flex: 1; min-width: 0; border: 0; background: none; font: 500 15px var(--mono); color: var(--key); outline: none; }
.search input::placeholder { color: var(--key-soft); opacity: 0.8; }
#results { margin-top: 8px; max-height: 40vh; overflow: auto; border-top: 1px dashed var(--key-soft); }
#results button {
  display: grid;
  grid-template-columns: 14px 1fr;
  column-gap: 8px;
  align-items: start;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px dashed rgba(35, 47, 107, 0.3);
  background: none;
  padding: 7px 4px;
  font-weight: 600;
}
#results button small { grid-column: 2; display: block; font: 400 11.5px/1.35 var(--mono); color: var(--key-soft); }
#results button:hover, #results button:focus-visible { background: var(--yellow-tint); outline: none; }
#results .none { padding: 7px 4px; font: 12px var(--mono); color: var(--key-soft); }
/* Under a chain that matched a search: local places of the same sort nearby (place-card.js). */
#results .instead { margin: 0 0 0 22px; padding: 6px 4px 2px; font: 600 10.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--pink); }
#results button.local-pick { margin-left: 22px; width: calc(100% - 22px); background: linear-gradient(90deg, var(--yellow-tint), transparent 85%); }
#results button.local-pick:hover, #results button.local-pick:focus-visible { background: var(--yellow-tint); }
#results .instead-end { margin-bottom: 4px; border-bottom: 1.5px solid var(--key); }
.sw { width: 12px; height: 12px; margin-top: 4px; border: 1.2px solid var(--key); display: inline-block; }
.sw.k-local { background: var(--pink); box-shadow: 0 0 0 3px var(--yellow); }
.sw.k-indie { background: var(--yellow-tint); }
.sw.k-chain { background: var(--paper-hi); }
.sw.k-pe { background: linear-gradient(var(--pink-tint) 45%, var(--paper-hi) 45%); }
.sw.k-public { background: linear-gradient(var(--blue-tint) 45%, var(--paper-hi) 45%); }
.sw.ghost { border-style: dashed; background-color: transparent; }

.legend { left: 18px; bottom: 34px; width: 350px; padding: 12px 16px 12px; }
.legend h2 { margin: 0 0 6px; padding-bottom: 5px; border-bottom: 1.5px solid var(--key); }
.fold {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  border: 0;
  padding: 0;
  background: none;
  font: 600 11px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
}
.fold span::after { content: "–"; font-size: 14px; }
.fold[aria-expanded="false"] span::after { content: "+ how height works"; font-size: 10px; letter-spacing: 0.04em; color: var(--pink); }
.fold:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
#legend { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
#legend button {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 2px 4px 2px 0;
  text-align: left;
  font-size: 13px;
  line-height: 1.15;
  font-weight: 600;
}
#legend button:hover { background: var(--yellow-tint); }
#legend button[data-kind="local"] { grid-column: 1 / -1; font-weight: 700; background: linear-gradient(90deg, var(--yellow-tint), transparent 80%); }
#legend button:focus-visible { outline: 2px solid var(--pink); outline-offset: 1px; }
#legend button[aria-pressed="false"] { opacity: 0.35; }
#legend button[aria-pressed="false"] .label { text-decoration: line-through; text-decoration-thickness: 2px; }
#legend canvas { width: 48px; height: 40px; }
#legend .count { font: 600 12px var(--mono); color: var(--key-soft); }
/* Show chains: one switch for every chain kind, on the county map and the models (place-card.js). */
.switch { position: relative; width: 26px; height: 14px; border: 1.5px solid var(--key); border-radius: 999px; background: var(--paper-hi); }
.switch::after { content: ""; position: absolute; top: 1.5px; left: 1.5px; width: 8px; height: 8px; border-radius: 50%; background: var(--key-soft); transition: transform 0.15s; }
#show-chains[aria-checked="true"] .switch { background: var(--yellow); }
#show-chains[aria-checked="true"] .switch::after { background: var(--key); transform: translateX(12px); }
@media (prefers-reduced-motion: reduce) { .switch::after { transition: none; } }
#legend #show-chains { grid-column: 1 / -1; grid-template-columns: 44px 1fr auto; margin-top: 2px; padding: 5px 4px 3px 0; border-top: 1px dashed var(--key-soft); font-weight: 700; }
#legend #show-chains .switch { justify-self: center; }
.owned-by { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin: 6px 0 0; padding-top: 6px; border-top: 1px dashed var(--key-soft); }
.owned-by .ob-label { font: 600 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--key-soft); margin-right: 2px; }
.owned-by button { border: 1.5px solid var(--key); background: none; color: var(--key); border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 600; line-height: 1.3; cursor: pointer; }
.owned-by button b { font: 600 11px var(--mono); color: var(--key-soft); margin-left: 3px; }
.owned-by button:hover { background: var(--yellow-tint); }
.owned-by button[aria-pressed="true"] { background: var(--key); color: #fff; }
.owned-by button[aria-pressed="true"] b { color: var(--yellow-tint); }
.owned-by button:disabled { opacity: 0.4; cursor: default; background: none; }
.owned-by button:focus-visible { outline: 2px solid var(--pink); outline-offset: 1px; }
.heights { margin: 8px 0 0; padding-top: 6px; border-top: 1px dashed var(--key-soft); }
#height-key { display: block; width: 100%; height: 92px; }
.heights figcaption { font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.fine { margin: 6px 0 0; font: 11px/1.4 var(--mono); color: var(--key-soft); }

.controls { position: fixed; z-index: 2; right: 18px; bottom: 44px; display: grid; gap: 8px; }
.controls button {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--key);
  background: var(--paper-hi);
  font: 500 22px/1 var(--mono);
  color: var(--key);
  box-shadow: 3px 3px 0 var(--blue);
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.controls button:hover { background: var(--yellow); }
.controls button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--blue); }
.controls button:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
#turn { position: relative; }
.needle { --a: 0rad; position: absolute; inset: 3px; display: block; transform: rotate(var(--a)); transition: transform 0.35s; }
.needle i { position: absolute; left: 50%; top: 11px; margin-left: -4px; border: 4px solid transparent; border-top: 0; border-bottom: 9px solid var(--pink); }
.needle i::after { content: ""; position: absolute; left: -4px; top: 9px; border: 4px solid transparent; border-bottom: 0; border-top: 8px solid var(--key); }
.needle b { position: absolute; left: 50%; top: 0; width: 12px; margin-left: -6px; font: 600 10px/10px var(--mono); text-align: center; transform: rotate(calc(-1 * var(--a))); }

#tip {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  max-width: 260px;
  padding: 5px 9px 6px;
  background: var(--paper-hi);
  border: 1.5px solid var(--key);
  box-shadow: 3px 3px 0 var(--yellow);
}
#tip b { display: block; font: 800 15px/1.15 var(--display); }
#tip small { display: block; margin-top: 2px; font: 11px/1.3 var(--mono); color: var(--key-soft); }

/* The place card: one printed zine page. */
#card {
  position: fixed;
  z-index: 3;
  top: 18px;
  right: 80px;
  width: min(410px, calc(100vw - 36px));
  max-height: calc(100vh - 60px);
  overflow: auto;
  background: var(--grain), var(--paper-hi);
  border: 1.5px solid var(--key);
  box-shadow: 6px 6px 0 var(--blue);
  padding: 0 20px 22px;
}
#card.in { animation: print 0.32s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes print {
  from { transform: translateY(-14px); opacity: 0; clip-path: inset(0 0 100% 0); }
  to { transform: none; opacity: 1; clip-path: inset(0 0 0 0); }
}
#card .close {
  position: sticky;
  top: 8px;
  float: right;
  z-index: 2;
  margin: 8px -10px 0 0;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--key);
  background: var(--paper-hi);
  font: 500 20px/1 var(--mono);
}
#card .close:hover { background: var(--pink); color: var(--paper-hi); }
#card .close:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
#card .loading { font: 13px var(--mono); padding-top: 24px; }
#card .folio {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 44px 6px 0;
  border-bottom: 1.5px solid var(--key);
  font: 600 10.5px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#card .folio .kind { padding: 1px 6px; border: 1.2px solid var(--key); }
.k-local { background: var(--pink); color: var(--paper-hi); }
.k-indie { background: var(--yellow); }
.k-chain { background: #e4e2dc; }
.k-pe { background: var(--pink-tint); }
.k-public { background: var(--blue-tint); }
#card .room { margin: 12px 0 0; border: 1.5px solid var(--key); position: relative; }
#card .room canvas { display: block; width: 100%; height: 184px; }
#card .room figcaption {
  position: absolute;
  right: 6px;
  bottom: 5px;
  font: 9.5px var(--mono);
  letter-spacing: 0.04em;
  color: var(--key-soft);
  background: rgba(250, 246, 234, 0.85);
  padding: 1px 4px;
}
#card h2 { font: 800 32px/0.95 var(--display); letter-spacing: -0.02em; margin: 14px 0 6px; text-transform: uppercase; }
#card h3 {
  font: 600 11px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 18px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1.5px solid var(--key);
}
#card p { margin: 4px 0; }
#card .addr { font: 12px var(--mono); color: var(--key-soft); margin-bottom: 10px; }
#card .height { margin: 0 0 12px; padding: 8px 10px; background: var(--dots), var(--yellow-tint); border-left: 4px solid var(--key); font-size: 14px; }
#card .badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1.5px solid var(--key);
  font: 600 11.5px var(--mono);
  letter-spacing: 0.03em;
  background: var(--paper);
}
#card .badge.pe { background: var(--pink); color: var(--paper-hi); border-color: var(--key); }
#card .callout, #card .claim, #card .estimate { margin: 12px 0 0; padding: 10px 12px; border: 1.5px solid var(--key); background: var(--paper); }
#card .callout.pe { background: var(--dots), var(--pink-tint); box-shadow: 4px 4px 0 var(--pink); }
#card .callout.public { background: var(--dots), var(--blue-tint); box-shadow: 4px 4px 0 var(--blue); }
#card .estimate { border-style: dashed; background: none; }
#card small, #card .note { display: block; margin-top: 6px; font: 11px/1.45 var(--mono); color: var(--key-soft); }
#card .traits { display: grid; gap: 0; border: 1.5px solid var(--key); }
#card .trait { display: grid; grid-template-columns: 116px 1fr; gap: 8px; font-size: 13.5px; padding: 6px 8px; border-bottom: 1px dashed var(--key-soft); }
#card .trait:last-child { border-bottom: 0; }
#card .trait > span:first-child { font-weight: 800; }
#card .trait.yes > span:first-child { box-shadow: inset 0 -6px 0 var(--yellow); }
#card .trait.unknown > span:last-child { color: var(--key-soft); }
#card .order .trait > span:first-child { align-self: start; }
/* A chain's card: local places nearby (place-card.js nearbyHtml), each opening its own card. */
#card .nearby { list-style: none; margin: 6px 0 0; padding: 0; border: 1.5px solid var(--key); background: var(--paper); }
#card .nearby li + li { border-top: 1px dashed var(--key-soft); }
#card .nearby button {
  display: block;
  width: 100%;
  padding: 6px 8px 6px 26px;
  border: 0;
  background: none;
  text-align: left;
  font: 800 14px/1.2 var(--display);
  color: var(--key);
  cursor: pointer;
  position: relative;
}
#card .nearby button::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--yellow);
  border: 1.5px solid var(--pink);
}
#card .nearby button:hover, #card .nearby button:focus-visible { background: var(--yellow-tint); outline: none; }
#card .nearby small { margin-top: 1px; }
#card a { color: var(--blue); }

.credit {
  position: fixed;
  z-index: 1;
  right: 80px;
  bottom: 10px;
  margin: 0;
  font: 11px var(--mono);
  color: var(--key-soft);
  text-align: right;
}
.credit a:hover { color: var(--pink); }
.credit { background: var(--paper); padding: 2px 6px; }
#status {
  position: fixed;
  z-index: 1;
  left: 50%;
  top: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  font: 800 30px var(--display);
  text-transform: uppercase;
  color: var(--blue);
}
#status:empty { display: none; }

/* Layouts (sheet.js sets <html data-layout>). Wide is everything above: panels over the map. The
   key never runs under the masthead on a short laptop screen; it scrolls instead. */
[data-layout="wide"] .legend { max-height: calc(100dvh - var(--mast-h, 220px) - 72px); overflow-y: auto; }
.grab { display: none; }
.search { position: relative; }

/* A phone held upright: a slim masthead, the model full screen, the key as a bottom sheet. */
[data-layout="sheet"] .mast {
  top: calc(8px + env(safe-area-inset-top));
  left: 8px;
  width: calc(100vw - 16px);
  padding: 6px 10px 8px;
  box-shadow: 3px 3px 0 var(--pink);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
}
[data-layout="sheet"] .masthead-row { grid-column: 1 / -1; padding-bottom: 4px; }
[data-layout="sheet"] .home { font-size: 12px; }
[data-layout="sheet"] .mast h1 { grid-column: 1; font-size: 25px; margin: 7px 0 1px; white-space: nowrap; overflow: hidden; }
[data-layout="sheet"] .dek, [data-layout="sheet"] .nav .next { display: none; }
[data-layout="sheet"] .nav { position: absolute; top: 7px; right: 10px; margin: 0; font-size: 11px; }
[data-layout="sheet"] .nav .up { margin: 0; }
[data-layout="sheet"] .mast:has(.nav:not([hidden])) .issue { visibility: hidden; }
[data-layout="sheet"] .search { grid-column: 2; grid-row: 2; width: 40px; height: 36px; margin-top: 7px; padding: 0; justify-content: center; }
[data-layout="sheet"] .search input { position: absolute; left: 0; width: 1px; opacity: 0; }
[data-layout="sheet"] .mast.searching h1 { display: none; }
[data-layout="sheet"] .mast.searching .search { grid-column: 1 / -1; width: auto; padding: 0 10px; justify-content: flex-start; }
[data-layout="sheet"] .mast.searching .search input { position: static; width: auto; opacity: 1; font-size: 16px; }
[data-layout="sheet"] #results { grid-column: 1 / -1; max-height: 50dvh; }

[data-layout="sheet"] .legend {
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  max-height: 72dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 14px calc(10px + env(safe-area-inset-bottom));
  border-width: 1.5px 0 0;
  box-shadow: 0 -4px 0 var(--pink);
}
[data-layout="sheet"] .grab {
  display: block;
  position: sticky;
  top: 0;
  z-index: 3;
  height: 20px;
  margin: 0 -14px;
  background: inherit;
  touch-action: none;
  cursor: grab;
}
.grab::before { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--key-soft); opacity: 0.55; }
[data-layout="sheet"] .legend h2 { touch-action: none; margin-bottom: 6px; }
[data-layout="sheet"] .fold { min-height: 26px; }
/* The kinds as a row of chips to swipe through: each still hides or shows its kind. */
[data-layout="sheet"] #legend {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 -14px;
  padding: 2px 14px 4px;
  scrollbar-width: none;
}
[data-layout="sheet"] #legend::-webkit-scrollbar { display: none; }
[data-layout="sheet"] #legend button {
  flex: none;
  grid-template-columns: 30px auto auto;
  gap: 5px;
  padding: 2px 11px 2px 4px;
  border: 1.5px solid var(--key);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  white-space: nowrap;
}
[data-layout="sheet"] #legend button[data-kind="local"] { grid-column: auto; background: var(--yellow-tint); }
[data-layout="sheet"] #legend #show-chains { order: -1; margin-top: 0; padding: 2px 11px 2px 4px; border: 1.5px solid var(--key); }
[data-layout="sheet"] #legend canvas { width: 30px; height: 25px; }
[data-layout="sheet"] .legend:has(.fold[aria-expanded="false"]) .owned-by:not(:has([aria-pressed="true"])) { display: none; }
[data-layout="sheet"] .heights { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: center; }
[data-layout="sheet"] #height-key { height: 64px; }
[data-layout="sheet"] .heights figcaption { font-size: 12.5px; }
[data-layout="sheet"] .fine { font-size: 12px; }

[data-layout="sheet"] #card {
  top: auto;
  bottom: 0;
  right: 0;
  left: 0;
  width: auto;
  max-height: 62dvh;
  overscroll-behavior: contain;
  box-shadow: 0 -4px 0 var(--blue);
  border-width: 1.5px 0 0;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
}
[data-layout="sheet"] #card .grab { margin: 0 -16px -12px; }
[data-layout="sheet"] #card .close { z-index: 4; }
[data-layout="sheet"] #card.in { animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes rise {
  from { transform: translateY(35%); opacity: 0; }
  to { transform: none; opacity: 1; }
}
[data-layout="sheet"] #card h2 { font-size: 27px; }
/* One sheet at a time: a place's page takes the key's place. */
[data-layout="sheet"] body:has(#card:not([hidden])) .legend { display: none; }

[data-layout="sheet"] .controls { right: 10px; bottom: calc(var(--sheet-h, 100px) + 12px); gap: 8px; transition: bottom 0.2s; }
[data-layout="sheet"] .controls button { width: 42px; height: 42px; font-size: 20px; box-shadow: 2px 2px 0 var(--blue); }
[data-layout="sheet"] .credit {
  left: 8px;
  right: auto;
  bottom: calc(var(--sheet-h, 100px) + 8px);
  max-width: calc(100vw - 72px);
  font-size: 10.5px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: bottom 0.2s;
}

/* A phone on its side: masthead and key down the left, the card down the right. */
[data-layout="side"] .mast {
  top: 0;
  left: 0;
  width: calc(300px + env(safe-area-inset-left));
  padding: 8px 12px 8px calc(12px + env(safe-area-inset-left));
  border-width: 0 1.5px 1.5px 0;
  box-shadow: 4px 0 0 var(--pink);
}
[data-layout="side"] .mast h1 { font-size: 24px; margin: 7px 0 6px; white-space: nowrap; overflow: hidden; }
[data-layout="side"] .dek, [data-layout="side"] .nav .next { display: none; }
[data-layout="side"] .nav { margin: 0 0 7px; font-size: 11px; }
[data-layout="side"] .search { padding: 4px 8px; }
[data-layout="side"] .search input { font-size: 16px; }
[data-layout="side"] #results { max-height: calc(100dvh - 140px); }
[data-layout="side"] .legend {
  top: var(--mast-h, 140px);
  left: 0;
  bottom: 0;
  width: calc(300px + env(safe-area-inset-left));
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  border-width: 0 1.5px 0 0;
  box-shadow: 4px 0 0 var(--pink);
}
[data-layout="side"] #legend { grid-template-columns: 1fr; }
[data-layout="side"] #legend button { grid-template-columns: 34px 1fr auto; }
[data-layout="side"] #legend canvas { width: 36px; height: 30px; }
[data-layout="side"] #height-key { height: 72px; }
[data-layout="side"] .heights figcaption { font-size: 12px; }
[data-layout="side"] .fine { font-size: 11.5px; }
[data-layout="side"] #card {
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 42vw);
  max-height: none;
  border-width: 0 0 0 1.5px;
  box-shadow: -4px 0 0 var(--blue);
  padding: 0 calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) 16px;
}
[data-layout="side"] #card h2 { font-size: 26px; }
[data-layout="side"] .controls { right: calc(10px + env(safe-area-inset-right)); bottom: 10px; gap: 6px; }
[data-layout="side"] body:has(#card:not([hidden])) .controls { right: calc(min(340px, 42vw) + 12px); }
[data-layout="side"] .controls button { width: 40px; height: 40px; font-size: 19px; box-shadow: 2px 2px 0 var(--blue); }
[data-layout="side"] .credit {
  left: calc(314px + env(safe-area-inset-left));
  right: 64px;
  bottom: 4px;
  font-size: 10.5px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-layout="sheet"] .credit .wide, [data-layout="side"] .credit .wide,
[data-layout="sheet"] .marks, [data-layout="side"] .marks { display: none; }
/* Touch screens pinch to zoom, so the zoom buttons go; home and turn stay. */
@media (hover: none) {
  [data-layout="sheet"] #zoom-in, [data-layout="sheet"] #zoom-out,
  [data-layout="side"] #zoom-in, [data-layout="side"] #zoom-out { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .controls, .controls button, .needle, .credit { transition: none !important; }
  #card.in { animation: none !important; }
}
/* On a phone, a neighborhood's way out is its district (the county is one more step up). */
[data-layout="sheet"] .nav .up:not(:last-of-type) { display: none; }
