/* ============================================
   glolos.com - Underwater Field Journal
   Hand-drawn reef exploration experience
   ============================================ */

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

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

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.7;
    color: #3E2C1C;
    background: #F5E6D3;
    overflow-x: hidden;
    position: relative;
}

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

/* --- Typography --- */
.display-heading {
    font-family: 'Gloock', serif;
    font-weight: 400;
    color: #3B2F2F;
    text-shadow: 1px 1px 0px #5C4033, -0.5px 0px 0px #A0876B;
    font-size: clamp(64px, 10vw, 140px);
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.sub-heading {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    color: #6B4423;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    margin-bottom: 0.5em;
}

.sub-heading-light {
    color: #D4B896;
}

.body-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    color: #3E2C1C;
    font-size: 1.05rem;
    line-height: 1.7;
}

.body-text-light {
    color: #F5E6D3;
}

.annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 0.85rem;
    color: #8B6F47;
    display: inline-block;
    margin-top: 0.5em;
}

.annotation-light {
    color: #A0876B;
}

.annotation-rotated {
    display: inline-block;
}

/* --- Spine (Left Vertical Rail) --- */
.spine {
    position: fixed;
    left: 65px;
    top: 0;
    width: 30px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}

.spine-svg {
    position: absolute;
    left: 5px;
    top: 0;
    width: 20px;
    height: 100%;
}

.spine-line {
    stroke-dasharray: 5000;
    stroke-dashoffset: 5000;
    transition: stroke-dashoffset 0s;
}

.spine-line.revealed {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 2s ease-out;
}

.spine-node {
    position: absolute;
    left: -2px;
    transform: translateY(-50%);
    pointer-events: auto;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.spine-node:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.15);
}

.spine-node.active {
    opacity: 1;
}

/* --- Plate Sections --- */
.plate {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
    padding: 0;
}

.plate-1 { background-color: #F5E6D3; }
.plate-2 { background-color: #D4B896; }
.plate-3 { background-color: #8B7355; }
.plate-4 { background-color: #3E2C1C; }
.plate-5 { background-color: #1A0F0A; }

/* Stipple texture overlay on plates */
.plate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Ccircle cx='1' cy='1' r='0.5' fill='%233E2C1C' opacity='0.04'/%3E%3Ccircle cx='4' cy='4' r='0.4' fill='%235C4033' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

.plate-content {
    position: relative;
    z-index: 10;
    padding: 8vh 5vw 8vh 120px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3vh;
}

.plate-content-inverted .sub-heading {
    color: #D4B896;
}

.plate-content-abyss {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* --- Branches --- */
.branch {
    position: relative;
    padding-left: 20px;
}

.branch-full { width: 100%; }
.branch-65 { width: 65%; }
.branch-75 { width: 75%; }
.branch-50 { width: 50%; }

.branch-line {
    width: 100%;
    height: 8px;
    display: block;
    margin-bottom: 1rem;
}

/* --- Content Panels --- */
.content-panel {
    background: rgba(245, 230, 211, 0.5);
    padding: 1.5rem 2rem;
    position: relative;
    border-radius: 8px;
    filter: url(#hand-drawn-edge);
    border: 1.5px solid #A0876B;
    max-width: 700px;
}

.content-panel-wide {
    max-width: 900px;
}

.content-panel-dark {
    background: rgba(92, 64, 51, 0.4);
    border-color: #A0876B;
}

/* Plate 3 panels */
.plate-3 .content-panel {
    background: rgba(245, 230, 211, 0.35);
    border-color: #A0876B;
}

.plate-3 .body-text {
    color: #F5E6D3;
}

.plate-3 .sub-heading {
    color: #D4B896;
}

.plate-3 .annotation {
    color: #D4B896;
}

/* --- Torn Paper Edges --- */
.torn-edge {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30px;
    z-index: 20;
}

.torn-edge-1 {
    background: linear-gradient(to right,
        transparent 0%, #D4B896 2%, transparent 4%,
        #D4B896 6%, transparent 8%, #D4B896 10%,
        transparent 12%, #D4B896 14%, transparent 16%,
        #D4B896 18%, transparent 20%, #D4B896 22%,
        transparent 24%, #D4B896 26%, transparent 28%,
        #D4B896 30%, transparent 32%, #D4B896 34%,
        transparent 36%, #D4B896 38%, transparent 40%,
        #D4B896 42%, transparent 44%, #D4B896 46%,
        transparent 48%, #D4B896 50%, transparent 52%,
        #D4B896 54%, transparent 56%, #D4B896 58%,
        transparent 60%, #D4B896 62%, transparent 64%,
        #D4B896 66%, transparent 68%, #D4B896 70%,
        transparent 72%, #D4B896 74%, transparent 76%,
        #D4B896 78%, transparent 80%, #D4B896 82%,
        transparent 84%, #D4B896 86%, transparent 88%,
        #D4B896 90%, transparent 92%, #D4B896 94%,
        transparent 96%, #D4B896 98%, transparent 100%
    );
    clip-path: polygon(
        0% 100%, 0% 60%,
        2% 30%, 4% 55%, 6% 20%, 8% 50%, 10% 15%,
        12% 45%, 14% 25%, 16% 55%, 18% 10%, 20% 50%,
        22% 30%, 24% 60%, 26% 20%, 28% 55%, 30% 35%,
        32% 60%, 34% 15%, 36% 50%, 38% 25%, 40% 55%,
        42% 20%, 44% 50%, 46% 30%, 48% 60%, 50% 10%,
        52% 45%, 54% 25%, 56% 55%, 58% 15%, 60% 50%,
        62% 35%, 64% 60%, 66% 20%, 68% 50%, 70% 30%,
        72% 55%, 74% 15%, 76% 50%, 78% 25%, 80% 55%,
        82% 20%, 84% 50%, 86% 35%, 88% 60%, 90% 15%,
        92% 50%, 94% 30%, 96% 55%, 98% 20%, 100% 50%,
        100% 100%
    );
}

.torn-edge-2 {
    clip-path: polygon(
        0% 100%, 0% 50%,
        3% 25%, 5% 55%, 7% 15%, 10% 50%, 12% 30%,
        15% 60%, 17% 20%, 20% 45%, 22% 10%, 25% 55%,
        27% 35%, 30% 60%, 32% 20%, 35% 50%, 37% 25%,
        40% 55%, 42% 15%, 45% 50%, 47% 30%, 50% 55%,
        52% 20%, 55% 50%, 57% 35%, 60% 60%, 62% 15%,
        65% 45%, 67% 25%, 70% 55%, 72% 10%, 75% 50%,
        77% 30%, 80% 55%, 82% 20%, 85% 50%, 87% 35%,
        90% 60%, 92% 20%, 95% 45%, 97% 25%, 100% 50%,
        100% 100%
    );
    background: #8B7355;
}

.torn-edge-3 {
    clip-path: polygon(
        0% 100%, 0% 55%,
        2% 30%, 5% 60%, 7% 20%, 10% 50%, 13% 15%,
        15% 55%, 18% 25%, 20% 55%, 23% 10%, 25% 45%,
        28% 35%, 30% 60%, 33% 20%, 35% 55%, 38% 30%,
        40% 60%, 43% 15%, 45% 50%, 48% 25%, 50% 55%,
        53% 20%, 55% 50%, 58% 35%, 60% 60%, 63% 15%,
        65% 50%, 68% 25%, 70% 55%, 73% 10%, 75% 50%,
        78% 30%, 80% 60%, 83% 20%, 85% 50%, 88% 35%,
        90% 55%, 93% 15%, 95% 50%, 98% 30%, 100% 55%,
        100% 100%
    );
    background: #3E2C1C;
}

.torn-edge-4 {
    clip-path: polygon(
        0% 100%, 0% 50%,
        3% 20%, 6% 55%, 8% 15%, 11% 50%, 14% 25%,
        16% 60%, 19% 20%, 22% 50%, 24% 10%, 27% 45%,
        30% 30%, 32% 55%, 35% 15%, 38% 50%, 40% 25%,
        43% 60%, 46% 20%, 48% 50%, 51% 30%, 54% 55%,
        56% 15%, 59% 50%, 62% 35%, 64% 60%, 67% 20%,
        70% 45%, 72% 25%, 75% 55%, 78% 10%, 80% 50%,
        83% 30%, 86% 55%, 88% 20%, 91% 50%, 94% 35%,
        96% 60%, 98% 20%, 100% 50%,
        100% 100%
    );
    background: #1A0F0A;
}

/* --- Organic Blobs --- */
.blob {
    position: absolute;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    background: var(--blob-color);
    filter: blur(40px);
    z-index: 0;
    pointer-events: none;
    will-change: border-radius, transform;
}

.blob-1 {
    width: 450px;
    height: 400px;
    top: 15%;
    right: 10%;
    animation: blob-morph-1 18s ease-in-out infinite, blob-drift-1 40s ease-in-out infinite;
}

.blob-2 {
    width: 350px;
    height: 350px;
    top: 55%;
    right: 25%;
    animation: blob-morph-2 20s ease-in-out infinite, blob-drift-2 35s ease-in-out infinite;
}

.blob-3 {
    width: 400px;
    height: 380px;
    top: 10%;
    right: 5%;
    animation: blob-morph-1 16s ease-in-out infinite, blob-drift-1 38s ease-in-out infinite;
}

.blob-4 {
    width: 300px;
    height: 320px;
    top: 60%;
    right: 30%;
    animation: blob-morph-2 22s ease-in-out infinite, blob-drift-2 42s ease-in-out infinite;
}

.blob-5 {
    width: 500px;
    height: 450px;
    top: 5%;
    right: 8%;
    animation: blob-morph-1 15s ease-in-out infinite, blob-drift-1 36s ease-in-out infinite;
}

.blob-6 {
    width: 380px;
    height: 400px;
    top: 45%;
    right: 20%;
    animation: blob-morph-2 19s ease-in-out infinite, blob-drift-2 40s ease-in-out infinite;
}

.blob-7 {
    width: 320px;
    height: 300px;
    top: 70%;
    right: 50%;
    animation: blob-morph-1 17s ease-in-out infinite, blob-drift-1 44s ease-in-out infinite;
}

.blob-8 {
    width: 420px;
    height: 400px;
    top: 15%;
    right: 15%;
    animation: blob-morph-1 16s ease-in-out infinite, blob-drift-1 38s ease-in-out infinite;
}

.blob-9 {
    width: 350px;
    height: 380px;
    top: 55%;
    right: 35%;
    animation: blob-morph-2 20s ease-in-out infinite, blob-drift-2 42s ease-in-out infinite;
}

.blob-10 {
    width: 400px;
    height: 420px;
    top: 20%;
    right: 20%;
    animation: blob-morph-1 18s ease-in-out infinite, blob-drift-1 40s ease-in-out infinite;
}

.blob-11 {
    width: 300px;
    height: 300px;
    top: 60%;
    left: 30%;
    animation: blob-morph-2 22s ease-in-out infinite, blob-drift-2 36s ease-in-out infinite;
}

.blob-bioluminescent {
    filter: blur(50px);
    animation-duration: 14s, 35s;
}

@keyframes blob-morph-1 {
    0%   { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
    25%  { border-radius: 58% 42% 55% 45% / 45% 60% 40% 55%; }
    50%  { border-radius: 40% 60% 35% 65% / 65% 35% 60% 40%; }
    75%  { border-radius: 65% 35% 50% 50% / 40% 55% 45% 60%; }
    100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
}

@keyframes blob-morph-2 {
    0%   { border-radius: 50% 50% 40% 60% / 60% 40% 55% 45%; }
    25%  { border-radius: 35% 65% 60% 40% / 45% 55% 35% 65%; }
    50%  { border-radius: 60% 40% 45% 55% / 35% 65% 50% 50%; }
    75%  { border-radius: 42% 58% 55% 45% / 55% 45% 60% 40%; }
    100% { border-radius: 50% 50% 40% 60% / 60% 40% 55% 45%; }
}

@keyframes blob-drift-1 {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(30px, -20px); }
    50%  { transform: translate(-15px, 25px); }
    75%  { transform: translate(20px, 10px); }
    100% { transform: translate(0, 0); }
}

@keyframes blob-drift-2 {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(-25px, 15px); }
    50%  { transform: translate(20px, -20px); }
    75%  { transform: translate(-10px, -15px); }
    100% { transform: translate(0, 0); }
}

/* --- Accent Color Assignments (fish & decorative elements) --- */
.clownfish svg { color: #E07B3C; }
.chromis svg { color: #2A8B7A; }
.coral circle { color: #C4726C; }
.seaweed-1 path { stroke: #6B8E6B; }
.seaweed-2 path { stroke: #4A6741; }

/* --- Fish Animations --- */
.fish {
    position: absolute;
    z-index: 5;
    pointer-events: none;
}

/* Clownfish - hero fish */
.clownfish {
    right: -140px;
    top: 40%;
    opacity: 0;
    animation: clownfish-enter 2s ease-out 2s forwards, swim-undulate 3s ease-in-out infinite;
}

@keyframes clownfish-enter {
    0%   { right: -140px; opacity: 0; }
    100% { right: 15%; opacity: 1; }
}

/* Chromis school */
.chromis {
    position: absolute;
    opacity: 0;
}

.chromis-1 { right: 20%; top: 20%; animation: swim-horizontal-chromis 28s linear infinite, swim-undulate 2.3s ease-in-out infinite; animation-delay: 0s, 0s; }
.chromis-2 { right: 30%; top: 30%; animation: swim-horizontal-chromis 32s linear infinite, swim-undulate 2.7s ease-in-out infinite; animation-delay: 1.7s, 0.3s; }
.chromis-3 { right: 15%; top: 45%; animation: swim-horizontal-chromis 26s linear infinite, swim-undulate 2.1s ease-in-out infinite; animation-delay: 3.1s, 0.7s; }
.chromis-4 { right: 25%; top: 55%; animation: swim-horizontal-chromis 30s linear infinite, swim-undulate 2.5s ease-in-out infinite; animation-delay: 5.3s, 1.1s; }
.chromis-5 { right: 10%; top: 35%; animation: swim-horizontal-chromis 34s linear infinite, swim-undulate 2.9s ease-in-out infinite; animation-delay: 7.1s, 0.5s; }
.chromis-6 { right: 35%; top: 25%; animation: swim-horizontal-chromis 29s linear infinite, swim-undulate 2.4s ease-in-out infinite; animation-delay: 2.3s, 0.9s; }
.chromis-7 { right: 18%; top: 50%; animation: swim-horizontal-chromis 31s linear infinite, swim-undulate 2.6s ease-in-out infinite; animation-delay: 4.7s, 0.2s; }

.fish-school {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

@keyframes swim-horizontal-chromis {
    0%   { transform: translateX(100px); }
    50%  { transform: translateX(-200px); }
    100% { transform: translateX(100px); }
}

/* Angelfish */
.angelfish {
    right: -180px;
    top: 30%;
    opacity: 0;
    transition: opacity 1.5s ease, right 3s ease;
}

.angelfish.visible {
    right: 10%;
    opacity: 0.9;
    animation: swim-undulate-slow 4s ease-in-out infinite, angelfish-drift 40s linear infinite;
}

@keyframes angelfish-drift {
    0%   { transform: translateX(0); }
    50%  { transform: translateX(-150px); }
    100% { transform: translateX(0); }
}

/* Moorish Idol */
.moorish-idol {
    right: -160px;
    top: 25%;
    opacity: 0;
    transition: opacity 2s ease-out, right 3s ease-out;
}

.moorish-idol.visible {
    right: 12%;
    opacity: 0.9;
    animation: swim-undulate-slow 3.5s ease-in-out infinite;
}

/* Pufferfish */
.pufferfish {
    position: absolute;
    right: 25%;
    top: 45%;
    z-index: 15;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.pufferfish.inflated {
    transform: scale(1.6);
}

.pufferfish.inflated svg ellipse:first-of-type {
    rx: 42;
    ry: 42;
}

.pufferfish-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%) rotate(2deg);
    white-space: nowrap;
    color: #A0876B;
    opacity: 0.7;
    font-size: 0.9rem;
}

/* General swim undulation */
@keyframes swim-undulate {
    0%   { transform: translateY(0) rotate(0deg); }
    25%  { transform: translateY(-6px) rotate(-1.5deg); }
    50%  { transform: translateY(0) rotate(0deg); }
    75%  { transform: translateY(6px) rotate(1.5deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

@keyframes swim-undulate-slow {
    0%   { transform: translateY(0) rotate(0deg); }
    25%  { transform: translateY(-8px) rotate(-2deg); }
    50%  { transform: translateY(0) rotate(0deg); }
    75%  { transform: translateY(8px) rotate(2deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

/* --- Seaweed --- */
.seaweed {
    position: absolute;
    z-index: 2;
    pointer-events: none;
}

.seaweed-1 {
    bottom: 10%;
    right: 8%;
    animation: seaweed-sway 6s ease-in-out infinite;
}

.seaweed-2 {
    bottom: 5%;
    right: 45%;
    animation: seaweed-sway 7s ease-in-out infinite;
    animation-delay: 1.3s;
}

.seaweed-3 {
    bottom: 15%;
    right: 55%;
    animation: seaweed-sway 5.5s ease-in-out infinite;
    animation-delay: 2.1s;
}

@keyframes seaweed-sway {
    0%   { transform: rotate(0deg); transform-origin: bottom center; }
    25%  { transform: rotate(3deg); }
    50%  { transform: rotate(0deg); }
    75%  { transform: rotate(-3deg); }
    100% { transform: rotate(0deg); }
}

/* --- Coral --- */
.coral {
    position: absolute;
    z-index: 3;
    pointer-events: none;
}

.coral-1 {
    bottom: 15%;
    left: 100px;
}

.coral-2 {
    bottom: 10%;
    left: 95px;
}

/* --- Compass Rose --- */
.compass-rose {
    position: absolute;
    bottom: 5vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    animation: compass-rotate 120s linear infinite;
    opacity: 0.7;
}

@keyframes compass-rotate {
    0%   { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

/* --- Abyss Heading --- */
.abyss-heading {
    color: #D4A017;
    text-shadow: 0 0 40px rgba(212, 160, 23, 0.4), 0 0 80px rgba(212, 160, 23, 0.2), 1px 1px 0px #5C4033;
    font-size: clamp(72px, 12vw, 160px);
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.5s ease, transform 1.5s ease;
}

.abyss-heading.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Plate 1 Heading Animation --- */
.plate-1-heading {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

.plate-1-heading.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Ripple Effect --- */
.ripple-container {
    position: absolute;
    top: 0;
    left: 65px;
    width: 0;
    height: 0;
    z-index: 50;
    pointer-events: none;
}

.ripple-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    transform: scale(0);
    animation: ripple-expand 1.2s ease-out forwards;
}

.ripple-ring:nth-child(1) { animation-delay: 0s; }
.ripple-ring:nth-child(2) { animation-delay: 0.2s; }
.ripple-ring:nth-child(3) { animation-delay: 0.4s; }

@keyframes ripple-expand {
    0%   { transform: scale(0); opacity: 0.2; }
    100% { transform: scale(1); opacity: 0; }
}

/* --- Chromis visibility --- */
.plate-2 .chromis {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.plate-2.in-view .chromis {
    opacity: 1;
}

/* --- Responsive: Tablet --- */
@media (min-width: 768px) and (max-width: 1024px) {
    .plate-content {
        padding-left: 100px;
    }

    .branch-full { width: 100%; }
    .branch-65 { width: 80%; }
    .branch-75 { width: 85%; }
    .branch-50 { width: 70%; }

    .spine {
        left: 40px;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 767px) {
    .spine {
        left: 0;
        width: 8px;
    }

    .spine-svg {
        left: 0;
        width: 4px;
    }

    .spine-line {
        stroke-width: 4;
    }

    .spine-node {
        display: none;
    }

    .plate-content {
        padding: 6vh 5vw 6vh 30px;
    }

    .branch-full,
    .branch-65,
    .branch-75,
    .branch-50 {
        width: 100%;
    }

    .display-heading {
        font-size: clamp(48px, 12vw, 80px);
    }

    .blob {
        width: 200px !important;
        height: 200px !important;
    }

    .fish-school {
        width: 70%;
    }

    .clownfish {
        top: 55%;
    }

    .angelfish.visible,
    .moorish-idol.visible {
        right: 5%;
    }

    .pufferfish {
        right: 15%;
        top: 55%;
    }

    .content-panel {
        padding: 1rem 1.2rem;
    }

    .coral {
        display: none;
    }
}
