/* ================================================
   layer2.quest — styles.css
   Earth-tone split-screen contemplative design
   ================================================ */

/* --- CSS Custom Properties --- */
:root {
    --volcanic-basalt: #1C1A17;
    --warm-slate: #2A2621;
    --desert-sand: #C2A676;
    --ash-stone: #8B8378;
    --terracotta-oxide: #A0522D;
    --patina-green: #6B8E6B;
    --ochre-flare: #D4A243;
    --deep-loam: #0F0E0C;
    --clay-brown: #5C4033;

    --font-display: 'Anybody', sans-serif;
    --font-body: 'Newsreader', serif;
    --font-mono: 'Martian Mono', monospace;
}

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

html {
    scroll-behavior: auto;
}

body {
    background: var(--volcanic-basalt);
    color: var(--ash-stone);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- Intro Overlay --- */
#intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--volcanic-basalt);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 800ms ease-in-out;
}

#intro-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#intro-overlay.hidden {
    display: none;
}

#intro-line {
    width: 0;
    height: 1px;
    background: var(--terracotta-oxide);
    transition: width 1200ms ease-in-out;
}

#intro-line.expanded {
    width: 100vw;
}

/* --- Floating Domain Name --- */
#floating-domain {
    position: fixed;
    top: 24px;
    left: 24px;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--desert-sand);
    opacity: 0.7;
    z-index: 100;
    letter-spacing: 0.02em;
    line-height: 1;
    pointer-events: none;
}

/* --- Split-Screen Container --- */
#split-screen {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 2px minmax(280px, 1fr);
    height: 100vh;
    width: 100vw;
    opacity: 0;
    transition: opacity 800ms ease-in-out;
}

#split-screen.visible {
    opacity: 1;
}

/* --- Central Divider --- */
#divider {
    width: 2px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--terracotta-oxide) 15%,
        var(--terracotta-oxide) 85%,
        transparent 100%
    );
    position: relative;
    z-index: 10;
}

/* --- Left Hemisphere --- */
#left-hemisphere {
    background: var(--warm-slate);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#left-hemisphere::-webkit-scrollbar {
    display: none;
}

.terrain-section {
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.terrain-svg {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 150ms ease-out;
}

/* --- Glitch Effect --- */
.glitch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
}

.glitch-active .terrain-svg {
    animation: glitch-distort 600ms steps(8, end) forwards;
}

.glitch-active .glitch-overlay {
    opacity: 1;
    animation: glitch-scanlines 600ms steps(8, end) forwards;
}

@keyframes glitch-distort {
    0% {
        clip-path: inset(0);
        filter: none;
    }
    15% {
        clip-path: inset(8px 0 0 0);
        filter: hue-rotate(180deg);
    }
    30% {
        clip-path: inset(0 0 12px 0);
        filter: none;
    }
    45% {
        clip-path: inset(4px 0 0 0);
        filter: saturate(3);
    }
    60% {
        clip-path: inset(0);
        filter: hue-rotate(90deg);
    }
    100% {
        clip-path: inset(0);
        filter: none;
    }
}

@keyframes glitch-scanlines {
    0% {
        background: transparent;
    }
    15% {
        background: repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 3px,
            rgba(160, 82, 45, 0.6) 3px,
            rgba(160, 82, 45, 0.6) 6px
        );
        transform: translateX(2px);
    }
    30% {
        background: transparent;
        transform: translateX(-2px);
    }
    45% {
        background: repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 5px,
            rgba(160, 82, 45, 0.4) 5px,
            rgba(160, 82, 45, 0.4) 8px
        );
        transform: translateX(1px);
    }
    60% {
        background: transparent;
        transform: translateX(0);
    }
    100% {
        background: transparent;
        transform: translateX(0);
    }
}

/* --- Right Hemisphere --- */
#right-hemisphere {
    background: var(--volcanic-basalt);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0;
}

#right-hemisphere::-webkit-scrollbar {
    display: none;
}

/* --- Content Sections --- */
.content-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 80px 60px;
    position: relative;
}

/* --- Hero Section --- */
#section-hero {
    justify-content: center;
    align-items: flex-start;
}

.hero-content {
    max-width: 600px;
}

#hero-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(5rem, 12vw, 10rem);
    color: var(--desert-sand);
    letter-spacing: 0.02em;
    line-height: 0.92;
    margin-bottom: 40px;
    overflow: hidden;
}

#hero-title .char {
    display: inline-block;
    opacity: 0;
    transition: opacity 80ms ease-in-out;
}

#hero-title .char.visible {
    opacity: 1;
}

#hero-subtitle {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--ash-stone);
    opacity: 0;
    transition: opacity 600ms ease-in-out;
}

#hero-subtitle.visible {
    opacity: 0.6;
}

/* --- Content Plates --- */
.content-plate {
    padding-top: 120px;
    padding-bottom: 120px;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 500ms cubic-bezier(0.25, 0, 0.15, 1),
                transform 500ms cubic-bezier(0.25, 0, 0.15, 1);
}

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

/* --- Plate Indicator (Pulse Dot) --- */
.plate-indicator {
    margin-bottom: 32px;
}

.pulse-dot {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--patina-green);
    opacity: 0.4;
    transition: opacity 300ms ease;
}

.content-plate.revealed .pulse-dot {
    animation: pulse-once 600ms ease-out forwards;
}

@keyframes pulse-once {
    0% {
        opacity: 0.4;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(107, 142, 107, 0.4);
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
        box-shadow: 0 0 0 8px rgba(107, 142, 107, 0);
    }
    100% {
        opacity: 0.7;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(107, 142, 107, 0);
    }
}

/* --- Section Motif --- */
.section-motif {
    margin-bottom: 24px;
    opacity: 0.6;
}

/* --- Typography --- */
.display-heading {
    font-family: var(--font-display);
    font-weight: 900;
    letter-spacing: 0.02em;
    line-height: 0.92;
    color: var(--desert-sand);
}

.section-heading {
    font-size: clamp(2rem, 5vw, 4rem);
    margin-bottom: 40px;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    color: var(--ash-stone);
    margin-bottom: 2.4em;
    max-width: 540px;
}

.body-italic {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
}

.mono-text {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: var(--patina-green);
    line-height: 1.8;
}

/* --- Footer: Bedrock --- */
#section-bedrock {
    background: var(--deep-loam);
    min-height: 80vh;
}

.footer-content {
    max-width: 540px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 40px;
    margin-bottom: 60px;
}

.footer-link {
    color: var(--patina-green);
    text-decoration: none;
    position: relative;
    display: inline-block;
    width: fit-content;
    padding-bottom: 2px;
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--terracotta-oxide);
    transition: width 300ms ease-in-out;
}

.footer-link:hover::after {
    width: 100%;
}

.footer-link:hover {
    color: var(--desert-sand);
}

.footer-note {
    margin-top: 80px;
    opacity: 0.4;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
}

/* --- Mobile Layout (< 768px) --- */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
    }

    #split-screen {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    #left-hemisphere {
        display: none;
    }

    #divider {
        display: none;
    }

    #right-hemisphere {
        overflow: visible;
        width: 100%;
    }

    .content-section {
        min-height: auto;
        padding: 60px 24px;
    }

    #section-hero {
        min-height: 100vh;
    }

    #hero-title {
        font-size: clamp(3rem, 15vw, 6rem);
    }

    .section-heading {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

    .content-plate {
        padding-top: 60px;
        padding-bottom: 60px;
    }

    /* Mobile terrain dividers between sections */
    .content-plate::before {
        content: '';
        display: block;
        width: 100%;
        height: 120px;
        margin-bottom: 40px;
        background: linear-gradient(
            to bottom,
            var(--volcanic-basalt) 0%,
            var(--warm-slate) 30%,
            var(--clay-brown) 50%,
            var(--warm-slate) 70%,
            var(--volcanic-basalt) 100%
        );
        opacity: 0.3;
        border-radius: 0;
    }

    #floating-domain {
        font-size: 0.9rem;
        top: 16px;
        left: 16px;
    }

    .body-text {
        max-width: 100%;
    }

    .footer-content {
        max-width: 100%;
    }
}

/* --- Subtle luminance gradient for depth --- */
#right-hemisphere::after {
    content: '';
    position: fixed;
    bottom: 0;
    right: 0;
    width: 50%;
    height: 200px;
    background: linear-gradient(to top, var(--deep-loam), transparent);
    pointer-events: none;
    z-index: 5;
    opacity: 0.3;
}

@media (max-width: 768px) {
    #right-hemisphere::after {
        display: none;
    }
}
