/* VNgine site theme — "Ambience"
   Sailfish-influenced, not a Silica copy. Dark blue ambience by default;
   a light ambience follows the OS preference, and [data-ambience="light"|"dark"]
   on <html> overrides it.

   Swapping the hue: every colour below derives from --amb-h (hue) and the four
   --amb-* stops. Change those five values and the whole site re-tints.

   IMPORTANT: this file styles the markup this site actually produces —
   header/footer built by assets/js/nav.js (.site-header .bar .brand /
   .site-nav), cards built by assets/js/cards.js (.card .card-body), and the
   hand-written .layout/.sidebar/.tree wiki chrome. It also re-declares the
   legacy --bg/--fg/--accent/... custom properties that assets/css/tool.css
   depends on, aliased to the ambience tokens, so the JSON generator pages
   pick up the same theme instead of falling back to unstyled defaults. */

:root {
  --amb-h: 210;                              /* ambience hue — change me */

  --canvas:        oklch(0.18 0.035 var(--amb-h));
  --amb-top:       oklch(0.40 0.085 var(--amb-h) / 0.85);
  --amb-mid:       oklch(0.16 0.040 var(--amb-h) / 0.62);
  --amb-deep:      oklch(0.12 0.030 var(--amb-h) / 0.90);
  --amb-foot:      oklch(0.33 0.070 var(--amb-h) / 0.75);
  --amb-glow-a:    oklch(0.55 0.110 var(--amb-h) / 0.34);
  --amb-glow-b:    oklch(0.45 0.120 calc(var(--amb-h) + 30) / 0.22);
  --amb-glow-c:    oklch(0.70 0.070 var(--amb-h) / 0.16);
  --texture:       oklch(1 0 0 / 0.055);     /* 3px dot grain */

  --highlight:     oklch(0.80 0.075 var(--amb-h));       /* #8ec6ee-ish  */
  --highlight-up:  oklch(0.90 0.050 var(--amb-h));       /* hover        */
  --highlight-mark:oklch(0.80 0.075 var(--amb-h) / 0.45);/* chevron ring */
  --warn:          oklch(0.78 0.130 70);

  --ink:           oklch(1 0 0 / 0.95);
  --ink-2:         oklch(0.89 0.035 var(--amb-h) / 0.82); /* tinted body  */
  --ink-3:         oklch(0.89 0.035 var(--amb-h) / 0.72); /* mono meta    */
  --ink-faint:     oklch(0.89 0.035 var(--amb-h) / 0.28); /* marks only   */
  --surface:       oklch(1 0 0 / 0.055);                  /* output block */
  --surface-2:     oklch(1 0 0 / 0.09);
  --line:          oklch(1 0 0 / 0.14);

  --font: "Open Sans", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --shell:  1180px;
  --gutter: clamp(20px, 5vw, 64px);
  --measure: 40ch;
  --radius: 8px;

  /* one step larger and lighter than a typical web scale */
  --step-page:    clamp(38px, 7vw, 96px);   /* page header    */
  --step-section: clamp(20px, 2.4vw, 28px); /* section label  */
  --step-entry:   clamp(22px, 2.6vw, 29px); /* entry title    */
  --step-lede:    clamp(16px, 1.7vw, 20px);
  --step-body:    15px;
  --step-meta:    11px;

  --gap-section: clamp(56px, 9vw, 104px);
  --gap-block:   clamp(32px, 5vw, 72px);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* --- legacy tokens: assets/css/tool.css reads these directly --- */
  --bg:          var(--canvas);
  --bg-elev:     var(--surface);
  --bg-elev-2:   var(--surface-2);
  --fg:          var(--ink);
  --fg-dim:      var(--ink-2);
  --fg-faint:    var(--ink-3);
  --accent:      var(--highlight);
  --accent-dim:  var(--highlight-mark);
  --sans: var(--font);
  --page-max: var(--shell);
}

/* Dark by default, following the ambience token values in :root above.
   A light ambience follows the visitor's OS/browser preference; explicit
   [data-ambience="light"|"dark"] on <html> overrides it either way (e.g.
   for a future manual theme toggle). Every token gets a light-tuned value
   here, including --warn — that one was missing before, which is why the
   TODO badges' orange (tuned for a near-black canvas) looked wrong once a
   light canvas was introduced. */
@media (prefers-color-scheme: light) {
  :root:not([data-ambience="dark"]) {
    --canvas:        oklch(0.96 0.010 var(--amb-h));
    --amb-top:       oklch(0.88 0.045 var(--amb-h) / 0.85);
    --amb-mid:       oklch(0.97 0.012 var(--amb-h) / 0.60);
    --amb-deep:      oklch(0.99 0.006 var(--amb-h) / 0.85);
    --amb-foot:      oklch(0.90 0.040 var(--amb-h) / 0.70);
    --amb-glow-a:    oklch(0.80 0.070 var(--amb-h) / 0.30);
    --amb-glow-b:    oklch(0.82 0.060 calc(var(--amb-h) + 30) / 0.20);
    --amb-glow-c:    oklch(0.90 0.050 var(--amb-h) / 0.18);
    --texture:       oklch(0 0 0 / 0.040);

    --highlight:     oklch(0.50 0.100 var(--amb-h));
    --highlight-up:  oklch(0.38 0.100 var(--amb-h));
    --highlight-mark:oklch(0.50 0.100 var(--amb-h) / 0.45);
    --warn:          oklch(0.50 0.150 55);

    --ink:           oklch(0.22 0.030 var(--amb-h));
    --ink-2:         oklch(0.34 0.035 var(--amb-h) / 0.92);
    --ink-3:         oklch(0.40 0.035 var(--amb-h) / 0.90);
    --ink-faint:     oklch(0.40 0.035 var(--amb-h) / 0.30);
    --surface:       oklch(0 0 0 / 0.040);
    --surface-2:     oklch(0 0 0 / 0.065);
    --line:          oklch(0 0 0 / 0.12);
  }
}

:root[data-ambience="light"] {
  --canvas:        oklch(0.96 0.010 var(--amb-h));
  --amb-top:       oklch(0.88 0.045 var(--amb-h) / 0.85);
  --amb-mid:       oklch(0.97 0.012 var(--amb-h) / 0.60);
  --amb-deep:      oklch(0.99 0.006 var(--amb-h) / 0.85);
  --amb-foot:      oklch(0.90 0.040 var(--amb-h) / 0.70);
  --amb-glow-a:    oklch(0.80 0.070 var(--amb-h) / 0.30);
  --amb-glow-b:    oklch(0.82 0.060 calc(var(--amb-h) + 30) / 0.20);
  --amb-glow-c:    oklch(0.90 0.050 var(--amb-h) / 0.18);
  --texture:       oklch(0 0 0 / 0.040);

  --highlight:     oklch(0.50 0.100 var(--amb-h));
  --highlight-up:  oklch(0.38 0.100 var(--amb-h));
  --highlight-mark:oklch(0.50 0.100 var(--amb-h) / 0.45);
  --warn:          oklch(0.50 0.150 55);

  --ink:           oklch(0.22 0.030 var(--amb-h));
  --ink-2:         oklch(0.34 0.035 var(--amb-h) / 0.92);
  --ink-3:         oklch(0.40 0.035 var(--amb-h) / 0.90);
  --ink-faint:     oklch(0.40 0.035 var(--amb-h) / 0.30);
  --surface:       oklch(0 0 0 / 0.040);
  --surface-2:     oklch(0 0 0 / 0.065);
  --line:          oklch(0 0 0 / 0.12);
}

/* ---------------- base ---------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font: 300 17px/1.7 var(--font);
  text-wrap: pretty;
  position: relative;
}

/* the ambience: gradient wash + two glows + dot grain, all fixed */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
body::before {
  background:
    radial-gradient(1200px 620px at 88% -8%, var(--amb-glow-a), transparent 60%),
    radial-gradient(900px 700px at -6% 34%, var(--amb-glow-b), transparent 62%),
    radial-gradient(900px 520px at 50% 112%, var(--amb-glow-c), transparent 66%),
    linear-gradient(180deg, var(--amb-top) 0%, var(--amb-mid) 26%, var(--amb-deep) 58%, var(--amb-foot) 100%);
}
body::after {
  opacity: 0.5;
  background-image: radial-gradient(var(--texture) 0.5px, transparent 0.5px);
  background-size: 3px 3px;
}

a { color: var(--highlight); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover, a:focus-visible { color: var(--highlight-up); }
:focus-visible { outline: 1px solid var(--highlight); outline-offset: 4px; }
::selection { background: var(--highlight); color: var(--canvas); }

img, svg, video { max-width: 100%; height: auto; display: block; }

hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

/* ---------------- type ---------------- */

h1, h2, h3, h4 { margin: 0 0 0.6em; font-weight: 300; letter-spacing: -0.01em; }

/* page header: right-aligned, light, large — the .page hero gets the full
   right-aligned treatment; inside the narrower wiki column it reads better
   left-aligned, still large and light. */
.page > h1, .hero-text h1 {
  font-size: var(--step-page);
  line-height: 1.02;
  letter-spacing: -0.015em;
  text-align: right;
  margin: 0;
}
.layout main h1 {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-align: left;
  margin: 0;
}
.page > h1 + p.lede, .hero-text h1 + p.lede {
  margin: 20px 0 0 auto;
  max-width: 62ch;
  font-size: var(--step-lede);
  color: var(--ink-2);
  text-align: right;
}
.layout main h1 + p.lede {
  margin: 16px 0 0;
  max-width: 62ch;
  font-size: var(--step-lede);
  color: var(--ink-2);
  text-align: left;
}
.lede {
  font-size: var(--step-lede);
  color: var(--ink-2);
}

h2 {
  font-size: var(--step-section);
  color: var(--highlight);
  text-align: right;
  margin: 0 0 clamp(30px, 4vw, 52px);
  font-weight: 300;
}

h3 { font-size: 19px; font-weight: 600; color: var(--ink); }
h4 { font-size: 16px; font-weight: 600; color: var(--ink); }

p, li { font-size: var(--step-body); line-height: 1.75; color: var(--ink-2); }
p { max-width: 68ch; margin: 0.8em 0; }
strong { color: var(--ink); font-weight: 600; }

code, pre, kbd, samp, .mono { font-family: var(--mono); }
code {
  font-size: 0.85em;
  color: var(--highlight);
  background: var(--surface);
  border-radius: 4px;
  padding: 0.12em 0.4em;
}
pre {
  margin: 18px 0 0;
  padding: 24px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink);
  overflow: auto;
}
pre code { color: inherit; background: none; padding: 0; }

blockquote {
  margin: 22px 0 0;
  padding-left: 20px;
  border-left: 2px solid var(--highlight-mark);
  color: var(--ink-2);
}

table { border-collapse: collapse; width: 100%; margin: 1.2rem 0; font-size: 0.93rem; }
th, td { border: 1px solid var(--line); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
th { background: var(--surface); font-weight: 600; color: var(--ink); }
td code { white-space: nowrap; }

/* ---------------- header (built by assets/js/nav.js) ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in oklch, var(--canvas) 78%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .bar {
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(22px, 5vw, 50px);
}
.brand {
  display: inline-flex;
  align-items: baseline;
  font-size: clamp(18px, 2.1vw, 22px);
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--ink);
  padding-bottom: 7px;
  border-bottom: 2px solid transparent;
}
.brand:hover { color: var(--highlight-up); }
.brand .dot { color: var(--highlight); }

.site-nav { display: flex; gap: clamp(22px, 5vw, 50px); flex-wrap: wrap; }
.site-nav a {
  font-size: clamp(17px, 2vw, 20px);
  font-weight: 300;
  color: var(--ink-2);
  padding-bottom: 7px;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--highlight-up); }
.site-nav a.active { color: var(--highlight); border-bottom-color: var(--highlight); }

/* the only affordance mark: a circled chevron, used on the breadcrumb-less pager and cards */
.breadcrumb {
  font-family: var(--mono);
  font-size: var(--step-meta);
  color: var(--ink-3);
  margin-bottom: 14px;
}
.breadcrumb a { color: inherit; }
.breadcrumb a:hover { color: var(--highlight); }

/* ---------------- page shells ---------------- */

.page, .site-header .bar, .site-footer .bar {
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.page {
  padding-block: clamp(40px, 6vw, 72px) clamp(56px, 9vw, 104px);
}
.page.wide { max-width: 1420px; }

.layout {
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-block: clamp(40px, 6vw, 72px) clamp(56px, 9vw, 104px);
  display: grid;
  grid-template-columns: minmax(190px, 232px) minmax(0, 1fr);
  gap: clamp(34px, 5vw, 80px);
  align-items: start;
}
@media (max-width: 780px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static !important; }
}

/* ---------------- wiki sidebar tree ---------------- */

.sidebar { position: sticky; top: 84px; }
.sidebar .tree-title {
  font-family: var(--mono);
  font-size: var(--step-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 14px;
}
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--line); }
.tree a {
  display: block;
  padding: 6px 0;
  font-size: 15px;
  color: var(--ink-2);
}
.tree a:hover { color: var(--highlight); }
.tree a.active { color: var(--highlight); }
.tree .branch-row { display: flex; align-items: center; }
.tree .branch-row > a { flex: 1; }
.tree .twisty {
  background: none;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 0 6px 0 0;
  width: 18px;
  text-align: left;
}
.tree li.collapsed > ul { display: none; }

/* article prose inside <main> */
.layout main h2 { text-align: left; margin-top: clamp(44px, 6vw, 72px); }
.layout main h3 { margin-top: clamp(30px, 4vw, 44px); }
.layout main > * + * { margin-top: 22px; }

/* ---------------- home page: hero media & placeholders ---------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 300px);
  gap: clamp(28px, 6vw, 64px);
  align-items: start;
}
.hero-text { min-width: 0; }
@media (max-width: 720px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero .media { max-width: 240px; margin-inline: auto; }
}

.media { margin: 0; }
.media figcaption {
  margin-top: 12px;
  max-width: var(--measure);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-3);
}
.hero .media figcaption { max-width: none; }

/* a mosaic of screenshot placeholders that tiles into one (near-)rectangle,
   puzzle-piece style, instead of a loose wrapped row. Two 16:9 tiles stack
   in the left column; two 9:16 tiles fill the right two columns at full
   height. With columns at 8fr/5fr/5fr and two equal rows, each cell's own
   aspect ratio already lands within ~1% of its content's native ratio when
   the whole mosaic is held at 2:1 — so nothing has to stretch or letterbox
   to fit. Captions live as a bottom-anchored overlay (the "footer text")
   baked into each tile, so the tile — image plus caption — stays a clean
   rectangle and the mosaic packs edge to edge. */
.mosaic {
  display: grid;
  grid-template-columns: 8fr 5fr 5fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 2 / 1;
  gap: clamp(10px, 1.4vw, 16px);
  margin: clamp(28px, 4vw, 44px) 0 0;
}
.mosaic-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ink-faint);
  border-radius: 18px;
  background: repeating-linear-gradient(135deg, var(--ink-faint) 0 7px, transparent 7px 14px);
}
.mosaic-item:nth-child(1) { grid-column: 1; grid-row: 1; }
.mosaic-item:nth-child(2) { grid-column: 1; grid-row: 2; }
.mosaic-item:nth-child(3) { grid-column: 2; grid-row: 1 / span 2; }
.mosaic-item:nth-child(4) { grid-column: 3; grid-row: 1 / span 2; }

/* a real <img> dropped in later should cover its tile the same way */
.mosaic-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.mosaic-tag {
  position: absolute;
  top: 10px;
  left: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

/* caption as a bottom overlay, not page prose: a fixed dark scrim + light
   text, same convention as the game banner cards, because once these are
   real screenshots their brightness won't follow the site's light/dark
   theme — the scrim has to stay legible either way. */
.mosaic-item figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  margin: 0;
  padding: 28px 14px 12px;
  background: linear-gradient(180deg, transparent, oklch(0.14 0.02 250 / 0.55) 45%, oklch(0.14 0.02 250 / 0.9));
  color: oklch(0.97 0.01 250);
  font-size: 12.5px;
  line-height: 1.5;
  max-width: none;
}

@media (max-width: 700px) {
  .mosaic {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
    aspect-ratio: auto;
    gap: 14px;
  }
  .mosaic-item:nth-child(1), .mosaic-item:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: auto;
    aspect-ratio: 16 / 9;
  }
  .mosaic-item:nth-child(3), .mosaic-item:nth-child(4) {
    grid-column: span 1;
    grid-row: auto;
    aspect-ratio: 9 / 16;
  }
}

/* placeholder: a stand-in image box, diagonal hazard-stripe fill, rounded
   corners, a small mono label pinned to the bottom-left corner. Swap the
   div for a real <img> when there's something to show. */
.placeholder {
  width: 100%;
  border: 1px solid var(--ink-faint);
  border-radius: 18px;
  background: repeating-linear-gradient(135deg, var(--ink-faint) 0 7px, transparent 7px 14px);
  display: flex;
  align-items: flex-end;
  padding: 16px;
  font-family: var(--mono);
  font-size: var(--step-meta);
  line-height: 1.6;
  color: var(--ink-3);
}
.placeholder-portrait { aspect-ratio: 9 / 16; max-width: 280px; }
.placeholder-landscape { aspect-ratio: 16 / 9; }

/* ---------------- entry cards (built by assets/js/cards.js) ---------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  column-gap: clamp(36px, 6vw, 90px);
  row-gap: clamp(34px, 5vw, 52px);
  margin: clamp(32px, 5vw, 56px) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: card;
}
.card {
  counter-increment: card;
  position: relative;
  display: block;
  color: var(--ink);
  padding-left: 44px;
}
.card::before {
  content: counter(card, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--highlight);
}
.card .card-body { padding: 0; }
.card h3 {
  font-size: var(--step-entry);
  font-weight: 300;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
}
.card p { margin-top: 9px; max-width: var(--measure); color: var(--ink-2); }
.card .status {
  font-size: 12px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warn);
  margin-top: 6px;
}
.card:hover h3 { color: var(--highlight); }

/* card with a banner image behind the text */
.card.banner-card {
  padding-left: 0;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  min-height: 190px;
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--line);
}
.card.banner-card::before { display: none; }
.card-banner {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: 50% 38%;
  opacity: 0.6;
  transition: opacity 0.15s var(--ease), transform 0.3s var(--ease);
}
.card.banner-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, oklch(0.12 0.03 var(--amb-h) / 0.12) 0%, oklch(0.12 0.03 var(--amb-h) / 0.65) 45%, oklch(0.12 0.03 var(--amb-h) / 0.92) 100%);
}
.card.banner-card:hover .card-banner { opacity: 0.8; transform: scale(1.03); }
.card.banner-card .card-body { position: relative; z-index: 1; padding: 20px 22px; width: 100%; }

/* ---------------- misc content blocks ---------------- */

.todo {
  border-left: 3px solid var(--warn);
  background: color-mix(in oklch, var(--warn) 10%, transparent);
  padding: 0.8rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-2);
  margin: 1.5rem 0;
  max-width: none;
}
.todo strong { color: var(--warn); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}

img.hero {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin: 0 0 1.5rem;
  display: block;
}

/* ---------------- footer ---------------- */

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: clamp(48px, 8vw, 96px);
}
.site-footer .bar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-block: clamp(24px, 4vw, 32px) clamp(40px, 6vw, 64px);
  font-family: var(--mono);
  font-size: var(--step-meta);
  color: var(--ink-3);
}
.site-footer a { color: var(--ink-3); }
.site-footer a:hover { color: var(--highlight); }

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