/* ==========================================================================
   ARSENE GAME STUDIO — layout: grid, chrome, section rhythm, breakpoints
   phone <640 · tablet 640–899 · desktop ≥900 · wide ≥1800   (brief §2.3, §9)
   ========================================================================== */

/* ---- containers ---------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: var(--col-gap);
}

/* the page sits to the right of the spine rail on desktop */
main, .colophon { position: relative; z-index: var(--z-content); }
@media (min-width: 900px) {
  main, .colophon { margin-left: var(--spine-w); }
}

/* every chapter: vertical rhythm + the section head (folio above a drawn rule) */
.chapter { position: relative; padding-block: var(--section-y); }
.section-head { margin-bottom: var(--space-6); }
.folio { color: var(--muted); margin-bottom: var(--space-2); }
.rule {
  height: var(--hairline);
  background: var(--line-strong);
  transform-origin: 0 50%;
  z-index: var(--z-rules);
}

/* plates: separated by hairlines, never by shadow */
.plate {
  position: relative;
  display: block;
  background: var(--plate);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius);
}
.hairline-top    { border-top: var(--hairline) solid var(--line); }
.hairline-bottom { border-bottom: var(--hairline) solid var(--line); }

/* ---- skip link (z 90, visible on focus) --------------------------------- */
.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-4);
  background: var(--paper);
  color: var(--ink);
  transform: translateY(-200%);
}
.skip-link:focus, .skip-link:focus-visible {
  transform: none;
  outline-color: var(--rose);
}

/* ---- top bar (fixed, 64px, transparent, z 50) --------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-chrome);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: var(--gutter);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
@media (min-width: 900px) {
  .topbar { left: var(--spine-w); }
}
.topbar__brand {
  position: relative;
  display: block;
  width: 140px;
  height: 29px;
}
.topbar__logo {
  width: 140px;
  height: 29px;
  max-width: 160px;
  transition: opacity 200ms var(--ease-expo);
}
.topbar__seal {
  position: absolute;
  left: 0; top: 50%;
  width: 32px; height: 32px;
  transform: translateY(-50%);
  color: var(--rose);
  opacity: 0;
  transition: opacity 200ms var(--ease-expo);
}
.topbar.is-scrolled .topbar__logo { opacity: 0; }
.topbar.is-scrolled .topbar__seal { opacity: 1; }
.topbar__controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* ---- spine (desktop rail, fixed left 56px, z 50) ------------------------ */
.spine {
  display: none;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: var(--z-chrome);
  width: var(--spine-w);
  border-right: var(--hairline) solid var(--line);
  background: var(--ink);
}
@media (min-width: 900px) {
  .spine { display: block; }
}
.spine__list {
  position: absolute;
  left: 50%;
  top: calc(100% - var(--space-6));
  display: flex;
  align-items: center;
  gap: var(--space-5);
  height: 44px;
  white-space: nowrap;
  transform-origin: 0 0;
  transform: rotate(-90deg) translate(0, -50%);
}
.spine__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 44px;
  color: var(--muted);
}
.spine__glyph {
  display: inline-block;
  width: 10px; height: 10px;
  color: currentColor;
}
.spine__num {
  display: inline-block;
  height: 44px;
  overflow: hidden;
  line-height: 44px;
}
.spine__num-inner {
  display: inline-block;
  font-size: 11px;
  line-height: 44px;
  --wdth: 62;
  transition: color var(--t-micro) var(--ease-expo);
}
.spine__label { font-size: 11px; }
.spine__item.is-active .spine__link { color: var(--paper); }
.spine__item.is-active .spine__glyph { color: var(--hue); }
.spine__item.is-active .spine__num-inner {
  font-size: 44px;
  color: var(--hue);
  --wdth: 100;
}
.spine__link:hover { color: var(--paper); }

/* ---- mobile strip (<900, fixed bottom 44px, z 55) ----------------------- */
.strip {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-strip);
  height: var(--strip-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: var(--gutter);
  background: var(--plate);
  border-top: var(--hairline) solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.strip__chapter { color: var(--paper); }
.strip__index {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--paper);
}
@media (min-width: 900px) {
  .strip { display: none; }
}
/* make room for the strip at the bottom of the document on small screens */
@media (max-width: 899px) {
  .colophon { padding-bottom: var(--strip-h); }
}

/* ---- full-viewport sections reserve their height (CLS 0, brief §8.4) --- */
.cover { height: 100svh; min-height: 480px; }
.gallery__stage { height: 100svh; }

/* ---- no horizontal overflow at any width -------------------------------- */
.cover, .ticker__strip, .gallery__stage, .colophon__mark, .ledger__brief, .word-stage { overflow: hidden; }
.drift { overflow: hidden; }

/* ---- wide (≥1800): grid capped, gutters grow ----------------------------- */
@media (min-width: 1800px) {
  .container { padding-inline: max(var(--gutter), calc((100% - var(--content-max)) / 2 + var(--gutter))); }
}
