/* The First Quest — illuminated manuscript, layered-depth */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --parchment: #e8dcc8;
  --umber: #4a3220;
  --gold: #c4a040;
  --red: #8a2a2a;
  --cream: #f0e8d8;
  --shadow: #3a2818;
  --dust: #8a8070;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { scroll-behavior: smooth; }

body {
  background-color: var(--parchment);
  color: var(--umber);
  font-family: "Lora", Georgia, serif;
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.85;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(196,160,64,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(138,42,42,0.06) 0%, transparent 55%),
    repeating-radial-gradient(circle at 30% 40%, rgba(74,50,32,0.04) 0px, transparent 2px),
    repeating-radial-gradient(circle at 70% 60%, rgba(58,40,24,0.05) 0px, transparent 3px);
  background-size: 100% 100%, 100% 100%, 7px 7px, 11px 11px;
}

/* HERO */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  background:
    radial-gradient(ellipse at center, var(--cream) 0%, var(--parchment) 60%, #d8caaf 100%);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 32px;
  border: 1px solid var(--gold);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 40px;
  border: 1px solid rgba(196,160,64,0.4);
  pointer-events: none;
}

.heraldic {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(70px, 9vw, 130px);
  height: auto;
  opacity: 0;
  transition: opacity 1.2s ease, transform 1.2s var(--spring);
}
.heraldic-left { left: clamp(20px, 5vw, 80px); transform: translate(-40px, -50%); }
.heraldic-right { right: clamp(20px, 5vw, 80px); transform: translate(40px, -50%); }

.heraldic.is-visible { opacity: 1; }
.heraldic-left.is-visible { transform: translate(0, -50%); }
.heraldic-right.is-visible { transform: translate(0, -50%); }

.heraldic path,
.heraldic circle {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: drawStroke 2.4s ease forwards;
  animation-delay: 0.4s;
}
.heraldic.is-visible circle { animation-delay: 1.4s; }

@keyframes drawStroke {
  to { stroke-dashoffset: 0; }
}

.hero-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 820px;
}

.hero-eyebrow {
  display: inline-block;
  font-family: "Cinzel", "Playfair Display", serif;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  font-size: clamp(11px, 1vw, 13px);
  color: var(--red);
  margin-bottom: 28px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.8s ease 0.2s, transform 0.8s var(--spring) 0.2s;
}

.hero-title {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: clamp(32px, 7vw, 84px);
  letter-spacing: 0.04em;
  line-height: 1.05;
  color: var(--shadow);
  margin-bottom: 28px;
  opacity: 0;
  transform: translateY(40px) scale(0.94);
  transition: opacity 0.9s ease 0.5s, transform 0.9s var(--spring) 0.5s;
}

.hero-epigraph {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: clamp(16px, 1.6vw, 20px);
  color: var(--umber);
  max-width: 580px;
  margin: 0 auto 36px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.9s ease 0.9s, transform 0.9s var(--spring) 0.9s;
}

.is-loaded .hero-eyebrow,
.is-loaded .hero-title,
.is-loaded .hero-epigraph {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chevron-divider {
  width: clamp(160px, 26vw, 260px);
  margin: 12px auto 24px;
}
.chevron-divider svg { display: block; width: 100%; height: auto; }

.hero-scroll-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dust);
  opacity: 0;
  animation: fadeInBounce 1s var(--spring) 1.4s forwards;
}
.hero-scroll-hint svg {
  width: 22px;
  height: 30px;
  animation: gentleBounce 2.4s ease-in-out infinite 2s;
}
@keyframes fadeInBounce {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes gentleBounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

/* LAYERS */
main { position: relative; }

.layer {
  position: relative;
  padding: clamp(72px, 12vh, 140px) 24px;
  max-width: 1100px;
  margin: 0 auto;
  z-index: 1;
}

.layer + .layer { margin-top: -40px; }
.layer-i { z-index: 4; }
.layer-ii { z-index: 3; margin-left: clamp(0px, 4vw, 60px); }
.layer-iii { z-index: 2; margin-right: clamp(0px, 4vw, 60px); margin-left: auto; }
.layer-iv { z-index: 1; margin-left: clamp(0px, 6vw, 100px); }

.layer-stamp {
  position: absolute;
  top: 36px;
  left: 24px;
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(60px, 10vw, 120px);
  color: rgba(196,160,64,0.18);
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.layer-frame {
  position: relative;
  background: var(--cream);
  border: 1px solid var(--gold);
  padding: clamp(36px, 6vw, 64px);
  box-shadow:
    0 6px 0 -1px var(--parchment),
    0 6px 1px 0 var(--gold),
    0 18px 40px -10px rgba(58,40,24,0.35);
}
.layer-frame::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(196,160,64,0.5);
  pointer-events: none;
}

.layer-eyebrow {
  display: inline-block;
  font-family: "Cinzel", serif;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--red);
  margin-bottom: 18px;
}

.layer-title {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: clamp(28px, 4.4vw, 52px);
  color: var(--shadow);
  margin-bottom: 22px;
  line-height: 1.15;
}
.layer-title::after {
  content: "";
  display: block;
  width: 80px;
  height: 2px;
  margin-top: 18px;
  background: var(--gold);
}

.layer-lead {
  font-size: clamp(16px, 1.6vw, 19px);
  color: var(--umber);
  margin-bottom: 18px;
  font-style: italic;
}

.layer p {
  margin-bottom: 14px;
  color: var(--umber);
}

/* REVEAL ANIMATION (spring) */
.reveal {
  opacity: 0;
  transform: translateY(60px) scale(0.96);
  transition:
    opacity 0.7s ease,
    transform 0.7s var(--spring);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* CODEX */
.codex {
  max-width: 1100px;
  margin: clamp(60px, 10vh, 120px) auto 0;
  padding: clamp(48px, 8vw, 96px) 24px;
  text-align: center;
}

.codex-title {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: clamp(28px, 4.2vw, 48px);
  color: var(--shadow);
  margin-bottom: 12px;
}
.codex-title::after {
  content: "";
  display: block;
  width: 110px;
  height: 2px;
  margin: 18px auto 36px;
  background: var(--gold);
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
  margin-top: 30px;
}

.codex-card {
  background: var(--cream);
  border: 1px solid rgba(196,160,64,0.5);
  padding: 28px 22px;
  text-align: center;
  transition: transform 0.5s var(--spring), box-shadow 0.5s ease;
}
.codex-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 30px -10px rgba(58,40,24,0.35);
}

.codex-shield {
  width: 60px;
  margin: 0 auto 14px;
}
.codex-shield svg { width: 100%; height: auto; display: block; }

.codex-card h3 {
  font-family: "Cinzel", serif;
  font-size: 16px;
  letter-spacing: 0.18em;
  color: var(--red);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.codex-card p {
  font-family: "Lora", serif;
  color: var(--umber);
  font-size: 15px;
  line-height: 1.6;
}

/* COLOPHON */
.colophon {
  max-width: 720px;
  margin: clamp(40px, 8vh, 100px) auto;
  padding: 60px 24px 100px;
  text-align: center;
}
.colophon-title {
  font-family: "Cinzel", serif;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 14px;
  color: var(--red);
  margin: 18px 0 22px;
}
.colophon p {
  font-style: italic;
  color: var(--umber);
  margin-bottom: 14px;
}
.colophon-mark {
  margin-top: 24px;
  font-family: "Playfair Display", serif;
  font-style: italic;
  color: var(--dust);
}

@media (max-width: 720px) {
  .heraldic { display: none; }
  .layer-ii, .layer-iii, .layer-iv { margin-left: 0; margin-right: 0; }
  .layer + .layer { margin-top: -10px; }
}
