/* charcoal and chalk, as on the rest of Mushlove: here it's always the dark one */
:root {
  --charcoal: #141311; --chalk: #f3f0e8;
  --bg: var(--charcoal); --ink: var(--chalk); --paper: var(--bg);
  --soft: color-mix(in srgb, var(--ink) 58%, var(--bg));
  --faint: color-mix(in srgb, var(--ink) 34%, var(--bg));
  --line: color-mix(in srgb, var(--ink) 16%, transparent);
  --wash: color-mix(in srgb, var(--ink) 6%, transparent);
  --wash2: color-mix(in srgb, var(--ink) 11%, transparent);
  --glass: color-mix(in srgb, var(--charcoal) 82%, transparent);
  --ring: color-mix(in srgb, var(--ink) 55%, transparent);
  --sans: 'Manrope', system-ui, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased }
button { font: inherit; color: inherit }
a { color: inherit }
::selection { background: var(--ink); color: var(--bg) }

#map { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; cursor: grab; touch-action: none }
#map.dragging { cursor: grabbing }
#map.over { cursor: pointer }

/* ---------- the bar ---------- */
.bar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 18px; padding: 14px 18px; z-index: 10; pointer-events: none;
  background: linear-gradient(var(--bg) 30%, transparent) }
.bar > * { pointer-events: auto }
.embedded .bar .brand { display: none }
.brand .logo { display: block; width: 118px; aspect-ratio: 1387.1 / 203.8; background: var(--ink); -webkit-mask: url(vendor/mushlove.svg) center / contain no-repeat; mask: url(vendor/mushlove.svg) center / contain no-repeat }
.title { display: flex; flex-direction: column; line-height: 1.1 }
.title b { font-weight: 800; font-size: 17px; letter-spacing: -.02em }
/* the buttons, as Space Slinky's: small capitals in the mono, in a thin ring */
.layers { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--ring); border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px) }
.layers button, .seg button { border: 0; background: transparent; min-height: 28px; padding: 4px 10px; border-radius: 999px; font: 400 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--soft); cursor: pointer; transition: background .15s, color .15s }
.layers button:not([aria-selected="true"]):hover, .seg button:not([aria-pressed="true"]):hover { color: var(--ink) }
.layers [aria-selected="true"], .seg [aria-pressed="true"] { background: var(--ink); color: var(--bg) }
.right { margin-left: auto; display: flex; gap: 10px; align-items: center }
.seg { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--ring); border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px) }
.seg.small button { min-height: 24px; padding: 3px 9px }
.story-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); min-height: 28px; padding: 4px 11px 4px 9px; border-radius: 999px; font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; cursor: pointer }
.story-btn svg { width: 11px; height: 11px; fill: currentColor }
.story-btn:hover { opacity: .88 }
/* the laws map keeps to a lifetime and tells no story, so its clock has no scale switch and no story button */
[data-topic="laws"] .time .seg, [data-topic="laws"] .story-btn { display: none }
/* where they grow and the mycelium have no clock: the land and the soil as they are, so only the credit stays at the foot */
:is([data-topic="grow"], [data-topic="mycelium"]) :is(.era, .track, .time .seg, .story-btn) { display: none }
:is([data-topic="grow"], [data-topic="mycelium"]) .legend { bottom: 48px }
/* the mycelium page fades the map's foot into its own words and credits the maps there, so the foot goes and the key rises above the fade */
[data-topic="mycelium"] .time { display: none }
[data-topic="mycelium"] .legend { bottom: 76px }
.layers[hidden] { display: none }

/* ---------- filters, legend, caption ---------- */
.filters { position: fixed; top: calc(var(--bar-h, 62px) + 4px); left: 18px; display: flex; flex-wrap: wrap; gap: 6px; max-width: min(760px, calc(100vw - 36px)); z-index: 9 }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ring); background: var(--glass); backdrop-filter: blur(8px); border-radius: 999px; min-height: 28px; padding: 3px 10px 3px 5px; font: 400 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--soft); cursor: pointer }
.chip.text { padding-left: 10px }
.chip img { width: 18px; height: 18px }
.chip:not([aria-pressed="true"]):hover { color: var(--ink) }
.chip[aria-pressed="true"] { color: var(--bg); background: var(--ink); border-color: var(--ink) }
.chip[aria-pressed="true"] img { filter: invert(1) }
.pick { position: relative; display: flex; gap: 6px; align-items: flex-start }
.chip .caret { width: 12px; height: 12px; margin-right: -3px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s }
.chip[aria-expanded="true"] .caret { transform: rotate(180deg) }
.chip.x { padding: 4px 10px; font-size: 14px; line-height: 1 }
.pick .menu { position: absolute; top: calc(100% + 6px); left: 0; display: flex; flex-wrap: wrap; gap: 6px; width: max-content; max-width: min(440px, calc(100vw - 36px)); padding: 8px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(14px); box-shadow: 0 12px 32px rgb(0 0 0 / .35) }
.legend { position: fixed; left: 18px; bottom: 112px; z-index: 9; display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--soft); padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--glass); backdrop-filter: blur(8px); max-width: 280px }
.legend:empty { display: none }
.legend .row { display: flex; align-items: center; gap: 8px }
.legend .sw { width: 22px; height: 14px; border-radius: 3px; border: 1px solid var(--line); flex: none; background-color: var(--bg) }
.legend b { color: var(--ink); font-weight: 700; font-size: 12px }
.legend .note { margin-top: 3px; line-height: 1.4 }
.legend .scale { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; margin: 2px 0 3px; font-family: var(--mono); font-size: 10px; letter-spacing: .02em }
.legend .scale i { grid-column: 1 / -1; height: 10px; border-radius: 3px; border: 1px solid var(--line) }
.legend .scale span:last-child { text-align: right }
.legend .src { font-size: 10.5px; opacity: .8 }
.legend .src a { color: inherit; text-decoration-color: var(--faint); text-underline-offset: 2px }
.legend .ramp { width: 22px; height: 10px; border-radius: 3px; flex: none; background: linear-gradient(90deg, transparent, var(--ink)); border: 1px solid var(--line) }
.legend .how { align-self: flex-start; margin-top: 4px }
.caption { position: fixed; left: 50%; top: 112px; transform: translateX(-50%); margin: 0; z-index: 8; pointer-events: none; text-align: center; font-weight: 800; font-size: clamp(20px, 3vw, 34px); letter-spacing: -.02em; opacity: 0; transition: opacity .8s; max-width: 80vw; text-shadow: 0 0 24px var(--bg) }
.caption.on { opacity: .92 }
.caption small { display: block; font-family: var(--mono); font-weight: 400; font-size: 12px; letter-spacing: .03em; color: var(--soft); margin-top: 6px; text-shadow: 0 0 6px var(--bg), 0 0 14px var(--bg) }

/* ---------- time ---------- */
.time { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; align-items: flex-end; gap: 22px; padding: 14px 22px 18px; background: linear-gradient(transparent, var(--bg) 55%) }
.era { flex: none; width: 230px; display: flex; flex-direction: column; gap: 2px }
.era span { font-weight: 800; font-size: 24px; letter-spacing: -.02em; line-height: 1.05 }
.era small { font-family: var(--mono); font-size: 11px; color: var(--soft); min-height: 1.3em }
.track-wrap { position: relative; flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0 }
.track-top { display: flex; align-items: center; gap: 8px }
.time .story-btn { padding: 4px 12px 4px 9px; font-size: 13px; gap: 5px }
.time .story-btn svg { width: 12px; height: 12px }
.credit { flex: 1; min-width: 0; text-align: right; font-family: var(--mono); font-size: 10px; line-height: 1.3; color: var(--soft); opacity: .7 }
.panel .then { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px }
.panel .then .muted { display: block; margin-top: 4px; font-size: 12px }
.track { position: relative; height: 44px }
.track input { position: absolute; left: 0; right: 0; top: 4px; width: 100%; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; height: 22px; z-index: 2; cursor: pointer }
.track input::-webkit-slider-runnable-track { height: 2px; background: var(--faint) }
.track input::-moz-range-track { height: 2px; background: var(--faint) }
.track input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -8px; border-radius: 50%; background: var(--ink); border: 4px solid var(--bg); box-shadow: 0 0 0 1px var(--ink) }
.track input::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 4px solid var(--bg); box-shadow: 0 0 0 1px var(--ink) }
.ticks, .marks { position: absolute; left: 0; right: 0; pointer-events: none }
.ticks { top: 26px }
.ticks span { position: absolute; transform: translateX(-50%); font-family: var(--mono); font-size: 10px; color: var(--soft); white-space: nowrap }
.ticks span::before { content: ''; position: absolute; left: 50%; top: -9px; width: 1px; height: 5px; background: var(--faint) }
.ticks span.hush { color: transparent }
.marks { top: 6px; height: 16px }
.marks i { position: absolute; top: 4px; width: 2px; height: 8px; margin-left: -1px; background: var(--ink); opacity: .5; border-radius: 1px }

/* ---------- the side panel ---------- */
.panel { position: fixed; top: 70px; right: 14px; bottom: 112px; width: min(380px, calc(100vw - 28px)); z-index: 11; overflow: auto; padding: 22px 22px 26px; border: 1px solid var(--line); border-radius: 20px; background: var(--glass); backdrop-filter: blur(14px);
  transform: translateX(calc(100% + 24px)); transition: transform .35s cubic-bezier(.2,.8,.2,1); scrollbar-width: thin }
.panel.open { transform: none }
.panel .x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--soft) }
.panel .x:hover { color: var(--ink); background: var(--wash) }
.panel .kick { font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--soft); margin: 0 0 6px }
.panel h2 { font-size: 28px; font-weight: 800; letter-spacing: -.025em; line-height: 1.05; margin: 0 40px 10px 0 }
.panel h3 { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); margin: 22px 0 8px; padding-top: 14px; border-top: 1px solid var(--line) }
.panel p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.55; color: color-mix(in srgb, var(--ink) 88%, var(--bg)) }
.panel .tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 12px }
.panel .tag { font-family: var(--mono); font-size: 11px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--soft) }
.panel .tag.debated { border-style: dashed }
.panel .tag.speculative { border-style: dotted }
.panel ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px }
.panel li { font-size: 13.5px; line-height: 1.45 }
.panel li .y { font-family: var(--mono); font-size: 12px; color: var(--soft); margin-right: 6px }
.panel .law { display: flex; align-items: center; gap: 10px; font-size: 14px }
.panel .law .sw { width: 26px; height: 16px; border-radius: 3px; border: 1px solid var(--line); flex: none; background-color: var(--bg) }
.panel .law b { font-weight: 700; min-width: 86px }
.panel .law span { color: var(--soft) }
.panel .bar-i { display: flex; align-items: center; gap: 10px; font-size: 14px }
.panel .bar-i img { width: 22px; height: 22px }
.panel .bar-i .b { flex: 1; height: 4px; background: var(--wash2); border-radius: 2px; position: relative; overflow: hidden }
.panel .bar-i .b i { position: absolute; inset: 0 auto 0 0; background: var(--ink); border-radius: 2px }
.panel .sources a { text-decoration-color: var(--faint); text-underline-offset: 2px }
.panel button.ev { all: unset; cursor: pointer; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px }
.panel .muted { color: var(--soft); font-size: 13px }

/* ---------- story mode ---------- */
.story { position: fixed; left: 14px; top: 70px; bottom: 112px; width: 300px; z-index: 12; display: flex; flex-direction: column; align-items: center; padding: 14px 18px 18px; border: 1px solid var(--line); border-radius: 22px; background: var(--glass); backdrop-filter: blur(14px) }
.story[hidden] { display: none }
.story .head { flex: 1; min-height: 140px; width: 100%; display: grid; place-items: center }
.story svg { width: 100%; height: 100%; max-height: 300px; color: var(--ink); overflow: visible }
.story .who { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; font-family: var(--mono); font-size: 12px; color: var(--soft) }
.story .who button { border: 0; background: transparent; color: var(--soft); font-size: 18px; cursor: pointer; padding: 0 6px }
.story .who button:hover { color: var(--ink) }
.story .who #whoName { font: inherit; padding: 2px 4px; color: var(--ink) }
.story #head { cursor: pointer }
.story .chap { margin: 8px 0 0; font-family: var(--mono); font-size: 10px; letter-spacing: .05em; color: var(--soft); opacity: .55; text-align: center }
.story .line { margin: 0; padding: 0 18px; min-height: 7.2em; font-size: 12.5px; font-weight: 500; line-height: 1.55; text-align: center; letter-spacing: -.005em }
.story .ctl { display: flex; gap: 6px; margin-top: 12px }
.story .ctl button { border: 1px solid var(--line); background: transparent; border-radius: 999px; min-width: 38px; height: 34px; padding: 0 10px; cursor: pointer; font-size: 14px }
.story .ctl button:hover { background: var(--wash) }
.story .ctl button[id] { display: grid; place-items: center; color: var(--ink) }
.story .ctl svg { width: 15px; height: 15px; fill: currentColor; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round }
.story .ctl svg .w { fill: none }
.story .dots { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; justify-content: center }
.story .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); cursor: pointer }
.story .dots i.on { background: var(--ink) }
body.storying .filters, body.storying .legend { opacity: .0; pointer-events: none }
@media (min-width: 861px) { body.storying .caption { left: calc(50% + 157px) } }

.tip { position: fixed; z-index: 20; pointer-events: none; padding: 4px 9px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; white-space: nowrap; transform: translate(12px, -28px) }
.tip small { display: block; font-weight: 500; font-size: 11px; opacity: .75 }

@media (max-width: 860px) {
  .title, .brand { display: none }
  .bar { flex-wrap: wrap; gap: 8px; padding: 10px 12px }
  .right { margin-left: 0 }
  .layers, .seg { padding: 2px }
  .layers button, .seg button { min-height: 24px; padding: 3px 7px; font-size: 10px }
  .time .story-btn { min-height: 24px; padding: 3px 9px 3px 7px; font-size: 10px; gap: 4px }
  .time .story-btn svg { width: 11px; height: 11px }
  /* the caption would sit on the map's lines and cover it, so phones go without */
  .caption { display: none }
  .filters { top: calc(var(--bar-h, 80px) - 2px); left: 12px; max-width: calc(100vw - 24px) }
  .pick .menu { max-width: calc(100vw - 24px) }
  .chip { min-height: 24px; padding: 2px 8px 2px 4px; font-size: 10px; gap: 4px }
  .chip.text { padding-left: 8px }
  .chip img { width: 15px; height: 15px }
  .era { width: auto }
  .time { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 16px 14px }
  .panel { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: 62dvh; border-radius: 20px 20px 0 0; transform: translateY(105%) }
  .story { left: 0; right: 0; top: auto; bottom: 0; width: 100%; flex-direction: row; flex-wrap: wrap; border-radius: 20px 20px 0 0; padding: 10px 14px 14px; gap: 6px }
  .story .head { flex: none; width: 90px; height: 110px; min-height: 0 }
  .story .head svg { width: 90px; height: 110px }
  .story .line { flex: 1; min-width: 180px; padding: 0; font-size: 15px; min-height: 0; text-align: left }
  .story .chap, .story .who { display: none }
  .legend { bottom: 150px }
  .legend .drawn { display: none }
  :is([data-topic="grow"], [data-topic="mycelium"]) .legend { bottom: 44px }
  [data-topic="mycelium"] .legend { bottom: 72px }
}
@media (prefers-reduced-motion: reduce) { .panel, .caption { transition: none } }
