/* ============================================================
   SANCTUARY OF THE MOSS-GILT GUARDIAN — Gothic Hunter Green
   ============================================================ */

:root {
  /* Hunter green spectrum */
  --hunter-deepest:   #0f2b1a;    /* deepest forest shadow */
  --hunter-dark:      #1a3d2c;    /* midnight moss */
  --hunter-mid:       #2a5a3f;    /* cathedral ivy */
  --hunter-leaf:      #3d7a53;    /* stained-glass leaf */
  --hunter-light:     #5c9e70;    /* light filtering through canopy */

  /* Accents */
  --oxidised-copper:  #5b7b6a;    /* aged copper patina */
  --gilt-gold:        #c9a84c;    /* tarnished gold leaf */
  --gilt-bright:      #e8d48b;    /* candle-lit gold */
  --bone:             #d4cfc1;    /* aged parchment / bone */
  --ivory:            #ede8db;    /* bleached ivory */

  /* Gothic shadows */
  --shadow-gloom:     #080f0a;    /* nearly-black green */
  --shadow-arch:      rgba(8, 15, 10, 0.7);

  /* Glass */
  --glass-ruby:       #8b1e2b;
  --glass-sapphire:   #1e3a5f;
  --glass-amethyst:   #4a2c5e;
  --glass-emerald:    #2d6e3e;

  /* Misc */
  --glow-gold:        0 0 12px rgba(201, 168, 76, 0.4);
  --glow-green:       0 0 16px rgba(42, 90, 63, 0.5);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--hunter-deepest);
  font-family: 'Cormorant Garamond', serif;
  color: var(--bone);
}

/* ============================================================
   CATHEDRAL NAVE
   ============================================================ */
.cathedral {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Subtle moss texture */
  background:
    radial-gradient(ellipse at 50% 0%, var(--hunter-dark) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 100%, var(--hunter-mid) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 100%, var(--hunter-mid) 0%, transparent 40%),
    linear-gradient(180deg, var(--hunter-deepest) 0%, #0a1f12 50%, var(--hunter-deepest) 100%);
  z-index: 1;
}

/* ============================================================
   PILLARS WITH GOTHIC ARCHES (via pseudo-elements)
   ============================================================ */
.pillar {
  position: absolute;
  top: 0;
  width: 80px;
  height: 100vh;
  background: linear-gradient(180deg,
    var(--hunter-dark) 0%,
    var(--hunter-mid) 40%,
    var(--hunter-dark) 100%
  );
  z-index: 2;
  pointer-events: none;
}
.pillar::before {
  content: '';
  position: absolute;
  top: -40px;
  left: -10px;
  width: 100px;
  height: 60px;
  background: radial-gradient(ellipse at 50% 100%,
    transparent 50%,
    var(--hunter-dark) 51%,
    transparent 52%
  );
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.pillar::after {
  content: '';
  position: absolute;
  left: 5px;
  width: 70px;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 30px,
    rgba(201, 168, 76, 0.04) 30px,
    rgba(201, 168, 76, 0.04) 31px
  );
}

.left-pillar  { left: 0; }
.right-pillar { right: 0; }

/* ============================================================
   STAINED-GLASS ROSE WINDOW — Turtle motif
   ============================================================ */
.rose-window {
  position: absolute;
  top: 4%;
  width: 260px;
  height: 260px;
  z-index: 5;
  animation: windowPulse 6s ease-in-out infinite;
}
@keyframes windowPulse {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 20px var(--glass-emerald)); }
  50%      { filter: brightness(1.15) drop-shadow(0 0 40px var(--gilt-gold)); }
}

.rose-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--hunter-dark);
  border: 4px solid var(--gilt-gold);
  box-shadow: 0 0 30px rgba(45, 110, 62, 0.4), inset 0 0 20px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 8 radial petals mimicking a turtle-shell rose */
.rose-petal {
  position: absolute;
  width: 40%;
  height: 40%;
  background: linear-gradient(
    135deg,
    var(--glass-emerald) 0%,
    var(--glass-sapphire) 40%,
    var(--glass-ruby) 70%,
    var(--gilt-gold) 100%
  );
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  opacity: 0.7;
  mix-blend-mode: screen;
  transform-origin: 50% 100%;
  border-radius: 0 0 30% 30%;
  transition: all 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.rose-petal:nth-child(1) { transform: rotate(0deg) translateY(-10%) scaleY(1.1); }
.rose-petal:nth-child(2) { transform: rotate(45deg) translateY(-10%) scaleY(1.1); }
.rose-petal:nth-child(3) { transform: rotate(90deg) translateY(-10%) scaleY(1.1); }
.rose-petal:nth-child(4) { transform: rotate(135deg) translateY(-10%) scaleY(1.1); }
.rose-petal:nth-child(5) { transform: rotate(180deg) translateY(-10%) scaleY(1.1); }
.rose-petal:nth-child(6) { transform: rotate(225deg) translateY(-10%) scaleY(1.1); }
.rose-petal:nth-child(7) { transform: rotate(270deg) translateY(-10%) scaleY(1.1); }
.rose-petal:nth-child(8) { transform: rotate(315deg) translateY(-10%) scaleY(1.1); }

/* When shattered, petals fly outward */
.rose-petal.shattered {
  animation: shatter 1s ease-out forwards;
}
@keyframes shatter {
  0%   { opacity: 0.7; transform: rotate(var(--r, 0deg)) translateY(-10%) scaleY(1.1); filter: brightness(1); }
  100% { opacity: 0; transform: rotate(calc(var(--r, 0deg) + 180deg)) translateY(-200%) scale(0.3); filter: brightness(2); }
}
.rose-petal.restored {
  animation: restore 1.2s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
}
@keyframes restore {
  0%   { opacity: 0; transform: rotate(calc(var(--r, 0deg) + 180deg)) translateY(-200%) scale(0.3); }
  100% { opacity: 0.7; transform: rotate(var(--r, 0deg)) translateY(-10%) scaleY(1.1); }
}

.rose-hub {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gilt-bright) 0%, var(--gilt-gold) 50%, var(--hunter-mid) 100%);
  z-index: 6;
  box-shadow: var(--glow-gold);
  border: 2px solid var(--hunter-dark);
}

/* ============================================================
   ALTAR — Where the Guardian dwells
   ============================================================ */
.altar {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  margin-top: 60px;
}

/* ============================================================
   TURTLE GUARDIAN — Pure CSS Art
   A gothic cathedral-turtle: shell = vaulted dome,
   scutes = rose-window patterns, head = carved gargoyle
   ============================================================ */
.turtle-guardian {
  position: relative;
  width: 320px;
  height: 200px;
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  filter: drop-shadow(0 10px 30px rgba(8, 15, 10, 0.8));
}

/* ---- SHELL (the vaulted dome) ---- */
.turtle-guardian::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20px;
  width: 280px;
  height: 160px;
  background:
    radial-gradient(ellipse at 30% 30%, var(--hunter-light) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 20%, var(--hunter-leaf) 0%, transparent 40%),
    linear-gradient(145deg,
      var(--hunter-dark) 0%,
      var(--hunter-mid) 30%,
      var(--hunter-leaf) 55%,
      var(--oxidised-copper) 80%,
      var(--hunter-dark) 100%
    );
  border-radius: 50% 50% 45% 45% / 60% 60% 30% 30%;
  border: 3px solid var(--gilt-gold);
  box-shadow:
    inset 0 -20px 40px rgba(0,0,0,0.6),
    inset 0 10px 20px rgba(201, 168, 76, 0.2),
    0 8px 20px var(--shadow-arch);
  z-index: 2;
}

/* Shell scutes — gothic pointed patterns */
.turtle-guardian::after {
  content: '';
  position: absolute;
  top: 15px;
  left: 45px;
  width: 230px;
  height: 120px;
  background:
    /* Central gothic arch scute */
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 8px,
      rgba(201, 168, 76, 0.08) 8px,
      rgba(201, 168, 76, 0.08) 9px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 8px,
      rgba(201, 168, 76, 0.08) 8px,
      rgba(201, 168, 76, 0.08) 9px
    );
  border-radius: 50%;
  clip-path: polygon(50% 0%, 85% 25%, 85% 75%, 50% 100%, 15% 75%, 15% 25%);
  border: 2px solid rgba(201, 168, 76, 0.3);
  z-index: 3;
}

/* Shell ridge — the "keel" of the gothic dome */
#shellPattern {
  position: absolute;
  top: 25px;
  left: 75px;
  width: 170px;
  height: 100px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 0%, transparent 40%, rgba(201, 168, 76, 0.15) 41%, transparent 42%),
    radial-gradient(ellipse at 50% 20%, transparent 40%, rgba(201, 168, 76, 0.1) 41%, transparent 42%),
    radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(201, 168, 76, 0.08) 41%, transparent 42%);
  z-index: 4;
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-radius: 50%;
}

/* ---- HEAD (gargoyle-inspired) ---- */
.turtle-head {
  position: absolute;
  top: -5px;
  left: 245px;
  width: 70px;
  height: 50px;
  background: linear-gradient(160deg,
    var(--hunter-mid) 0%,
    var(--hunter-leaf) 40%,
    var(--hunter-dark) 100%
  );
  border-radius: 40% 30% 50% 40% / 50% 30% 60% 40%;
  border: 2px solid var(--gilt-gold);
  box-shadow: inset 0 -5px 15px rgba(0,0,0,0.5);
  z-index: 5;
  transition: all 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* Snout */
.turtle-head::before {
  content: '';
  position: absolute;
  top: 12px;
  right: -6px;
  width: 16px;
  height: 12px;
  background: var(--hunter-dark);
  border-radius: 50% 30% 50% 30%;
  border: 1px solid var(--gilt-gold);
}

/* Eyes — golden glowing embers */
.turtle-eye {
  position: absolute;
  width: 12px;
  height: 14px;
  background: radial-gradient(circle at 40% 35%,
    var(--gilt-bright) 0%,
    var(--gilt-gold) 40%,
    #8a6e20 80%
  );
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.6);
  top: 12px;
  transition: all 0.3s ease;
}
.left-eye  { left: 10px; }
.right-eye { left: 35px; }
.turtle-eye::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 3px;
  width: 4px;
  height: 4px;
  background: var(--bone);
  border-radius: 50%;
}

/* ===== EYE GLOW (activated on click) ===== */
.turtle-eye.glowing {
  box-shadow: 0 0 20px var(--gilt-gold), 0 0 40px var(--gilt-bright);
  animation: eyeBlaze 0.8s ease-in-out 3;
}
@keyframes eyeBlaze {
  0%, 100% { box-shadow: 0 0 8px rgba(201, 168, 76, 0.6); }
  50%      { box-shadow: 0 0 30px var(--gilt-gold), 0 0 60px var(--gilt-bright); }
}

/* ---- LEGS (gothic column legs) ---- */
.turtle-leg {
  position: absolute;
  width: 24px;
  height: 35px;
  background: linear-gradient(90deg, var(--hunter-dark), var(--hunter-mid), var(--hunter-dark));
  border-radius: 30% 30% 40% 40%;
  border: 1px solid var(--gilt-gold);
  box-shadow: inset 0 -5px 10px rgba(0,0,0,0.4);
  z-index: 1;
  bottom: 0;
}
.fl { left: 50px;  border-right: 2px solid rgba(201, 168, 76, 0.15); }
.fr { left: 110px; border-left: 2px solid rgba(201, 168, 76, 0.15); }
.bl { left: 170px; border-right: 2px solid rgba(201, 168, 76, 0.15); }
.br { left: 230px; border-left: 2px solid rgba(201, 168, 76, 0.15); }

/* ---- TAIL (small pointed spire) ---- */
.turtle-tail {
  position: absolute;
  bottom: 5px;
  left: 285px;
  width: 20px;
  height: 14px;
  background: var(--hunter-dark);
  clip-path: polygon(0 30%, 100% 0%, 100% 100%, 0 70%);
  border: 1px solid var(--gilt-gold);
  z-index: 1;
}

/* === RETRACT (click to hide head/legs/tail) === */
.turtle-guardian.retracted .turtle-head { transform: translateY(20px) scaleY(0.3); opacity: 0.3; }
.turtle-guardian.retracted .turtle-leg { transform: translateY(10px) scaleY(0.5); opacity: 0.3; }
.turtle-guardian.retracted .turtle-tail { transform: translateY(8px) scaleY(0.3); opacity: 0.2; }
.turtle-guardian.retracted::before {
  border-radius: 50% 50% 45% 45% / 60% 60% 50% 50%;
  height: 175px;
}
.turtle-guardian.retracted {
  transform: scale(0.95);
}

/* ============================================================
   FILIGREE OVERLAY — Gothic ornamentation, revealed on hover
   ============================================================ */
.filigree-overlay {
  position: absolute;
  bottom: 10%;
  width: 80%;
  max-width: 600px;
  opacity: 0;
  transition: opacity 1.5s ease;
  z-index: 8;
  pointer-events: none;
}
.filigree-overlay.visible {
  opacity: 0.25;
}
.filigree-svg { width: 100%; height: auto; }
.filigree-path {
  stroke: var(--gilt-gold);
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
  animation: drawFiligree 3s ease forwards;
}
.filigree-overlay.visible .filigree-path {
  stroke-dashoffset: 0;
}
@keyframes drawFiligree {
  to { stroke-dashoffset: 0; }
}
.filigree-knot {
  fill: var(--gilt-gold);
  opacity: 0.6;
  filter: blur(1px);
}

/* ============================================================
   CANDLES — Ambience
   ============================================================ */
.candle {
  position: absolute;
  bottom: 15%;
  width: 14px;
  height: 50px;
  background: linear-gradient(180deg, var(--ivory), var(--bone));
  border-radius: 3px;
  z-index: 3;
  box-shadow: inset 0 -5px 10px rgba(0,0,0,0.3);
}
.candle::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 2px;
  width: 10px;
  height: 6px;
  background: var(--hunter-dark);
  border-radius: 2px;
}
.candle-left  { left: 15%; }
.candle-right { right: 15%; }

.flame {
  position: absolute;
  top: -22px;
  left: 2px;
  width: 10px;
  height: 25px;
  background: radial-gradient(ellipse at 50% 100%,
    var(--gilt-bright) 0%,
    var(--gilt-gold) 30%,
    rgba(201, 168, 76, 0.6) 60%,
    transparent 100%
  );
  border-radius: 50% 50% 20% 20%;
  animation: flicker 1.5s ease-in-out infinite alternate;
  filter: blur(1px);
}
@keyframes flicker {
  0%   { transform: scaleY(1) scaleX(1); opacity: 0.9; }
  25%  { transform: scaleY(1.1) scaleX(0.9); opacity: 1; }
  50%  { transform: scaleY(0.9) scaleX(1.05); opacity: 0.8; }
  75%  { transform: scaleY(1.05) scaleX(0.95); opacity: 0.95; }
  100% { transform: scaleY(0.95) scaleX(1.02); opacity: 0.85; }
}

/* ============================================================
   CANVAS (Fireflies) — Full screen, behind content
   ============================================================ */
#fireflyCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* ============================================================
   PROPHECY TEXT — Ancient script reveal
   ============================================================ */
.prophecy {
  position: absolute;
  bottom: -60px;
  font-family: 'UnifrakturMaguntia', cursive;
  font-size: 1.3rem;
  color: var(--gilt-gold);
  text-align: center;
  text-shadow: 0 0 15px rgba(201, 168, 76, 0.3);
  opacity: 0;
  transition: opacity 2s ease, transform 2s ease;
  transform: translateY(10px);
  pointer-events: none;
  max-width: 400px;
  line-height: 1.5;
  white-space: nowrap;
}
.prophecy.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   HIDDEN SIGIL — Easter egg trigger
   ============================================================ */
.hidden-sigil {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--hunter-deepest);
  border: 1px solid rgba(201, 168, 76, 0.15);
  cursor: pointer;
  z-index: 100;
  transition: all 0.5s ease;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  user-select: none;
}
.hidden-sigil:hover {
  border-color: var(--gilt-gold);
  box-shadow: 0 0 15px rgba(201, 168, 76, 0.3);
  width: 120px;
  border-radius: 20px;
  color: var(--gilt-gold);
}
.hidden-sigil:hover::after {
  content: '🜁 sigillum testudinis';
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.75rem;
  letter-spacing: 2px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .turtle-guardian { transform: scale(0.65); }
  .turtle-guardian.retracted { transform: scale(0.6); }
  .rose-window { width: 180px; height: 180px; top: 2%; }
  .candle { transform: scale(0.7); }
  .pillar { width: 40px; }
  .pillar::before { width: 60px; left: -10px; }
  .pillar::after { width: 30px; }
  .prophecy { font-size: 1rem; white-space: normal; max-width: 280px; }
}

@media (max-width: 480px) {
  .turtle-guardian { transform: scale(0.45); }
  .turtle-guardian.retracted { transform: scale(0.4); }
  .rose-window { width: 130px; height: 130px; }
}

/* ============================================================
   FLOATING ANIMATIONS
   ============================================================ */
@keyframes slowFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.turtle-guardian:not(.retracted) {
  animation: slowFloat 4s ease-in-out infinite;
}
