/* ============================================================
   Base — reset, primitives, grid helpers
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: clip;                 /* lock the document side-to-side — no horizontal scroll / rubber-band anywhere */
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overscroll-behavior-x: none;      /* no horizontal overscroll chaining (e.g. from the news carousel) */
  min-height: 100vh;
}

/* ——— media loading — a black box + a monospace "LOADING…" typewriter, shown until the media decodes.
   TV slides key off :not(.is-ready) (v3-tv.js); images key off .is-loading (added near-view by the media
   loaders in js/project.js). ——— */
@keyframes ds-type  { 0% { width: 0; } 60%, 100% { width: 10ch; } }
@keyframes ds-caret { 0%, 100% { border-color: transparent; } 50% { border-color: rgba(255,255,255,0.5); } }
.is-loading { position: relative; }
.is-loading::before,
.tv__slide:not(.is-ready)::before {
  content: ""; position: absolute; inset: 0; z-index: 4; background: var(--ink, #111); pointer-events: none;
}
.is-loading::after,
.tv__slide:not(.is-ready)::after {
  content: "LOADING..."; position: absolute; z-index: 5; top: 50%; left: 50%;
  width: 10ch; margin: -0.55em 0 0 -5ch; overflow: hidden; white-space: nowrap;
  font-family: var(--mono, monospace); font-size: clamp(0.6rem, 0.52rem + 0.3vw, 0.74rem);
  letter-spacing: 0; color: rgba(255,255,255,0.9); border-right: 2px solid rgba(255,255,255,0.5);
  animation: ds-type 2s steps(10) infinite, ds-caret 0.7s step-end infinite; pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .is-loading::after, .tv__slide:not(.is-ready)::after { animation: none; width: 10ch; border-right: 0; }
}

img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: #d2d2cf; }
::-webkit-scrollbar-thumb:hover { background: #bcbcb8; }

/* —— Layout primitives ————————————————————————————————— */
.page {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--margin);
}
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: var(--gutter);
}

.rule { border: 0; border-top: 1px solid var(--line); width: 100%; }

/* —— Mono caption / label ————————————————————————————— */
.mono {
  font-family: var(--mono);
  font-size: var(--t-cap);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-feature-settings: "tnum" 1;   /* tabular figures for grid alignment */
}

/* —— Reveal (calm fade-up) ————————————————————————————— */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* —— Faint column grid overlay (toggle with the "g" key) ——— */
.gridlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--margin);
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: var(--gutter);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.gridlines.show { opacity: 1; }
.gridlines span { border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }

/* (variant switcher removed) */
