/* undo.quest - Cinematic Rewind Experience */

:root {
  /* Palette */
  --color-parchment: #F4EBD9;
  --color-walnut: #2A1F17;
  --color-ash: #5C4A3A;
  --color-linen: #D9CCBA;
  --color-umber: #6B3A2A;
  --color-gold: #C4956A;
  --color-amber-haze: #B8865440;
  --color-dust: #8B7355;

  /* Scene defaults */
  --bg: var(--color-parchment);
  --text: var(--color-ash);
  --heading: var(--color-umber);
  --accent: var(--color-gold);
  --grain-blend: multiply;
}

/* Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
}

body {
  font-family: "Epilogue", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Typography */
h1, h2 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.1;
  color: var(--heading);
}

.scene-heading {
  font-size: clamp(3rem, 8vw, 7rem);
  text-transform: uppercase;
}

.scene-heading-final {
  font-size: clamp(1.8rem, 4.5vw, 3.5rem);
  text-transform: uppercase;
}

.scene-text {
  font-weight: 300;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  line-height: 1.85;
  letter-spacing: 0.01em;
  max-width: 38ch;
  margin-bottom: 1rem;
}

.scene-text-begin {
  font-weight: 300;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  line-height: 1.85;
  letter-spacing: 0.01em;
  max-width: 38ch;
  opacity: 0;
  animation: fadeInBegin 4s ease-out 2s forwards;
}

.scene-caption {
  font-family: "Epilogue", sans-serif;
  font-weight: 200;
  font-style: italic;
  font-size: clamp(0.7rem, 1vw, 0.85rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.5rem;
}

/* Page Container */
.page-container {
  position: relative;
  width: 100%;
}

/* Scenes */
.scene {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 300ms cubic-bezier(0.25, 0.1, 0.25, 1);
  overflow: hidden;
}

.scene::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="4" result="noise"/></filter><rect width="200" height="200" fill="%238B7355" filter="url(%23noise)" opacity="0.04"/></svg>');
  background-repeat: repeat;
  mix-blend-mode: var(--grain-blend);
  pointer-events: none;
  opacity: 0;
  animation: grainFadeIn 200ms ease-out forwards;
}

/* Dark Scenes */
.scene--dark {
  --bg: var(--color-walnut);
  --text: var(--color-linen);
  --heading: var(--color-linen);
  --grain-blend: soft-light;
}

/* Scene Content */
.scene-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 90%;
}

.scene-content--left {
  margin-left: -18.2%;
  text-align: left;
  animation: slideInLeft 800ms cubic-bezier(0.25, 0.1, 0.25, 1) 200ms backwards;
}

.scene-content--right {
  margin-left: 18.2%;
  text-align: left;
  animation: slideInRight 800ms cubic-bezier(0.25, 0.1, 0.25, 1) 200ms backwards;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes grainFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Rewind Spine (Vertical Center Line) */
.page-container::before {
  content: '';
  position: fixed;
  left: 50%;
  top: 0;
  width: 1px;
  height: 100vh;
  background: linear-gradient(to bottom, transparent, var(--color-gold) 50%, transparent);
  opacity: 0.2;
  z-index: 1;
  transform: translateX(-50%);
  pointer-events: none;
}

/* Spine Tick Marks */
@keyframes spineTick {
  0%, 100% { opacity: 0%; }
  50% { opacity: 40%; }
}

/* Nature Motifs */

/* Horizon Lines */
.horizon-line {
  position: absolute;
  bottom: 20%;
  left: 50%;
  width: 200px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--color-gold), transparent);
  transform: translateX(-50%);
  opacity: 0.25;
  animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.35; }
}

/* Leaf Silhouettes */
.leaf-silhouette {
  position: absolute;
  z-index: 0;
}

.leaf-left {
  left: -50px;
  top: 20%;
  width: 120px;
  height: 150px;
  clip-path: polygon(30% 0%, 100% 0%, 70% 100%, 0% 100%);
  background-color: rgba(0, 0, 0, 0.05);
}

.leaf-right {
  right: -50px;
  bottom: 15%;
  width: 100px;
  height: 140px;
  clip-path: polygon(0% 0%, 70% 0%, 100% 100%, 30% 100%);
  background-color: rgba(0, 0, 0, 0.05);
}

/* Water Ripples */
.ripple-container {
  position: absolute;
  right: 15%;
  bottom: 20%;
  width: 200px;
  height: 200px;
  z-index: 0;
}

.ripple-rings {
  width: 100%;
  height: 100%;
  color: var(--color-gold);
  animation: rippleExpand 12s ease-out infinite;
}

@keyframes rippleExpand {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Undo Button */
.undo-button {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: none;
  border: none;
  font-family: "Epilogue", sans-serif;
  font-weight: 200;
  font-size: 0.85rem;
  font-style: italic;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 200ms ease-out;
  z-index: 10;
  padding: 0.5rem 1rem;
}

.undo-button:hover {
  opacity: 1;
}

.undo-button:active {
  opacity: 0.8;
}

/* Fixed Navigation Circle */
.nav-circle {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

.nav-toggle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  background-color: var(--color-gold);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease-out;
  position: relative;
}

.nav-toggle:hover {
  width: 14px;
  height: 14px;
}

.nav-circle-dot {
  display: inline-block;
  width: 2px;
  height: 6px;
  background-color: var(--color-walnut);
  animation: spin 120s linear infinite reverse;
  position: absolute;
}

@keyframes spin {
  from { transform: rotate(0deg) translateY(-8px); }
  to { transform: rotate(360deg) translateY(-8px); }
}

/* Navigation Menu */
.nav-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  background-color: rgba(244, 235, 217, 0.95);
  padding: 20px;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  z-index: 999;
}

.nav-circle[data-expanded="true"] .nav-menu {
  display: flex;
}

.nav-item {
  font-family: "Cormorant Garamond", serif;
  font-size: 0.95rem;
  color: var(--color-umber);
  text-decoration: none;
  cursor: pointer;
  transition: color 200ms ease-out;
  padding: 4px 8px;
}

.nav-item:hover {
  color: var(--color-gold);
}

/* Wind Lines (subtle, optional) */
@keyframes windDrift {
  0% { transform: translateX(-10vw); }
  100% { transform: translateX(110vw); }
}

/* Scene-specific positioning at golden ratio */
.scene--2 .scene-content--left {
  margin-left: calc(38.2% - 19%);
}

.scene--3 .scene-content--right {
  margin-left: calc(61.8% - 19%);
}

.scene--4 .scene-content--left {
  margin-left: calc(38.2% - 19%);
}

.scene--5 .scene-content--right {
  margin-left: calc(61.8% - 19%);
}

.scene--6 .scene-content--left {
  margin-left: calc(38.2% - 19%);
}

.scene--7 .scene-content--right {
  margin-left: calc(61.8% - 19%);
}

.scene--8 .scene-content--left {
  margin-left: calc(38.2% - 19%);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .scene-content--left,
  .scene-content--right {
    margin-left: 0;
    text-align: center;
  }

  .leaf-left,
  .leaf-right {
    opacity: 0.03;
  }

  .ripple-container {
    right: 10%;
  }

  .nav-menu {
    width: 90vw;
    max-width: 300px;
  }
}

/* Print Styles */
@media print {
  .nav-circle,
  .undo-button,
  .scene::before {
    display: none;
  }
}
