/* undo.quest - Surreal Sepia Dreamscape */
/* Colors: #f4ead5 #5c3d2e #c8956c #2e1f14 #b8867a #e8dcc8 #7a8fa6 */
/* Fonts: Rokkitt (headlines), Lora (body), Zilla Slab (accents) */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #f4ead5;
    color: #5c3d2e;
    font-family: 'Lora', Georgia, serif;
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* Noise Texture Overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.035;
    filter: url(#noiseFilter);
    background: #f4ead5;
}

/* Crystal Dust Canvas */
#crystal-dust {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Scroll Progress Indicator - Left margin, fills bottom to top */
#scroll-progress {
    position: fixed;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    height: 200px;
    width: 2px;
    z-index: 100;
}

#scroll-track {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(92, 61, 46, 0.1);
}

#scroll-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: #c8956c;
    transition: height 0.15s ease;
}

.crystal-marker {
    position: absolute;
    left: -3px;
    width: 8px;
    height: 8px;
    transform: rotate(45deg);
    border: 1px solid rgba(92, 61, 46, 0.25);
    background: transparent;
}

/* ======================== */
/* HERO SECTION             */
/* ======================== */
.section-hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f4ead5;
    overflow: hidden;
}

.hero-crystal-container {
    position: relative;
    width: 280px;
    height: 280px;
}

.hero-crystal {
    width: 100%;
    height: 100%;
}

/* Crystal facets - stroke-dashoffset animation */
.crystal-facet,
.crystal-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: crystal-draw 2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.crystal-facet.c1 { animation-delay: 1.5s; }
.crystal-facet.c2 { animation-delay: 1.7s; }
.crystal-facet.c3 { animation-delay: 1.8s; }
.crystal-facet.c4 { animation-delay: 1.9s; }
.crystal-facet.c5 { animation-delay: 2.0s; }
.crystal-facet.c6 { animation-delay: 2.1s; }
.crystal-facet.c7 { animation-delay: 2.2s; }

.crystal-line.cl1 { animation-delay: 2.3s; }
.crystal-line.cl2 { animation-delay: 2.4s; }
.crystal-line.cl3 { animation-delay: 2.5s; }
.crystal-line.cl4 { animation-delay: 2.6s; }
.crystal-line.cl5 { animation-delay: 2.65s; }
.crystal-line.cl6 { animation-delay: 2.7s; }
.crystal-line.cl7 { animation-delay: 2.75s; }

.crystal-wash {
    opacity: 0;
    animation: wash-fade 1.2s cubic-bezier(0.23, 1, 0.32, 1) 2.5s forwards;
}

@keyframes crystal-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes wash-fade {
    to {
        opacity: 1;
    }
}

/* Hero title - letter by letter reveal */
.hero-title {
    font-family: 'Rokkitt', 'Courier New', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4rem);
    letter-spacing: -0.02em;
    color: #5c3d2e;
    margin-top: 2rem;
    position: relative;
    z-index: 5;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: letter-appear 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    animation-delay: calc(2.8s + var(--i) * 0.1s);
}

.hero-title .letter.dot {
    color: #c8956c;
}

@keyframes letter-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll hint */
.hero-scroll-hint {
    position: absolute;
    bottom: 40px;
    opacity: 0;
    animation: hint-fade 1s ease 4.5s forwards;
}

.scroll-arrow {
    width: 24px;
    height: 40px;
    animation: arrow-bob 2.5s ease-in-out infinite;
    animation-delay: 5s;
}

@keyframes hint-fade {
    to { opacity: 1; }
}

@keyframes arrow-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* ======================== */
/* CONTENT COLUMN           */
/* ======================== */
#content-column {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
    padding: 4rem 1.5rem 6rem;
    z-index: 5;
}

.content-section {
    padding: 3rem 0;
    position: relative;
}

/* Alternating section background via subtle opacity shift */
.section-alt {
    position: relative;
}

.section-alt::before {
    content: '';
    position: absolute;
    top: -2rem;
    left: -20vw;
    right: -20vw;
    bottom: -2rem;
    background-color: #e8dcc8;
    opacity: 0.4;
    z-index: -1;
    mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
}

/* Crystal Dividers */
.section-crystal-divider {
    text-align: center;
    margin-bottom: 2rem;
}

.divider-crystal {
    width: 200px;
    max-width: 80%;
    height: auto;
}

/* Content blocks - fragment reveal animation */
.content-block {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.9s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.9s cubic-bezier(0.23, 1, 0.32, 1);
}

.content-block.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Section Headings */
.section-heading {
    font-family: 'Rokkitt', 'Courier New', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3rem);
    letter-spacing: -0.02em;
    color: #5c3d2e;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

/* Body Text */
.body-text {
    font-family: 'Lora', Georgia, serif;
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.75;
    color: #5c3d2e;
    margin-bottom: 1.25rem;
}

/* Accent text - Zilla Slab italic */
.accent-text {
    font-family: 'Zilla Slab', 'Courier New', serif;
    font-weight: 300;
    font-style: italic;
    color: #c8956c;
    font-size: 1.15rem;
}

/* Phantom Blue text - rare cool accent */
.phantom-blue-text {
    font-family: 'Zilla Slab', 'Courier New', serif;
    font-weight: 300;
    font-style: italic;
    color: #7a8fa6;
    font-size: 1.15rem;
}

/* Caption text */
.caption-text {
    font-family: 'Zilla Slab', 'Courier New', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.95rem;
    color: #b8867a;
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
}

/* ======================== */
/* ILLUSTRATIONS            */
/* ======================== */
.illustration-container {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.dissolving-object {
    width: 180px;
    height: auto;
    opacity: 0.8;
}

/* Dissolving parts animation */
.dissolve-part {
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.dissolving-object.dissolving .dissolve-part.d7,
.dissolving-object.dissolving .dissolve-part.d8,
.dissolving-object.dissolving .dissolve-part.d9 {
    transform: translate(var(--dx, 5px), var(--dy, -8px));
    opacity: 0.15;
}

/* Compass needle counter-clockwise spin */
.compass-needle {
    transform-origin: 100px 100px;
    animation: counter-spin 20s linear infinite;
}

@keyframes counter-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

/* ======================== */
/* REWINDING THREADS        */
/* ======================== */
.rewinding-thread {
    display: block;
    width: 160px;
    max-width: 60%;
    margin: 1rem auto;
    overflow: visible;
}

.thread-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.thread-path.rewound {
    stroke-dashoffset: 300;
}

/* ======================== */
/* FINAL CRYSTAL FORMATION  */
/* ======================== */
.final-crystal-formation {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.final-crystal {
    width: 240px;
    height: auto;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 1.2s cubic-bezier(0.23, 1, 0.32, 1),
                transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.final-crystal.visible {
    opacity: 1;
    transform: scale(1);
}

/* ======================== */
/* INK WASH BACKGROUNDS     */
/* ======================== */
.ink-wash {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: multiply;
}

.ink-wash-1 {
    width: 600px;
    height: 600px;
    top: -100px;
    right: -200px;
    background: radial-gradient(ellipse at center, rgba(200, 149, 108, 0.08) 0%, transparent 70%);
}

.ink-wash-2 {
    width: 500px;
    height: 500px;
    bottom: 20%;
    left: -250px;
    background: radial-gradient(ellipse at center, rgba(184, 134, 122, 0.06) 0%, transparent 70%);
}

.ink-wash-3 {
    width: 400px;
    height: 400px;
    top: 40%;
    right: -150px;
    background: radial-gradient(ellipse at center, rgba(122, 143, 166, 0.04) 0%, transparent 70%);
}

/* ======================== */
/* RESPONSIVE               */
/* ======================== */
@media (max-width: 768px) {
    #scroll-progress {
        left: 12px;
        height: 150px;
    }

    #content-column {
        padding: 3rem 1.25rem 4rem;
    }

    .hero-crystal-container {
        width: 220px;
        height: 220px;
    }

    .section-heading {
        font-size: clamp(1.6rem, 4vw, 2.4rem);
    }

    .ink-wash {
        display: none;
    }
}

@media (max-width: 480px) {
    #scroll-progress {
        display: none;
    }

    .hero-crystal-container {
        width: 180px;
        height: 180px;
    }

    .body-text {
        font-size: 1rem;
    }
}

/* Dissolving Margins - column edges fade into parchment */
#content-column::before,
#content-column::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60px;
    pointer-events: none;
    z-index: 10;
}

#content-column::before {
    left: -30px;
    background: linear-gradient(to right, #f4ead5, transparent);
}

#content-column::after {
    right: -30px;
    background: linear-gradient(to left, #f4ead5, transparent);
}

/* Parallax layers */
.parallax-bg {
    will-change: transform;
}
