/* =====================================================================
   PPUZZL.org — Marble Theater / Inflated-3D / Mysterious-Moody
   Palette:
     #1A1018  Deep Velvet Night (primary background)
     #2C1E2E  Bruised Dusk (secondary dark)
     #EFE8DC  Marble Cream (primary light surface)
     #D4824A  Candlelight Amber (warm accent)
     #C4748A  Faded Rose (secondary accent)
     #B8834F  Twilight Ochre (warm mid)
     #D0C8CE  Ash Violet (text on dark)
     #F5F0E8  Pale Vein (marble highlight)
     rgba(212,130,74,0.25)  Ember Glow (candle halo)
===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Playfair+Display:ital,wght@0,600;1,600&family=EB+Garamond:wght@400;500&family=Cinzel+Decorative:wght@400&display=swap');

/* ----- Reset & Base ----- */

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

html, body {
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: #1A1018;
    color: #D0C8CE;
    font-family: "EB Garamond", Georgia, serif;
    font-size: 17px;
    line-height: 1.75;
}

/* ----- Scroll Stage ----- */

.scroll-stage {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

/* Hide scrollbar but keep functionality */
.scroll-stage::-webkit-scrollbar {
    display: none;
}
.scroll-stage {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ----- Panel Base ----- */

.panel {
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ----- Typography Utilities ----- */

.cinzel-label {
    font-family: "Cinzel Decorative", serif;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #B8834F;
}

/* ----- Reveal Mechanism ----- */

.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 800ms ease, transform 600ms ease;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* =====================================================================
   SECTION I — THE ALTAR (Marble Hero)
===================================================================== */

.panel-altar {
    background:
        radial-gradient(ellipse 60% 40% at 30% 20%, rgba(200,190,175,0.4) 0%, transparent 70%),
        radial-gradient(ellipse 40% 60% at 75% 60%, rgba(180,170,155,0.3) 0%, transparent 60%),
        linear-gradient(127deg, #EFE8DC 0%, #E0D5C5 35%, #EDE4D5 60%, #E8DDD0 100%);
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Marble SVG veins */
.marble-veins {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Candlelight shimmer overlay (oscillating radial) */
.candlelight-shimmer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse 50% 40% at 50% 50%, rgba(212,130,74,0.10) 0%, transparent 65%);
    pointer-events: none;
    z-index: 2;
    animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

/* Section label (top-left corner of each section) */
.section-label {
    position: absolute;
    top: 48px;
    left: 60px;
    z-index: 10;
}

.panel-altar .section-label {
    color: #B8834F;
}

/* Ornamental flourish wrapper */
.ornament-wrap {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: 240px;
}

.ornament-wrap.reveal {
    transform: translateX(-50%) translateY(12px);
}

.ornament-wrap.reveal.is-visible {
    transform: translateX(-50%) translateY(0);
}

.ornament {
    width: 240px;
    height: 36px;
    display: block;
}

/* Ornament path-draw animation */
.ornament-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ornament-path.drawn {
    stroke-dashoffset: 0;
}

/* Altar center content */
.altar-center {
    position: relative;
    z-index: 10;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

/* PPUZZL Wordmark — inflated-3D treatment */
.wordmark {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 700;
    font-size: clamp(72px, 12vw, 140px);
    letter-spacing: 0.06em;
    line-height: 1;
    background: radial-gradient(ellipse at 30% 30%, #F5EEE0 0%, #D4B896 40%, #A07850 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 12px rgba(26,16,24,0.35)) drop-shadow(0 1px 2px rgba(26,16,24,0.5));
    margin: 0;
    padding: 0;
}

.wordmark-domain {
    font-family: "Cinzel Decorative", serif;
    font-size: clamp(16px, 2.5vw, 28px);
    letter-spacing: 0.25em;
    color: #B8834F;
    margin-top: -8px;
    filter: drop-shadow(0 2px 6px rgba(26,16,24,0.3));
}

.altar-tagline {
    font-family: "Playfair Display", Georgia, serif;
    font-style: italic;
    font-size: clamp(14px, 1.8vw, 20px);
    color: #7A6858;
    letter-spacing: 0.04em;
    margin-top: 16px;
    max-width: 480px;
}

/* Scroll invitation */
.scroll-invite {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    z-index: 10;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.scroll-invite.is-visible {
    transform: translateX(-50%) translateY(0);
}

.scroll-arrow {
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, #B8834F, transparent);
    margin: 0 auto;
    animation: arrow-pulse 2s ease-in-out infinite;
}

@keyframes arrow-pulse {
    0%, 100% { opacity: 0.4; transform: scaleY(1); }
    50% { opacity: 1; transform: scaleY(1.2); }
}

/* =====================================================================
   SECTION II — THE PUZZLE CHAMBER
===================================================================== */

.panel-chamber {
    background: #1A1018;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
}

.candle-glow-bg {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    background: radial-gradient(ellipse at center, rgba(212,130,74,0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}

/* Puzzle pieces scattered across dark bg */
.puzzle-field {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
}

.puzzle-piece {
    position: absolute;
    opacity: 0;
    transition: opacity 800ms ease, transform 600ms ease;
}

.puzzle-piece.drawn {
    opacity: 1;
}

/* Individual piece placements */
.piece-1 { width: 130px; height: 130px; top: 8%; left: 5%; transform: rotate(-15deg); }
.piece-2 { width: 100px; height: 100px; top: 15%; right: 10%; transform: rotate(22deg); }
.piece-3 { width: 110px; height: 110px; top: 45%; left: 12%; transform: rotate(-8deg); }
.piece-4 { width: 90px; height: 90px; top: 55%; right: 18%; transform: rotate(35deg); }
.piece-5 { width: 120px; height: 120px; bottom: 20%; left: 40%; transform: rotate(-28deg); }
.piece-6 { width: 85px; height: 85px; bottom: 15%; right: 8%; transform: rotate(12deg); }

/* Chamber panel content (bottom-left) */
.panel-content {
    position: relative;
    z-index: 10;
    padding: 80px 60px;
    max-width: 620px;
}

.panel-content-chamber {
    align-self: flex-end;
}

/* Panel titles - inflated-3D on dark backgrounds */
.panel-title {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 700;
    font-size: clamp(36px, 5vw, 64px);
    letter-spacing: 0.04em;
    line-height: 1.1;
    margin-bottom: 20px;
}

.panel-title-dark {
    background: radial-gradient(ellipse at 30% 30%, #F5EEE0 0%, #D4B896 40%, #A07850 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 12px rgba(26,16,24,0.6)) drop-shadow(0 1px 2px rgba(26,16,24,0.9));
}

.panel-title-light {
    background: radial-gradient(ellipse at 30% 30%, #F5EEE0 0%, #D4B896 40%, #A07850 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 3px 8px rgba(26,16,24,0.4));
}

.panel-body {
    font-family: "EB Garamond", Georgia, serif;
    font-size: 17px;
    line-height: 1.75;
    margin-bottom: 16px;
}

.panel-body-dark {
    color: #D0C8CE;
}

.panel-body-light {
    color: #4A3828;
}

/* Section labels inside panels */
.panel-content .section-label,
.codex-left .section-label,
.archive-content .section-label {
    position: static;
    margin-bottom: 8px;
    display: block;
}

.panel-content .ornament-wrap,
.codex-left .ornament-wrap,
.archive-content .ornament-wrap,
.seal-content .ornament-wrap {
    position: static;
    transform: none;
    left: auto;
    margin-bottom: 24px;
}

.panel-content .ornament-wrap.reveal,
.codex-left .ornament-wrap.reveal,
.archive-content .ornament-wrap.reveal,
.seal-content .ornament-wrap.reveal {
    transform: translateY(12px);
}

.panel-content .ornament-wrap.reveal.is-visible,
.codex-left .ornament-wrap.reveal.is-visible,
.archive-content .ornament-wrap.reveal.is-visible,
.seal-content .ornament-wrap.reveal.is-visible {
    transform: translateY(0);
}

.panel-content .ornament,
.codex-left .ornament,
.archive-content .ornament,
.seal-content .ornament {
    width: 200px;
    height: 30px;
}

/* =====================================================================
   SECTION III — THE CODEX (Editorial split)
===================================================================== */

.panel-codex {
    background: #1A1018;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
}

/* Left 60% */
.codex-left {
    width: 60%;
    height: 100%;
    background:
        radial-gradient(ellipse 80% 60% at 20% 50%, rgba(44,30,46,0.8) 0%, transparent 70%),
        radial-gradient(ellipse 60% 80% at 80% 30%, rgba(26,16,24,0.6) 0%, transparent 60%),
        linear-gradient(135deg, #241820 0%, #1E1418 50%, #211820 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 80px 60px;
    position: relative;
    z-index: 5;
}

/* Right 40% */
.codex-right {
    width: 40%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 5;
    background: linear-gradient(180deg, #1A1018 0%, #201418 100%);
}

/* CTA label */
.codex-cta {
    display: inline-block;
    border: 1px solid rgba(184,131,79,0.4);
    padding: 10px 24px;
    margin-top: 24px;
    cursor: pointer;
    transition: border-color 400ms ease, background 400ms ease;
}

.codex-cta:hover {
    border-color: rgba(212,130,74,0.7);
    background: rgba(212,130,74,0.08);
}

.cinzel-cta {
    font-size: 12px;
    color: #B8834F;
    letter-spacing: 0.25em;
}

/* ----- Candle CSS ----- */

.candle-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
}

.candle-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Candle body */
.candle-body {
    width: 40px;
    height: 160px;
    background: linear-gradient(to right, #E8D8C0 0%, #F0E4CC 30%, #EAD9BE 70%, #D8C8A8 100%);
    border-radius: 3px 3px 2px 2px;
    position: relative;
    box-shadow:
        inset 0 0 12px rgba(26,16,24,0.15),
        0 4px 20px rgba(26,16,24,0.6),
        0 2px 6px rgba(26,16,24,0.8);
}

.candle-highlight {
    position: absolute;
    top: 0; left: 8px;
    width: 8px;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.08) 50%, transparent 100%);
    border-radius: 4px;
}

/* Wick */
.wick {
    width: 2px;
    height: 14px;
    background: linear-gradient(to top, #5a4030, #3a2a1a);
    border-radius: 1px;
    margin-bottom: -2px;
    position: relative;
    z-index: 2;
}

/* Flame outer wrapper (for glow) */
.flame-outer {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 60px;
    width: 60px;
}

/* Flame */
.flame {
    width: 22px;
    height: 38px;
    background: linear-gradient(to top, #D4824A 0%, #E8A060 30%, #FFDD88 70%, #FFF0A0 100%);
    border-radius: 50% 50% 35% 35%;
    position: absolute;
    bottom: 0;
    box-shadow:
        0 0 12px 4px rgba(212,130,74,0.6),
        0 0 30px 8px rgba(212,130,74,0.3),
        0 0 50px 16px rgba(212,130,74,0.15);
    transform-origin: center bottom;
    animation: flicker 1.8s ease-in-out infinite;
}

/* Flame glow bloom */
.flame-glow {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255,220,100,0.3) 0%, rgba(212,130,74,0.15) 40%, transparent 70%);
    position: absolute;
    bottom: -5px;
    animation: flicker-glow 1.8s ease-in-out infinite;
}

@keyframes flicker {
    0%, 100% {
        transform: scaleX(1) scaleY(1) rotate(-1deg);
        opacity: 0.95;
    }
    33% {
        transform: scaleX(0.95) scaleY(1.05) rotate(1deg);
        opacity: 1;
    }
    66% {
        transform: scaleX(1.03) scaleY(0.97) rotate(-0.5deg);
        opacity: 0.9;
    }
}

@keyframes flicker-glow {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    33% { transform: scale(1.1) scaleX(0.95); opacity: 1; }
    66% { transform: scale(0.95) scaleX(1.05); opacity: 0.7; }
}

/* Candle ambient radial glow behind it on dark bg */
.candle-radial-glow {
    position: absolute;
    top: -40px; left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 300px;
    background: radial-gradient(ellipse at 50% 30%, rgba(212,130,74,0.18) 0%, transparent 65%);
    pointer-events: none;
    z-index: -1;
}

.candle-caption {
    margin-top: 8px;
    color: rgba(184,131,79,0.6);
    font-size: 10px;
}

/* =====================================================================
   SECTION IV — THE ARCHIVE (Sunset gradient)
===================================================================== */

.panel-archive {
    background: linear-gradient(160deg, #C88040 0%, #B06838 25%, #9A5030 50%, #7A3820 75%, #5A2818 100%);
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Archive ornament (large, top-center) */
.archive-ornament-wrap {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    z-index: 10;
    width: 360px;
}

.archive-ornament-wrap.is-visible {
    transform: translateX(-50%) translateY(0);
}

.archive-ornament {
    width: 360px;
    height: 60px;
    display: block;
}

/* Content */
.archive-content {
    position: relative;
    z-index: 10;
    text-align: center;
    max-width: 660px;
    padding: 0 40px;
    margin-top: 60px;
}

.archive-content .cinzel-label {
    color: rgba(240,220,180,0.7);
}

.archive-content .ornament {
    filter: brightness(1.5) sepia(0.3);
}

/* =====================================================================
   SECTION V — THE SEAL
===================================================================== */

.panel-seal {
    background: linear-gradient(160deg, #2C1218 0%, #1A1018 40%, #200A14 70%, #2A0E1A 100%);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
}

.seal-glow {
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: radial-gradient(ellipse at center, rgba(212,130,74,0.08) 0%, transparent 60%);
}

/* Seal SVG */
.seal-wrap {
    position: relative;
    z-index: 10;
}

.seal-svg {
    width: clamp(200px, 28vw, 280px);
    height: clamp(200px, 28vw, 280px);
    display: block;
}

/* Seal path-draw animation */
.seal-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1800ms cubic-bezier(0.4, 0, 0.2, 1);
}

.seal-path.drawn {
    stroke-dashoffset: 0;
}

/* Seal text content */
.seal-content {
    position: relative;
    z-index: 10;
    text-align: center;
    margin-top: 32px;
}

.seal-wordmark {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 700;
    font-size: clamp(28px, 4vw, 48px);
    letter-spacing: 0.08em;
    background: radial-gradient(ellipse at 30% 30%, #F5EEE0 0%, #D4B896 40%, #A07850 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 3px 10px rgba(26,16,24,0.7)) drop-shadow(0 1px 2px rgba(26,16,24,0.9));
    margin: 0 0 8px;
}

.seal-tagline {
    display: block;
    color: rgba(184,131,79,0.75);
    margin: 8px 0 16px;
    font-size: 11px;
    letter-spacing: 0.25em;
}

.seal-body {
    font-family: "EB Garamond", Georgia, serif;
    font-style: italic;
    font-size: 18px;
    line-height: 1.8;
    color: #D0C8CE;
    opacity: 0.75;
}

/* =====================================================================
   REVEAL DELAYS
===================================================================== */

/* Data-delay attributes handled by JS, but provide CSS fallback for
   elements that enter in sequence */
[data-delay="200"] { transition-delay: 200ms; }
[data-delay="400"] { transition-delay: 400ms; }
[data-delay="500"] { transition-delay: 500ms; }
[data-delay="600"] { transition-delay: 600ms; }
[data-delay="800"] { transition-delay: 800ms; }
[data-delay="900"] { transition-delay: 900ms; }

/* =====================================================================
   SELECTION
===================================================================== */

::selection {
    background: rgba(212,130,74,0.3);
    color: #F5EEE0;
}
