/* ═══════════════════════════════════════════════════════════════
   Adventure Codex — Level Intro Page
   Aesthetic: Illuminated Manuscript × Magical Forest
   Anchor: Golden-seal button + staggered parchment reveal

   DFII 14/15  |  Impact:4  Fit:5  Feasibility:5  Perf:5  Risk:1

   What this avoids:
   - Generic form-button CTA → wax-seal golden button
   - Static load → staggered cinematic entrance
   - Plain typography → manuscript chapter-title hierarchy
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&display=swap');

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  --color-abyss:      #071210;
  --color-forest:     #0b1f19;
  --color-gold:       #f0c94a;
  --color-gold-deep:  #b8861e;
  --color-gold-warm:  #ffe88a;
  --color-cream:      #fef3d4;
  --font-display:     'Ma Shan Zheng', 'STKaiti', 'KaiTi', 'FZKai-Z03', serif;
  --font-body:        'HarmonyOS Sans SC', 'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--color-abyss);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════════
   VIEWPORT & STAGE
   ═══════════════════════════════════════════════════════════════ */
.viewport {
  position: relative;
  display: grid;
  width: 100vw;
  height: 100vh;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background: var(--color-abyss);
}

.stage {
  position: relative;
  width: min(100vw, 150vh);
  aspect-ratio: 1536 / 1024;
  overflow: hidden;
  isolation: isolate;
  background: #102820;
  box-shadow: 0 0 72px rgba(0,0,0,0.74);
}

.stage img {
  user-select: none;
  -webkit-user-drag: none;
}

/* ── Scene Background ───────────────────────────────────────── */
.scene-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.04) brightness(0.84);
}

.scene-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(240,201,74,0.10), transparent 38%),
    linear-gradient(180deg, rgba(5,18,21,0.12), rgba(4,13,16,0.42));
}

/* ── Back Button ────────────────────────────────────────────── */
.back-button {
  position: absolute;
  top: 1.25%;
  left: 1.15%;
  z-index: 5;
  display: block;
  width: 6.55%;
  aspect-ratio: 1;
  transform-origin: center;
  text-decoration: none;
}

.back-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter:
    drop-shadow(0 0.7vmin 0.42vmin rgba(0,0,0,0.58))
    drop-shadow(0 0 0.65vmin rgba(255,215,104,0.36));
}

/* ═══════════════════════════════════════════════════════════════
   SCROLL PANEL — the manuscript container
   ═══════════════════════════════════════════════════════════════ */
.scroll-panel {
  position: absolute;
  inset: 8.4% 8.5% 6.5%;
  z-index: 3;
  display: grid;
  place-items: center;
  animation: scroll-enter 620ms cubic-bezier(0.22,0.61,0.36,1) both;
}

.scroll-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter:
    drop-shadow(0 1.3vmin 1vmin rgba(0,0,0,0.34))
    drop-shadow(0 0 1.6vmin rgba(255,212,112,0.24));
}

/* ── Scroll Content ─────────────────────────────────────────── */
.scroll-copy {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(67%, 880px);
  min-height: 48%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2% 2.6% 3%;
  color: #5b3213;
  text-align: center;
}

/* Eyebrow — decorative chapter label ──────────────────────── */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 1.4em;
  margin: 0 0 0.8em;
  color: #8d5621;
  font-size: clamp(13px, 1.65vmin, 20px);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  animation: fade-up 0.5s cubic-bezier(0.22,0.61,0.36,1) both;
  animation-delay: 0.30s;
}

.eyebrow span {
  display: block;
  width: 2.2em;
  height: 0.08em;
  background: linear-gradient(90deg, transparent, #a0682e 40%, #a0682e 60%, transparent);
}

/* Level Title — manuscript chapter heading ─────────────────── */
.scroll-copy h1 {
  margin: 0 0 0.55em;
  color: #4c1e08;
  font-family: var(--font-display);
  font-size: clamp(34px, 5.6vmin, 66px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: 0.10em;
  text-shadow:
    0 0.06em 0 rgba(255,235,170,0.60),
    0 0.10em 0.10em rgba(80,40,10,0.25);
  animation: fade-up 0.5s cubic-bezier(0.22,0.61,0.36,1) both;
  animation-delay: 0.45s;
}

/* Description — lore text ──────────────────────────────────── */
.scroll-copy p {
  max-width: 30em;
  margin: 0;
  font-size: clamp(16px, 2.05vmin, 26px);
  font-weight: 600;
  line-height: 1.82;
  letter-spacing: 0.02em;
  animation: fade-up 0.5s cubic-bezier(0.22,0.61,0.36,1) both;
  animation-delay: 0.60s;
}

/* ═══════════════════════════════════════════════════════════════
   START BUTTON — the golden seal
   This IS the element users remember.
   Not a generic pill — a wax-seal-like gateway that breathes.
   ═══════════════════════════════════════════════════════════════ */
.start-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 8.5em;
  min-height: 3em;
  margin-top: 2.2em;
  padding: 0 1.8em;
  text-decoration: none;

  /* Gold gradient with depth — like an engraved seal */
  background:
    linear-gradient(180deg, rgba(255,255,240,0.18) 0%, transparent 40%),
    linear-gradient(180deg, #efc44a 0%, #d49a1f 35%, #a46810 70%, #7a4208 100%);
  border: 0.14vmin solid #ffe49e;
  border-radius: 0.7vmin;

  /* Inner relief + outer glow */
  box-shadow:
    inset 0 0.10em 0 rgba(255,255,210,0.45),
    inset 0 -0.06em 0.10em rgba(60,20,0,0.40),
    0 0.40vmin 0.55vmin rgba(0,0,0,0.42),
    0 0 1.4vmin rgba(240,201,74,0.22);

  /* Breathing animation — draws the eye */
  animation:
    fade-up 0.5s cubic-bezier(0.22,0.61,0.36,1) both,
    seal-breathe 2.4s ease-in-out 1s infinite;
  animation-delay: 0.80s, 1s;

  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
              filter 0.22s ease;
}

.btn-text {
  position: relative;
  z-index: 1;
  color: #2d1300;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.9vmin, 38px);
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1;
  text-shadow:
    0 0.04em 0 rgba(255,235,160,0.55),
    0 0.06em 0.08em rgba(60,20,0,0.35);
}

/* Subtle inner glow overlay */
.btn-glow {
  position: absolute;
  inset: 18% 12%;
  z-index: 0;
  border-radius: 0.4vmin;
  background: radial-gradient(ellipse at 50% 25%, rgba(255,248,200,0.28), transparent 60%);
  pointer-events: none;
}

/* ── Button interactions ────────────────────────────────────── */
.start-button:hover,
.start-button:focus-visible {
  transform: translateY(-3%) scale(1.04);
  filter: brightness(1.10);
}

.start-button:hover,
.start-button:focus-visible {
  box-shadow:
    inset 0 0.10em 0 rgba(255,255,210,0.50),
    inset 0 -0.06em 0.10em rgba(60,20,0,0.40),
    0 0.50vmin 0.65vmin rgba(0,0,0,0.44),
    0 0 2.2vmin rgba(240,201,74,0.38);
}

.start-button:focus-visible {
  outline: 0.26vmin solid rgba(255,248,180,0.95);
  outline-offset: 0.35vmin;
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

/* Scroll panel entrance */
@keyframes scroll-enter {
  from {
    opacity: 0;
    transform: translateY(3%) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Staggered text fade-up */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(1.2vmin); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Button breathing — the golden seal pulses */
@keyframes seal-breathe {
  0%, 100% {
    box-shadow:
      inset 0 0.10em 0 rgba(255,255,210,0.45),
      inset 0 -0.06em 0.10em rgba(60,20,0,0.40),
      0 0.40vmin 0.55vmin rgba(0,0,0,0.42),
      0 0 1.4vmin rgba(240,201,74,0.22);
  }
  50% {
    box-shadow:
      inset 0 0.10em 0 rgba(255,255,210,0.50),
      inset 0 -0.06em 0.10em rgba(60,20,0,0.40),
      0 0.50vmin 0.60vmin rgba(0,0,0,0.44),
      0 0 2.6vmin rgba(240,201,74,0.42);
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile Portrait
   ═══════════════════════════════════════════════════════════════ */
@media (max-aspect-ratio: 1536 / 1024) {
  .stage { width: auto; height: 100vh; }
}

@media (max-width: 760px) and (orientation: portrait) {
  .stage { width: 100vw; height: 100vh; aspect-ratio: auto; }

  .scene-bg {
    width: 160vh;
    max-width: none;
    transform: translateX(-31%);
  }

  .back-button { width: 15%; }

  .scroll-panel { inset: 12% -14% 7%; }

  .scroll-copy {
    width: 58%;
    min-height: 58%;
    padding-top: 5%;
  }

  .scroll-copy h1 { font-size: clamp(28px, 7vw, 42px); }

  .scroll-copy p {
    max-width: 18em;
    font-size: clamp(13px, 3vw, 17px);
    line-height: 1.62;
  }

  .start-button {
    min-height: 2.8em;
    margin-top: 1.6em;
  }

  .btn-text { font-size: clamp(19px, 4.5vw, 28px); }
}

@media (max-width: 760px) and (orientation: landscape) {
  .stage { width: 100vw; height: auto; }
}

/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
