/* how-big-is: a web toy on white. One friendly typeface (Rubik), the question centred and big,
   chunky press-down buttons, rounded everything, the orange shape as the only loud colour. */
:root {
  --ink: #1c1b22; --ink-2: #4a4855; --muted: #6e6b78; --line: #ebe8e3; --wash: #f6f4f0; --peach: #fff1e8;
  --orange: #ff5b1f; --orange-deep: #c43d0a; --orange-edge: #d4470f; --orange-line: #e14a12;
  --sans: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --map-h: 540px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #fff; color: var(--ink); font: 400 1.0625rem/1.65 var(--sans); }
a { color: var(--ink); text-decoration-color: var(--orange); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--orange-deep); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- masthead ---------- */
.masthead { max-width: 1240px; margin: 0 auto; padding: 16px 24px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { font: 800 1.5rem/1 var(--sans); letter-spacing: -.02em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand b { color: var(--orange); font-weight: 800; }
.ask { flex: 1 1 320px; max-width: 460px; height: 46px; padding: 4px; display: flex; align-items: center; border: 2px solid var(--line); border-radius: 999px; background: #fff; }
.ask:focus-within { border-color: var(--ink); }
.ask label { font: 500 15px var(--sans); color: var(--muted); padding: 0 4px 0 14px; white-space: nowrap; }
.ask input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font: 400 16px var(--sans); color: var(--ink); padding: 0 6px; }
.ask input:focus { outline: none; }
.ask button { height: 34px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font: 600 15px var(--sans); padding: 0 16px; cursor: pointer; transition: transform .08s; }
.ask button:active { transform: scale(.96); }
.topnav { display: flex; gap: 20px; font: 500 15px var(--sans); }
.topnav a { text-decoration: none; }

/* ---------- layout with ad rail ---------- */
.layout {
  max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px;
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px;
}
/* ads off (site.ads in things.json): no rail, one centred column about as wide as the main column beside it */
.layout.no-rail { grid-template-columns: minmax(0, 1fr); max-width: 940px; }
main { min-width: 0; }
.rail { position: relative; }
.rail .ad + .ad { margin-top: 32px; }
.rail .sticky { position: sticky; top: 24px; }

/* ---------- ads (placeholders with reserved space, never touching the map) ---------- */
.ad {
  display: grid; place-items: center; align-content: center; text-align: center; margin: 0 auto;
  background: #f3f3f3; color: #8a8a8a; font: 500 12px/1.5 var(--sans);
}
.ad span { display: block; font-size: 11px; }
.ad-300x250 { width: 300px; height: 250px; }
.ad-300x600 { width: 300px; height: 600px; }
.ad-incontent { width: 100%; max-width: 728px; height: 90px; margin: 40px auto; }
.ad-anchor { display: none; }

/* ---------- the question, centred, then the number ---------- */
main > .crumbs, main > h1, main > .answer, main > .event-meta { text-align: center; }
.crumbs { font: 400 14px var(--sans); color: var(--muted); margin: 8px 0 10px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs span { margin: 0 6px; }
h1 { margin: 0 0 18px; }
.h1-lead { display: block; font: 600 clamp(1.25rem, 2.2vw, 1.6rem)/1.2 var(--sans); color: var(--muted); margin-bottom: 4px; }
.h1-subject { display: block; font: 800 clamp(2.6rem, 6.4vw, 4.6rem)/1 var(--sans); letter-spacing: -.035em; text-wrap: balance; }
.h1-subject em { font-style: normal; color: var(--orange); }
/* home: the subject flips through the things we have pages for (app.js). The words are CSS content on an
   aria-hidden span, so screen readers and search read the heading as "How big is anything?". Fixed height,
   one line: long words shrink to fit, so the page never moves when a word changes. The flip fills the box
   (it never resizes either), or Chrome counts each new word's width as a layout shift. */
.flip-box { display: flex; height: 1.25em; margin: -.125em 0; overflow: hidden; } /* room for descenders, same line as a plain h1 */
.flip { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; white-space: nowrap; }
.flip::before { content: attr(data-word); }
.flip::after { content: "?"; color: var(--orange); }
.event-meta { margin: 0 0 18px; }
.event-meta p { margin: 0; }
.ev-when { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--peach); color: var(--orange-deep); font: 500 14px/1.4 var(--sans); }
.ev-when .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); flex: none; }
.event-meta .ev-src { font: 400 13px/1.45 var(--sans); color: var(--muted); margin-top: 6px; }
/* widths in em, not ch: ch follows whichever font has loaded, so a late web font changed the line length.
   31.75em and 40.64em are Rubik's 50ch and 64ch (its "0" is 0.635em wide). */
.answer { font: 400 1.2rem/1.6 var(--sans); color: var(--ink-2); max-width: 31.75em; margin: 0 auto 22px; }
.answer mark { background: none; color: var(--ink); font-weight: 700; }

/* readout: every unit as a pill, the headline unit first */
.readout { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 auto 30px; }
.readout div { display: inline-flex; align-items: baseline; gap: 6px; padding: 8px 16px; background: var(--wash); border-radius: 999px; }
.readout div:first-child { background: var(--peach); }
.readout div:first-child dd { color: var(--orange-deep); }
.readout dd { order: -1; margin: 0; font: 700 1.1rem/1.2 var(--sans); font-variant-numeric: tabular-nums; }
.readout dt { font: 400 15px/1.2 var(--sans); color: var(--muted); }

/* home: jump links to each category */
.cat-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 auto 18px; }
.cat-links a {
  padding: 9px 16px; border-radius: 999px; background: var(--wash); color: var(--ink); text-decoration: none; white-space: nowrap;
  font: 600 15px/1.2 var(--sans); transition: background-color .12s, transform .08s;
}
.cat-links a:hover { background: var(--peach); color: var(--orange-deep); }
.cat-links a:active { transform: scale(.96); }

/* ---------- the plate (map) ---------- */
.plate { position: relative; margin: 0 0 10px; }
.plate-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 0 0 14px; }
.plate-label { font: 600 16px var(--sans); }
.drop-form { display: flex; flex: 0 1 420px; min-width: 0; height: 48px; padding: 4px; align-items: center; border: 2px solid var(--line); border-radius: 999px; background: #fff; }
.drop-form:focus-within { border-color: var(--ink); }
.drop-form input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font: 400 16px var(--sans); padding: 0 14px; color: var(--ink); }
.drop-form input:focus { outline: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; cursor: pointer; text-decoration: none;
  font: 600 15px/1 var(--sans); height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--wash); color: var(--ink);
  box-shadow: 0 3px 0 #dcd8d1; transition: transform .08s, box-shadow .08s, background-color .12s;
}
.btn:hover { background: #efece6; color: var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 #dcd8d1; } /* presses down on touch, not on release */
.btn[aria-busy="true"] { cursor: progress; opacity: .7; }
.btn-primary { background: var(--orange); color: var(--ink); box-shadow: 0 3px 0 var(--orange-edge); }
.btn-primary:hover { background: #ff6a33; }
.btn-primary:active { box-shadow: 0 0 0 var(--orange-edge); }
.drop-form .btn { height: 36px; box-shadow: none; }
.drop-form .btn:active { transform: scale(.96); }

.map { position: relative; height: var(--map-h); overflow: hidden; border-radius: 24px; background: var(--wash); }
.map .maplibregl-canvas:focus-visible { outline: none; }
.map .maplibre-host { position: absolute; inset: 0; } /* beats maplibre-gl.css's .maplibregl-map {position: relative} */
.poster { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity .5s ease; z-index: 1; }
.poster svg { width: 88%; height: 82%; overflow: visible; }
.poster .shape { fill: rgba(255, 91, 31, .3); stroke: var(--orange-line); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.poster text { font: 500 14px var(--sans); fill: var(--muted); }
.poster .bar { stroke: var(--ink); stroke-width: 3; }
.poster-status { position: absolute; left: 18px; bottom: 14px; font: 400 14px var(--sans); color: var(--muted); }
.map.live .poster { opacity: 0; pointer-events: none; }

.chip {
  position: absolute; z-index: 2; top: 14px; left: 14px; max-width: calc(100% - 80px); padding: 10px 14px; border-radius: 16px;
  background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 6px 20px rgba(28, 27, 34, .14);
}
.chip b { display: block; font: 700 1.05rem/1.2 var(--sans); }
.chip span { display: block; font: 500 14px/1.4 var(--sans); color: var(--orange-deep); font-variant-numeric: tabular-nums; }
.chip i { display: block; font: 400 14px/1.35 var(--sans); color: var(--muted); font-style: normal; }

.plate-foot { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: center; padding: 14px 0 0; font: 500 15px var(--sans); }
.rotate { display: flex; align-items: center; gap: 10px; flex: 0 1 320px; }
.rotate input { flex: 1; accent-color: var(--orange); }
.rotate output { min-width: 3.4em; text-align: right; font-variant-numeric: tabular-nums; }
.plate-foot .spacer { display: none; }
.map-hint { text-align: center; font: 400 15px/1.5 var(--sans); color: var(--muted); margin: 10px 0 0; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0; z-index: 50; pointer-events: none;
  background: var(--ink); color: #fff; font: 600 15px var(--sans); padding: 12px 20px; border-radius: 999px;
  transition: opacity .22s ease, transform .22s cubic-bezier(.2, .8, .2, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- cookie choice (src/consent.js; Europe only, Analytics pages only) ---------- */
.consent {
  position: fixed; z-index: 60; left: 16px; bottom: 16px; max-width: 420px; padding: 16px 18px; border-radius: 18px;
  background: #fff; border: 2px solid var(--line); box-shadow: 0 10px 30px rgba(28, 27, 34, .16);
}
.consent p { margin: 0 0 12px; font: 400 15px/1.5 var(--sans); color: var(--ink-2); }
.consent-btns { display: flex; gap: 10px; justify-content: flex-end; }
@media (max-width: 640px) { .consent { left: 12px; right: 12px; bottom: 12px; max-width: none; } }

/* ---------- "Use this map" panel ---------- */
.use { margin: 40px 0 8px; padding: 8px; background: var(--wash); border-radius: 24px; }
.use-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 14px 14px 12px; }
.use-head h2 { margin: 0; font: 800 1.5rem/1.1 var(--sans); letter-spacing: -.02em; }
.use-head p { margin: 0; font: 400 15px/1.5 var(--sans); color: var(--muted); }
.use-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.use-card { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 16px; background: #fff; border-radius: 18px; }
.use-card h3 { margin: 0; font: 700 1.05rem/1.2 var(--sans); }
.use-card p { margin: 0; font: 400 15px/1.5 var(--sans); color: var(--ink-2); flex: 1; }
.use-card small { font: 400 14px/1.4 var(--sans); color: var(--muted); }
.embed-code {
  width: 100%; resize: vertical; min-height: 92px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink-2); font: 400 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.credit-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px 6px; }
.credit-line span { font: 700 15px var(--sans); }
.credit-line code { flex: 1 1 260px; font: 400 15px var(--sans); color: var(--ink-2); }
article .credit-line { background: var(--wash); border-radius: 16px; padding: 12px 16px; margin: 6px 0 14px; }

/* ---------- article ---------- */
article { max-width: 40.64em; margin: 0 auto; }
article h2 { font: 800 1.75rem/1.15 var(--sans); letter-spacing: -.025em; margin: 48px 0 10px; }
article p { margin: 0 0 1em; color: var(--ink-2); }
.compare { list-style: none; padding: 0; margin: 0; }
.compare li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 16px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--line); }
.compare .num { font: 700 1.15rem var(--sans); color: var(--orange-deep); font-variant-numeric: tabular-nums; }
/* FAQ. Scoped to the article: MapLibre's attribution control is also a details/summary */
article details { background: var(--wash); border-radius: 16px; padding: 14px 18px; margin: 0 0 8px; }
article summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; font: 600 1.05rem/1.4 var(--sans); }
article summary::-webkit-details-marker { display: none; }
article summary::after { content: "+"; font: 700 1.4rem/1 var(--sans); color: var(--orange-deep); }
article details[open] summary::after { content: "\2212"; }
article details p { margin: 8px 0 0; }
.sources { font-size: 15px; color: var(--muted); }

/* ---------- shape cards (home + related) ---------- */
.cat-h { font: 800 1.5rem/1.1 var(--sans); letter-spacing: -.02em; margin: 52px 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; margin: 0; padding: 0; list-style: none; }
.card a {
  display: grid; grid-template-rows: 130px auto; height: 100%; text-decoration: none; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 20px; overflow: hidden;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), border-color .2s;
}
.card a:hover { transform: translateY(-3px); border-color: var(--ink); color: var(--ink); }
.card a:active { transform: scale(.98); transition-duration: 60ms; }
.card .spec { display: grid; place-items: center; padding: 14px; background: var(--peach); }
.card svg { width: 100%; height: 100px; }
.card .shape { fill: rgba(255, 91, 31, .38); stroke: var(--orange-line); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.card .meta { padding: 12px 14px 14px; }
.card .meta b { display: block; font: 700 1.1rem/1.2 var(--sans); }
.card .meta span { display: block; font: 400 14px/1.4 var(--sans); color: var(--muted); margin-top: 2px; }

/* ---------- embed (inside news sites' iframes) ---------- */
body.embed { padding: 0; margin: 0; background: #fff; }
.embed-plate { height: 100vh; display: flex; flex-direction: column; margin: 0; }
.embed-plate .plate-bar { padding: 8px; }
.embed-plate .map { flex: 1 1 auto; height: auto; min-height: 220px; border-radius: 0; }
body.embed .btn { box-shadow: none; } /* flat in someone else's story */
body.embed .btn:active { transform: scale(.96); }
.embed-foot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 7px 10px; background: var(--wash); color: var(--ink); }
.embed-foot .brand { font-size: 1.1rem; }
.embed-foot .q { font: 400 14px var(--sans); flex: 1 1 auto; }
.embed-foot .src { font: 400 12px var(--sans); color: var(--muted); }
body.embed .toast { bottom: 60px; }

/* ---------- footer ---------- */
footer { background: var(--wash); color: var(--ink-2); }
footer .inner { max-width: 1240px; margin: 0 auto; padding: 36px 24px 40px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; font: 400 15px/1.6 var(--sans); }
footer small { display: block; margin-top: 10px; font: 400 13px/1.6 var(--sans); color: var(--muted); }

/* ---------- load choreography ---------- */
/* transform only: text stays visible from the first frame, so the answer counts for LCP straight away */
@keyframes rise { from { transform: translateY(10px); } to { transform: none; } }
.reveal { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
.reveal.d1 { animation-delay: .04s; } .reveal.d2 { animation-delay: .1s; } .reveal.d3 { animation-delay: .16s; } .reveal.d4 { animation-delay: .22s; }

@media (max-width: 900px) {
  .use-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
  .btn, .card a, .poster, .ask button, .cat-links a { transition: none; }
  .card a:hover { transform: none; }
  .toast { transform: translate(-50%, 0); transition: opacity .2s ease; } /* fade only, no slide */
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .chip { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .crumbs, .crumbs a, .map-hint, .use-card small, .event-meta .ev-src, .chip i { color: var(--ink); }
  .ad { color: var(--ink); }
}

/* ---------- mobile + tablet: no rail, in-content ads, sticky anchor ---------- */
@media (max-width: 1099px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-top: 18px; }
  .rail { display: none; }
  .ad-incontent { width: 300px; height: 250px; }
  .ad-anchor { display: grid; place-items: center; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: 62px; background: #fff; border-top: 1px solid var(--line); }
  .ad-anchor .inner { width: 320px; height: 50px; display: grid; place-items: center; align-content: center; background: #f3f3f3; }
  .ad-anchor .close { position: absolute; right: 8px; top: -26px; width: 24px; height: 24px; padding: 0; cursor: pointer; border-radius: 50%;
    border: 1px solid #d0d0d0; background: #fff; color: var(--ink-2); font: 500 14px/1 var(--sans); }
  body.ads { padding-bottom: 62px; } /* room for the anchor ad */
  footer .inner { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --map-h: clamp(360px, 60vh, 500px); }
  .masthead { padding: 12px 16px; gap: 10px; }
  .masthead .topnav { display: none; }
  .masthead .ask label { display: none; }
  .ask { max-width: none; }
  .layout { padding: 14px 16px 48px; }
  /* phones: the answer, then straight to the map; the full set of units follows it (DOM order unchanged for search) */
  main { display: flex; flex-direction: column; }
  main > * { order: 3; }
  main > .crumbs, main > h1, main > .event-meta, main > .answer, main > .cat-links, main > .plate, main > .map-hint { order: 0; }
  main > .readout { order: 1; }
  main > .answer { text-align: left; } /* five centred lines are hard to read */
  /* one swipeable row, so the map stays on the first screen */
  .cat-links { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
  .cat-links::-webkit-scrollbar { display: none; }
  .plate-label { display: none; }
  .drop-form { flex: 1 1 100%; }
  .map { border-radius: 18px; }
  .chip { top: 10px; left: 10px; padding: 8px 10px; }
  .readout { gap: 6px; }
  .readout div { padding: 6px 12px; }
  .readout dd { font-size: 1rem; }
  .readout dt { font-size: 14px; }
  .compare li { grid-template-columns: 5.5rem 1fr; gap: 12px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card a { grid-template-rows: 96px auto; }
  .card svg { height: 72px; }
}
