/* ============================================================
   Win16, Repaired — design system
   Colourful retro-GUI editorial. Cream paper, ink linework,
   hard offset shadows, colour-coded subsystems. Original chrome
   (not a recreation of any product's UI).
   ============================================================ */

:root {
  /* paper + ink */
  --paper:      oklch(0.962 0.012 90);
  --paper-2:    oklch(0.938 0.016 88);
  --card:       oklch(0.995 0.004 95);
  --ink:        oklch(0.215 0.018 60);
  --ink-soft:   oklch(0.40 0.02 60);
  --ink-faint:  oklch(0.55 0.018 60);
  --line:       oklch(0.215 0.018 60);
  --hair:       oklch(0.80 0.012 80);

  /* subsystem colours (also defined inline in JS for canvas) */
  --c-loader:   #2D6BE0;
  --c-kernel:   #8A45D6;
  --c-memory:   #1F9B59;
  --c-user:     #E8553B;
  --c-gdi:      #0E9BA6;
  --c-resource: #D23F8C;
  --c-control:  #E0871C;
  --c-dialog:   #C0395F;

  --shadow:     6px 6px 0 var(--ink);
  --shadow-sm:  3px 3px 0 var(--ink);
  --shadow-lg:  10px 10px 0 var(--ink);

  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --disp: "Bricolage Grotesque", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;

  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(oklch(0.215 0.018 60 / 0.045) 1px, transparent 1px),
    linear-gradient(90deg, oklch(0.215 0.018 60 / 0.045) 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--c-user); color: #fff; }

a { color: inherit; }

.mono { font-family: var(--mono); }
.disp { font-family: var(--disp); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

/* ---------- generic bits ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.eyebrow::before {
  content: "";
  width: 22px; height: 0;
  border-top: 2px solid currentColor;
}

.section { padding: 78px 0; border-top: 2px solid var(--line); }
.section.tight { padding: 56px 0; }

.section-head { max-width: 760px; margin-bottom: 40px; }
.section-head h2 {
  font-family: var(--disp);
  font-weight: 800;
  font-size: clamp(30px, 4.4vw, 50px);
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin: 14px 0 16px;
}
.section-head p {
  font-size: 19px;
  color: var(--ink-soft);
  margin: 0;
  max-width: 64ch;
}

/* ---------- chips / tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border: 2px solid var(--ink);
  background: var(--card);
  border-radius: 999px;
  white-space: nowrap;
}
.chip .swatch { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--ink); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.03em;
  padding: 11px 18px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .07s ease, box-shadow .07s ease, background .12s ease;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--c-user); color: #fff; }
.btn.cyan { background: var(--c-gdi); color: #fff; }

/* ============================================================
   WINDOW CHROME  (original, colour-coded)
   ============================================================ */
.win {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.win-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--barcol, var(--ink));
  color: #fff;
  border-bottom: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
}
.win-bar .dots { display: flex; gap: 5px; }
.win-bar .dots i {
  width: 11px; height: 11px; border-radius: 50%;
  background: #fff; opacity: 0.85; border: 1.5px solid rgba(0,0,0,.35);
  display: block;
}
.win-bar .title { font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-bar .ctrls { display: flex; gap: 4px; }
.win-bar .ctrls b {
  width: 16px; height: 14px;
  background: rgba(255,255,255,.85);
  border: 1.5px solid rgba(0,0,0,.4);
  display: grid; place-items: center;
  font-size: 10px; color: var(--ink); line-height: 1;
  border-radius: 2px;
}
.win-body { padding: 16px 18px; }

/* ============================================================
   HERO
   ============================================================ */
.hero { padding: 56px 0 40px; position: relative; overflow: hidden; }
.hero-top {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em;
  color: var(--ink-soft); text-transform: uppercase;
  padding-bottom: 18px; border-bottom: 2px solid var(--line);
}
.hero-top a { text-decoration: none; border-bottom: 2px solid var(--c-loader); padding-bottom: 1px; color: var(--ink); }
.hero-grid {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px;
  align-items: center; padding-top: 44px;
}
.hero h1 {
  font-family: var(--disp);
  font-weight: 800;
  font-size: clamp(46px, 7vw, 92px);
  line-height: 0.92;
  letter-spacing: -0.035em;
  margin: 0 0 22px;
}
.hero h1 .tint { position: relative; white-space: nowrap; }
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--c-user), var(--c-resource));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lede { font-size: 20px; color: var(--ink-soft); max-width: 52ch; margin: 0 0 26px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 26px; }

.statline {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  border: 2px solid var(--ink); border-radius: 6px; overflow: hidden;
  box-shadow: var(--shadow); background: var(--card);
}
.statline .cell { padding: 16px 14px; border-right: 2px solid var(--ink); }
.statline .cell:last-child { border-right: none; }
.statline .v { font-family: var(--disp); font-weight: 800; font-size: 30px; line-height: 1; }
.statline .k { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-top: 7px; }
.statline .s { font-size: 13px; color: var(--ink-faint); margin-top: 2px; font-family: var(--serif); }

/* stacked window motif in hero */
.hero-stack { position: relative; height: 380px; }
.hero-stack .win { position: absolute; width: 78%; }
.hero-stack .w1 { top: 0; left: 0; --barcol: var(--c-gdi); z-index: 3; }
.hero-stack .w2 { top: 70px; left: 16%; --barcol: var(--c-user); z-index: 2; }
.hero-stack .w3 { top: 150px; left: 4%; --barcol: var(--c-loader); z-index: 1; width: 86%; }
.hero-stack .win-body { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }
.hero-stack .pix { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 8px; }
.hero-stack .pix i { aspect-ratio: 1; border-radius: 2px; display:block; }

/* ============================================================
   INTRO / NARRATIVE
   ============================================================ */
.intro-lede {
  font-family: var(--disp);
  font-weight: 500;
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.22;
  letter-spacing: -0.015em;
  max-width: 22ch;
  margin: 0;
}
.intro-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 36px; }
.prose-block h3 {
  font-family: var(--disp); font-weight: 700; font-size: 21px;
  letter-spacing: -0.01em; margin: 0 0 8px;
}
.prose-block p { margin: 0; color: var(--ink-soft); font-size: 17.5px; }
.prose-block { padding: 22px; border: 2px solid var(--ink); border-radius: 6px; background: var(--card); box-shadow: var(--shadow-sm); }
.prose-block:nth-child(1) { border-top: 7px solid var(--c-loader); }
.prose-block:nth-child(2) { border-top: 7px solid var(--c-gdi); }
.prose-block:nth-child(3) { border-top: 7px solid var(--c-user); grid-column: 1 / -1; }

/* ============================================================
   NE ANATOMY  (interactive diagram)
   ============================================================ */
.anatomy { display: grid; grid-template-columns: 300px 1fr; gap: 26px; align-items: start; }
.ne-file { display: flex; flex-direction: column; gap: 0; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); background: var(--card); }
.ne-seg {
  padding: 13px 15px; cursor: pointer; border-bottom: 2px solid var(--ink);
  font-family: var(--mono); font-size: 13px; position: relative;
  transition: background .12s ease, padding-left .12s ease; background: var(--card);
  display: flex; align-items: center; gap: 10px;
}
.ne-seg:last-child { border-bottom: none; }
.ne-seg .tag { width: 9px; height: 22px; border-radius: 2px; border: 1.5px solid var(--ink); flex: none; }
.ne-seg .nm { font-weight: 500; }
.ne-seg .sz { margin-left: auto; font-size: 11px; color: var(--ink-faint); }
.ne-seg:hover { background: var(--paper-2); padding-left: 20px; }
.ne-seg.active { background: var(--seg, var(--ink)); color: #fff; }
.ne-seg.active .sz { color: rgba(255,255,255,.8); }
.ne-detail { border: 2px solid var(--ink); border-radius: 6px; padding: 24px; box-shadow: var(--shadow); background: var(--card); min-height: 280px; }
.ne-detail .lbl { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.ne-detail h3 { font-family: var(--disp); font-weight: 800; font-size: 27px; margin: 8px 0 14px; letter-spacing: -0.02em; }
.ne-detail p { margin: 0 0 12px; color: var(--ink-soft); font-size: 17px; }
.ne-detail .pin { font-family: var(--mono); font-size: 12.5px; padding: 9px 12px; border-left: 3px solid var(--seg, var(--ink)); background: var(--paper-2); border-radius: 0 4px 4px 0; }

/* ============================================================
   APPROACH cards
   ============================================================ */
.approach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.approach-card { padding: 22px 24px; border: 2px solid var(--ink); border-radius: 6px; background: var(--card); box-shadow: var(--shadow-sm); }
.approach-card .n { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); letter-spacing: 0.1em; }
.approach-card h4 { font-family: var(--disp); font-weight: 700; font-size: 20px; margin: 6px 0 10px; letter-spacing: -0.01em; }
.approach-card p { margin: 0; font-size: 16.5px; color: var(--ink-soft); }

/* ============================================================
   SCOREBOARD
   ============================================================ */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.app-cell {
  border: 2px solid var(--ink); border-radius: 6px; background: var(--card);
  box-shadow: var(--shadow-sm); overflow: hidden; cursor: default;
  transition: transform .08s ease, box-shadow .08s ease;
}
.app-cell:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }
.app-cell .top { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px; border-bottom: 2px solid var(--ink); }
.app-cell .nm { font-family: var(--mono); font-size: 13.5px; font-weight: 500; }
.app-cell .note { padding: 11px 13px; font-size: 15px; color: var(--ink-soft); line-height: 1.45; }
.tier { font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em; padding: 3px 7px; border: 1.5px solid var(--ink); border-radius: 3px; text-transform: uppercase; }
.tier.t3 { background: var(--c-memory); color: #fff; }
.tier.t2 { background: var(--c-control); color: #fff; }
.tier.t1 { background: var(--paper-2); color: var(--ink); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 18px; font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }

/* ============================================================
   FIXES GALLERY
   ============================================================ */
.filterbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.fbtn {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.02em;
  padding: 8px 13px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--card); cursor: pointer; color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px;
  transition: transform .06s ease;
}
.fbtn .swatch { width: 11px; height: 11px; border-radius: 3px; border: 1.5px solid var(--ink); }
.fbtn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.fbtn[aria-pressed="true"] .swatch { border-color: var(--paper); }
.fbtn.on-col[aria-pressed="true"] { background: var(--fc); border-color: var(--fc); color: #fff; }
.fbtn:active { transform: scale(0.96); }

.fcount { font-family: var(--mono); font-size: 12.5px; color: var(--ink-faint); margin-left: auto; }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
.fcard {
  text-align: left; cursor: pointer; padding: 0; border: 2px solid var(--ink);
  border-radius: 6px; background: var(--card); box-shadow: var(--shadow-sm);
  overflow: hidden; transition: transform .09s ease, box-shadow .09s ease;
  display: flex; flex-direction: column; font-family: var(--serif); color: var(--ink);
}
.fcard:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--ink); }
.fcard:active { transform: translate(1px,1px); box-shadow: 2px 2px 0 var(--ink); }
.fcard .fbar { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-bottom: 2px solid var(--ink); color: #fff; font-family: var(--mono); font-size: 11.5px; }
.fcard .fbar .num { font-weight: 700; }
.fcard .fbar .cat { margin-left: auto; opacity: 0.9; letter-spacing: 0.05em; text-transform: uppercase; font-size: 10px; }
.fcard .fbody { padding: 14px 15px 16px; flex: 1; display: flex; flex-direction: column; }
.fcard .ftitle { font-family: var(--disp); font-weight: 700; font-size: 19px; line-height: 1.1; letter-spacing: -0.01em; margin-bottom: 8px; }
.fcard .fsym { font-size: 15px; color: var(--ink-soft); line-height: 1.4; flex: 1; }
.fcard .ffoot { display: flex; align-items: center; justify-content: space-between; margin-top: 13px; }
.fcard .ord { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.spanners { letter-spacing: 1px; font-size: 13px; }
.fcard.toychip .ftitle::after {
  content: "▶ demo"; font-family: var(--mono); font-size: 9.5px; font-weight: 400;
  vertical-align: middle; margin-left: 8px; padding: 2px 6px; border-radius: 3px;
  background: var(--fc); color: #fff; letter-spacing: 0.05em;
}

/* ============================================================
   MODAL / case file
   ============================================================ */
.modal-scrim {
  position: fixed; inset: 0; background: oklch(0.215 0.018 60 / 0.55);
  backdrop-filter: blur(2px); z-index: 90;
  display: grid; place-items: center; padding: 24px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal {
  width: min(720px, 100%); max-height: 90vh; overflow: auto;
  --barcol: var(--seg);
  animation: pop .18s cubic-bezier(.2,.8,.3,1);
}
.modal .win-body { padding: 0; }
.case-head { padding: 22px 26px 16px; border-bottom: 2px solid var(--ink); }
.case-head .meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; font-family: var(--mono); font-size: 12px; }
.case-head h3 { font-family: var(--disp); font-weight: 800; font-size: clamp(26px, 4vw, 36px); letter-spacing: -0.025em; line-height: 1.02; margin: 0; }
.case-body { padding: 8px 26px 26px; }
.case-row { padding: 18px 0; border-bottom: 1px solid var(--hair); }
.case-row:last-child { border-bottom: none; }
.case-row .rl { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--seg); margin-bottom: 7px; display: flex; align-items: center; gap: 8px; }
.case-row .rl::before { content: ""; width: 7px; height: 7px; background: var(--seg); border-radius: 50%; }
.case-row p { margin: 0; font-size: 17.5px; color: var(--ink); line-height: 1.55; }
.case-row.war p { font-style: italic; color: var(--ink-soft); }
.case-row.unlocks p { color: var(--ink); }
.case-row.unlocks { background: var(--paper-2); margin: 0 -26px; padding: 18px 26px; border-bottom: 1px solid var(--hair); }

.kbd-hint { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); text-align: center; padding: 12px; }

/* toy mount inside modal */
.toy { border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; margin-top: 14px; background: var(--paper-2); }
.toy-head { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; padding: 8px 12px; border-bottom: 2px solid var(--ink); color: #fff; background: var(--seg); }
.toy-body { padding: 16px; }
.toy .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toy canvas { image-rendering: pixelated; border: 2px solid var(--ink); border-radius: 4px; background: #000; }
.toy select, .toy button.t {
  font-family: var(--mono); font-size: 12px; padding: 7px 10px;
  border: 2px solid var(--ink); border-radius: 4px; background: var(--card); cursor: pointer;
}
.toy .legend2 { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); margin-top: 10px; line-height: 1.5; }

/* before/after palette toy */
.swatchgrid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 2px; }
.swatchgrid i { aspect-ratio: 1; display: block; border-radius: 1px; }

/* message queue toy */
.mq { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mq .pane { border: 2px solid var(--ink); border-radius: 5px; background: var(--card); overflow: hidden; }
.mq .pane h5 { margin: 0; font-family: var(--mono); font-size: 11px; padding: 7px 10px; border-bottom: 2px solid var(--ink); letter-spacing: 0.06em; }
.mq .lane { height: 120px; padding: 8px; display: flex; flex-direction: column-reverse; gap: 4px; overflow: hidden; }
.mq .msg { font-family: var(--mono); font-size: 11px; padding: 4px 7px; border-radius: 3px; color: #fff; }

/* ============================================================
   CLOSING
   ============================================================ */
.closing { padding: 70px 0 30px; border-top: 2px solid var(--line); }
.next-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-top: 26px; }
.next-card { padding: 18px 20px; border: 2px solid var(--ink); border-radius: 6px; background: var(--card); box-shadow: var(--shadow-sm); }
.next-card h4 { font-family: var(--disp); font-weight: 700; font-size: 18px; margin: 0 0 6px; }
.next-card p { margin: 0; font-size: 15.5px; color: var(--ink-soft); }

.site-foot { border-top: 2px solid var(--line); margin-top: 40px; padding: 30px 0 60px; display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); letter-spacing: 0.06em; }
.site-foot a { color: var(--ink); }

/* status bar */
.statusbar {
  position: sticky; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--paper);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  padding: 9px 18px; border-top: 2px solid var(--ink);
}
.statusbar .blink { width: 8px; height: 14px; background: var(--c-memory); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.statusbar .quip { flex: 1; }
.statusbar .right { opacity: 0.7; }

/* easter-egg dialog */
.dlg-scrim { position: fixed; inset: 0; background: oklch(0.215 0.018 60 / 0.45); z-index: 95; display: grid; place-items: center; animation: fade .12s ease; }
.dlg { width: min(420px, 92vw); --barcol: var(--c-dialog); animation: pop .16s ease; }
.dlg .win-body { padding: 22px; text-align: center; }
.dlg .ico { font-size: 40px; }
.dlg p { font-size: 17px; margin: 12px 0 18px; }
.dlg .btns { display: flex; gap: 10px; justify-content: center; }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-stack { height: 320px; }
  .intro-cols { grid-template-columns: 1fr; }
  .prose-block:nth-child(3) { grid-column: auto; }
  .anatomy { grid-template-columns: 1fr; }
  .approach-grid { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .next-grid { grid-template-columns: 1fr; }
  .statline { grid-template-columns: repeat(2, 1fr); }
  .statline .cell:nth-child(2) { border-right: none; }
  .statline .cell:nth-child(1), .statline .cell:nth-child(2) { border-bottom: 2px solid var(--ink); }
}
@media (max-width: 560px) {
  body { font-size: 17px; }
  .wrap { padding: 0 18px; }
  .board { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: 1fr; }
  .mq { grid-template-columns: 1fr; }
  .section { padding: 54px 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; }
}
