/* mystical.day — surreal daybreak liturgy
   Pre-dawn Vellum palette
   --------------------------------------------------- */

:root {
    --vellum-cream: #E9E2D2;
    --tarnished-ivory: #C9C0AE;
    --slate-mist: #5B6675;
    --inkwell: #2A2F3A;
    --vermilion: #7E2B2B;
    --brass-patina: #B8A48A;
    --lit-cream: #F4EFE3;

    --font-display: 'Cormorant Garamond', 'Cormorant', Georgia, serif;
    --font-body: 'Spectral', 'Inter', Georgia, serif;
    --font-marginalia: 'EB Garamond', 'Inter', Georgia, serif;

    --page-pad: clamp(32px, 11vw, 220px);

    --ease-wake: cubic-bezier(0.2, 0.7, 0.1, 1);
}

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

html, body {
    background: var(--vellum-cream);
    color: var(--slate-mist);
    font-family: var(--font-body);
    font-size: 17.5px;
    line-height: 1.78;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    cursor: none;
    position: relative;
}

/* ===== Persistent Plane III veils ===== */
.paper-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        radial-gradient(circle at 12% 20%, rgba(184, 164, 138, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 60%, rgba(91, 102, 117, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 50% 90%, rgba(201, 192, 174, 0.06) 0%, transparent 45%);
    mix-blend-mode: multiply;
    opacity: 0.6;
    animation: paper-breathe 9s ease-in-out infinite;
}

.grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    opacity: 0.04;
    mix-blend-mode: multiply;
    background-image:
        repeating-radial-gradient(circle at 0 0, transparent 0, rgba(42, 47, 58, 0.18) 0.5px, transparent 1px, transparent 2px),
        repeating-radial-gradient(circle at 50% 50%, rgba(42, 47, 58, 0.12) 0, transparent 1.2px);
    background-size: 3px 3px, 5px 5px;
    animation: grain-chatter 0.084s steps(1) infinite;
}

@keyframes grain-chatter {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(-1px, 1px); }
    50%  { transform: translate(1px, -1px); }
    75%  { transform: translate(-1px, -1px); }
    100% { transform: translate(0, 0); }
}

@keyframes paper-breathe {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 0.75; }
}

/* ===== Cursor halo ===== */
.cursor-halo {
    position: fixed;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(244, 239, 227, 0.6) 0%, rgba(244, 239, 227, 0.15) 50%, transparent 80%);
    pointer-events: none;
    z-index: 8500;
    transform: translate(-50%, -50%);
    mix-blend-mode: screen;
    transition: opacity 600ms var(--ease-wake);
    opacity: 0;
}

body.awake .cursor-halo { opacity: 1; }

/* ===== Dateline marginalia ===== */
.dateline {
    position: fixed;
    top: 28px;
    left: 28px;
    font-family: var(--font-marginalia);
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--slate-mist);
    text-transform: uppercase;
    font-variant: small-caps;
    z-index: 100;
    opacity: 0;
    transition: opacity 1800ms var(--ease-wake);
}

body.awake .dateline { opacity: 0.7; }

/* ===== Clock thumbnail ===== */
.clock-thumb {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    z-index: 200;
    cursor: pointer;
    opacity: 0;
    transition: opacity 1800ms var(--ease-wake), transform 200ms ease;
    pointer-events: auto;
}

.clock-thumb:hover { transform: scale(1.05); }
body.awake .clock-thumb { opacity: 0.85; }
.clock-thumb svg { width: 100%; height: 100%; }

/* ===== Vertical Chamber ===== */
.vertical-chamber {
    position: relative;
    z-index: 2;
    width: 100%;
}

.act {
    position: relative;
    min-height: 100vh;
    padding: 12vh var(--page-pad);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    filter: blur(14px);
    opacity: 0;
    transition: filter 1400ms var(--ease-wake), opacity 1400ms var(--ease-wake);
}

.act.in-view {
    filter: blur(0);
    opacity: 1;
}

.act-i  { background: var(--vellum-cream); min-height: 110vh; }
.act-ii { background: var(--lit-cream); min-height: 130vh; }
.act-iii { background: var(--tarnished-ivory); min-height: 120vh; }
.act-iv { background: var(--vellum-cream); min-height: 130vh; }
.act-v  { background: var(--lit-cream); min-height: 130vh; }
.act-vi { background: var(--tarnished-ivory); min-height: 140vh; }
.act-vii { background: var(--vellum-cream); min-height: 110vh; }

/* Diagonal tilted acts (II, IV, VI tilt; VI returns to 0 per design — so II and IV are tilted) */
.act.tilted .tilt-wrap {
    transform: rotate(-7deg);
    transform-origin: center center;
    transition: transform 1600ms var(--ease-wake);
}

/* ===== Imperfect corner frames (3 of 4) ===== */
.act-corner {
    position: absolute;
    width: 56px;
    height: 56px;
    pointer-events: none;
    z-index: 5;
}
.act-corner.corner-tl {
    top: 6vh; left: 6vw;
    border-top: 1.25px solid var(--brass-patina);
    border-left: 1.25px solid var(--brass-patina);
}
.act-corner.corner-tr {
    top: 6vh; right: 6vw;
    border-top: 1.25px solid var(--brass-patina);
    border-right: 1.25px solid var(--brass-patina);
}
.act-corner.corner-bl {
    bottom: 6vh; left: 6vw;
    border-bottom: 1.25px solid var(--brass-patina);
    border-left: 1.25px solid var(--brass-patina);
}
.act-corner.corner-br {
    bottom: 6vh; right: 6vw;
    border-bottom: 1.25px solid var(--brass-patina);
    border-right: 1.25px solid var(--brass-patina);
}

/* ===== Vertical act rail (right side) ===== */
.act-rail {
    position: absolute;
    top: 50%;
    right: 2.4vw;
    transform: translateY(-50%) rotate(90deg);
    transform-origin: right center;
    font-family: var(--font-marginalia);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-variant: small-caps;
    color: var(--brass-patina);
    white-space: nowrap;
    z-index: 6;
}

/* ===== Veils between acts ===== */
.veil {
    position: absolute;
    left: 0;
    width: 100%;
    height: 120px;
    pointer-events: none;
    z-index: 4;
}
.veil-bottom { bottom: -1px; }
.veil-top    { top: -1px; }
.veil svg { width: 100%; height: 100%; display: block; }

/* ===== ACT I content ===== */
.act-content {
    position: relative;
    width: 100%;
    max-width: 1280px;
    z-index: 3;
}

.opening-line {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(2.4rem, 5.6vw, 4.8rem);
    color: var(--slate-mist);
    letter-spacing: 0.005em;
    line-height: 1.04;
    max-width: 22ch;
    margin-left: 5%;
}

.opening-line .typewriter {
    display: inline;
    white-space: pre-wrap;
}

.opening-line .caret {
    display: inline-block;
    color: var(--vermilion);
    font-weight: 300;
    margin-left: 2px;
    animation: caret-blink 1.1s steps(1) infinite;
}

@keyframes caret-blink {
    0%, 50%   { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

.subtitle {
    margin-top: 1.6em;
    margin-left: 5%;
    font-family: var(--font-marginalia);
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-variant: small-caps;
    color: var(--slate-mist);
    opacity: 0;
    transition: opacity 1400ms var(--ease-wake);
}

.subtitle.visible { opacity: 0.6; }

/* ===== ACT II — Hand ===== */
.tilt-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5vw;
    flex-wrap: wrap;
}

.hand-drift {
    flex: 0 0 auto;
    width: clamp(280px, 38vw, 480px);
    margin-left: auto;
    margin-right: 6%;
    animation: drift-orbit-110 110s ease-in-out infinite;
}

.hand-drift .hand-svg { width: 100%; height: auto; display: block; }

.hand-symbol {
    cursor: pointer;
    transition: transform 600ms var(--ease-wake);
    transform-box: fill-box;
    transform-origin: center;
}
.hand-symbol:hover {
    transform: scale(1.18);
}

@keyframes drift-orbit-110 {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(-22px, 14px) rotate(-1deg); }
    50%  { transform: translate(8px, 26px) rotate(0.6deg); }
    75%  { transform: translate(20px, -8px) rotate(1.2deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.prophecy {
    flex: 1 1 320px;
    max-width: 460px;
    min-height: 6em;
    padding: 2em 1.5em;
}

.prophecy-line {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--slate-mist);
    line-height: 1.78;
    transition: opacity 600ms var(--ease-wake);
}

/* ===== ACT III — Tide ===== */
.act-iii .act-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4vh;
}

.tide-block {
    width: 100%;
    max-width: 900px;
}
.tide-svg {
    width: 100%;
    height: auto;
    display: block;
}

.tide-line {
    fill: none;
    stroke: var(--slate-mist);
    stroke-width: 1.1;
    stroke-linecap: round;
}

.tide-phrase {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1.4rem, 2.6vw, 2.1rem);
    color: var(--slate-mist);
    text-align: center;
    max-width: 38ch;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 1800ms var(--ease-wake);
}

.act-iii.in-view .tide-phrase { opacity: 1; }

/* ===== ACT IV — Candle ===== */
.candle-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6vw;
    flex-wrap: wrap;
}

.candle-block {
    flex: 0 0 auto;
    width: clamp(180px, 22vw, 280px);
    position: relative;
}

.candle-block::before {
    content: '';
    position: absolute;
    inset: -40px;
    background: radial-gradient(circle, rgba(126, 43, 43, 0.18) 0%, transparent 70%);
    z-index: -1;
    animation: candle-glow-pulse 2.2s ease-in-out infinite;
}

@keyframes candle-glow-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50%      { opacity: 1.0; transform: scale(1.06); }
}

.candle-svg { width: 100%; height: auto; display: block; }

.flame {
    transform-origin: 100px 110px;
    animation: flame-flicker 0.45s ease-in-out infinite alternate;
}
.flame-inner {
    transform-origin: 100px 110px;
    animation: flame-flicker 0.32s ease-in-out infinite alternate;
}

@keyframes flame-flicker {
    0%   { transform: scale(1, 1) translateY(0); }
    100% { transform: scale(1.04, 0.96) translateY(-1px); }
}

.candle-text {
    flex: 1 1 320px;
    max-width: 46ch;
}

.candle-text p {
    font-family: var(--font-body);
    font-weight: 300;
    color: var(--slate-mist);
    font-size: 1.05rem;
    line-height: 1.8;
}

/* ===== ACT V — Egg ===== */
.egg-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3vh;
}

.egg-block {
    width: clamp(200px, 24vw, 320px);
    position: relative;
}
.egg-svg { width: 100%; height: auto; display: block; }

.egg-crack {
    transition: transform 900ms var(--ease-wake);
    transform-origin: center;
}

.egg-contents {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 900ms var(--ease-wake), transform 900ms var(--ease-wake);
}

.act-v.egg-open .egg-crack {
    transform: translateY(-1.4px);
}

.act-v.egg-open .egg-contents {
    opacity: 1;
    transform: translateY(0);
}

.egg-caption {
    font-family: var(--font-marginalia);
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-variant: small-caps;
    color: var(--slate-mist);
    opacity: 0;
    transition: opacity 1400ms var(--ease-wake);
}

.act-v.egg-open .egg-caption { opacity: 0.85; }

/* ===== ACT VI — Aurora + Sigil ===== */
.act-vi {
    position: relative;
}

.aurora-ribbon {
    position: absolute;
    top: 18%;
    left: -10%;
    width: 130%;
    height: 1.5px;
    background: conic-gradient(
        from 90deg at 50% 50%,
        rgba(192, 144, 168, 0.18),
        rgba(168, 184, 168, 0.22),
        rgba(160, 152, 188, 0.2),
        rgba(192, 144, 168, 0.18)
    );
    box-shadow:
        0 0 18px 3px rgba(192, 144, 168, 0.16),
        0 0 32px 6px rgba(168, 184, 168, 0.12);
    filter: blur(1px);
    animation: aurora-drift 38s linear infinite;
    pointer-events: none;
    z-index: 4;
}

@keyframes aurora-drift {
    0%   { transform: translateX(0) skewX(0deg); }
    50%  { transform: translateX(-8%) skewX(-1deg); }
    100% { transform: translateX(0) skewX(0deg); }
}

.sigil-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3.4vh;
    margin-top: 6vh;
    position: relative;
    z-index: 5;
}

.sigil-block {
    width: clamp(220px, 28vw, 380px);
}

.sigil-svg { width: 100%; height: auto; display: block; }

.sigil-path {
    fill: none;
    stroke: var(--inkwell);
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sigil-caption {
    font-family: var(--font-marginalia);
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-variant: small-caps;
    color: var(--slate-mist);
    opacity: 0;
    transition: opacity 1400ms var(--ease-wake) 4400ms;
}

.act-vi.in-view .sigil-caption { opacity: 0.8; }

/* ===== ACT VII — Evening ===== */
.evening-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.6vh;
    padding-top: 24vh;
}

.closing-line {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1.8rem, 4.2vw, 3.4rem);
    color: var(--slate-mist);
    line-height: 1.04;
    letter-spacing: 0.005em;
}

.closing-subtitle {
    font-family: var(--font-marginalia);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-variant: small-caps;
    color: var(--slate-mist);
    opacity: 0.55;
}

.door-svg {
    width: clamp(120px, 14vw, 200px);
    height: auto;
    display: block;
    margin-top: 6vh;
    opacity: 0.7;
}

/* ===== Responsive: soften tilts and collapse acts under 720px ===== */
@media (max-width: 720px) {
    :root { --page-pad: 28px; }

    body { font-size: 16px; line-height: 1.7; }

    .act {
        min-height: 100vh !important;
        padding: 10vh var(--page-pad);
    }

    .act.tilted .tilt-wrap {
        transform: rotate(-3deg);
    }

    .clock-thumb {
        bottom: auto;
        top: 16px;
        right: 16px;
        width: 28px;
        height: 28px;
    }

    .dateline {
        top: 16px;
        left: 16px;
        font-size: 9px;
    }

    .act-rail {
        font-size: 9px;
        right: 1.2vw;
    }

    .opening-line {
        font-size: clamp(2rem, 7vw, 3rem);
        margin-left: 0;
    }

    .subtitle { margin-left: 0; }

    .candle-wrap, .tilt-wrap {
        flex-direction: column;
        gap: 4vh;
    }

    .hand-drift {
        margin: 0 auto;
        width: 70vw;
    }

    .candle-block {
        width: 50vw;
    }

    .act-corner {
        width: 36px;
        height: 36px;
    }
}
