@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@400;600;800&family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #d9eef2; --ink-frame: #0d2530; --accent: #0a7c8c;
  --paper: #fbfdfc; --ink: #10202b; --muted: #5b6b75; --line: #d5dde2;
  --red: #d7263d; --green: #1c9a5b; --blue: #1f6fd6; --yellow: #f5b700; --orange: #ef7b1a; --purple: #7b4bd1;
  --display: 'Unbounded', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 22px; line-height: 1.45;
  transition: background .6s ease;
  background-image:
    repeating-linear-gradient(174deg, transparent 0 46px, rgba(0,0,0,.035) 46px 48px),
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.25), transparent 55%);
}

/* depth gauge */
#gauge { position: fixed; left: 0; top: 0; bottom: 64px; width: 34px; display: flex; flex-direction: column; z-index: 5; border-right: 2px solid rgba(0,0,0,.25); }
.g-band { flex: 1; position: relative; opacity: .55; transition: opacity .3s, flex .4s; }
.g-band.side { flex: .8; border-top: 3px dashed rgba(255,255,255,.6); }
.g-band.here { opacity: 1; flex: 1.8; box-shadow: inset -6px 0 0 #10202b; }
.g-band:not(.here) span { display: none; }
.g-band span { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(-90deg); white-space: nowrap; font: 600 9px var(--display); letter-spacing: .08em; text-transform: uppercase; color: rgba(0,0,0,.6); }
.g-band[title="Physical"] span, .g-band[title="Link"] span, .g-band[title="Their server"] span, .g-band[title="Network"] span { color: rgba(255,255,255,.75); }
.g-band.here span { font-size: 10px; }

/* stage */
#viewport { position: fixed; left: 34px; right: 34px; top: 0; bottom: 64px; }
#stage { position: absolute; left: 50%; top: 50%; width: 1280px; height: 760px; transform-origin: center; }
.slide {
  position: absolute; inset: 22px; background: var(--paper); border-radius: var(--radius);
  box-shadow: 0 2px 0 rgba(0,0,0,.08), 0 24px 60px -24px rgba(0,0,0,.35);
  padding: 56px 72px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
}
.slide > * { flex: 0 0 auto; }
.slide.enter-right { animation: inR .45s cubic-bezier(.2,.8,.2,1); }
.slide.enter-left { animation: inL .45s cubic-bezier(.2,.8,.2,1); }
.slide.enter-fade { animation: inF .5s ease; }
@keyframes inR { from { opacity: 0; transform: translateX(40px); } }
@keyframes inL { from { opacity: 0; transform: translateX(-40px); } }
@keyframes inF { from { opacity: 0; transform: translateY(14px); } }
.slide.dark { background: #0f1a2e; color: #e8f0ff; }
.slide.dark .muted { color: #9fb1cc; }

/* layouts */
.l-center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.l-center p { max-width: 760px; }
.l-split { display: grid; grid-template-columns: 400px 1fr; gap: 56px; align-items: center; }
.l-split-r { display: grid; grid-template-columns: 1fr 400px; gap: 56px; align-items: center; }
.l-top { display: flex; flex-direction: column; gap: 22px; }

/* type */
h1, h2, h3 { font-family: var(--display); margin: 0 0 .5em; line-height: 1.12; letter-spacing: -.01em; }
h1 { font-size: 54px; font-weight: 800; }
h2 { font-size: 38px; font-weight: 800; }
h3 { font-size: 22px; font-weight: 600; }
p { margin: 0 0 .7em; }
.lead { font-size: 26px; }
.big { font-size: 30px; line-height: 1.3; }
.muted { color: var(--muted); }
.small { font-size: 17px; }
.note { font-size: 16.5px; }
.kicker { font: 600 15px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; display: block; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: #eef2f4; padding: .08em .35em; border-radius: 6px; }
.dark code { background: #1d2a44; }
em { font-style: italic; }
b, strong { font-weight: 700; }
.hl { background: linear-gradient(transparent 55%, #ffe27a 55%); padding: 0 .1em; }
.note { font-size: 16px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 12px; }
.note b { color: var(--ink); }

/* controls */
.btn {
  font: 600 17px var(--display); letter-spacing: .01em; color: var(--ink); background: #fff;
  border: 2.5px solid var(--ink); border-radius: 999px; padding: 12px 24px; cursor: pointer;
  box-shadow: 0 4px 0 var(--ink); transition: transform .08s, box-shadow .08s, background .2s;
}
.btn:hover { background: #fff7d6; }
.btn:active, .btn.pressed { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #26404f; }
.btn.small { font-size: 14px; padding: 8px 16px; box-shadow: 0 3px 0 var(--ink); }
.btn.on { background: var(--ink); color: #fff; }
.row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 14px; }
input[type=range] { accent-color: var(--ink); width: 100%; height: 28px; cursor: pointer; }
input[type=text], textarea, select {
  font: 20px var(--mono); border: 2.5px solid var(--ink); border-radius: 12px; padding: 10px 14px; background: #fff; color: var(--ink); width: 100%;
}
label.ctl { display: flex; flex-direction: column; gap: 4px; font-size: 16px; font-weight: 700; }
label.ctl .val { font-family: var(--mono); font-weight: 400; color: var(--accent); }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 18px; user-select: none; }
.toggle input { width: 22px; height: 22px; accent-color: var(--ink); }

/* doors: links into other decks */
.door {
  position: relative; display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 14px; padding: 12px 18px; background: #fff; cursor: pointer;
  font-weight: 700; transition: transform .15s, box-shadow .15s; box-shadow: 4px 4px 0 var(--ink);
}
.door:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--ink); }
.door .sub { display: block; font-weight: 400; font-size: 15px; color: var(--muted); }
.door .arrow { font-family: var(--display); margin-left: auto; }
/* a door you've already been through: a quiet green edge, no badge to collide with */
.door.visited { border-color: var(--green); box-shadow: 4px 4px 0 var(--green); }
.door.visited:hover { box-shadow: 6px 6px 0 var(--green); }
.door.visited .arrow { color: var(--green); }
.door.visited .arrow::before { content: '✓ '; font-size: .7em; }
.term { color: inherit; text-decoration: underline; text-decoration-style: wavy; text-decoration-color: var(--accent); text-underline-offset: 5px; cursor: pointer; }
.term:hover { background: #fff3c4; }

/* cards & stage boxes */
.card { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.box { border: 2.5px solid var(--ink); border-radius: 14px; background: #fff; }
.demo { position: relative; background: #f3f6f7; border-radius: 16px; border: 2px solid var(--line); }
.dark .demo { background: #16233d; border-color: #2a3b5c; }
.pill { display: inline-block; font: 600 13px var(--display); padding: 4px 10px; border-radius: 999px; background: #eef2f4; }
.code {
  font: 17px/1.55 var(--mono); background: #0f1a2e; color: #e3ecff; border-radius: 14px; padding: 18px 22px; white-space: pre; overflow: hidden;
}
.code .k { color: #ff8fb1; } .code .s { color: #b7f28a; } .code .c { color: #7f8fb0; } .code .n { color: #ffd479; } .code .f { color: #7cd3ff; }
.good { color: var(--green); } .bad { color: var(--red); }
.flash-good { animation: fg .7s; } .flash-bad { animation: fb .7s; }
@keyframes fg { 30% { background: #c9f5dc; } } @keyframes fb { 30% { background: #ffd2d8; } }
.pop-in { animation: popin .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes popin { from { transform: scale(.6); opacity: 0; } }
.bob { animation: bob 2.4s ease-in-out infinite; } @keyframes bob { 50% { transform: translateY(-6px); } }

/* ladder */
.ladder { color: var(--ink); overflow: visible; }
.lad-actor { font: 600 16px var(--display); fill: currentColor; }
.lad-life { stroke: currentColor; stroke-width: 2; stroke-dasharray: 3 6; opacity: .5; }
.lad-step { opacity: 0; transition: opacity .3s; }
.lad-step.on { opacity: 1; }
.lad-step.on .lad-line { stroke-dasharray: 600; animation: draw .6s ease forwards; }
@keyframes draw { from { stroke-dashoffset: 600; } to { stroke-dashoffset: 0; } }
.lad-label { font: 600 16px var(--mono); fill: currentColor; paint-order: stroke; stroke: var(--paper); stroke-width: 6px; }
.dark .lad-label { stroke: #0f1a2e; }

/* nav */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: 64px; background: #10202b; color: #e8f0f3; z-index: 10;
  display: grid; grid-template-columns: auto 1fr auto auto auto 1fr; align-items: center; gap: 16px; padding: 0 20px;
}
#nav button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.nav-map { display: flex; align-items: center; gap: 8px; font: 600 13px var(--display) !important; text-transform: uppercase; letter-spacing: .1em; padding: 8px 14px !important; border: 1.5px solid #3b5261 !important; border-radius: 999px; }
.nav-map:hover { background: #1f3644 !important; }
.nav-deck { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.nav-stratum { font: 600 10px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--nav-hi, var(--bg)); }
.nav-title { font: 600 15px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-arrow { font: 800 22px var(--display) !important; width: 46px; height: 46px; border-radius: 50%; border: 2px solid #3b5261 !important; }
.nav-arrow:hover:not(:disabled) { background: #1f3644 !important; }
.nav-arrow:disabled { opacity: .25; cursor: default !important; }
.nav-arrow.locked { opacity: .45; border-style: dashed !important; }
.nav-arrow.pop { animation: navpop .9s ease; background: var(--nav-hi) !important; color: #10202b !important; border-color: var(--nav-hi) !important; }
@keyframes navpop { 0% { transform: scale(1); } 30% { transform: scale(1.35); } 60% { transform: scale(.95); } }
.dots { display: flex; gap: 9px; align-items: center; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #8399a6 !important; padding: 0; }
.dot.reachable { border-color: #c8d6de !important; }
.dot.seen { background: #5d7483 !important; }
.dot.here { background: var(--nav-hi) !important; border-color: var(--nav-hi) !important; transform: scale(1.3); }
.dot:disabled { opacity: .7; cursor: default !important; }
.nav-hint { font-size: 14px; color: #ffd479; justify-self: start; }
.nav-hint.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* map */
#map { position: fixed; inset: 0; background: rgba(8,16,22,.72); z-index: 20; display: none; padding: 26px 40px; backdrop-filter: blur(3px); }
#map.open { display: flex; flex-direction: column; animation: inF .3s; }
.map-head { display: flex; justify-content: space-between; align-items: flex-end; color: #fff; margin-bottom: 12px; }
.map-head h2 { font-size: 28px; margin: 0; }
.map-head p { margin: 4px 0 0; font-size: 16px; color: #b8c7cf; }
.map-legend { font-size: 14px; }
.map-right { display: flex; gap: 14px; align-items: center; font-size: 15px; color: #b8c7cf; }
.map-close, .map-reset { background: none; border: 1.5px solid #6c8390; color: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font: 14px var(--body); }
.map-close { font-size: 18px; }
.map-svg { flex: 1; min-height: 0; border-radius: 18px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.map-svg svg { width: 100%; height: 100%; display: block; background: #d9eef2; }
.m-band { font: 600 12px var(--display); letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.m-sea { font: 600 12px var(--display); letter-spacing: .15em; fill: #0d3a4a; opacity: .7; text-transform: uppercase; }
.m-edge { fill: none; stroke: #10202b; stroke-opacity: .16; stroke-width: 2.5; stroke-dasharray: 5 6; transition: stroke-opacity .2s; pointer-events: none; }
.m-edge.mine { stroke-opacity: .5; }
.m-edge.hover { stroke-opacity: .85; stroke-width: 3; }
.m-node { cursor: pointer; }
.m-node .m-disc { stroke: #10202b; stroke-width: 2.5; }
.m-node .m-ring-bg { fill: none; stroke: rgba(16,32,43,.18); stroke-width: 5; }
.m-node .m-ring { fill: none; stroke: #10202b; stroke-width: 5; stroke-linecap: round; }
.m-node .m-icon { font-size: 24px; }
.m-node .m-label { font: 600 13px var(--display); fill: #10202b; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 4px; }
.m-node:hover .m-disc { stroke-width: 4; }
.m-node:hover { filter: drop-shadow(0 4px 6px rgba(0,0,0,.3)); }
.m-node.here .m-disc { stroke-width: 4; }
.m-halo { fill: none; stroke: #10202b; stroke-width: 3; stroke-dasharray: 3 7; opacity: .8; animation: spin 14s linear infinite; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.map-where { font: 600 14px var(--display); color: #fff; background: rgba(255,255,255,.14); border-radius: 999px; padding: 6px 14px; }
.m-node:not(.seen) .m-disc { fill: #eef2f4; stroke-dasharray: 5 5; }
.m-node:not(.seen) .m-icon { opacity: .55; }
.dark .kicker, .dark label.ctl .val { color: #6ee7ff; }
.dark .term { text-decoration-color: #6ee7ff; }
.dark .term:hover { background: #22345a; }
/* keep -> and => literal in code (the font shorthand resets ligatures, so this sits last) */
code, .mono, .code, pre, textarea, input, [class*="code"] { font-variant-ligatures: none !important; font-feature-settings: "calt" 0, "liga" 0 !important; }

/* keyboard focus */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
#nav :focus-visible { outline: 3px solid #ffd479; outline-offset: 2px; }

/* 18. respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* 15. the last slide points at the doors instead of going grey */
.nav-arrow.to-doors { border-color: #ffd479 !important; color: #ffd479 !important; opacity: 1; font-size: 15px !important; }
.door.beckon { animation: beckon 1.2s ease 2; }
@keyframes beckon { 40% { transform: translate(-3px,-3px); box-shadow: 8px 8px 0 var(--ink); } }
.map-foot { text-align: right; padding-top: 8px; }
.map-foot .map-reset { opacity: .55; font-size: 12px; }
.map-foot .map-reset:hover { opacity: 1; }

/* the click timeline, always on screen: where this deck sits in the 262 ms */
.nav-right { justify-self: end; display: flex; align-items: center; gap: 18px; }
.ribbon { display: flex; flex-direction: column; gap: 4px; width: 210px; }
.rib-label { font: 600 9px var(--display); letter-spacing: .08em; text-transform: uppercase; color: #9fb3bf; white-space: nowrap; }
.rib-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; border: 1px solid #3b5261; }
.rib-seg { border: 0; padding: 0; cursor: pointer; opacity: .28; transition: opacity .2s; }
.rib-seg.on { opacity: 1; }
.rib-seg:hover { opacity: .8; }
