/* ============================================
   martial.quest - Styles
   Ocean Deep / Graffiti-Scholarly / Watercolor
   Fonts: Space Mono" (Google Fonts), IBM Plex Mono" (Google Fonts) 400/500, Caveat
   Interaction Pattern:** Ripple - Interaction elements with IntersectionObserver
   character appears with distortion effect: (centered on the character
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --abyssal-black: #050E18;
    --midnight-trench: #091B2A;
    --bathyal-blue: #0A2540;
    --bioluminescent-teal: #4ECDC4;
    --phosphor-cyan: #00BCD4;
    --graffiti-coral: #FF6B6B;
    --foam-white: #E0F7FA;
    --washed-slate: #B0C4D8;
    --depth-mist: #546E7A;
    --watercolor-teal: #26C6DA;
    --ink-wash-indigo: #1A237E;
}

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

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

body {
    background: var(--abyssal-black);
    color: var(--washed-slate);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    /* Long gradient simulating oceanic depth descent */
    background: linear-gradient(
        to bottom,
        var(--midnight-trench) 0%,
        var(--bathyal-blue) 15%,
        var(--midnight-trench) 30%,
        #071824 50%,
        var(--abyssal-black) 70%,
        #030910 85%,
        #010508 100%
    );
    background-attachment: fixed;
    background-size: 100% 600vh;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Domain Watermark --- */
.domain-watermark {
    position: fixed;
    top: 24px;
    left: 24px;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(0.85rem, 1.2vw, 1.1rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--foam-white);
    opacity: 0.12;
    z-index: 100;
    transition: opacity 0.4s ease;
    pointer-events: auto;
    cursor: default;
    user-select: none;
}

.domain-watermark:hover {
    opacity: 0.3;
}

/* --- Particle Canvas --- */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* --- Ripple Container --- */
#ripple-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none;
    overflow: hidden;
}

.ripple-ring {
    position: absolute;
    border-radius: 50%;
    border: 1.5px solid var(--bioluminescent-teal);
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

/* --- Zones --- */
.zone {
    position: relative;
    overflow: hidden;
}

/* --- ZONE 1: THE THRESHOLD --- */
.zone-threshold {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--midnight-trench) 0%, var(--bathyal-blue) 100%);
}

/* Hero Title */
.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(2.8rem, 6vw, 5rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.15;
    color: var(--foam-white);
    text-align: center;
    position: relative;
    z-index: 10;
    opacity: 0;
}

.hero-title .char {
    display: inline-block;
    opacity: 0;
    position: relative;
}

.hero-title .char.revealed {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.hero-title .char .ripple-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(78, 205, 196, 0.2) 0%, rgba(78, 205, 196, 0) 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Scroll Invitation */
.scroll-invitation {
    width: 2px;
    height: 120px;
    margin-top: 40px;
    z-index: 10;
    opacity: 0;
}

.scroll-invitation.visible {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* --- Watercolor Washes --- */
.wash {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    z-index: 1;
}

/* Threshold washes */
.wash-threshold-1 {
    width: 80vw;
    height: 60vh;
    top: 10%;
    left: -10%;
    background: radial-gradient(ellipse at center, rgba(9, 27, 42, 0.15) 0%, transparent 70%);
    filter: url(#watercolor-wash);
    opacity: 0;
    animation: wash-drift 20s ease-in-out infinite alternate;
}

.wash-threshold-2 {
    width: 70vw;
    height: 50vh;
    top: 30%;
    right: -15%;
    background: radial-gradient(ellipse at center, rgba(10, 37, 64, 0.15) 0%, transparent 70%);
    filter: url(#watercolor-wash-2);
    opacity: 0;
    animation: wash-drift 25s ease-in-out infinite alternate-reverse;
}

.wash-threshold-3 {
    width: 60vw;
    height: 45vh;
    top: 20%;
    left: 20%;
    background: radial-gradient(ellipse at center, rgba(38, 198, 218, 0.12) 0%, transparent 70%);
    filter: url(#watercolor-wash-3);
    opacity: 0;
    animation: wash-drift 22s ease-in-out infinite alternate;
}

/* Codex washes */
.wash-codex-1 {
    width: 100vw;
    height: 40vh;
    top: 5%;
    left: -20%;
    background: radial-gradient(ellipse at center, rgba(38, 198, 218, 0.18) 0%, transparent 70%);
    filter: url(#watercolor-wash);
    opacity: 0.7;
    animation: wash-drift 24s ease-in-out infinite alternate;
}

.wash-codex-2 {
    width: 90vw;
    height: 35vh;
    top: 40%;
    right: -10%;
    background: radial-gradient(ellipse at center, rgba(26, 35, 126, 0.15) 0%, transparent 70%);
    filter: url(#watercolor-wash-2);
    opacity: 0.6;
    animation: wash-drift 28s ease-in-out infinite alternate-reverse;
}

.wash-codex-3 {
    width: 80vw;
    height: 30vh;
    top: 75%;
    left: 10%;
    background: radial-gradient(ellipse at center, rgba(10, 37, 64, 0.2) 0%, transparent 70%);
    filter: url(#watercolor-wash-3);
    opacity: 0.5;
    animation: wash-drift 20s ease-in-out infinite alternate;
}

/* Training washes */
.wash-training-1 {
    width: 110vw;
    height: 50vh;
    top: 10%;
    left: -15%;
    background: radial-gradient(ellipse at center, rgba(38, 198, 218, 0.15) 0%, transparent 65%);
    filter: url(#watercolor-wash);
    opacity: 0.6;
    animation: wash-drift 26s ease-in-out infinite alternate;
}

.wash-training-2 {
    width: 90vw;
    height: 45vh;
    top: 55%;
    right: -20%;
    background: radial-gradient(ellipse at center, rgba(26, 35, 126, 0.12) 0%, transparent 65%);
    filter: url(#watercolor-wash-2);
    opacity: 0.5;
    animation: wash-drift 22s ease-in-out infinite alternate-reverse;
}

/* Deep washes */
.wash-deep-1 {
    width: 70vw;
    height: 40vh;
    top: 20%;
    left: 15%;
    background: radial-gradient(ellipse at center, rgba(38, 198, 218, 0.1) 0%, transparent 60%);
    filter: url(#watercolor-wash-3);
    opacity: 0.4;
    animation: wash-drift 30s ease-in-out infinite alternate;
}

/* Dissolution washes */
.wash-dissolution-1 {
    width: 60vw;
    height: 30vh;
    top: 10%;
    left: 20%;
    background: radial-gradient(ellipse at center, rgba(78, 205, 196, 0.06) 0%, transparent 60%);
    filter: url(#watercolor-wash);
    opacity: 0.3;
    animation: wash-drift 35s ease-in-out infinite alternate;
}

@keyframes wash-drift {
    0% { transform: translateX(-5px); }
    100% { transform: translateX(10px); }
}

/* --- ZONE 2: THE CODEX --- */
.zone-codex {
    min-height: 200vh;
    padding: 15vh 0;
    position: relative;
}

/* --- ZONE 3: THE TRAINING GROUND --- */
.zone-training {
    min-height: 150vh;
    padding: 10vh 0;
    position: relative;
}

/* --- ZONE 4: THE DEEP --- */
.zone-deep {
    min-height: 100vh;
    padding: 10vh 0;
    position: relative;
    background: linear-gradient(180deg, transparent 0%, rgba(5, 14, 24, 0.6) 100%);
}

/* --- ZONE 5: THE DISSOLUTION --- */
.zone-dissolution {
    min-height: 60vh;
    padding: 10vh 0 20vh;
    position: relative;
}

/* --- Content Blocks --- */
.content-block {
    max-width: 720px;
    margin: 0 auto;
    padding: 3vh 5vw;
    position: relative;
    z-index: 5;
    margin-bottom: min(12vh, 120px);
    background: radial-gradient(ellipse at center, rgba(9, 27, 42, 0.03) 0%, transparent 70%);
}

.content-block.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.content-block.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Serpentine left-right alignment */
.content-left {
    margin-left: 8vw;
    margin-right: auto;
}

.content-right {
    margin-right: 8vw;
    margin-left: auto;
}

/* Training Ground blocks */
.training-block {
    max-width: 900px;
}

.training-block-1 {
    transform: rotate(-0.5deg);
}

.training-block-1.visible {
    transform: rotate(-0.5deg) translateY(0);
}

.training-block-2 {
    transform: rotate(1.2deg);
    margin-left: 12vw;
}

.training-block-2.visible {
    transform: rotate(1.2deg) translateY(0);
}

.training-block-3 {
    transform: rotate(-0.8deg);
    margin-right: 10vw;
    margin-left: auto;
}

.training-block-3.visible {
    transform: rotate(-0.8deg) translateY(0);
}

/* Deep blocks */
.deep-block {
    max-width: 480px;
}

/* Dissolution blocks */
.dissolution-block {
    max-width: 480px;
    text-align: center;
}

.dissolution-text {
    opacity: 0.6;
    transition: opacity 0.5s ease;
}

.dissolution-text-deep {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--foam-white);
    opacity: 0.15;
}

/* --- Typography --- */
.section-heading {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.15;
    color: var(--foam-white);
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: var(--washed-slate);
    margin-bottom: 1.2rem;
}

.body-text:last-child {
    margin-bottom: 0;
}

/* --- Margin Annotations --- */
.margin-annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--bioluminescent-teal);
    opacity: 0;
    position: absolute;
    white-space: nowrap;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    z-index: 6;
}

.annotation-right {
    right: -180px;
    top: 20px;
    transform: translateX(30px) rotate(2deg);
}

.annotation-left {
    left: -180px;
    top: 20px;
    transform: translateX(-30px) rotate(-1.5deg);
}

.margin-annotation.visible {
    opacity: 0.8;
}

.annotation-right.visible {
    transform: translateX(0) rotate(2deg);
}

.annotation-left.visible {
    transform: translateX(0) rotate(-1.5deg);
}

/* --- Seal Marks --- */
.seal-mark {
    position: absolute;
    top: -8px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--graffiti-coral);
    opacity: 0.25;
    z-index: 6;
}

/* --- Drip Trails --- */
.drip-trail {
    position: absolute;
    top: 0;
    left: 15px;
    width: 1px;
    height: 80px;
    background: linear-gradient(to bottom, rgba(78, 205, 196, 0.3) 0%, rgba(78, 205, 196, 0) 100%);
    z-index: 6;
}

/* --- Page Fold Lines --- */
.page-fold-line {
    width: 100%;
    height: 1px;
    border: none;
    border-top: 1px dashed rgba(176, 196, 216, 0.08);
    margin: 6vh 0;
    position: relative;
    z-index: 2;
}

/* --- Brush Number Watermarks --- */
.brush-number {
    position: absolute;
    top: 10vh;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 20vw;
    color: var(--midnight-trench);
    opacity: 0.06;
    z-index: 0;
    pointer-events: none;
    line-height: 1;
    user-select: none;
}

/* --- Graffiti Tag Lines --- */
.tag-line {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 100px;
    margin: 2vh auto;
    display: block;
    z-index: 3;
    overflow: visible;
}

.tag-line-3 {
    max-width: 900px;
    height: 120px;
}

.tag-line-4 {
    max-width: 500px;
    height: 60px;
}

/* --- Stencil Fragments --- */
.stencil-fragment {
    position: absolute;
    z-index: 2;
    pointer-events: none;
}

.stencil-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid var(--graffiti-coral);
    opacity: 0.15;
    top: 15%;
    right: 5%;
    transform: rotate(2deg);
}

.stencil-triangle {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 86px solid var(--graffiti-coral);
    opacity: 0.1;
    top: 55%;
    left: 3%;
    transform: rotate(-3deg);
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.stencil-lines {
    width: 80px;
    height: 60px;
    top: 70%;
    right: 8%;
    transform: rotate(1.5deg);
    opacity: 0.12;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 8px,
        var(--graffiti-coral) 8px,
        var(--graffiti-coral) 10px
    );
}

/* --- Interactive text hover effect --- */
.section-heading {
    transition: filter 0.4s ease;
    cursor: default;
}

.section-heading:hover {
    filter: url(#water-distort);
}

/* --- Opening sequence --- */
body.loading {
    background: var(--abyssal-black) !important;
}

body.loading .zone-threshold {
    background: var(--abyssal-black);
}

body.loading .wash,
body.loading .hero-title,
body.loading .scroll-invitation,
body.loading .domain-watermark {
    opacity: 0 !important;
}

/* --- Wash intensity on scroll (added by JS) --- */
.wash.intensified {
    opacity: 1 !important;
    transition: opacity 0.6s ease;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .content-left,
    .content-right {
        margin-left: auto;
        margin-right: auto;
        padding: 3vh 6vw;
    }

    .training-block-2 {
        margin-left: auto;
    }

    .training-block-3 {
        margin-right: auto;
    }

    .margin-annotation {
        position: relative;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        display: block;
        margin-bottom: 1rem;
        transform: rotate(0deg) !important;
        opacity: 0.6;
        white-space: normal;
    }

    .margin-annotation.visible {
        transform: translateX(0) rotate(0deg) !important;
        opacity: 0.8;
    }

    .brush-number {
        font-size: 30vw;
    }

    .stencil-circle {
        width: 80px;
        height: 80px;
    }

    .hero-title {
        font-size: clamp(2rem, 8vw, 3.5rem);
    }
}

@media (max-width: 480px) {
    .content-block {
        padding: 2vh 5vw;
    }

    .hero-title {
        font-size: clamp(1.6rem, 10vw, 2.8rem);
    }
}
