@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  /* Color palette */
  --canvas: #EEEEEE;
  --paper: #FDFDFC;
  --ink: #141416;
  --ink-secondary: #5A5A5F;
  --link: #334488;
  --void: #0B0C10;
  --stamp: #FF4A17;
  --hairline: #D6D6D2;

  /* Typography scale */
  --t-display: clamp(6rem, 18vw, 19rem);
  --t-h1: 4.768rem;
  --t-h2: 3.052rem;
  --t-h3: 1.953rem;
  --t-h4: 1.5625rem;
  --t-lead: 1.25rem;
  --t-body: 1rem;
  --t-small: 0.8rem;
  --t-label: 0.64rem;

  /* Font families */
  --font-mono: 'IBM Plex Mono', monospace;
  --font-sans: 'IBM Plex Sans', sans-serif;

  /* 8pt spacing scale */
  --space-1: 0.5rem;   /* 8px */
  --space-2: 1rem;     /* 16px */
  --space-3: 1.5rem;   /* 24px */
  --space-4: 2rem;     /* 32px */
  --space-5: 2.5rem;   /* 40px */
  --space-6: 3rem;     /* 48px */
  --space-8: 4rem;     /* 64px */
  --space-10: 5rem;    /* 80px */
  --space-12: 6rem;    /* 96px */
  --space-16: 8rem;    /* 128px */
  --space-20: 10rem;   /* 160px */
  --space-24: 12rem;   /* 192px */
  --space-32: 16rem;   /* 256px */
  --space-40: 20rem;   /* 320px */

  /* Elevation / shadow system (hard offsets, no soft shadows) */
  --elevation-1: 2px 2px 0 var(--ink);
  --elevation-2: 4px 4px 0 var(--stamp);
  --elevation-3: -2px -2px 0 var(--stamp);
  --elevation-inset: inset 0 0 0 1px var(--hairline);
}

/* ── Reset & base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Page wrapper ── */
.page {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-2);
  background: var(--ink);
  color: var(--canvas);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--t-small);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  z-index: 1000;
  transition: top 0.2s ease;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-2);
}

/* ── Grain texture overlay ── */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.grain__field {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20width%3D'300'%20height%3D'300'%3E%3Cfilter%20id%3D'n'%3E%3CfeTurbulence%20type%3D'fractalNoise'%20baseFrequency%3D'0.85'%20numOctaves%3D'4'%20stitchTiles%3D'stitch'%2F%3E%3C%2Ffilter%3E%3Crect%20width%3D'100%25'%20height%3D'100%25'%20filter%3D'url(%23n)'%20opacity%3D'0.6'%2F%3E%3C%2Fsvg%3E");
  background-repeat: repeat;
  background-size: 300px 300px;
  opacity: 0.035;
  mix-blend-mode: multiply;
}

/* ── Story & chapters ── */
.story {
  display: flex;
  flex-direction: column;
  position: relative;
}

.chapter {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-20) var(--space-4);
}

.chapter__inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

.chapter__index {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-secondary);
  margin-bottom: var(--space-4);
  display: block;
}

.chapter__title {
  margin-bottom: var(--space-4);
}

.chapter__line {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  color: var(--ink-secondary);
  margin-bottom: var(--space-2);
}

/* ── Typography tokens ── */
.t-label {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  line-height: 1.2;
}

.t-h3 {
  font-family: var(--font-mono);
  font-size: var(--t-h3);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.t-h2 {
  font-family: var(--font-mono);
  font-size: var(--t-h2);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.t-lead {
  font-family: var(--font-sans);
  font-size: var(--t-lead);
  font-weight: 400;
  line-height: 1.5;
}

.t-body {
  font-family: var(--font-sans);
  font-size: var(--t-body);
  font-weight: 400;
  line-height: 1.55;
}

.t-small {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.t-display {
  font-family: var(--font-mono);
  font-size: var(--t-display);
  font-weight: 700;
  line-height: 0.88;
  letter-spacing: -0.04em;
}

/* ── Utility measures ── */
.measure-narrow {
  max-width: 48ch;
}

.measure {
  max-width: 68ch;
}

/* ── Chapter 00 — The Caret ── */
.chapter--caret {
  background-color: var(--canvas);
  padding-top: 96px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.caret-stage {
  display: flex;
  align-items: center;
  min-height: 1.5em;
  margin-top: var(--space-8);
}

.caret {
  display: inline-block;
  width: 2ch;
  height: 1.2em;
  background-color: var(--ink);
  animation: blink 1.2s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.fold-rule {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: var(--hairline);
}

/* ── Chapter 01 — The Name ── */
.chapter--name {
  background-color: var(--canvas);
  overflow: hidden;
}

.wordmark {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-left: -0.5ch;
}

.wordmark__word {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 0.88;
  letter-spacing: -0.04em;
}

.wordmark__word--offset {
  margin-left: clamp(2rem, 10vw, 12rem);
  color: var(--ink-secondary);
}

/* ── Chapter 02 — The Reservation ── */
.chapter--reservation {
  background-color: var(--canvas);
}

.chapter__lead {
  margin-bottom: var(--space-8);
}

.ledger {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: var(--hairline);
  border: 1px solid var(--hairline);
  max-width: 900px;
}

.ledger__row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background-color: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
  margin-bottom: 2px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.ledger__row:nth-child(odd) {
  background-color: var(--canvas);
}

.ledger__row:hover {
  transform: translate(-1px, -1px);
  background-color: #fff;
}

.ledger__key {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-secondary);
}

.ledger__val {
  font-family: var(--font-mono);
  font-size: var(--t-body);
  font-weight: 400;
  color: var(--ink);
}

/* ── Chapter 03 — The Mirror ── */
.chapter--mirror {
  background-color: var(--void);
  color: var(--canvas);
  overflow: hidden;
  position: relative;
}

.chapter--mirror::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--void) 0%, transparent 20%, transparent 80%, var(--void) 100%);
  pointer-events: none;
}

.mirror__wordmark {
  position: relative;
  font-family: var(--font-mono);
  font-size: var(--t-display);
  font-weight: 700;
  line-height: 0.88;
  letter-spacing: -0.04em;
  color: var(--canvas);
  mix-blend-mode: difference;
  display: inline-block;
  z-index: 1;
}

.mirror__letters {
  display: block;
}

.mirror__rule {
  width: 100%;
  height: 1px;
  background-color: var(--stamp);
  margin-top: var(--space-4);
  position: relative;
  z-index: 1;
}

.mirror__note {
  margin-top: var(--space-6);
  font-family: var(--font-mono);
  font-size: var(--t-small);
  color: var(--ink-secondary);
  position: relative;
  z-index: 1;
}

/* ── Chapter 04 — The Family ── */
.chapter--family {
  background-color: var(--canvas);
  position: relative;
}

.dotfield {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle, var(--ink) 1px, transparent 1px);
  mask-image: radial-gradient(circle, var(--ink) 1px, transparent 1px);
  -webkit-mask-size: 24px 24px;
  mask-size: 24px 24px;
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  opacity: 0.12;
  z-index: 0;
}

.rail {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-8);
  position: relative;
  z-index: 1;
}

.rail__item {
  font-family: var(--font-mono);
  font-size: var(--t-h4);
  font-weight: 500;
  color: var(--ink-secondary);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--hairline);
  background-color: var(--canvas);
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
  cursor: default;
}

.rail__item:hover {
  background-color: var(--ink);
  color: var(--canvas);
  border-color: var(--ink);
  transform: translateY(-2px);
}

/* ── Chapter 05 — The Handoff ── */
.chapter--handoff {
  background-color: var(--canvas);
  text-align: center;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.handoff__link {
  display: inline-block;
  margin-top: var(--space-8);
}

.link {
  font-family: var(--font-sans);
  font-size: var(--t-lead);
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.link:hover {
  border-bottom-color: var(--link);
  color: #2a3666;
}

.stamp {
  display: inline-block;
  margin-top: var(--space-6);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--stamp);
  border: 2px solid var(--stamp);
  transform: rotate(-2deg);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 2% 90%, 0 80%, 2% 70%, 0 60%, 2% 50%, 0 40%, 2% 30%, 0 20%, 2% 10%, 0 0);
}

/* ── Footer ── */
.site-footer {
  background-color: var(--canvas);
  padding: var(--space-12) var(--space-4);
  border-top: 1px solid var(--hairline);
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.site-footer__mark {
  font-family: var(--font-mono);
  font-size: var(--t-h4);
  font-weight: 600;
  color: var(--ink);
}

.site-nav {
  width: 100%;
}

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  list-style: none;
}

.site-nav__item {
  /* no additional styles needed */
}

.site-nav__link {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  color: var(--ink-secondary);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  transition: color 0.2s ease;
}

.site-nav__link:hover {
  color: var(--link);
}

.site-footer__meta {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  color: var(--ink-secondary);
}

.site-footer__legal {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-secondary);
}

/* ── Focus ring (orange) ── */
:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
}

/* ── Scroll-driven reveal animations ── */
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chapter__inner > * {
  animation: reveal linear both;
  animation-timeline: view();
  animation-range: entry 10% cover 30%;
}

/* ── Responsive adjustments ── */
@media (min-width: 768px) {
  .chapter {
    padding: var(--space-32) var(--space-8);
  }

  .ledger__row {
    grid-template-columns: 1fr 3fr;
    padding: var(--space-4) var(--space-5);
  }

  .site-footer__inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .site-nav {
    width: auto;
  }

  .site-footer__mark {
    font-size: var(--t-h3);
  }
}

@media (min-width: 1024px) {
  .chapter {
    padding: var(--space-40) var(--space-12);
  }

  .wordmark__word--offset {
    margin-left: clamp(4rem, 14vw, 16rem);
  }

  .mirror__wordmark {
    font-size: clamp(8rem, 22vw, 24rem);
  }
}