/* ==========================================================================
   Base — reset, document defaults, typography, layout primitives, and the
   two shape primitives every component is built from (.block, .hud).
   ========================================================================== */

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  /* In-page anchors must clear the fixed nav. */
  scroll-padding-top: calc(var(--nav-h) + 1.25rem);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--night-950);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

img {
  height: auto;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 750;
  line-height: 1.04;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); line-height: 1.15; letter-spacing: -0.015em; }
h4 { font-size: var(--text-lg); line-height: 1.25; letter-spacing: -0.01em; font-weight: 700; }

p {
  margin: 0;
  text-wrap: pretty;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--algo-sky);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--t-fast);
}

a:hover {
  color: var(--ink);
}

strong {
  color: var(--ink);
  font-weight: 600;
}

button {
  font: inherit;
  color: inherit;
}

code,
kbd {
  font-family: var(--font-hud);
  font-size: 0.9em;
}

code {
  padding: 0.1em 0.4em;
  background: var(--night-700);
  color: var(--oasis-lime);
}

::selection {
  background: var(--oasis-lime);
  color: var(--ink-on-accent);
}

:focus-visible {
  outline: 2px solid var(--algo-sky);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: var(--s-3);
  left: var(--s-3);
  z-index: var(--z-toast);
  padding: var(--s-3) var(--s-4);
  background: var(--oasis-lime);
  color: var(--ink-on-accent);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */

.wrap {
  width: min(100% - var(--gutter) * 2, var(--w-page));
  margin-inline: auto;
}

.section {
  position: relative;
  padding-block: var(--section-y);
}

.section--tight {
  padding-block: calc(var(--section-y) * 0.6);
}

/* A raised band: one step up the surface ladder, edged with hairlines. */
.section--band {
  background: var(--night-900);
  border-block: 1px solid var(--line);
}

.stack > * + * {
  margin-top: var(--s-4);
}

.grid {
  display: grid;
  gap: var(--s-5);
}

/* Grid children default to min-width: auto, which lets one wide child (a
   table, a scrolling link row) push the whole page sideways on a phone. */
.grid > *,
.split > *,
.with-index > *,
.steps > *,
.field > * {
  min-width: 0;
}

@media (min-width: 720px) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1040px) {
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
}

/* --------------------------------------------------------------------------
   .hud — the game's own lettering, for labels and numerals only.
   -------------------------------------------------------------------------- */

.hud {
  font-family: var(--font-hud);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  /* The face is drawn on a pixel grid; smoothing blurs it. */
  -webkit-font-smoothing: none;
  font-smooth: never;
}

/* --------------------------------------------------------------------------
   .block — the site's signature surface. Corners are stepped by one "pixel"
   (--notch) instead of rounded, the way a rounded rect is drawn in pixel art.

   clip-path would also clip a real border at the corners, so the edge is
   painted instead: the element's own background is the border colour, and
   ::before, inset by the border width and clipped to the same stepped shape,
   paints the fill on top of it.
   -------------------------------------------------------------------------- */

.block {
  --n: var(--notch);
  --block-fill: var(--night-800);
  --block-edge: var(--line-strong);
  --block-bw: 1px;
  position: relative;
  isolation: isolate;
  background: var(--block-edge);
  clip-path: polygon(
    0 var(--n), var(--n) var(--n), var(--n) 0,
    calc(100% - var(--n)) 0, calc(100% - var(--n)) var(--n), 100% var(--n),
    100% calc(100% - var(--n)), calc(100% - var(--n)) calc(100% - var(--n)), calc(100% - var(--n)) 100%,
    var(--n) 100%, var(--n) calc(100% - var(--n)), 0 calc(100% - var(--n))
  );
}

.block::before {
  content: "";
  position: absolute;
  inset: var(--block-bw);
  z-index: -1;
  background: var(--block-fill);
  clip-path: polygon(
    0 var(--n), var(--n) var(--n), var(--n) 0,
    calc(100% - var(--n)) 0, calc(100% - var(--n)) var(--n), 100% var(--n),
    100% calc(100% - var(--n)), calc(100% - var(--n)) calc(100% - var(--n)), calc(100% - var(--n)) 100%,
    var(--n) 100%, var(--n) calc(100% - var(--n)), 0 calc(100% - var(--n))
  );
}

/* Focus rings are clipped along with everything else, so draw them inside. */
.block:focus-visible,
.block:has(> a:focus-visible:only-child) {
  outline-offset: -5px;
}

/* --------------------------------------------------------------------------
   Section heading pattern: HUD eyebrow → headline → lede.
   -------------------------------------------------------------------------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  color: var(--oasis-lime);
  font-size: var(--text-xs);
}

/* A single lit "pixel" ahead of the label. */
.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.eyebrow--sky {
  color: var(--algo-sky);
}

.head {
  max-width: 46rem;
  margin-bottom: var(--s-7);
}

.head--center {
  margin-inline: auto;
  text-align: center;
}

.head--center .eyebrow {
  justify-content: center;
}

.lede {
  margin-top: var(--s-5);
  color: var(--ink-soft);
  font-size: var(--text-lg);
  line-height: 1.6;
  max-width: 40rem;
}

.head--center .lede {
  margin-inline: auto;
}

/* The one accent word in a headline. */
.lit {
  background: var(--oasis-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lit--sky {
  background: linear-gradient(180deg, #d6f1ff 0%, var(--algo-blue) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

/* --------------------------------------------------------------------------
   Scroll reveal. Content is visible by default; only once site.js has run
   (html.js) do un-revealed elements start hidden, so a script failure can
   never leave the page blank.
   -------------------------------------------------------------------------- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 70ms);
}

.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* --------------------------------------------------------------------------
   Page transitions — moving between pages cross-fades instead of flashing,
   so the site reads as one place. Native (no script); browsers without it
   navigate as before. The nav bar is named so it holds still while the page
   beneath it changes.
   -------------------------------------------------------------------------- */

@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--t-base);
  animation-timing-function: var(--ease-out);
}

.nav {
  view-transition-name: site-nav;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .js [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
