/* haskell.quest - Goblincore Functional Programming */
/* Design: Forgotten alchemist's workshop meets Haskell elegance */

:root {
  --bg-abyss: #0a0e1a;
  --bg-midnight: #111827;
  --bg-stone: #1e2436;
  --text-marble: #e8dcc8;
  --text-mushroom: #d4c9b0;
  --text-lichen: #7a8b7e;
  --accent-moss: #5b8a72;
  --accent-torch: #c8943e;
  --accent-spore: #9a7b3c;
  --depth-shadow: rgba(0, 0, 0, 0.5);
  --glass-moss: rgba(91, 138, 114, 0.08);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-abyss);
  color: var(--text-marble);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  line-height: 1.72;
  letter-spacing: 0.01em;
  overflow-x: hidden;
}

/* ======================= */
/* FLOATING TYPE PARTICLES */
/* ======================= */

.type-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.particle {
  position: absolute;
  font-family: 'Fira Code', monospace;
  font-size: clamp(0.75rem, 1.2vw, 1rem);
  color: var(--accent-torch);
  opacity: 0.08;
  animation: particle-drift linear infinite;
}

.particle-1 { top: 10%; left: 5%; animation-duration: 80s; animation-delay: 0s; }
.particle-2 { top: 25%; left: 85%; animation-duration: 95s; animation-delay: -20s; }
.particle-3 { top: 40%; left: 15%; animation-duration: 70s; animation-delay: -10s; }
.particle-4 { top: 55%; left: 75%; animation-duration: 110s; animation-delay: -35s; }
.particle-5 { top: 70%; left: 45%; animation-duration: 90s; animation-delay: -5s; }
.particle-6 { top: 15%; left: 65%; animation-duration: 100s; animation-delay: -15s; }
.particle-7 { top: 85%; left: 25%; animation-duration: 75s; animation-delay: -40s; }
.particle-8 { top: 50%; left: 55%; animation-duration: 85s; animation-delay: -25s; }
.particle-9 { top: 35%; left: 35%; animation-duration: 105s; animation-delay: -50s; }
.particle-10 { top: 65%; left: 90%; animation-duration: 60s; animation-delay: -30s; }

@keyframes particle-drift {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 0.08; }
  90% { opacity: 0.08; }
  100% { transform: translateY(-100vh) translateX(-50px); opacity: 0; }
}

/* ======================= */
/* VINE PROGRESS INDICATOR */
/* ======================= */

.vine-progress {
  position: fixed;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  height: 60vh;
}

.vine-line {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 100%;
  background: var(--text-lichen);
  opacity: 0.2;
}

.vine-fill {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 0%;
  background: var(--accent-moss);
  transition: height 0.3s ease;
  animation: pulse-vine 4s ease-in-out infinite;
}

@keyframes pulse-vine {
  0%, 100% { box-shadow: 0 0 4px rgba(91, 138, 114, 0.2); }
  50% { box-shadow: 0 0 12px rgba(91, 138, 114, 0.5); }
}

.vine-node {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.3;
  transition: opacity 0.5s ease;
}

.vine-node:nth-child(3) { top: 0%; }
.vine-node:nth-child(4) { top: 25%; }
.vine-node:nth-child(5) { top: 50%; }
.vine-node:nth-child(6) { top: 75%; }
.vine-node:nth-child(7) { top: 100%; }

.vine-node.active {
  opacity: 1;
}

.mushroom-icon {
  display: block;
}

/* ======================= */
/* SCROLL CONTAINER        */
/* ======================= */

.scroll-container {
  scroll-snap-type: y proximity;
  perspective: 1200px;
}

/* ======================= */
/* LAYER BASE STYLES       */
/* ======================= */

.layer {
  min-height: 100vh;
  scroll-snap-align: start;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Marble texture overlay */
.layer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(212, 201, 176, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(200, 148, 62, 0.02) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 80%, rgba(91, 138, 114, 0.03) 0%, transparent 45%);
  pointer-events: none;
  z-index: 0;
}

/* ======================= */
/* SECTION 0: THE SURFACE  */
/* ======================= */

.layer-surface {
  background: var(--bg-abyss);
  flex-direction: column;
}

.column-decor {
  position: absolute;
  top: 10%;
  height: 80%;
  width: 60px;
  opacity: 0.15;
  z-index: 1;
}

.column-left {
  left: 8%;
}

.column-right {
  right: 8%;
}

.surface-content {
  position: relative;
  z-index: 2;
  text-align: center;
  transform: translateZ(60px);
}

.title-domain {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(3rem, 8vw, 7rem);
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--text-marble);
  margin-bottom: 0.5em;
  animation: pulse-glow 4s ease-in-out infinite;
}

.title-domain .letter {
  display: inline-block;
  transition: transform 0.3s ease, text-shadow 0.3s ease;
}

.title-domain .letter:hover {
  transform: translateY(-4px);
  text-shadow: 0 0 30px rgba(200, 148, 62, 0.6);
}

.title-domain .dot {
  color: var(--accent-torch);
}

@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 20px rgba(200, 148, 62, 0.2); }
  50% { text-shadow: 0 0 50px rgba(200, 148, 62, 0.5), 0 0 80px rgba(200, 148, 62, 0.15); }
}

.tagline {
  font-family: 'Crimson Text', Georgia, serif;
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.4rem);
  color: var(--text-mushroom);
  margin-bottom: 2em;
  opacity: 0.85;
}

.lambda-vine-divider {
  width: clamp(200px, 50vw, 400px);
  margin: 1em auto;
  opacity: 0.7;
}

.vine-svg {
  width: 100%;
  height: auto;
}

.scroll-hint {
  margin-top: 3em;
  animation: bounce-hint 2s ease-in-out infinite;
}

.scroll-arrow {
  font-size: 1.5rem;
  color: var(--accent-moss);
  opacity: 0.5;
}

@keyframes bounce-hint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

/* ============================== */
/* SECTION 1: THE UNDERGROWTH     */
/* ============================== */

.layer-undergrowth {
  background: var(--bg-midnight);
  align-items: flex-start;
  padding: 5vh 0;
}

.undergrowth-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.section-title {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(3rem, 7vw, 6rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-marble);
  margin-bottom: 1em;
  text-align: center;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.layer.visible .section-title {
  opacity: 1;
  transform: translateY(0);
}

.concept-panels {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
  position: relative;
}

.concept-panel {
  flex: 1 1 320px;
  max-width: 380px;
  opacity: 0;
  transform: translateX(-40px) rotate(-1.5deg);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.concept-panel.panel-functions {
  transform: translateY(40px) rotate(1deg);
}

.concept-panel.panel-purity {
  transform: translateX(40px) rotate(2deg);
}

.layer.visible .concept-panel {
  opacity: 1;
  transform: translateX(0) translateY(0) rotate(0);
}

.panel-inner {
  background: var(--bg-stone);
  border: 1px solid rgba(91, 138, 114, 0.15);
  padding: 2rem;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  /* Marble texture */
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(212, 201, 176, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(200, 148, 62, 0.02) 0%, transparent 40%);
}

.panel-title {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-weight: 400;
  font-size: 1.8rem;
  letter-spacing: 0.08em;
  color: var(--accent-torch);
  margin-bottom: 0.5em;
  text-transform: uppercase;
}

.panel-text {
  color: var(--text-mushroom);
  margin-bottom: 1.2em;
  font-size: 0.95rem;
  line-height: 1.7;
}

.code-block {
  background: rgba(15, 25, 50, 0.5);
  border-left: 3px solid var(--accent-moss);
  padding: 1.2em 1.5em;
  overflow-x: auto;
  backdrop-filter: blur(4px);
}

.code-block pre {
  margin: 0;
}

.code-block code {
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: clamp(0.75rem, 1.2vw, 0.95rem);
  color: var(--text-mushroom);
  line-height: 1.6;
}

.isometric-code {
  transform: rotateX(8deg) rotateY(-12deg);
  border: 1px solid rgba(91, 138, 114, 0.2);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.3), 12px 12px 24px rgba(0, 0, 0, 0.2);
  transition: transform 0.4s ease;
}

.isometric-code:hover {
  transform: rotateX(2deg) rotateY(-3deg);
}

.fern-decor {
  position: absolute;
  bottom: 5%;
  z-index: 1;
  opacity: 0.3;
}

.fern-left {
  left: 3%;
}

.fern-right {
  right: 3%;
}

/* ============================== */
/* SECTION 2: THE STONE LIBRARY   */
/* ============================== */

.layer-stone {
  background: var(--bg-stone);
  box-shadow: inset 0 8px 32px rgba(0, 0, 0, 0.6);
}

.stone-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem;
  transform: translateZ(-20px);
}

.stone-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-top: 2rem;
}

.stone-column-content {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.layer.visible .stone-column-content {
  opacity: 1;
  transform: translateY(0);
}

.layer.visible .stone-column-content:nth-child(2) {
  transition-delay: 0.2s;
}

.stone-heading {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-torch);
  margin-bottom: 0.6em;
}

.stone-text {
  color: var(--text-mushroom);
  margin-bottom: 1.5em;
  font-size: 0.95rem;
  line-height: 1.72;
}

.stone-text code {
  font-family: 'Fira Code', monospace;
  font-size: 0.85em;
  color: var(--accent-moss);
  background: rgba(15, 25, 50, 0.4);
  padding: 0.15em 0.4em;
}

/* ============================== */
/* SECTION 3: CHAMBER OF TYPES    */
/* ============================== */

.layer-chamber {
  background: var(--bg-midnight);
}

.chamber-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 4rem 2rem;
  text-align: center;
}

.type-orbit {
  position: relative;
  width: 100%;
  height: 450px;
  margin: 2rem auto;
  perspective: 800px;
}

.orbit-block {
  position: absolute;
  background: var(--bg-stone);
  border: 1px solid rgba(91, 138, 114, 0.25);
  padding: 1em 1.5em;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.25), 10px 10px 20px rgba(0, 0, 0, 0.15);
  transform: rotateX(8deg) rotateY(-12deg);
  animation: iso-float 6s ease-in-out infinite;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  cursor: default;
  opacity: 0;
}

.layer.visible .orbit-block {
  opacity: 1;
}

.orbit-block:hover {
  transform: scale(1.1) rotateX(0) rotateY(0);
  box-shadow: 0 4px 20px rgba(200, 148, 62, 0.2);
  z-index: 10;
}

.orbit-block code {
  font-family: 'Fira Code', monospace;
  font-size: clamp(0.8rem, 1.3vw, 1rem);
  color: var(--text-marble);
  white-space: nowrap;
}

.orbit-block[data-orbit="0"] { top: 5%; left: 10%; animation-delay: 0s; }
.orbit-block[data-orbit="1"] { top: 15%; right: 5%; animation-delay: -1s; }
.orbit-block[data-orbit="2"] { top: 40%; left: 5%; animation-delay: -2s; }
.orbit-block[data-orbit="3"] { top: 50%; right: 10%; animation-delay: -3s; }
.orbit-block[data-orbit="4"] { top: 70%; left: 15%; animation-delay: -4s; }
.orbit-block[data-orbit="5"] { top: 75%; right: 15%; animation-delay: -5s; }

@keyframes iso-float {
  0%, 100% { transform: rotateX(8deg) rotateY(-12deg) translateY(0); }
  50% { transform: rotateX(8deg) rotateY(-12deg) translateY(-8px); }
}

.chamber-inscription {
  margin-top: 3rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease 0.5s, transform 1s ease 0.5s;
}

.layer.visible .chamber-inscription {
  opacity: 1;
  transform: translateY(0);
}

.chamber-inscription p {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: var(--accent-torch);
  font-style: italic;
}

.mushroom-scatter {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.mushroom-deco {
  position: absolute;
  opacity: 0.15;
}

.m1 { bottom: 8%; left: 5%; }
.m2 { bottom: 12%; right: 8%; }
.m3 { top: 15%; right: 3%; }

/* ============================== */
/* SECTION 4: THE FOUNDATION      */
/* ============================== */

.layer-foundation {
  background: var(--bg-abyss);
}

.foundation-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem;
}

.foundation-title {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(6rem, 15vw, 12rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-marble);
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1s ease, transform 1s ease;
}

.layer.visible .foundation-title {
  opacity: 1;
  transform: translateY(0);
  animation: pulse-glow-intense 4s ease-in-out infinite;
}

.foundation-title .letter {
  display: inline-block;
}

@keyframes pulse-glow-intense {
  0%, 100% { text-shadow: 0 0 30px rgba(200, 148, 62, 0.3); }
  50% { text-shadow: 0 0 60px rgba(200, 148, 62, 0.6), 0 0 100px rgba(200, 148, 62, 0.2), 0 0 140px rgba(200, 148, 62, 0.1); }
}

.foundation-lambda {
  margin: 1rem auto;
  width: 120px;
  opacity: 0;
  transition: opacity 1.5s ease 0.3s;
}

.layer.visible .foundation-lambda {
  opacity: 1;
}

.lambda-glyph {
  width: 100%;
  height: auto;
  animation: pulse-glow-svg 4s ease-in-out infinite;
}

@keyframes pulse-glow-svg {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(200, 148, 62, 0.2)); }
  50% { filter: drop-shadow(0 0 20px rgba(200, 148, 62, 0.5)); }
}

.foundation-text {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  color: var(--text-mushroom);
  max-width: 500px;
  margin: 2rem auto;
  line-height: 1.72;
  opacity: 0;
  transition: opacity 1s ease 0.5s;
}

.layer.visible .foundation-text {
  opacity: 0.85;
}

.foundation-sigil {
  margin-top: 2rem;
  opacity: 0;
  transition: opacity 1.2s ease 0.7s;
}

.layer.visible .foundation-sigil {
  opacity: 1;
}

.sigil-text {
  font-family: 'Fira Code', monospace;
  font-size: 1.5rem;
  color: var(--accent-torch);
  letter-spacing: 0.2em;
  opacity: 0.6;
  animation: pulse-glow 4s ease-in-out infinite;
}

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

@media (max-width: 768px) {
  .vine-progress {
    left: 12px;
  }

  .stone-columns {
    grid-template-columns: 1fr;
  }

  .concept-panels {
    flex-direction: column;
    align-items: center;
  }

  .concept-panel {
    max-width: 100%;
  }

  .column-decor {
    display: none;
  }

  .type-orbit {
    height: 600px;
  }

  .orbit-block {
    position: relative;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    margin: 1rem auto;
    display: block;
    width: fit-content;
    max-width: 90%;
  }

  .fern-decor {
    display: none;
  }
}

@media (max-width: 480px) {
  .vine-progress {
    display: none;
  }

  .title-domain {
    font-size: clamp(2.5rem, 12vw, 4rem);
  }

  .foundation-title {
    font-size: clamp(4rem, 20vw, 8rem);
  }
}
