:root {
  color-scheme: dark;
  --ink: #f3eee3;
  --ink-muted: #b8b0a2;
  --paper: #0a0a09;
  --paper-soft: #11110f;
  --line: rgba(243, 238, 227, 0.18);
  --accent: #d4a75a;
  --scene-accent: #d4a75a;
  --gutter: clamp(1.25rem, 4vw, 5rem);
  --max-width: 100rem;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 20%, rgba(212, 167, 90, 0.04), transparent 30rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  content: "";
  opacity: 0.18;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.24) 0 0.035rem, transparent 0.05rem) 0 0 / 0.32rem 0.32rem,
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.14) 0 0.025rem, transparent 0.045rem) 0 0 / 0.23rem 0.23rem;
  mix-blend-mode: soft-light;
}

a {
  color: inherit;
}

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 1rem rgba(212, 167, 90, 0.6);
  transform-origin: left;
}

.hero {
  position: relative;
  display: flex;
  min-height: 100svh;
  align-items: center;
  overflow: hidden;
  padding: clamp(6rem, 12vh, 10rem) var(--gutter);
  border-bottom: 1px solid var(--line);
}

.hero-backdrop {
  position: absolute;
  inset: -3rem;
  background-image: url("images/01%20-%20516%20am.png");
  background-position: center;
  background-size: cover;
  filter: saturate(0.7) brightness(0.72);
  transform: scale(1.03);
  animation: hero-drift 18s ease-out both;
}

.hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 5, 4, 0.96) 0%, rgba(5, 5, 4, 0.77) 42%, rgba(5, 5, 4, 0.15) 84%),
    linear-gradient(0deg, rgba(5, 5, 4, 0.72), transparent 42%);
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(58rem, 83vw);
}

.eyebrow {
  margin: 0 0 1.5rem;
  color: var(--accent);
  font-size: clamp(0.7rem, 1vw, 0.84rem);
  font-weight: 700;
  letter-spacing: 0.19em;
  line-height: 1.4;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 10ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4.25rem, 10.5vw, 10.5rem);
  font-weight: 400;
  letter-spacing: -0.065em;
  line-height: 0.8;
  text-wrap: balance;
}

.hero-time {
  display: flex;
  width: min(29rem, 100%);
  align-items: center;
  gap: 1rem;
  margin: clamp(2.3rem, 5vh, 4rem) 0 2.2rem;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
}

.hero-time span {
  height: 1px;
  flex: 1;
  background: var(--line);
}

.begin {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid rgba(243, 238, 227, 0.6);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 180ms ease, border-color 180ms ease;
}

.begin:hover,
.begin:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.begin-arrow {
  font-size: 1.1rem;
}

.hero-index {
  position: absolute;
  right: var(--gutter);
  bottom: 2rem;
  z-index: 1;
  margin: 0;
  color: rgba(243, 238, 227, 0.55);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#story {
  position: relative;
}

.story-scene {
  --wash: rgba(212, 167, 90, 0.08);
  position: relative;
  min-height: 126vh;
  padding: 16vh var(--gutter);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 85% 20%, var(--wash), transparent 33rem),
    var(--paper);
}

.story-scene[data-phase="morning"] {
  --scene-accent: #e0ad5a;
  --wash: rgba(224, 173, 90, 0.08);
}

.story-scene[data-phase="day"] {
  --scene-accent: #c9b87f;
  --wash: rgba(171, 192, 178, 0.07);
}

.story-scene[data-phase="evening"] {
  --scene-accent: #e08a59;
  --wash: rgba(224, 112, 76, 0.075);
}

.story-scene[data-phase="night"] {
  --scene-accent: #84a8d2;
  --wash: rgba(71, 105, 165, 0.11);
}

.scene-grid {
  display: grid;
  width: min(100%, var(--max-width));
  margin: 0 auto;
  align-items: start;
  grid-template-columns: minmax(0, 1.42fr) minmax(21rem, 0.76fr);
  gap: clamp(2rem, 6vw, 7rem);
}

.story-scene:nth-child(even) .scene-visual {
  grid-column: 2;
}

.story-scene:nth-child(even) .scene-copy {
  grid-row: 1;
  grid-column: 1;
}

.scene-visual {
  position: sticky;
  top: 10vh;
  margin: 0;
  opacity: 0.32;
  transform: translateY(2.5rem) scale(0.985);
  transition: opacity 700ms ease, transform 900ms cubic-bezier(0.2, 0.72, 0.15, 1);
}

.story-scene.is-visible .scene-visual {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.visual-shell {
  position: relative;
  overflow: hidden;
  min-height: min(70vh, 52rem);
  border: 1px solid rgba(255, 255, 255, 0.11);
  background-color: #151513;
  box-shadow: 0 2rem 6rem rgba(0, 0, 0, 0.37);
  isolation: isolate;
}

.visual-shell::before {
  position: absolute;
  inset: -2rem;
  z-index: -2;
  content: "";
  background-image: var(--scene-image);
  background-position: center;
  background-size: cover;
  filter: blur(2.1rem) brightness(0.36) saturate(0.75);
  transform: scale(1.08);
}

.visual-shell::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background: linear-gradient(180deg, transparent 70%, rgba(0, 0, 0, 0.26));
}

.visual-shell img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-number {
  position: absolute;
  right: 1rem;
  bottom: 0.8rem;
  z-index: 2;
  color: rgba(255, 255, 255, 0.7);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
}

.scene-copy {
  align-self: center;
  padding: clamp(3rem, 15vh, 10rem) 0;
  opacity: 0.22;
  transform: translateY(2rem);
  transition: opacity 650ms ease 100ms, transform 800ms cubic-bezier(0.2, 0.72, 0.15, 1) 100ms;
}

.story-scene.is-visible .scene-copy {
  opacity: 1;
  transform: translateY(0);
}

.scene-time-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.scene-time-row::after {
  height: 1px;
  flex: 1;
  content: "";
  background: linear-gradient(90deg, var(--scene-accent), transparent);
  opacity: 0.42;
}

.scene-time {
  margin: 0;
  color: var(--scene-accent);
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.scene-copy p {
  margin: 0 0 1.25rem;
  color: #d4cec3;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 1.45vw, 1.27rem);
  line-height: 1.72;
}

.scene-copy p:first-of-type::first-letter {
  float: left;
  margin: 0.08em 0.1em 0 0;
  color: var(--ink);
  font-size: 3.5em;
  line-height: 0.78;
}

.scene-copy .scene-emphasis {
  margin-top: 2rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-style: italic;
}

.story-status {
  position: fixed;
  right: var(--gutter);
  bottom: 1.5rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(10, 10, 9, 0.78);
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  backdrop-filter: blur(0.8rem);
  transition: opacity 200ms ease;
}

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

.status-rule {
  width: 1.5rem;
  height: 1px;
  background: var(--line);
}

.scene-nav {
  position: fixed;
  top: 50%;
  left: clamp(0.65rem, 1.3vw, 1.25rem);
  z-index: 55;
  transform: translateY(-50%);
}

.scene-nav ol {
  display: flex;
  margin: 0;
  padding: 0;
  flex-direction: column;
  gap: 0.34rem;
  list-style: none;
}

.scene-nav a {
  position: relative;
  display: block;
  width: 0.38rem;
  height: 0.38rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: transparent;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.scene-nav a::after {
  position: absolute;
  top: 50%;
  left: 1rem;
  width: max-content;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line);
  background: rgba(10, 10, 9, 0.92);
  color: var(--ink);
  content: attr(data-label);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  transform: translate(0.3rem, -50%);
  transition: opacity 150ms ease, transform 150ms ease;
}

.scene-nav a:hover::after,
.scene-nav a:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.scene-nav a.is-active {
  border-color: var(--scene-accent, var(--accent));
  background: var(--scene-accent, var(--accent));
  transform: scale(1.65);
}

.end-card {
  display: grid;
  min-height: 80svh;
  place-content: center;
  padding: 10vh var(--gutter);
  text-align: center;
}

.closing-line {
  max-width: 18ch;
  margin: 0 auto 3rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 6vw, 6rem);
  letter-spacing: -0.045em;
  line-height: 0.98;
  text-wrap: balance;
}

.end-card a {
  justify-self: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
}

.end-card a:hover,
.end-card a:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.noscript-message {
  position: fixed;
  inset: auto 1rem 1rem;
  z-index: 200;
  padding: 1rem;
  background: #7b2424;
  color: #fff;
  text-align: center;
}

@keyframes hero-drift {
  from { transform: scale(1.08); }
  to { transform: scale(1.01); }
}

@media (max-width: 980px) {
  .story-scene {
    min-height: auto;
    padding-top: 5rem;
    padding-bottom: 7rem;
  }

  .scene-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .scene-visual,
  .story-scene:nth-child(even) .scene-visual {
    position: relative;
    top: auto;
    width: 100%;
  }

  .visual-shell {
    min-height: 0;
    aspect-ratio: 16 / 11;
  }

  .scene-copy {
    width: min(100%, 42rem);
    padding: 3rem 0 0;
  }

  .scene-nav {
    display: none;
  }

  .hero-shade {
    background:
      linear-gradient(90deg, rgba(5, 5, 4, 0.94), rgba(5, 5, 4, 0.35)),
      linear-gradient(0deg, rgba(5, 5, 4, 0.82), transparent 60%);
  }
}

@media (max-width: 620px) {
  .hero {
    align-items: flex-end;
    padding-bottom: 7rem;
  }

  .hero-content {
    width: 100%;
  }

  .hero h1 {
    font-size: clamp(3.8rem, 18vw, 6rem);
  }

  .hero-index {
    display: none;
  }

  .story-scene {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .visual-shell {
    aspect-ratio: 4 / 3;
  }

  .scene-copy p {
    font-size: 1.03rem;
    line-height: 1.67;
  }

  .story-status {
    right: 0.75rem;
    bottom: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

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