/* ============================================
   THE ERA OF COMPUTATIONAL DESIGN — Design Tokens
   ============================================ */
:root {
  --bg: #1A1816;
  --surface: #22201D;
  --surface-hover: #2D2A26;
  --border: #3D3630;
  --border-subtle: rgba(255,255,255,0.06);
  --text-primary: #E8E2DA;
  --text-secondary: #A69985;
  --text-muted: #73676D;
  --accent: #C8A064;
  --success: #7EC896;
  --error: #D4756A;
  --warning: #D4A054;
  --info: #6BA3BE;
  --purple: #9B7DB8;
  --teal: #6BA3BE;
  --deep-tan: #856B4E;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;
  --sp-3xl: 64px;
  --sp-4xl: 96px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   LIGHT MODE
   ============================================ */
html[data-theme="light"] {
  --bg: #F5F2EE;
  --surface: #EBE7E1;
  --surface-hover: #E2DDD6;
  --border: #D1C9BE;
  --border-subtle: rgba(0,0,0,0.06);
  --text-primary: #3D3630;
  --text-secondary: #736B5F;
  --text-muted: #A09790;
  --accent: #A07830;
  --success: #3D8A5A;
  --error: #B8483E;
  --warning: #B08030;
  --info: #3D7A8F;
  --purple: #7B5D9E;
  --teal: #3D7A8F;
  --deep-tan: #A68860;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #F5F2EE;
    --surface: #EBE7E1;
    --surface-hover: #E2DDD6;
    --border: #D1C9BE;
    --border-subtle: rgba(0,0,0,0.06);
    --text-primary: #3D3630;
    --text-secondary: #736B5F;
    --text-muted: #A09790;
    --accent: #A07830;
    --success: #3D8A5A;
    --error: #B8483E;
    --warning: #B08030;
    --info: #3D7A8F;
    --purple: #7B5D9E;
    --teal: #3D7A8F;
    --deep-tan: #A68860;
  }
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-secondary);
  line-height: 1.7;
  overflow-x: hidden;
}

::selection {
  background: rgba(200, 160, 100, 0.3);
  color: var(--text-primary);
}

html[data-theme="light"] ::selection {
  background: rgba(160, 120, 48, 0.25);
}

a { color: var(--accent); text-decoration: none; }
strong { color: var(--text-primary); font-weight: 500; }
em { font-style: italic; color: var(--text-primary); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  border: 1px solid var(--border-subtle);
}


/* ============================================
   HERO
   ============================================ */
.hero {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.hero__content {
  position: relative;
  z-index: 1;
}

.hero__title {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.hero__title-line {
  display: block;
  opacity: 0;
  transform: translateY(30px);
}

.hero__title-line--1 {
  font-family: var(--font-body);
  font-size: clamp(0.875rem, 2vw, 1.125rem);
  font-weight: 300;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.hero__title-line--2 {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 7vw, 5rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero__title-line--3 {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 7vw, 5rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero__subtitle {
  margin-top: var(--sp-2xl);
  font-size: 0.9375rem;
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(20px);
}

.hero__subtitle strong {
  color: var(--text-secondary);
}

.hero__scroll-hint {
  position: absolute;
  bottom: var(--sp-2xl);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  opacity: 0;
}

.hero__scroll-dot {
  animation: hero-scroll-bob 2s ease-in-out infinite;
}

@keyframes hero-scroll-bob {
  0%, 100% { cy: 8; }
  50% { cy: 16; }
}


/* ============================================
   PROLOGUE
   ============================================ */
.prologue {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-xl);
  position: relative;
  overflow: hidden;
}

.prologue::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(200,160,100,0.04) 0%, transparent 70%);
  pointer-events: none;
}

html[data-theme="light"] .prologue::before {
  background: radial-gradient(ellipse at center, rgba(160,120,48,0.04) 0%, transparent 70%);
}

.prologue__content {
  max-width: 700px;
}

.prologue__line {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.75rem);
  color: var(--text-secondary);
  line-height: 1.4;
  opacity: 0;
  transform: translateY(20px);
}

.prologue__line--2 {
  margin-top: var(--sp-lg);
  color: var(--text-primary);
}

.prologue__line--3 {
  margin-top: var(--sp-lg);
  color: var(--text-primary);
}

.prologue__line--3 em {
  color: var(--accent);
  font-style: italic;
}


/* ============================================
   TYPOGRAPHY SCALE
   ============================================ */
.act__label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.act__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.15;
  margin-top: var(--sp-sm);
}

.step__label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: inline-block;
  margin-bottom: var(--sp-sm);
}

.step__label--teal { color: var(--teal); }
.step__label--purple { color: var(--purple); }
.step__label--gold { color: var(--accent); }

.step__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: var(--sp-md);
}

.step__body {
  font-size: 1.0625rem;
  line-height: 1.75;
  max-width: 36ch;
}


/* ============================================
   LAYOUT — SECTIONS
   ============================================ */
.act {
  padding: var(--sp-4xl) var(--sp-xl);
  max-width: 1200px;
  margin: 0 auto;
}

.act__header {
  margin-bottom: var(--sp-3xl);
  opacity: 0;
  transform: translateY(30px);
}

.act__header.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}


/* ============================================
   SCROLLYTELLING
   ============================================ */
.scrolly {
  position: relative;
  display: flex;
  gap: var(--sp-xl);
}

.scrolly__graphic {
  position: sticky;
  top: 0;
  width: 50%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
  border-radius: var(--radius-lg);
}

.scrolly__graphic-inner {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1;
}

.scrolly__text {
  width: 50%;
  padding: 40vh 0;
}

.scrolly__step {
  min-height: 60vh;
  padding: var(--sp-2xl) var(--sp-lg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0.15;
  transition: opacity 0.6s var(--ease-out);
}

.scrolly__step.is-active {
  opacity: 1;
}


/* ============================================
   PULL QUOTE
   ============================================ */
.pull-quote {
  padding: var(--sp-4xl) var(--sp-xl);
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.pull-quote blockquote {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  color: var(--text-secondary);
  line-height: 1.6;
  font-style: italic;
}

.pull-quote__highlight {
  color: var(--accent);
  font-style: normal;
  font-weight: 700;
}


/* ============================================
   EPILOGUE
   ============================================ */
.epilogue {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-xl);
  position: relative;
}

.epilogue::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(200,160,100,0.06) 0%, transparent 60%);
  pointer-events: none;
}

html[data-theme="light"] .epilogue::before {
  background: radial-gradient(ellipse at center, rgba(160,120,48,0.04) 0%, transparent 70%);
}

.epilogue__content {
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2xl);
}

.epilogue__line {
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 2.5vw, 1.5rem);
  color: var(--text-secondary);
  line-height: 1.5;
  opacity: 0;
  transform: translateY(15px);
}

.epilogue__line--gold {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  color: var(--accent);
  font-weight: 700;
}


/* ============================================
   ESSAY NAV
   ============================================ */
.essay-nav {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--sp-3xl) var(--sp-xl) var(--sp-2xl);
  display: flex;
  gap: var(--sp-md);
}

.essay-nav__link {
  display: block;
  flex: 1;
  padding: var(--sp-lg) var(--sp-2xl);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-decoration: none;
  text-align: right;
  transition: border-color 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}

.essay-nav__link--prev { text-align: left; }

.essay-nav__link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.essay-nav__direction {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-xs);
}

.essay-nav__title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: var(--sp-xs);
}

.essay-nav__desc {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}


/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  text-align: center;
  padding: var(--sp-3xl) var(--sp-xl);
  border-top: 1px solid var(--border-subtle);
}

.site-footer__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--sp-sm);
}

.site-footer__credit {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.6;
}


/* ============================================
   CUSTOM SCROLLBARS
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(61, 54, 48, 0.6); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(166, 153, 133, 0.5); }
::-webkit-scrollbar-thumb:active { background: rgba(200, 160, 100, 0.4); }
::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(61, 54, 48, 0.6) transparent; }

html[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(209, 201, 190, 0.7); }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(160, 120, 48, 0.4); }
html[data-theme="light"] ::-webkit-scrollbar-thumb:active { background: rgba(160, 120, 48, 0.5); }
html[data-theme="light"] * { scrollbar-color: rgba(209, 201, 190, 0.7) transparent; }


/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease, background 0.3s ease, transform 0.15s ease;
  padding: 0;
  outline: none;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.06);
}
.theme-toggle:active { transform: scale(0.95); }
.theme-toggle svg { display: block; }


/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .scrolly { flex-direction: column; }
  .scrolly__graphic { position: sticky; width: 100%; height: 50vh; }
  .scrolly__graphic-inner { max-width: 300px; }
  .scrolly__text { width: 100%; padding: 20vh 0; }
  .step__body { max-width: none; }
  .essay-nav { flex-direction: column; }
}
