/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'Lora', serif;
    background: #0B2545;
    color: #D6CFC7;
    overflow-x: hidden;
    position: relative;
}

/* ===== PAPER GRAIN OVERLAY ===== */
.paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ===== DEPTH SECTIONS ===== */
.depth-section {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

/* ===== PARALLAX LAYERS ===== */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}

.fg-layer {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 100vh;
}

.section-content {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 4rem;
}

/* ===== SECTION 1: SURFACE ===== */
.section-surface {
    background: radial-gradient(ellipse at 40% 40%, #C9A84C 0%, #0B6E6E 60%, #0B2545 100%);
}

.surface-glow {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 30%, rgba(201, 168, 76, 0.4) 0%, transparent 60%);
}

.surface-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding-left: 8%;
    padding-top: 10vh;
}

.main-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3.5rem, 10vw, 8rem);
    letter-spacing: -0.05em;
    color: #C9A84C;
    line-height: 1;
    margin-bottom: 2rem;
    display: inline-flex;
}

.title-letter {
    display: inline-block;
    transform: translateY(calc(sin(var(--delay) * 0.7) * 8px));
    animation: letterFloat 3s ease-in-out infinite;
    animation-delay: calc(var(--delay) * 0.2s);
}

@keyframes letterFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.handwritten-note {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: #E8927C;
    display: inline;
}

.surface-note {
    transform: rotate(-2deg);
    margin-top: 1rem;
}

/* ===== TYPEWRITER ===== */
.typewriter-cursor {
    display: inline-block;
    color: #C9A84C;
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: 1.4rem;
    animation: cursorBlink 530ms step-end infinite;
    vertical-align: baseline;
    margin-left: 2px;
}

.typewriter-cursor.hidden {
    display: none;
}

.typewriter-cursor.fading {
    animation: cursorFade 1590ms step-end forwards;
}

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

@keyframes cursorFade {
    0% { opacity: 1; }
    16.67% { opacity: 0; }
    33.33% { opacity: 1; }
    50% { opacity: 0; }
    66.67% { opacity: 1; }
    83.33% { opacity: 0; }
    100% { opacity: 0; }
}

.typewriter-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    color: #D6CFC7;
    display: inline;
}

.typewriter-text .glow-char {
    color: #5EE4D0;
    text-shadow: 0 0 10px #5EE4D0, 0 0 20px rgba(94, 228, 208, 0.3);
    transition: color 0.8s ease, text-shadow 0.8s ease;
}

.typewriter-text .glow-char.settled {
    color: #C9A84C;
    text-shadow: none;
}

/* ===== SECTION 2: THERMOCLINE ===== */
.section-thermocline {
    background: linear-gradient(180deg, #0B6E6E 0%, #1B3A4B 50%, #0B2545 100%);
}

.thermocline-wash {
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 60% 50%, rgba(11, 110, 110, 0.5) 0%, transparent 70%);
}

.thermocline-content {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 6%;
}

.glass-container {
    max-width: 480px;
    padding: 2.5rem 3rem;
    background: rgba(11, 37, 69, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid rgba(201, 168, 76, 0.15);
    /* Bleached Shell #F0EDE5 used as subtle inner glow */
    box-shadow: inset 0 0 30px rgba(240, 237, 229, 0.03);
}

.glass-dark {
    background: rgba(7, 25, 43, 0.7);
    border: 1px solid rgba(94, 228, 208, 0.15);
}

.section-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
    line-height: 1.1;
}

.dark-title {
    color: #C9A84C;
}

.glow-title {
    color: #C9A84C;
    text-shadow: 0 0 20px rgba(94, 228, 208, 0.3);
}

.abyss-title {
    color: #C9A84C;
    text-shadow: 0 0 30px rgba(201, 168, 76, 0.4);
}

.body-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    margin-bottom: 1.25rem;
}

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

.light-text {
    color: #D6CFC7;
}

.dark-text {
    color: #1B3A4B;
}

/* ===== GLITCH OVERLAY ===== */
.glitch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
}

.glitch-overlay.active {
    animation: glitchBurst 300ms linear forwards;
}

.glitch-overlay::before,
.glitch-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-overlay.active::before {
    background: rgba(11, 110, 110, 0.15);
    mix-blend-mode: difference;
    transform: translateX(-4px);
}

.glitch-overlay.active::after {
    background: rgba(232, 146, 124, 0.15);
    mix-blend-mode: difference;
    transform: translateX(4px);
}

@keyframes glitchBurst {
    0% { opacity: 1; clip-path: inset(20% 0 60% 0); }
    20% { clip-path: inset(50% 0 10% 0); }
    40% { clip-path: inset(10% 0 70% 0); }
    60% { clip-path: inset(40% 0 30% 0); }
    80% { clip-path: inset(70% 0 5% 0); }
    100% { opacity: 0; clip-path: inset(0 0 100% 0); }
}

/* ===== SCANLINES ===== */
.scanlines-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(94, 228, 208, 0.03) 2px,
        rgba(94, 228, 208, 0.03) 4px
    );
    mix-blend-mode: difference;
}

/* ===== SECTION 3: TWILIGHT ===== */
.section-twilight {
    background: linear-gradient(180deg, #0B2545 0%, #07192B 100%);
}

.twilight-wash {
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 30% 60%, rgba(94, 228, 208, 0.08) 0%, transparent 50%);
}

.twilight-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-left: 10%;
    padding-top: 5vh;
}

.twilight-content .glass-container {
    max-width: 550px;
    margin-top: 2rem;
}

/* ===== SECTION 4: ABYSS ===== */
.section-abyss {
    background: #07192B;
    min-height: 100vh;
}

.abyss-wash {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(11, 37, 69, 0.5) 0%, #07192B 70%);
}

.abyss-content {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    padding-right: 8%;
    padding-bottom: 8vh;
}

/* ===== BIOLUMINESCENT POINTS ===== */
.bio-point {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #5EE4D0;
    border-radius: 50%;
    box-shadow: 0 0 6px #5EE4D0, 0 0 12px rgba(94, 228, 208, 0.3);
    animation: bioGlow 4s ease-in-out infinite;
}

@keyframes bioGlow {
    0%, 100% { opacity: 0.2; transform: scale(0.8); }
    50% { opacity: 0.8; transform: scale(1.2); }
}

/* ===== GILDED FRAME ===== */
.gilded-frame {
    position: relative;
    max-width: 550px;
    padding: 2rem;
}

.gilded-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.frame-inner {
    position: relative;
    z-index: 2;
    padding: 2rem;
}

.abyss-note {
    display: block;
    margin-top: 2rem;
    transform: rotate(1.5deg);
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: #E8927C;
    opacity: 0.8;
}

/* ===== MANDARINFISH ===== */
.fish-mandarin {
    position: absolute;
    width: 60%;
    max-width: 600px;
    left: 5%;
    top: 15%;
    opacity: 0.85;
}

#mandarinEye {
    animation: fishBlink 5s ease-in-out infinite;
    transform-origin: center center;
}

@keyframes fishBlink {
    0%, 95%, 100% { transform: scaleY(1); }
    97.5% { transform: scaleY(0.1); }
}

/* ===== FISH ANIMATIONS ===== */
.fish {
    position: absolute;
    pointer-events: none;
}

.fish-butterfly {
    width: 120px;
    height: auto;
}

.fish-1 {
    top: 35%;
    left: -150px;
    animation: swimRight 20s linear infinite;
    animation-delay: -3s;
}

.fish-2 {
    top: 55%;
    right: -150px;
    animation: swimLeft 25s linear infinite;
    animation-delay: -8s;
}

.fish-angel {
    width: 100px;
    height: auto;
}

.fish-3 {
    top: 25%;
    left: -120px;
    animation: swimRight 22s linear infinite;
    animation-delay: -5s;
}

.fish-4 {
    top: 60%;
    right: -120px;
    animation: swimLeft 18s linear infinite;
    animation-delay: -2s;
}

.fish-lion {
    width: 140px;
    height: auto;
}

.fish-5 {
    top: 30%;
    left: -160px;
    animation: swimRight 24s linear infinite;
    animation-delay: -7s;
}

.fish-6 {
    top: 65%;
    right: -160px;
    animation: swimLeft 21s linear infinite;
    animation-delay: -4s;
}

@keyframes swimRight {
    0% {
        transform: translateX(0) translateY(0);
    }
    25% {
        transform: translateX(calc(25vw + 50px)) translateY(-15px);
    }
    50% {
        transform: translateX(calc(50vw + 100px)) translateY(10px);
    }
    75% {
        transform: translateX(calc(75vw + 150px)) translateY(-8px);
    }
    100% {
        transform: translateX(calc(100vw + 200px)) translateY(0);
    }
}

@keyframes swimLeft {
    0% {
        transform: translateX(0) translateY(0);
    }
    25% {
        transform: translateX(calc(-25vw - 50px)) translateY(12px);
    }
    50% {
        transform: translateX(calc(-50vw - 100px)) translateY(-10px);
    }
    75% {
        transform: translateX(calc(-75vw - 150px)) translateY(8px);
    }
    100% {
        transform: translateX(calc(-100vw - 200px)) translateY(0);
    }
}

/* ===== TRANSITION FISH ===== */
.transition-fish {
    position: relative;
    height: 0;
    z-index: 15;
    overflow: visible;
}

.fish-angelfish-transition {
    width: 80px;
    position: absolute;
    top: -60px;
    animation: transitionSwim1 15s linear infinite;
}

.fish-lionfish-transition {
    width: 110px;
    position: absolute;
    top: -70px;
    animation: transitionSwim2 18s linear infinite;
    animation-delay: -6s;
}

@keyframes transitionSwim1 {
    0% { left: -100px; transform: translateY(0); }
    25% { transform: translateY(-20px); }
    50% { transform: translateY(10px); }
    75% { transform: translateY(-15px); }
    100% { left: calc(100vw + 100px); transform: translateY(0); }
}

@keyframes transitionSwim2 {
    0% { right: -150px; left: auto; transform: translateY(0) scaleX(-1); }
    25% { transform: translateY(15px) scaleX(-1); }
    50% { transform: translateY(-12px) scaleX(-1); }
    75% { transform: translateY(8px) scaleX(-1); }
    100% { right: calc(100vw + 150px); left: auto; transform: translateY(0) scaleX(-1); }
}

/* ===== BUBBLES ===== */
.bubbles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: #5EE4D0;
    animation: bubbleFloat linear infinite;
    bottom: -20px;
}

@keyframes bubbleFloat {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0.4;
    }
    25% {
        transform: translateY(-25vh) translateX(10px);
        opacity: 0.35;
    }
    50% {
        transform: translateY(-50vh) translateX(-8px);
        opacity: 0.25;
    }
    75% {
        transform: translateY(-75vh) translateX(12px);
        opacity: 0.15;
    }
    100% {
        transform: translateY(-110vh) translateX(-5px);
        opacity: 0;
    }
}

/* ===== CORAL DIVIDER ===== */
.coral-divider {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 25;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.coral-divider.visible {
    opacity: 1;
}

/* ===== WATERCOLOR BLEEDS ===== */
.section-surface::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(180deg, rgba(11, 110, 110, 0) 0%, rgba(11, 110, 110, 0.2) 50%, rgba(11, 37, 69, 0.3) 100%);
    pointer-events: none;
    z-index: 3;
}

.section-thermocline::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(180deg, rgba(11, 37, 69, 0) 0%, rgba(7, 25, 43, 0.3) 100%);
    pointer-events: none;
    z-index: 3;
}

.section-twilight::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(180deg, rgba(7, 25, 43, 0) 0%, rgba(7, 25, 43, 0.5) 100%);
    pointer-events: none;
    z-index: 3;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .section-content {
        padding: 2rem;
    }

    .surface-content {
        padding-left: 5%;
    }

    .thermocline-content {
        justify-content: center;
        padding-right: 2rem;
    }

    .glass-container {
        max-width: 90%;
    }

    .twilight-content {
        padding-left: 5%;
    }

    .abyss-content {
        justify-content: center;
        padding-right: 2rem;
    }

    .gilded-frame {
        max-width: 90%;
    }

    .fish-mandarin {
        width: 80%;
        left: 2%;
    }

    .fish-butterfly {
        width: 80px;
    }

    .fish-angel {
        width: 70px;
    }

    .fish-lion {
        width: 100px;
    }
}
