/* ============================================
   undo.cafe — Y2K Futurism Scholarly Salon
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: #1A0E2E;
    color: #C8BDD4; /* alt dark: #2A1B3D */
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
}

/* --- THE TERMINAL --- */
#terminal {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1A0E2E;
    overflow: hidden;
}

.hero-title {
    position: relative;
    z-index: 2;
    font-size: clamp(4rem, 10vw, 9rem);
    letter-spacing: -0.03em;
    text-transform: lowercase;
    color: #E8E0F0;
    text-shadow: 0 0 40px rgba(138, 43, 226, 0.3), 0 0 80px rgba(138, 43, 226, 0.1);
}

.hero-epigraph {
    position: relative;
    z-index: 2;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    letter-spacing: 0.04em;
    color: #D4AF37;
    margin-top: 2rem;
    max-width: 65ch;
    text-align: center;
    opacity: 0;
    animation: fadeInEpigraph 1.5s ease forwards 1.5s;
}

@keyframes fadeInEpigraph {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Lens Flare */
.lens-flare--hero {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    z-index: 1;
    animation: breathe 6s ease-in-out infinite;
    pointer-events: none;
}

.flare-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(255,255,255,0.9) 0%, transparent 30%);
}

.flare-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle at center, transparent 20%, rgba(106,13,173,0.3) 40%, transparent 60%);
}

.flare-scatter {
    position: absolute;
    border-radius: 50%;
}

.flare-scatter--1 {
    top: 25%;
    left: 70%;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle, rgba(31,171,110,0.6) 0%, transparent 70%);
}

.flare-scatter--2 {
    top: 70%;
    left: 30%;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, rgba(196,30,58,0.5) 0%, transparent 70%);
}

.flare-streak {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(30deg);
    width: 600px;
    height: 4px;
    background: linear-gradient(90deg, transparent 0%, rgba(212,175,55,0.3) 30%, rgba(232,224,240,0.5) 50%, rgba(212,175,55,0.3) 70%, transparent 100%);
}

@keyframes breathe {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    50% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}

/* Chevron */
.chevron-down {
    position: absolute;
    bottom: 3rem;
    z-index: 2;
    animation: pulseChevron 2s ease-in-out infinite;
}

.chevron-arrow {
    display: block;
    width: 24px;
    height: 24px;
    border-right: 2px solid #B0B8C8;
    border-bottom: 2px solid #B0B8C8;
    transform: rotate(45deg);
}

@keyframes pulseChevron {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(8px); opacity: 1; }
}

/* --- Chrome Panel System --- */
.chrome-panel {
    border: 2px solid transparent;
    border-image: linear-gradient(90deg, #B0B8C8, #E8E0F0, #B0B8C8) 1;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(26, 14, 46, 0.6), inset 0 1px 0 rgba(232, 224, 240, 0.1);
    background: rgba(26, 14, 46, 0.7);
}

/* --- Reveal Animation --- */
.reveal-section .chrome-panel,
.reveal-section .residue-sidebar {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal-section.is-visible .chrome-panel,
.reveal-section.is-visible .residue-sidebar {
    opacity: 1;
    transform: translateY(0);
}

/* --- THE THESIS --- */
#thesis {
    padding: 8vh 5vw;
    background: linear-gradient(135deg, #1A0E2E 0%, #6A0DAD 40%, #1B3A6B 100%);
}

.thesis-panel {
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 3rem;
    padding: 4rem;
}

.thesis-left {
    flex: 0 0 60%;
    display: flex;
    align-items: center;
    background: #1B3A6B;
    border-radius: 8px;
    padding: 3rem;
}

.thesis-headline {
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    color: #E8E0F0;
    line-height: 1.1;
}

.thesis-right {
    flex: 0 0 calc(40% - 3rem);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.capsule-card {
    border-radius: 50px;
    padding: 1.5rem 2rem;
    color: #E8E0F0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
    cursor: default;
}

.capsule-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.capsule-card--amethyst { background: #6A0DAD; }
.capsule-card--emerald { background: #0D5E3A; }
.capsule-card--ruby { background: #C41E3A; }

.capsule-card p {
    font-size: 0.95rem;
    line-height: 1.6;
}

/* --- THE ARCHIVE --- */
#archive {
    padding: 8vh 5vw;
    background: linear-gradient(180deg, #1B3A6B 0%, #1A0E2E 100%);
}

.archive-panel {
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 2rem;
    padding: 3rem;
    background: rgba(27, 58, 107, 0.3);
    backdrop-filter: blur(10px);
}

.archive-left {
    flex: 0 0 50%;
}

.archive-heading {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    color: #E8E0F0;
    margin-bottom: 1.5rem;
}

.archive-text {
    max-width: 65ch;
    margin-bottom: 1.5rem;
    color: #C8BDD4;
}

.archive-center {
    flex: 0 0 25%;
}

.timeline {
    position: relative;
    padding: 1rem 0 1rem 2rem;
    height: 100%;
}

.timeline-line {
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #D4AF37;
}

.timeline-node {
    position: relative;
    margin-bottom: 2.5rem;
    padding-left: 1.5rem;
}

.timeline-dot {
    position: absolute;
    left: -1.5rem;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1FAB6E;
}

.timeline-date {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    color: #D4AF37;
    font-size: 1.1rem;
}

.timeline-label {
    display: block;
    font-size: 0.85rem;
    color: #B0B8C8;
    margin-top: 0.25rem;
}

.archive-right {
    flex: 0 0 calc(25% - 4rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Undo Stack Illustration */
.undo-stack {
    position: relative;
    width: 160px;
    height: 200px;
}

.stack-frame {
    position: absolute;
    border: 2px solid;
    border-image: linear-gradient(90deg, #B0B8C8, #E8E0F0, #B0B8C8) 1;
    border-radius: 8px;
    background: rgba(106, 13, 173, 0.1);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.stack-frame--1 { width: 160px; height: 200px; top: 0; left: 0; transition-delay: 0ms; }
.stack-frame--2 { width: 140px; height: 170px; top: 15px; left: 10px; transition-delay: 150ms; }
.stack-frame--3 { width: 120px; height: 140px; top: 30px; left: 20px; transition-delay: 300ms; }
.stack-frame--4 { width: 100px; height: 110px; top: 45px; left: 30px; transition-delay: 450ms; }
.stack-frame--5 { width: 80px; height: 80px; top: 60px; left: 40px; transition-delay: 600ms; }

.undo-stack:hover .stack-frame--1 { transform: translateY(-15px); opacity: 0; }
.undo-stack:hover .stack-frame--2 { transform: translateY(-12px); opacity: 0.3; }
.undo-stack:hover .stack-frame--3 { transform: translateY(-8px); opacity: 0.5; }
.undo-stack:hover .stack-frame--4 { transform: translateY(-4px); opacity: 0.7; }

/* --- THE RESIDUE --- */
#residue {
    position: relative;
    padding: 10vh 5vw;
    display: flex;
    gap: 3rem;
    background: #1A0E2E;
}

.residue-sidebar {
    flex: 0 0 20%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding-top: 2rem;
}

.chapter-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    opacity: 0.8;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.chapter-badge:hover {
    transform: scale(1.2);
    opacity: 1;
}

.residue-content {
    flex: 1;
    position: relative;
}

/* Botanical Leaves */
.leaf {
    position: absolute;
    opacity: 0.12;
    background: linear-gradient(180deg, #1FAB6E, #0D5E3A);
    clip-path: polygon(50% 0%, 80% 30%, 100% 50%, 80% 80%, 50% 100%, 20% 80%, 0% 50%, 20% 30%);
    pointer-events: none;
    z-index: 0;
}

.leaf--1 {
    width: 120px;
    height: 160px;
    top: 5%;
    right: 10%;
    transform: rotate(15deg);
}

.leaf--2 {
    width: 80px;
    height: 110px;
    top: 40%;
    right: 5%;
    transform: rotate(-25deg);
}

.leaf--3 {
    width: 100px;
    height: 130px;
    top: 75%;
    right: 15%;
    transform: rotate(40deg);
}

.leaf.is-ungrown {
    animation: unGrow 2s ease-in forwards;
}

@keyframes unGrow {
    from { transform: scale(1); opacity: 0.12; }
    to { transform: scale(0); opacity: 0; }
}

/* Residue Blocks */
.residue-block {
    position: relative;
    z-index: 1;
    padding: 2.5rem 3rem;
    margin-bottom: 15vh;
    max-width: 700px;
}

.residue-text {
    max-width: 65ch;
    color: #C8BDD4;
}

.residue-hidden {
    display: block;
    margin-top: 1rem;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    color: #D4AF37;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    letter-spacing: 0.04em;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Hover-Lift */
.hover-lift {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
    cursor: default;
}

.hover-lift:hover {
    transform: translateY(-12px);
    box-shadow: 0 16px 40px rgba(106, 13, 173, 0.3), 0 4px 20px rgba(26, 14, 46, 0.6), inset 0 1px 0 rgba(232, 224, 240, 0.1);
}

.hover-lift:hover .residue-hidden {
    opacity: 1;
    transform: translateY(0);
}

/* --- THE GROUNDS --- */
#grounds {
    position: relative;
    width: 100%;
    padding: 12vh 5vw;
    background: #1B3A6B;
    text-align: center;
    overflow: hidden;
}

.grounds-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 20vw;
    color: rgba(106, 13, 173, 0.08);
    white-space: nowrap;
    pointer-events: none;
    text-transform: lowercase;
}

.grounds-content {
    position: relative;
    z-index: 1;
}

.grounds-rule {
    border: none;
    border-top: 1px solid #B0B8C8;
    width: 40%;
    margin: 2rem auto;
}

.grounds-epitaph {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: #C41E3A;
    letter-spacing: 0.04em;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .thesis-panel {
        flex-direction: column;
        padding: 2rem;
    }
    .thesis-left, .thesis-right {
        flex: 1 1 auto;
    }
    .archive-panel {
        flex-direction: column;
        padding: 2rem;
    }
    .archive-left, .archive-center, .archive-right {
        flex: 1 1 auto;
    }
    #residue {
        flex-direction: column;
    }
    .residue-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
}
