:root {
  --navy: #16233a; --amber: #f2c46d; --green: #7fd4a0; --muted: #9fb0c6;
  --ink: #1f3a5f; --panel: #e8eef6; --text: #1c2433; --sub: #4a5568;
  --wall: #0f1a2c; --bar-h: 30px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--bar-h) + 12px); }
body { margin: 0; font-family: Figtree, system-ui, sans-serif; color: var(--text); min-height: 100vh;
  background: radial-gradient(1200px 700px at 75% 20%, #2a4066 0%, transparent 60%),
              radial-gradient(900px 600px at 10% 90%, #1f3a5f 0%, transparent 60%), var(--wall);
  background-attachment: fixed; }
a { color: var(--ink); font-weight: 700; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
h2, h3 { margin: 0; }

/* ---------- menu bar ---------- */
.bar { position: sticky; top: 0; z-index: 9999; height: var(--bar-h); display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: rgba(15,26,44,.6); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); color: #e6edf6; font-size: 13px; }
.bar b { font-weight: 800; }
.bar .sp { flex: 1; }
.bar a { color: #e6edf6; font-weight: 600; text-decoration: none; }
.bar a:hover { text-decoration: underline; }

/* ---------- windows (stacked page by default: phones and no-JS) ---------- */
#desktop { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
.win { background: #fff; border-radius: 11px; overflow: hidden; display: flex; flex-direction: column; margin: 0 0 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.08); }
.tb { height: 36px; flex: none; display: flex; align-items: center; padding: 0 12px; position: relative; user-select: none;
  background: #eef2f7; border-bottom: 1px solid #dde4ee; }
.tb .t { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: 13px; font-weight: 600; color: var(--sub); }
.dots { display: flex; gap: 7px; position: relative; z-index: 1; }
.dots > * { width: 12px; height: 12px; border-radius: 50%; display: block; border: 0; padding: 0; }
.dots .close { background: #e5655b; cursor: pointer; }
.dots i:nth-of-type(1) { background: #e9b949; }
.dots i:nth-of-type(2) { background: #5fbf74; }
.skip { margin-left: auto; position: relative; z-index: 1; background: none; border: 1px solid #3a5078; color: var(--muted);
  font: 600 11px "IBM Plex Mono", monospace; padding: 2px 8px; border-radius: 6px; cursor: pointer; }
.skip:hover { color: #fff; }
html:not(.desk) .close { cursor: default; pointer-events: none; }

.body { padding: 20px 22px 22px; overflow: auto; font-size: 15px; line-height: 1.6; }
.body h3 { margin: 16px 0 4px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); }
.body p { margin: 0 0 8px; }
.body ul { margin: 0 0 8px; padding-left: 20px; }
.body li { margin: 0 0 3px; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 8px; background: var(--panel); color: var(--ink); margin-bottom: 4px; }
.tag.live { background: #dff5e8; color: #1d6b40; }
.links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px !important; }
blockquote { margin: 16px 0 0; padding: 10px 14px; border-left: 3px solid var(--amber); background: #fbf6ea; font-style: italic; color: var(--sub); border-radius: 0 6px 6px 0; }
.note { font-size: 12.5px; color: var(--sub); }
.mini { margin: 12px 0 4px; padding: 12px 14px; border-radius: 8px; background: var(--navy); color: #e6edf6; overflow-x: auto;
  font: 12px/1.65 "IBM Plex Mono", Menlo, monospace; }

/* project images */
.shots { margin: 14px 0 6px; }
.shots img { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 0 0 1px #dde4ee; }
.shots.phones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.shots.phones img { border-radius: 10px; }
.shots figcaption { grid-column: 1 / -1; margin-top: 6px; font-size: 12.5px; color: var(--sub); }

/* hq flow diagram */
.flow { margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flow .node { flex: 1 1 120px; padding: 9px 11px; border-radius: 8px; background: var(--panel); color: var(--ink); font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.flow .node.dark { background: var(--navy); color: #fff; }
.flow small { display: block; font-weight: 400; font-size: 11.5px; opacity: .75; margin-top: 2px; }
.flow .arrow { color: var(--sub); font-size: 18px; }
.flow .buckets { flex: 1 1 100px; display: flex; flex-direction: column; gap: 3px; }
.flow .buckets span { padding: 2px 8px; border-radius: 6px; background: #dff5e8; color: #1d6b40; font: 600 12px "IBM Plex Mono", monospace; }

/* terminal */
.term .tb { background: #1b2a45; border-color: #24365a; }
.term .tb .t { color: var(--muted); }
.term .body { background: var(--navy); color: #e6edf6; font: 13.5px/1.7 "IBM Plex Mono", Menlo, monospace; min-height: 300px; position: relative; }
/* the real text keeps its space (no layout shift) but is see-through; the typed copy sits on top */
.term-src.ghost, .term-src.ghost .ln, .term-src.ghost .ln::before { color: transparent !important; }
.term-anim { position: absolute; inset: 20px 22px; }
.ln { display: block; min-height: 1.7em; }
.ln.gap { margin-top: .6em; }
.ln.p::before, .mini .p::before { content: "$ "; color: var(--amber); }
.ln.ok::before, .mini .ok::before { content: "✓ "; color: var(--green); }
.ln.m { color: var(--muted); }
.cursor { display: inline-block; width: 8px; height: 15px; background: var(--amber); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* numbers */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.stat b { display: block; font-family: "Bricolage Grotesque", sans-serif; font-size: 32px; line-height: 1.05; color: var(--ink); }
.stat span { font-size: 13px; line-height: 1.4; color: var(--sub); display: block; }

/* timeline */
.tl { list-style: none; margin: 0 0 6px; padding: 0 0 0 18px; border-left: 2px solid var(--panel); }
.tl li { margin: 0 0 14px; position: relative; font-size: 14.5px; }
.tl li::before { content: ""; position: absolute; left: -25px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px #fff; }
.tl .yr { display: block; font: 600 12px "IBM Plex Mono", monospace; color: var(--sub); }
.tl b { margin-right: 4px; }

/* desktop-only chrome */
.files, .dock, .bar-desk { display: none; }

/* phones */
@media (max-width: 600px) {
  .bar-tag { display: none; }
  .body { padding: 18px 18px 20px; }
  .stat b { font-size: 28px; }
}

/* ---------- desktop mode (set by JS on wide screens) ---------- */
.desk body { overflow: hidden; height: 100vh; }
.desk .bar { position: fixed; inset: 0 0 auto 0; }
.desk .bar-desk { display: inline; }
.desk #desktop { max-width: none; margin: 0; padding: 0; }
.desk .win { position: absolute; margin: 0; max-height: calc(100vh - var(--bar-h) - 140px); }
.desk .win:not(.open) { display: none; }
/* same positions script.js place() sets, so nothing jumps before JS runs */
.desk #term { width: min(580px, 46vw); left: max(24px, 4vw); top: 56px; }
.desk #numbers { width: min(420px, 34vw); left: calc(max(24px, 4vw) + min(580px, 46vw) + 24px); top: 56px; }
.win:focus { outline: none; }
.desk .tb { cursor: grab; }
.desk .tb:active { cursor: grabbing; }
.desk .term .body { min-height: 0; height: 320px; font-size: 13px; line-height: 1.6; } /* fixed so the widgets below don't jump while it types */

/* desktop widgets (macOS style) */
.widgets { position: fixed; z-index: 1; display: flex; gap: 20px; }
.widgets[hidden] { display: none; }
.widget { height: 180px; border: 0; padding: 0; border-radius: 20px; font: inherit; text-align: left; cursor: pointer; overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.08); transition: transform .15s; }
.widget:hover, .widget:focus-visible { transform: translateY(-3px); }
.widget.photo { width: 300px; position: relative; background: #000; }
.widget.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wcap { position: absolute; inset: auto 0 0 0; padding: 30px 14px 12px; color: #fff; font-size: 12.5px; line-height: 1.35;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); }
.wcap b { display: block; font-size: 14px; }
.widget.sticky { width: 245px; padding: 14px 18px; background: linear-gradient(180deg, #fff6b8, #fbe98a); color: #3b3517;
  display: flex; flex-direction: column; gap: 4px; transform: rotate(-1.5deg); border-radius: 6px; }
.widget.sticky:hover, .widget.sticky:focus-visible { transform: rotate(-1.5deg) translateY(-3px); }
.widget.sticky b { font-size: 14px; margin-bottom: 3px; }
.widget.sticky span { font-size: 12px; line-height: 1.25; }
.widget.sticky span::before { content: "– "; opacity: .6; }
.widget.live { width: 285px; padding: 12px 16px; cursor: default; color: #fff; display: flex; flex-direction: column; gap: 1px;
  background: rgba(255,255,255,.13); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.widget.live:hover { transform: none; }
.widget.live .wt { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.widget.live button { display: grid; grid-template-columns: 10px 1fr; column-gap: 8px; align-items: center; background: none; border: 0; padding: 2px 0;
  color: #fff; font: 700 13.5px Figtree, sans-serif; text-align: left; cursor: pointer; }
.widget.live button:hover { color: var(--amber); }
.widget.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); grid-row: span 2; }
.widget.live small { grid-column: 2; font: 400 11px/1.2 Figtree, sans-serif; color: var(--muted); }
@media (max-width: 1199px) { .widget.live { display: none; } }

.desk .files { display: flex; flex-direction: column; gap: 18px; position: fixed; right: 22px; top: calc(var(--bar-h) + 20px); z-index: 1; }
.file { width: 84px; text-align: center; color: #fff; font-size: 12px; font-weight: 600; text-decoration: none; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.file .ic { display: block; width: 52px; height: 62px; margin: 0 auto 6px; border-radius: 6px; background: #fff; position: relative; box-shadow: 0 4px 12px rgba(0,0,0,.35); }
.file .ic::after { content: attr(data-x); position: absolute; bottom: 8px; left: 6px; right: 6px; font-size: 10px; font-weight: 800; color: #fff; background: #e5655b; border-radius: 3px; text-shadow: none; }
.file .ic.card { width: 64px; height: 46px; margin: 8px auto 14px; display: grid; place-items: center; }
.file .ic.card::after { display: none; }
.file .ic.card svg { width: 50px; fill: var(--ink); stroke: none; }
.file .ic.card .ln2 { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }

/* "the dock is clickable" cues: a one-off bounce wave plus a small hint */
.dock-hint { display: none; }
.desk .dock-hint { display: block; position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 9997; margin: 0;
  background: var(--amber); color: var(--navy); font: 700 12.5px Figtree, sans-serif; padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35); opacity: 0; transition: opacity .4s; pointer-events: none; }
.dock-hint::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--amber); }
.dock-hint.show { opacity: 1; }
.app.bounce { animation: bounce .8s ease-out calc(var(--i) * 90ms) backwards; }
@keyframes bounce { 0%, 100% { transform: none; } 30% { transform: translateY(-18px); } 55% { transform: none; } 75% { transform: translateY(-6px); } }

.desk .dock { display: flex; gap: 10px; position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 9998; padding: 8px 10px; border-radius: 20px;
  background: rgba(255,255,255,.14); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 0 0 1px rgba(255,255,255,.18); }
/* macOS-style app icons: squircle-ish radius (22.5%), gradient, top highlight, soft drop shadow */
.app { position: relative; width: 54px; height: 54px; padding: 0; border: 0; border-radius: 12.5px; cursor: pointer;
  background: linear-gradient(180deg, var(--c1, #fff), var(--c2, #ddd));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), inset 0 -1px 0 rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.3);
  transition: transform .15s; display: grid; place-items: center; overflow: visible; }
.app::before { content: ""; position: absolute; inset: 0 0 50% 0; border-radius: 12.5px 12.5px 40% 40% / 12.5px 12.5px 14px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0)); pointer-events: none; }
.app img { width: 100%; height: 100%; border-radius: 12.5px; display: block; }
.app svg { position: relative; width: 29px; height: 29px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.28)); }
.term-ic svg .amber { stroke: var(--amber); stroke-width: 2.4; }
.term-ic svg .green { stroke: var(--green); stroke-width: 2.4; }
.app:hover, .app:focus-visible { transform: translateY(-8px) scale(1.1); }
.app .lbl { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: rgba(15,26,44,.88); color: #fff; font: 600 12px Figtree, sans-serif; padding: 4px 9px; border-radius: 6px; }
.app:hover .lbl, .app:focus-visible .lbl { opacity: 1; }
.app.on::after { content: ""; position: absolute; bottom: -6px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: #fff; }
.sep { width: 1px; background: rgba(255,255,255,.25); margin: 4px 2px; }

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .app, .app .lbl, .dock-hint { transition: none; }
  .app.bounce { animation: none; }
  .widget, .widget:hover { transition: none; }
  .app:hover, .app:focus-visible { transform: none; }
}
