/* Forest Layers - Parallax Forest CSS Art
   Technique: CSS transforms, z-index layering, gradients, parallax */

/* Custom Properties */
:root {
  /* Sky colors - dusk palette */
  --sky-top: #1a1a2e;
  --sky-mid: #16213e;
  --sky-bottom: #e94560;
  --sky-horizon: #ffc93c;

  /* Forest silhouette colors - back to front */
  --forest-6: #2d3436;
  --forest-5: #232931;
  --forest-4: #1e272e;
  --forest-3: #151b21;
  --forest-2: #0d1117;
  --forest-1: #050709;

  /* Mist colors */
  --mist-color: rgba(255, 200, 150, 0.15);
  --mist-dense: rgba(200, 150, 100, 0.2);

  /* Sun/celestial */
  --sun-core: #fff8e7;
  --sun-glow: #ffc93c;

  /* Text colors */
  --text-light: rgba(255, 255, 255, 0.9);
  --text-muted: rgba(255, 255, 255, 0.6);

  /* Parallax speeds */
  --parallax-strength: 20px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--sky-top);
  color: var(--text-light);
  line-height: 1.8;
}

/* Main Scene Container */
.forest-scene {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
  perspective: 1000px;
  transform-style: preserve-3d;
}

/* Sky Background */
.sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(
    to bottom,
    var(--sky-top) 0%,
    var(--sky-mid) 30%,
    var(--sky-bottom) 70%,
    var(--sky-horizon) 100%
  );
}

/* Celestial Body (Sun at dusk) */
.celestial-body {
  position: absolute;
  bottom: 25%;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 80px;
  z-index: 1;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    var(--sun-core) 0%,
    var(--sun-glow) 50%,
    transparent 70%
  );
  box-shadow:
    0 0 60px 30px rgba(255, 201, 60, 0.4),
    0 0 100px 60px rgba(233, 69, 96, 0.2);
  animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.9; transform: translateX(-50%) scale(1.05); }
}

/* Mist Layers */
.mist {
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  pointer-events: none;
}

.mist-1 {
  bottom: 20%;
  z-index: 25;
  background: linear-gradient(
    to top,
    var(--mist-dense) 0%,
    transparent 100%
  );
  animation: drift 20s ease-in-out infinite alternate;
}

.mist-2 {
  bottom: 30%;
  z-index: 15;
  background: linear-gradient(
    to top,
    var(--mist-color) 0%,
    transparent 80%
  );
  animation: drift 25s ease-in-out infinite alternate-reverse;
}

.mist-3 {
  bottom: 40%;
  z-index: 5;
  background: linear-gradient(
    to top,
    rgba(255, 200, 150, 0.08) 0%,
    transparent 60%
  );
  animation: drift 30s ease-in-out infinite alternate;
}

@keyframes drift {
  0% { transform: translateX(-5%) scaleX(1.1); }
  100% { transform: translateX(5%) scaleX(1); }
}

/* Forest Layers */
.forest-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  transition: transform 0.3s ease-out;
}

.trees {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  width: 120%;
  margin-left: -10%;
}

/* Tree Shapes - using clip-path for pine silhouettes */
.tree {
  position: relative;
  flex-shrink: 0;
}

.tree::before {
  content: '';
  display: block;
  clip-path: polygon(
    50% 0%,
    15% 35%,
    25% 35%,
    5% 65%,
    20% 65%,
    0% 100%,
    100% 100%,
    80% 65%,
    95% 65%,
    75% 35%,
    85% 35%
  );
}

/* Layer 6 - Furthest back, lightest */
.layer-6 {
  z-index: 2;
  height: 35%;
}

.layer-6 .tree::before {
  background: var(--forest-6);
  width: 40px;
  height: 80px;
}

.layer-6 .tree:nth-child(odd)::before {
  height: 70px;
}

/* Layer 5 */
.layer-5 {
  z-index: 4;
  height: 40%;
}

.layer-5 .tree::before {
  background: var(--forest-5);
  width: 50px;
  height: 100px;
}

.layer-5 .tree:nth-child(even)::before {
  height: 85px;
}

/* Layer 4 */
.layer-4 {
  z-index: 6;
  height: 45%;
}

.layer-4 .tree::before {
  background: var(--forest-4);
  width: 60px;
  height: 120px;
}

.layer-4 .tree:nth-child(odd)::before {
  height: 100px;
}

/* Layer 3 */
.layer-3 {
  z-index: 8;
  height: 50%;
}

.layer-3 .tree::before {
  background: var(--forest-3);
  width: 70px;
  height: 140px;
}

.layer-3 .tree:nth-child(even)::before {
  height: 120px;
}

/* Layer 2 */
.layer-2 {
  z-index: 10;
  height: 55%;
}

.layer-2 .tree::before {
  background: var(--forest-2);
  width: 80px;
  height: 160px;
}

.layer-2 .tree:nth-child(odd)::before {
  height: 140px;
}

/* Layer 1 - Foreground, darkest */
.layer-1 {
  z-index: 12;
  height: 60%;
}

.layer-1 .tree::before {
  background: var(--forest-1);
  width: 100px;
  height: 200px;
}

.layer-1 .tree:nth-child(even)::before {
  height: 180px;
}

/* Parallax Effect on Hover */
.forest-scene:hover .layer-6 {
  transform: translateX(calc(var(--parallax-strength) * 0.1));
}

.forest-scene:hover .layer-5 {
  transform: translateX(calc(var(--parallax-strength) * 0.2));
}

.forest-scene:hover .layer-4 {
  transform: translateX(calc(var(--parallax-strength) * 0.35));
}

.forest-scene:hover .layer-3 {
  transform: translateX(calc(var(--parallax-strength) * 0.5));
}

.forest-scene:hover .layer-2 {
  transform: translateX(calc(var(--parallax-strength) * 0.7));
}

.forest-scene:hover .layer-1 {
  transform: translateX(calc(var(--parallax-strength) * 1));
}

/* Subtle breathing animation for depth */
.layer-6 { animation: breathe 8s ease-in-out infinite; }
.layer-5 { animation: breathe 8s ease-in-out infinite 0.5s; }
.layer-4 { animation: breathe 8s ease-in-out infinite 1s; }
.layer-3 { animation: breathe 8s ease-in-out infinite 1.5s; }
.layer-2 { animation: breathe 8s ease-in-out infinite 2s; }
.layer-1 { animation: breathe 8s ease-in-out infinite 2.5s; }

@keyframes breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* Content Overlay */
.content {
  position: relative;
  z-index: 100;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem 2rem;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.3) 0%,
    transparent 30%,
    transparent 70%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

/* Header */
.header {
  text-align: center;
  padding-top: 2rem;
}

.header h1 {
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-shadow:
    0 2px 20px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(233, 69, 96, 0.3);
  margin-bottom: 0.5rem;
  animation: fadeIn 2s ease-out;
}

.subtitle {
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  font-style: italic;
  color: var(--text-muted);
  letter-spacing: 0.3em;
  animation: fadeIn 2s ease-out 0.5s both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Story Section */
.story {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.verse {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  margin: 2rem 0;
  line-height: 2;
  color: var(--text-light);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  animation: fadeIn 2s ease-out 1s both;
}

.verse:nth-child(2) {
  animation-delay: 1.5s;
}

.verse:nth-child(3) {
  animation-delay: 2s;
}

/* Footer */
.footer {
  text-align: center;
  padding-bottom: 2rem;
}

.quote {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.attribution {
  font-size: 0.9rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Floating Particles */
.particles {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: float 15s infinite ease-in-out;
}

.particle:nth-child(1) {
  top: 20%;
  left: 10%;
  animation-duration: 18s;
  animation-delay: 0s;
}

.particle:nth-child(2) {
  top: 30%;
  left: 30%;
  animation-duration: 22s;
  animation-delay: 3s;
}

.particle:nth-child(3) {
  top: 15%;
  left: 60%;
  animation-duration: 20s;
  animation-delay: 5s;
}

.particle:nth-child(4) {
  top: 40%;
  left: 80%;
  animation-duration: 25s;
  animation-delay: 2s;
}

.particle:nth-child(5) {
  top: 25%;
  left: 45%;
  animation-duration: 17s;
  animation-delay: 7s;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  50% {
    transform: translate(100px, 50px) scale(0.8);
    opacity: 0.6;
  }
  90% {
    opacity: 0.4;
  }
}

/* Back Link */
.back-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
}

.back-link a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.back-link a:hover {
  color: var(--text-light);
  background: rgba(0, 0, 0, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --parallax-strength: 10px;
  }

  .content {
    padding: 2rem 1rem;
  }

  .tree::before {
    transform: scale(0.7);
  }

  .layer-1 .tree::before {
    width: 70px;
    height: 140px;
  }

  .layer-2 .tree::before {
    width: 55px;
    height: 110px;
  }

  .verse {
    margin: 1.5rem 0;
  }

  .celestial-body {
    width: 60px;
    height: 60px;
    bottom: 30%;
  }
}

@media (max-width: 480px) {
  .header h1 {
    letter-spacing: 0.1em;
  }

  .trees {
    width: 150%;
    margin-left: -25%;
  }

  .tree::before {
    transform: scale(0.5);
  }

  .story {
    padding: 0 0.5rem;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .celestial-body,
  .mist,
  .forest-layer,
  .particle,
  .header h1,
  .subtitle,
  .verse {
    animation: none;
  }

  .forest-scene:hover .forest-layer {
    transform: none;
  }
}

/* Print styles */
@media print {
  .forest-scene {
    background: white;
    color: black;
  }

  .sky,
  .mist,
  .forest-layer,
  .celestial-body,
  .particles,
  .back-link {
    display: none;
  }

  .content {
    background: none;
  }
}
