/* Cascade — Finale section
   Merged glitch-point + coda into one powerful closing block.
   Dark backdrop, gold accent, breathing pause, terminal epilogue.
*/

.cascade {
    padding: 0 0 0;
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 30%, rgba(28, 44, 52, 0.8), var(--bg) 70%);
    min-height: 620px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Gold rule at top — visual anchor separating projects from finale */
.cascade-rule {
    width: 160px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 0 auto 64px;
    opacity: 0.6;
}

.cascade-core {
    text-align: center;
    max-width: 600px;
    padding: 40px 24px 64px;
    position: relative;
    z-index: 2;
}

/* --- Phase 1: Self-aware interface --- */

.cascade-label {
    font-family: "Playfair Display", Georgia, serif;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 0.58rem;
    color: rgba(214, 174, 86, 0.48);
    margin: 0 0 28px;
}

.cascade-question {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    line-height: 1.25;
    color: var(--ink);
    margin: 0 0 28px;
    letter-spacing: 0.02em;
    transition: transform 0.15s ease;
}

.cascade-question.is-glitching {
    animation: questionShake 0.3s steps(3) 2;
}

@keyframes questionShake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    20% { transform: translate3d(-3px, 1px, 0); }
    40% { transform: translate3d(3px, -1px, 0); }
    60% { transform: translate3d(-1px, 2px, 0); }
    80% { transform: translate3d(2px, -2px, 0); }
}

.cascade-subtext {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.9rem;
    line-height: 1.72;
    color: var(--paper-soft);
    opacity: 0;
    transform: translate3d(0, 12px, 0);
    transition: opacity 1.2s ease 0.4s, transform 1.2s ease 0.4s;
    margin: 0 0 32px;
}

.cascade-subtext.is-revealed {
    opacity: 0.72;
    transform: translate3d(0, 0, 0);
}

.cascade-button {
    display: inline-block;
    font-family: "Playfair Display", Georgia, serif;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.64rem;
    color: rgba(214, 174, 86, 0.52);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    border: none;
    border-bottom: 1px dashed rgba(214, 174, 86, 0.18);
    padding: 0 0 2px;
    background: none;
    margin-bottom: 64px;
}

.cascade-button:hover,
.cascade-button:focus-visible {
    color: var(--gold);
    text-shadow: 0 0 14px rgba(214, 174, 86, 0.3);
    border-bottom-color: rgba(214, 174, 86, 0.5);
    outline: none;
}

/* --- Phase 2: Void & Epilogue --- */

.cascade-void {
    position: relative;
    padding: 32px 0 44px;
}

.cascade-void::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(214, 174, 86, 0.25), transparent);
}

.cascade-ellipsis {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(2rem, 4vw, 3.2rem);
    color: var(--paper-soft);
    opacity: 0;
    transform: translate3d(0, 18px, 0);
    transition: opacity 2.4s ease, transform 2.4s ease;
    margin: 0;
    letter-spacing: 0.06em;
}

.cascade-ellipsis.is-visible {
    opacity: 0.4;
    transform: translate3d(0, 0, 0);
}

.cascade-resolution {
    max-width: 52ch;
    margin: 0 auto;
}

.cascade-resolution p {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.78;
    color: var(--paper);
    opacity: 0;
    transform: translate3d(0, 12px, 0);
    transition: opacity 1.8s ease 0.8s, transform 1.8s ease 0.8s;
    margin: 0;
}

.cascade-resolution.is-visible p {
    opacity: 0.72;
    transform: translate3d(0, 0, 0);
}

/* Terminal cursor at end */
.cascade-cursor {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    background: var(--gold);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: cursorBlink 1s step-end infinite;
    opacity: 0;
    transition: opacity 0.6s ease 2.5s;
}

.cascade-cursor.is-visible {
    opacity: 0.8;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Page-wide glitch cascade */
body.is-glitch-cascade {
    animation: pageWobble 0.4s ease-in-out;
}

@keyframes pageWobble {
    0%, 100% { transform: translate3d(0, 0, 0); filter: none; }
    15% { transform: translate3d(-4px, 2px, 0); filter: hue-rotate(8deg) saturate(1.3); }
    35% { transform: translate3d(4px, -3px, 0); filter: hue-rotate(-6deg) saturate(0.8); }
    55% { transform: translate3d(-2px, 1px, 0); }
    75% { transform: translate3d(1px, -1px, 0); filter: none; }
}

/* Scanline overlay */
.cascade-scanline {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(214, 174, 86, 0.03) 2px,
        rgba(214, 174, 86, 0.03) 4px
    );
    opacity: 0;
    transition: opacity 0.1s ease;
}

body.is-glitch-cascade .cascade-scanline {
    opacity: 1;
}

@media (max-width: 720px) {
    .cascade {
        min-height: 480px;
    }

    .cascade-core {
        padding: 32px 16px 48px;
    }

    .cascade-rule {
        margin-bottom: 48px;
    }

    .cascade-void {
        padding: 24px 0 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cascade-question.is-glitching {
        animation: none;
    }
    body.is-glitch-cascade {
        animation: none;
    }
    .cascade-cursor {
        animation: none;
        opacity: 0.5;
    }
}
