/* ===========================
   FUNDAMENTAL STYLES
   =========================== */

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

:root {
  /* Primary Colors */
  --obsidian-lodge: #1c1410;
  --charred-cedar: #2a1f18;
  --parchment-cream: #ede4d3;
  --ash-mist: #a89b8a;
  --burnt-sienna: #c4622a;
  --parchment-gold: #c8a96e;
  --copper-ember: #8b4a1f;
  --trail-dust: #5a3e28;
  --summit-amber: #e8913a;
  
  /* Near-black variations */
  --dark-fade: #0f0b08;
  --warm-dark: #221812;
  
  /* Functional spacing */
  --clamp-padding: clamp(80px, 12vh, 160px);
  --clamp-margin: clamp(48px, 6vw, 96px);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Source Serif 4", serif;
  font-weight: 400;
  line-height: 1.72;
  color: var(--parchment-cream);
  background-color: var(--obsidian-lodge);
  overflow-x: hidden;
  
  /* Ambient gradient background */
  background: linear-gradient(
    to bottom,
    var(--obsidian-lodge) 0%,
    var(--warm-dark) 100vh,
    var(--obsidian-lodge) 200vh,
    var(--warm-dark) 300vh
  );
  background-size: 100% 200vh;
  background-attachment: fixed;
}

/* ===========================
   NAVIGATION
   =========================== */

.fixed-nav {
  position: fixed;
  top: 32px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--clamp-margin);
  z-index: 1000;
  pointer-events: none;
}

.fixed-nav > * {
  pointer-events: auto;
}

.nav-logotype {
  font-family: "Zilla Slab", serif;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--parchment-gold);
  opacity: 0;
  animation: logotype-fade 1.8s ease-out forwards;
  animation-delay: 0.5s;
}

.nav-chapters {
  position: relative;
}

.chapters-label {
  font-family: "Arvo", serif;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--parchment-gold);
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 200ms ease;
  text-transform: uppercase;
}

.chapters-label:hover {
  opacity: 1;
}

.chapters-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 12px;
  min-width: 200px;
  background-color: var(--charred-cedar);
  border: 1px solid var(--trail-dust);
  padding: 16px;
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  transition: opacity 400ms cubic-bezier(0.25, 0, 0.1, 1),
              transform 400ms cubic-bezier(0.25, 0, 0.1, 1);
  backdrop-filter: blur(8px);
}

.nav-chapters:hover .chapters-panel {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.chapter-link {
  font-family: "Arvo", serif;
  font-size: 0.95rem;
  color: var(--parchment-cream);
  padding: 8px 0;
  cursor: pointer;
  transition: color 200ms ease;
  text-decoration: none;
}

.chapter-link:hover {
  color: var(--parchment-gold);
}

/* Navigation backdrop on scroll */
body.scrolled .fixed-nav {
  background-color: rgba(42, 31, 24, 0.7);
  backdrop-filter: blur(8px);
  padding-top: 16px;
  padding-bottom: 16px;
}

/* ===========================
   HERO SECTION
   =========================== */

.hero {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--clamp-margin);
  overflow: hidden;
}

.horizon-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.horizon-svg {
  stroke: var(--parchment-gold);
  stroke-width: 1px;
  opacity: 0.3;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: draw-line 1.2s cubic-bezier(0.25, 0, 0.1, 1) forwards;
  animation-delay: 0.5s;
}

@keyframes draw-line {
  to {
    stroke-dashoffset: 0;
  }
}

.hero-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 10;
}

.logotype-container {
  flex: 0 0 auto;
  margin-top: 15vh;
}

.logotype {
  font-family: "Zilla Slab", serif;
  font-size: clamp(2.8rem, 7vw, 6.5rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.1;
  margin: 0;
  opacity: 0;
  animation: logotype-fade 1.8s ease-out forwards;
  animation-delay: 0.7s;
}

.logotype-turing {
  color: var(--parchment-cream);
}

.logotype-test {
  color: var(--burnt-sienna);
  margin: 0 0.15em;
}

.logotype-quest {
  font-family: "Arvo", serif;
  font-weight: 400;
  font-style: italic;
  opacity: 0.6;
}

@keyframes logotype-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.hero-visual {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.7) contrast(1.1);
  opacity: 0;
  transform: translateY(3%);
  animation: mountain-rise 1.5s cubic-bezier(0.25, 0, 0.1, 1) forwards;
  animation-delay: 0.9s;
}

@keyframes mountain-rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, 
    transparent,
    rgba(196, 98, 42, 0.12)
  );
  pointer-events: none;
}

.tagline-container {
  position: absolute;
  bottom: 5%;
  right: var(--clamp-margin);
  max-width: 45%;
  text-align: right;
  z-index: 20;
}

.tagline {
  font-family: "Arvo", serif;
  font-style: italic;
  font-size: clamp(1.1rem, 1.8vw, 1.5rem);
  letter-spacing: 0.02em;
  color: var(--ash-mist);
  margin: 0;
  opacity: 0;
  animation: logotype-fade 1.2s ease-out forwards;
  animation-delay: 1.1s;
  line-height: 1.6;
}

/* ===========================
   TURING WINDOW MOTIF
   =========================== */

.turing-window {
  position: relative;
  border: 2px solid var(--parchment-gold);
  border-opacity: 40%;
  overflow: hidden;
  opacity: 0;
  animation: window-frame-in 0.8s ease-out forwards;
  transition: all 600ms cubic-bezier(0.25, 0, 0.1, 1);
}

@keyframes window-frame-in {
  from {
    opacity: 0;
    border-color: rgba(200, 169, 110, 0);
  }
  to {
    opacity: 1;
    border-color: rgba(200, 169, 110, 0.4);
  }
}

.turing-window:hover {
  border-color: var(--burnt-sienna);
  box-shadow: 0 0 20px rgba(196, 98, 42, 0.2);
}

.window-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.7) contrast(1.1);
  opacity: 0;
  animation: window-image-fade 1.2s ease-out 0.8s forwards;
  transition: filter 300ms ease;
}

@keyframes window-image-fade {
  to {
    opacity: 1;
  }
}

.turing-window:hover .window-image {
  filter: saturate(0.7) contrast(1.1) blur(0px);
  transform: scale(1.02);
}

/* ===========================
   CONTENT SECTIONS
   =========================== */

.content-section {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--clamp-padding) var(--clamp-margin);
  gap: clamp(40px, 8vw, 100px);
}

.section-content {
  flex: 1;
  max-width: 680px;
}

.section-visual {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-1,
.section-3 {
  flex-direction: row;
}

.section-2,
.section-4 {
  flex-direction: row-reverse;
}

.section-1 .section-left,
.section-3 .section-left {
  opacity: 0;
  transform: translateX(-60px);
  animation: slide-in-left 600ms cubic-bezier(0.25, 0, 0.1, 1) forwards;
}

.section-2 .section-right,
.section-4 .section-right {
  opacity: 0;
  transform: translateX(60px);
  animation: slide-in-right 600ms cubic-bezier(0.25, 0, 0.1, 1) forwards;
}

@keyframes slide-in-left {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slide-in-right {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.section-heading {
  font-family: "Zilla Slab", serif;
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: clamp(16px, 3vh, 32px);
  color: var(--parchment-cream);
}

.section-body {
  font-size: clamp(1rem, 1.3vw, 1.15rem);
  margin-bottom: clamp(16px, 2vh, 24px);
  color: var(--parchment-cream);
  line-height: 1.72;
}

.section-body:last-child {
  margin-bottom: 0;
}

/* Ridge divider SVG */
.ridge-divider {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100px;
  pointer-events: none;
  opacity: 0.4;
}

.ridge-path {
  fill: none;
  stroke: var(--parchment-gold);
  stroke-width: 1px;
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  opacity: 0.4;
}

.section-1 .ridge-divider {
  animation: draw-ridge 1.8s ease-out forwards;
  animation-delay: 600ms;
}

.section-2 .ridge-divider {
  animation: draw-ridge 1.8s ease-out forwards;
  animation-delay: 600ms;
}

@keyframes draw-ridge {
  to {
    stroke-dashoffset: 0;
  }
}

/* ===========================
   CLOSING SECTION
   =========================== */

.section-4 {
  position: relative;
  justify-content: center;
  align-items: center;
  height: auto;
  min-height: 120vh;
  background-color: rgba(15, 11, 8, 0.95);
}

.section-centered {
  text-align: center;
  z-index: 10;
}

.closing-text {
  font-family: "Arvo", serif;
  font-style: italic;
  font-size: clamp(1.8rem, 4vw, 3rem);
  color: var(--ash-mist);
  opacity: 0.7;
  margin: 0;
  letter-spacing: 0.02em;
  line-height: 1.6;
}

/* ===========================
   SCROLL-TRIGGERED ANIMATIONS
   =========================== */

.content-section {
  opacity: 0;
}

.content-section.in-view {
  opacity: 1;
}

.content-section.in-view .section-heading {
  animation: slide-heading 600ms cubic-bezier(0.25, 0, 0.1, 1) forwards;
}

.content-section.in-view .section-body {
  animation: slide-body 600ms cubic-bezier(0.25, 0, 0.1, 1) forwards;
}

.content-section.in-view .turing-window {
  animation: window-frame-in 0.8s ease-out forwards;
}

.section-1 .section-heading,
.section-3 .section-heading {
  opacity: 0;
  transform: translateX(-30px);
}

.section-2 .section-heading,
.section-4 .section-heading {
  opacity: 0;
  transform: translateX(30px);
}

@keyframes slide-heading {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.section-1 .section-body,
.section-3 .section-body {
  opacity: 0;
  transform: translateX(-30px);
}

.section-2 .section-body,
.section-4 .section-body {
  opacity: 0;
  transform: translateX(30px);
}

@keyframes slide-body {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Stagger effect for multiple body paragraphs */
.section-body:nth-of-type(1) {
  animation-delay: 600ms;
}

.section-body:nth-of-type(2) {
  animation-delay: 720ms;
}

.section-body:nth-of-type(3) {
  animation-delay: 840ms;
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */

@media (max-width: 1024px) {
  .content-section {
    flex-direction: column !important;
  }
  
  .section-visual {
    width: 100%;
    margin-top: clamp(40px, 8vh, 80px);
  }
  
  .turing-window {
    width: 70vw !important;
    height: 70vw !important;
  }
  
  .tagline-container {
    max-width: 90%;
    right: auto;
    left: var(--clamp-margin);
    text-align: left;
  }
}

@media (max-width: 768px) {
  .chapters-panel {
    min-width: 150px;
  }
  
  .section-heading {
    font-size: clamp(1.4rem, 4vw, 2rem);
  }
  
  .logotype {
    font-size: clamp(1.8rem, 5vw, 4rem);
  }
}

/* ===========================
   TEXTURE AND DETAIL
   =========================== */

@supports (filter: url(#noise)) {
  .charred-cedar-bg {
    background-color: var(--charred-cedar);
    filter: url(#emboss-filter);
  }
}

/* Monospace accent utility */
.monospace {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9em;
  color: var(--parchment-gold);
}

/* ===========================
   UTILITY CLASSES
   =========================== */

.no-scroll {
  overflow: hidden;
}

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