:root {
  --blue: #15407a;
  --blue-deep: #0f3263;
  --grid: rgba(255, 255, 255, 0.08);
  --grid-strong: rgba(255, 255, 255, 0.15);
  --paper: #edf1f5;
  --ink: #0e2444;
  --line: #6f96c9;
  --mark: #ffd23f;
  --mute: #4f6483;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--blue);
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 3px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- top bar ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 18px 24px; pointer-events: none;
}
.bar > * { pointer-events: auto; }
.mark {
  font-weight: 800; font-stretch: 125%; font-size: 20px;
  letter-spacing: -0.01em; text-decoration: none;
}
.bar nav { display: flex; gap: 22px; margin-left: auto; font-stretch: 82%; font-size: 16px; }
.bar nav a, .bar nav button {
  text-decoration: none; border-bottom: 1px solid transparent;
}
.bar nav a:hover, .bar nav button:hover { border-color: currentColor; }

/* ---------- home: the drawing table ---------- */
#field {
  position: fixed; inset: 0; overflow: hidden;
  cursor: grab; touch-action: none;
  background-color: var(--blue);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 200px 200px, 200px 200px;
}
#field.dragging { cursor: grabbing; }
#world { position: absolute; left: 0; top: 0; width: 2600px; height: 1800px; transform-origin: 0 0; will-change: transform; }

.sheet {
  position: relative; display: block;
  background: var(--paper); color: var(--ink); text-decoration: none;
  box-shadow: 0 22px 40px -22px rgba(4, 16, 40, 0.7);
}
#world .sheet { position: absolute; }
.sheet::before {
  content: ""; position: absolute; inset: 7px;
  border: 1px solid rgba(14, 36, 68, 0.55); pointer-events: none; z-index: 1;
}
.sheet canvas {
  position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - 64px);
  display: block;
}
.tb {
  position: absolute; left: 7px; right: 7px; bottom: 7px; height: 57px; z-index: 2;
  border-top: 1px solid rgba(14, 36, 68, 0.55);
  padding: 0 14px; display: flex; justify-content: space-between; align-items: center; gap: 14px;
}
.tb strong { font-weight: 800; font-stretch: 112%; font-size: 17px; line-height: 1.1; }
.tb span { font-stretch: 78%; font-size: 14px; color: var(--mute); text-align: right; max-width: 48%; line-height: 1.2; }
a.sheet:hover, a.sheet:focus-visible { outline: 4px solid var(--mark); outline-offset: 0; }

.hint {
  position: fixed; left: 24px; bottom: 34px;
  font-stretch: 82%; font-size: 15px; color: var(--paper);
  background: var(--blue-deep); padding: 8px 16px; border-radius: 99px;
  transition: opacity 0.4s; pointer-events: none;
}
.hint.gone { opacity: 0; }

/* ---------- project pages ---------- */
body.project {
  height: auto;
  background-color: var(--blue);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 200px 200px, 200px 200px;
}
.story { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.stage-col { min-width: 0; }
.stage { position: sticky; top: 0; height: 100vh; padding: 84px 0 36px 28px; }
.stage .sheet { width: 100%; height: 100%; }

.chapters { padding: 0 56px 0 40px; }
.chapter {
  min-height: 92vh; max-width: 540px;
  display: flex; flex-direction: column; justify-content: center;
}
.chapter h1 {
  font-weight: 800; font-stretch: 125%; font-size: clamp(36px, 4.6vw, 64px);
  line-height: 1; letter-spacing: -0.02em; margin-bottom: 18px;
}
.chapter h2 {
  font-weight: 800; font-stretch: 112%; font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1.1; margin-bottom: 14px;
}
.chapter .lede { font-size: 22px; line-height: 1.35; font-stretch: 90%; color: #cfe0f5; }
.chapter p { font-size: 18px; line-height: 1.55; max-width: 56ch; color: #dbe7f6; }
.chapter p + p { margin-top: 14px; }

.live { background: var(--paper); color: var(--ink); padding: 72px 28px 80px; }
.live-inner { max-width: 1200px; margin: 0 auto; }
.live h2 { font-weight: 800; font-stretch: 112%; font-size: 28px; margin-bottom: 20px; }
.app-slot {
  min-height: 420px; border: 1px solid var(--ink);
  display: grid; place-items: center; text-align: center; padding: 32px;
  background-image: linear-gradient(rgba(14,36,68,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(14,36,68,.07) 1px, transparent 1px);
  background-size: 24px 24px;
}
.app-slot p { font-size: 18px; color: var(--mute); max-width: 44ch; line-height: 1.5; }

.next {
  background: var(--paper); color: var(--ink);
  border-top: 1px solid rgba(14, 36, 68, 0.3);
  padding: 28px; display: flex; justify-content: space-between; gap: 24px;
  font-stretch: 90%; font-size: 18px;
}
.next a { text-decoration: none; border-bottom: 1px solid transparent; }
.next a:hover { border-color: var(--ink); }
.next a strong { font-weight: 800; font-stretch: 112%; }

@media (max-width: 820px) {
  .bar { padding: 14px 16px; }
  .story { grid-template-columns: 1fr; }
  .stage-col {
    position: sticky; top: 0; z-index: 5; height: 46vh;
    background: var(--blue); box-shadow: 0 12px 0 var(--blue);
  }
  .stage { position: static; height: 100%; padding: 58px 16px 0; }
  .chapters { padding: 0 20px; }
  .chapter { min-height: 70vh; }
  .live { padding: 48px 16px 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .hint { transition: none; }
}

/* ---------- name and introduction at the centre of the table ---------- */
.hero {
  --name-h: 88px;
  position: absolute; left: 1300px; top: 900px;
  transform: translate(-50%, calc(var(--name-h) / -2));
  display: flex; flex-direction: column; align-items: flex-end;
}
.name {
  white-space: nowrap; pointer-events: none; user-select: none; -webkit-user-select: none;
  font-weight: 800; font-stretch: 125%; font-size: var(--name-h); line-height: 1;
  letter-spacing: -0.025em; color: var(--paper);
}
.about-btn {
  margin-top: 22px; padding: 13px 28px;
  background: var(--paper); color: var(--ink);
  font-weight: 800; font-stretch: 112%; font-size: 18px; line-height: 1;
  box-shadow: 0 18px 30px -18px rgba(4, 16, 40, 0.7);
}
.about-btn:hover { background: var(--mark); }
@media (max-width: 700px) {
  .hero { --name-h: 40px; }
  .about-btn { margin-top: 14px; padding: 12px 22px; font-size: 16px; }
}

/* zoom controls */
.zoom { position: fixed; right: 20px; bottom: 20px; z-index: 10; display: flex; gap: 6px; }
.zoom button {
  min-width: 44px; height: 44px; padding: 0 14px;
  background: var(--paper); color: var(--ink);
  font-weight: 800; font-size: 22px; line-height: 1;
  box-shadow: 0 14px 24px -14px rgba(4, 16, 40, 0.7);
}
.zoom button.wide { font-stretch: 82%; font-size: 16px; padding: 0 18px; }
.zoom button:hover:not(:disabled) { background: var(--mark); }
.zoom button:disabled { opacity: 0.4; cursor: default; }

/* about panel */
dialog#about {
  margin: auto; max-width: 520px; width: calc(100% - 48px);
  padding: 32px 32px 28px; border: 0;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 30px 60px -20px rgba(4, 16, 40, 0.8);
}
dialog#about::backdrop { background: rgba(10, 30, 62, 0.6); }
dialog#about h2 { font-weight: 800; font-stretch: 112%; font-size: 24px; margin-bottom: 14px; }
dialog#about p { font-size: 17px; line-height: 1.55; margin-bottom: 12px; max-width: 60ch; }
dialog#about a { color: var(--ink); text-underline-offset: 3px; overflow-wrap: anywhere; }
dialog#about a:hover { background: var(--mark); }
dialog#about button {
  margin-top: 8px; padding: 8px 0; font-stretch: 82%; font-size: 16px;
  border-bottom: 1px solid var(--ink);
}

/* ---------- a live tool embedded on a project page ---------- */
.live.has-app .live-inner { max-width: 1500px; }
.has-app .app-slot { display: block; padding: 0; min-height: 0; background: none; }
.app-frame { display: block; width: 100%; height: min(92vh, 980px); min-height: 620px; border: 0; background: #fff; }
