/* ============================================================
   EMBERWING — cinematic 3D scroll experience
   ============================================================ */

:root {
  --ink: #0a0806;
  --ink-2: #12100c;
  --ink-3: #1b1712;
  --ember: #ff6b2b;
  --ember-hot: #ff8c3a;
  --ember-soft: #ffb35c;
  --gold: #ffd27f;
  --cream: #ffe9b0;
  --crystal: #ffd9a0;
  --ash: #9b7a5f;
  --smoke: rgba(120, 90, 70, 0.16);

  --font-display: "Cinzel", "Georgia", serif;
  --font-sans: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html {
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html, body { width: 100%; }

body {
  background:
    radial-gradient(120% 80% at 50% -10%, #221510 0%, var(--ink) 55%, #060504 100%);
  color: #f3e7d4;
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  overflow-x: hidden;
  cursor: crosshair;
}

::selection { background: var(--ember); color: #1a0d06; }

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ============ ATMOSPHERE LAYERS ============ */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.cave-layer {
  position: absolute;
  inset: -12%;
  will-change: transform;
}
.cave-far {
  background:
    radial-gradient(70% 55% at 50% 108%, rgba(255,122,43,0.10) 0%, transparent 60%),
    radial-gradient(40% 40% at 22% 88%, rgba(255,140,58,0.08) 0%, transparent 70%),
    radial-gradient(50% 45% at 80% 92%, rgba(200,90,40,0.07) 0%, transparent 70%);
  filter: blur(2px);
}
.cave-mid {
  background:
    radial-gradient(60% 50% at 50% 100%, transparent 55%, rgba(0,0,0,0.55) 100%),
    radial-gradient(35% 30% at 15% 80%, rgba(0,0,0,0.5) 0%, transparent 70%),
    radial-gradient(35% 30% at 85% 78%, rgba(0,0,0,0.5) 0%, transparent 70%);
}
.cave-near {
  background:
    radial-gradient(70% 40% at 50% 100%, rgba(0,0,0,0.78) 0%, transparent 65%);
}
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 50% 50%, transparent 55%, rgba(0,0,0,0.72) 100%);
}
.heat-shimmer {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background:
    repeating-radial-gradient(80% 60% at 50% 70%, rgba(255,140,58,0.05) 0 2px, transparent 2px 5px);
  mix-blend-mode: screen;
  animation: shimmer 9s linear infinite;
}
@keyframes shimmer {
  0% { transform: translateY(0); opacity: 0.22; }
  50% { transform: translateY(-14px); opacity: 0.4; }
  100% { transform: translateY(0); opacity: 0.22; }
}
.ember-field { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
.cursor-sparks { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* ============ HUD ============ */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 2px;
  z-index: 50;
  background: rgba(255,140,58,0.08);
}
.scroll-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ember), var(--gold));
  box-shadow: 0 0 12px var(--ember);
}
.hud-brand {
  position: fixed;
  top: 22px; left: 30px;
  z-index: 50;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.34em;
  font-size: 12px;
  color: var(--cream);
  opacity: 0.75;
  pointer-events: none;
}
.hud-nav {
  position: fixed;
  right: 26px; top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.nav-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,210,127,0.5);
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all .35s var(--ease-out);
}
.nav-dot span {
  position: absolute; inset: 2px;
  border-radius: 50%;
  background: var(--ember);
  transform: scale(0);
  transition: transform .35s var(--ease-out);
}
.nav-dot.is-active { border-color: var(--ember); box-shadow: 0 0 10px rgba(255,107,43,0.6); }
.nav-dot.is-active span { transform: scale(1); }
.nav-dot:hover { border-color: var(--gold); transform: scale(1.25); }

/* ============ PIN SCAFFOLDING ============ */
main { position: relative; z-index: 10; }
.pin-scene { position: relative; height: var(--len, 100vh); }
.pin-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* shared scene copy */
.scene-copy {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  max-width: 640px;
}
.eyebrow {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ember);
  margin-bottom: 18px;
  opacity: 0.9;
}
.scene-head {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 6.5vw, 5.2rem);
  line-height: 1.04;
  color: #f7ead2;
  text-shadow: 0 4px 40px rgba(255,140,58,0.28);
  margin-bottom: 22px;
  letter-spacing: 0.01em;
}
.scene-body {
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  font-weight: 300;
  color: #d8c6ae;
  max-width: 440px;
  line-height: 1.7;
}

/* reveal animation for copy (JS adds .revealed) */
.scene-copy .eyebrow,
.scene-copy .scene-head,
.scene-copy .scene-body,
.scene-copy .cta-btn {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
}
.scene-copy.revealed .eyebrow { transition-delay: 0.05s; }
.scene-copy.revealed .scene-head { transition-delay: 0.15s; }
.scene-copy.revealed .scene-body { transition-delay: 0.28s; }
.scene-copy.revealed .cta-btn { transition-delay: 0.4s; }
.scene-copy.revealed .eyebrow,
.scene-copy.revealed .scene-head,
.scene-copy.revealed .scene-body,
.scene-copy.revealed .cta-btn {
  opacity: 1;
  transform: translateY(0);
}

/* ============ HERO ============ */
.hero-stage { flex-direction: column; }
.hero-egg-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.hero-egg {
  width: min(52vh, 62vw);
  height: auto;
  filter: drop-shadow(0 0 60px rgba(255,140,58,0.45));
  animation: heroFloat 7s ease-in-out infinite;
}
@keyframes heroFloat {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}
.hero-title {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 0 20px;
  margin-top: 10vh;
  pointer-events: none;
}
.hero-kicker {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--ash);
  margin-bottom: 20px;
  opacity: 0;
  animation: fadeUp 1.2s var(--ease-out) 0.4s forwards;
}
.hero-word {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3.4rem, 12vw, 10rem);
  letter-spacing: 0.06em;
  line-height: 0.9;
  background: linear-gradient(180deg, #fff7e0 0%, #ffd27f 38%, #ff8c3a 70%, #e8551f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 6px 40px rgba(255,107,43,0.35));
  opacity: 0;
  animation: heroTitleIn 1.8s var(--ease-out) 0.7s forwards;
}
@keyframes heroTitleIn {
  0% { opacity: 0; letter-spacing: 0.2em; transform: scale(1.04); }
  100% { opacity: 1; letter-spacing: 0.06em; transform: scale(1); }
}
.hero-tag {
  margin-top: 22px;
  font-weight: 300;
  font-size: clamp(0.95rem, 1.4vw, 1.1rem);
  color: #cdb99b;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: fadeUp 1.2s var(--ease-out) 1.4s forwards;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero-cta {
  position: absolute;
  bottom: 13vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  opacity: 0;
  animation: fadeUp 1.2s var(--ease-out) 1.8s forwards;
}
.scroll-hint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  width: 22px; height: 36px;
  border: 1px solid rgba(255,210,127,0.4);
  border-radius: 12px;
}
.scroll-hint span {
  position: absolute;
  left: 50%; top: 7px;
  width: 3px; height: 8px;
  margin-left: -1.5px;
  border-radius: 3px;
  background: var(--ember);
  animation: scrollHint 1.8s ease-in-out infinite;
}
@keyframes scrollHint {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ============ ORIGIN ============ */
.origin-egg-wrap {
  position: absolute;
  right: 8%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: min(46vh, 50vw);
}
.origin-egg {
  width: 100%;
  filter: drop-shadow(0 0 50px rgba(255,140,58,0.4));
}
.origin-copy { left: 8%; }

/* ============ HATCH ============ */
.hatch-stage { justify-content: flex-start; }
.hatch-egg-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  width: min(56vh, 66vw);
}
.hatch-egg {
  width: 100%;
  filter: drop-shadow(0 0 70px rgba(255,140,58,0.5));
  transition: transform 1.4s var(--ease-inout), opacity 1s var(--ease-out);
}
.hatch-dragon-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 7;
  width: min(48vh, 58vw);
  opacity: 0;
  transition: opacity 1.2s var(--ease-out);
}
.hatch-dragon { width: 100%; filter: drop-shadow(0 0 40px rgba(255,140,58,0.45)); }
.hatch-copy { right: 8%; text-align: right; }
.hatch-copy .scene-body { margin-left: auto; }

/* egg open state (scale + fade applied to the light-DOM svg element) */
.hatch-egg.is-open { transform: scale(1.12); opacity: 0; filter: blur(8px); }

/* ============ DETAILS / ORBIT ============ */
.details-stage { justify-content: flex-start; }
.orbit-rig {
  position: absolute;
  left: 8%;
  top: 50%;
  transform: translateY(-50%);
  width: min(52vh, 54vw);
  aspect-ratio: 1;
  z-index: 6;
  perspective: 1000px;
}
.orbit-stage3d {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  display: flex;
  align-items: center;
  justify-content: center;
}
.orbit-ring {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 1px dashed rgba(255,140,58,0.25);
  transform-style: preserve-3d;
  animation: ringSpin 28s linear infinite;
}
@keyframes ringSpin { to { transform: rotateX(64deg) rotateZ(360deg); } }
.orbit-particles {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}
.orbit-particles .op-item {
  position: absolute;
  left: 50%; top: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  filter: drop-shadow(0 0 8px rgba(255,140,58,0.7));
}
.orbit-particles .op-item.crystal { width: 12px; height: 26px; margin: -13px 0 0 -6px; }
.orbit-particles .op-item svg { width: 100%; height: 100%; display: block; }
.orbit-dragon {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 50px rgba(255,107,43,0.5));
}
.details-copy { right: 8%; text-align: right; }
.details-copy .scene-body { margin-left: auto; }

.callouts { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.callout {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
}
.callout.visible { opacity: 1; transform: translateY(0); }
.callout-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 0 4px rgba(255,107,43,0.18), 0 0 18px var(--ember);
  animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse { 0%,100% { box-shadow: 0 0 0 4px rgba(255,107,43,0.18), 0 0 12px var(--ember);} 50% { box-shadow: 0 0 0 8px rgba(255,107,43,0.08), 0 0 26px var(--ember);} }
.callout-line {
  width: 90px; height: 1px;
  background: linear-gradient(90deg, var(--ember), transparent);
  opacity: 0.6;
}
.callout-card {
  background: rgba(18,14,10,0.72);
  border: 1px solid rgba(255,140,58,0.25);
  border-radius: 12px;
  padding: 12px 16px;
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.callout-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 2px;
}
.callout-card p { font-size: 12px; color: #cbb89c; font-weight: 300; }

.callout-wings { left: 20%; top: 24%; }
.callout-horns { left: 22%; top: 46%; }
.callout-scales { left: 20%; bottom: 26%; }
.callout-chest { right: 18%; bottom: 30%; }

/* ============ FIRE ============ */
.fire-stage { justify-content: flex-start; }
.fire-dragon-wrap {
  position: absolute;
  right: 10%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  width: min(44vh, 52vw);
}
.fire-dragon { width: 100%; filter: drop-shadow(0 0 40px rgba(255,140,58,0.45)); }
.interact-embers {
  position: absolute; inset: 0;
  z-index: 5;
}
.sneeze-spark {
  position: absolute;
  right: 6%;
  top: 34%;
  width: 90px; height: 90px;
  z-index: 7;
  background: radial-gradient(circle, #fff3c4 0%, #ffb35c 30%, transparent 70%);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.sneeze-spark.erupt {
  animation: sneeze .9s var(--ease-out);
}
@keyframes sneeze {
  0% { opacity: 0; transform: translate(0,0) scale(0.2); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(120px,-160px) scale(1.4); }
}
.fire-copy { left: 8%; }
.fire-prompt {
  position: absolute;
  bottom: 9%;
  left: 8%;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ash);
}

/* ============ FLIGHT ============ */
.flight-stage { justify-content: flex-start; }
.flight-sky {
  position: absolute; inset: 0;
  overflow: hidden;
}
.flight-layer {
  position: absolute;
  inset: -20%;
  will-change: transform;
}
.flight-far {
  background:
    radial-gradient(60% 50% at 20% 30%, rgba(255,140,58,0.14) 0%, transparent 60%),
    radial-gradient(50% 45% at 75% 60%, rgba(255,107,43,0.12) 0%, transparent 60%),
    radial-gradient(40% 40% at 50% 100%, rgba(255,80,30,0.15) 0%, transparent 70%);
}
.flight-mid {
  background:
    radial-gradient(30% 25% at 30% 20%, rgba(255,180,90,0.1) 0%, transparent 70%),
    radial-gradient(26% 22% at 70% 80%, rgba(255,150,70,0.1) 0%, transparent 70%);
}
.flight-near {
  background:
    radial-gradient(80% 40% at 50% 108%, rgba(0,0,0,0.8) 0%, transparent 65%);
}
.flight-dragon-wrap {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 7;
  width: min(42vh, 50vw);
}
.flight-dragon {
  width: 100%;
  filter: drop-shadow(0 0 50px rgba(255,107,43,0.5));
  transform-origin: center;
}
.flight-copy { left: 8%; bottom: 12%; top: auto; }
.flight-copy .scene-head { text-shadow: 0 4px 40px rgba(255,107,43,0.35); }

/* ============ CTA ============ */
.cta-stage { flex-direction: column; justify-content: flex-end; }
.cta-ledge {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 34vh;
  background:
    radial-gradient(60% 90% at 50% 100%, #1c130c 0%, #0a0806 70%);
  z-index: 4;
  clip-path: polygon(0 55%, 28% 40%, 50% 46%, 74% 38%, 100% 55%, 100% 100%, 0 100%);
}
.cta-dragon-wrap {
  position: absolute;
  bottom: 20vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  width: min(52vh, 62vw);
}
.cta-dragon { width: 100%; filter: drop-shadow(0 0 60px rgba(255,107,43,0.5)); }
.cta-copy {
  position: relative;
  z-index: 12;
  text-align: center;
  padding: 40px 20px 64px;
  pointer-events: auto;
  margin-bottom: 3vh;
}
.cta-copy .scene-body { margin-left: auto; margin-right: auto; }
.cta-main { margin-top: 10px; }

/* ============ BUTTONS ============ */
.cta-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 34px;
  border: 1px solid rgba(255,140,58,0.55);
  border-radius: 100px;
  background: linear-gradient(180deg, rgba(255,140,58,0.16), rgba(255,107,43,0.05));
  color: #ffe9c4;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow .5s var(--ease-out), border-color .5s, transform .5s var(--ease-out), background .5s;
  pointer-events: auto;
}
.cta-btn::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,180,90,0.35), rgba(255,107,43,0.2));
  opacity: 0;
  transition: opacity .5s;
}
.cta-label { position: relative; z-index: 2; }
.cta-ember {
  position: relative; z-index: 2;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 10px var(--ember);
}
.cta-btn:hover {
  border-color: #ffd27f;
  transform: translateY(-2px);
  background: linear-gradient(180deg, rgba(255,140,58,0.28), rgba(255,107,43,0.12));
  box-shadow: 0 0 24px rgba(255,107,43,0.55), 0 0 60px rgba(255,107,43,0.3), inset 0 0 20px rgba(255,180,90,0.15);
}
.cta-btn:hover::before { opacity: 1; }
.cta-btn:hover .cta-ember { box-shadow: 0 0 16px var(--ember), 0 0 34px var(--ember); }
.cta-btn:active { transform: translateY(0) scale(0.98); }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .origin-egg-wrap { right: 50%; transform: translate(50%,-50%); top: 30%; }
  .origin-copy { left: 50%; transform: translateX(-50%); text-align: center; top: 66%; width: 90%; }
  .hatch-copy, .details-copy { right: 50%; transform: translateX(50%); text-align: center; width: 90%; }
  .hatch-copy .scene-body, .details-copy .scene-body { margin: 0 auto; }
  .orbit-rig { left: 50%; transform: translate(-50%,-50%); }
  .fire-dragon-wrap { right: 50%; transform: translate(50%,-50%); top: 38%; }
  .fire-copy { left: 50%; transform: translateX(-50%); text-align: center; width: 90%; top: 72%; }
  .callout-card { display: none; }
  .callout-line { width: 44px; }
  .hud-brand { left: 16px; }
  .hud-nav { right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; }
  .pin-scene { height: 100vh; }
}
