/* ========================================
   bable.pro — Coastal Scandinavian Design
   ======================================== */

/* CSS Custom Properties */
:root {
    --deep-water: #1B2A3D;
    --drift-wood: #C4A882;
    --sea-glass: #7BA7BC;
    --morning-fog: #EEE8E0;
    --salt-flat: #F5F1EB;
    --harbor-steel: #6B7B8D;
    --signal-red: #C4564A;
    --carbon: #2D3436;
    --slate-gray: #4A5568;
    --cool-shift: #E8EDF2;

    --bg-warm: #F5F1EB;
    --bg-cool: #E8EDF2;
    --bg-current: var(--salt-flat);

    --angle: 6deg;
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --bounce-subtle: cubic-bezier(0.34, 1.2, 0.64, 1);

    --font-heading: 'Righteous', cursive;
    --font-sub: 'Advent Pro', sans-serif;
    --font-body: 'Karla', sans-serif;
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--carbon);
    background-color: var(--bg-current);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle noise texture on body */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.025;
    background-image:
        radial-gradient(circle at 20% 35%, var(--carbon) 1px, transparent 1px),
        radial-gradient(circle at 75% 44%, var(--carbon) 1px, transparent 1px),
        radial-gradient(circle at 46% 78%, var(--carbon) 1px, transparent 1px),
        radial-gradient(circle at 90% 12%, var(--carbon) 1px, transparent 1px),
        radial-gradient(circle at 33% 90%, var(--carbon) 1px, transparent 1px),
        radial-gradient(circle at 60% 20%, var(--carbon) 1px, transparent 1px),
        radial-gradient(circle at 15% 60%, var(--carbon) 1px, transparent 1px),
        radial-gradient(circle at 85% 70%, var(--carbon) 1px, transparent 1px);
    background-size: 200px 200px;
}

/* ========================================
   Fixed Horizon Line
   ======================================== */
.horizon-line {
    position: fixed;
    top: 38.2%;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--harbor-steel);
    opacity: 0.25;
    z-index: 100;
    transition: opacity 0.6s ease;
}

.horizon-line.drawn {
    width: 100%;
    transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ========================================
   Chapter Indicator
   ======================================== */
.chapter-indicator {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    font-family: var(--font-sub);
    font-weight: 300;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    color: var(--harbor-steel);
    opacity: 0.5;
    z-index: 200;
}

/* ========================================
   Ghost Grid Overlay
   ======================================== */
.ghost-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.ghost-grid.visible {
    opacity: 1;
}

.ghost-grid.fading {
    opacity: 0;
    transition: opacity 1s ease;
}

.ghost-grid-line {
    border-right: 1px solid rgba(27, 42, 61, 0.03);
    height: 100%;
}

/* ========================================
   Wayfinding Labels
   ======================================== */
.wayfinding {
    position: fixed;
    font-family: var(--font-sub);
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--harbor-steel);
    opacity: 0.4;
    z-index: 200;
    pointer-events: none;
}

.wayfinding-top-left {
    top: 2rem;
    left: 2rem;
}

.wayfinding-top-right {
    top: 2rem;
    right: 2rem;
}

.wayfinding-bottom-left {
    bottom: 2rem;
    left: 2rem;
}

/* ========================================
   Chapters — Base Styles
   ======================================== */
.chapter {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.chapter-content {
    position: relative;
    z-index: 10;
    max-width: 58ch;
    padding: 2rem;
}

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

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

.content-center {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* ========================================
   Typography
   ======================================== */
.domain-title {
    font-family: var(--font-heading);
    font-size: clamp(2.8rem, 7vw, 6rem);
    font-weight: 400;
    color: var(--deep-water);
    letter-spacing: -0.02em;
    line-height: 1.05;
    text-align: center;
}

.domain-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(-30px);
}

.domain-title .letter.animate {
    animation: letterBounceIn 0.5s var(--bounce) forwards;
    animation-delay: calc(var(--i) * 60ms + 400ms);
}

@keyframes letterBounceIn {
    0% {
        opacity: 0;
        transform: translateY(-30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-label {
    font-family: var(--font-sub);
    font-weight: 300;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sea-glass);
    margin-bottom: 1rem;
}

.section-heading {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 400;
    color: var(--deep-water);
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin-bottom: 1.5rem;
}

.section-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.72;
    color: var(--slate-gray);
    max-width: 58ch;
    margin-bottom: 1.5em;
}

/* ========================================
   Scroll Chevron
   ======================================== */
.scroll-chevron {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: chevronBounce 2s var(--bounce) infinite;
    animation-delay: 3s;
    z-index: 10;
}

.scroll-chevron.visible {
    opacity: 1;
}

@keyframes chevronBounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
        opacity: 0.6;
    }
    50% {
        transform: translateX(-50%) translateY(8px);
        opacity: 1;
    }
}

/* ========================================
   Diagonal Clips
   ======================================== */
.diagonal-clip {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.diagonal-clip-lr {
    clip-path: polygon(0 4%, 100% 0, 100% 100%, 0 96%);
}

.diagonal-clip-rl {
    clip-path: polygon(0 0, 100% 4%, 100% 96%, 0 100%);
}

/* ========================================
   Chapters — Individual Backgrounds
   ======================================== */
.chapter-1 {
    background: var(--salt-flat);
    justify-content: center;
    flex-direction: column;
    align-items: center;
}

.chapter-2 {
    background: var(--morning-fog);
}

.chapter-3 {
    background: var(--salt-flat);
}

.chapter-4 {
    background: var(--morning-fog);
}

.chapter-5 {
    background: var(--salt-flat);
}

.chapter-6 {
    background: var(--morning-fog);
}

.chapter-7 {
    background: linear-gradient(180deg, var(--morning-fog) 0%, var(--cool-shift) 100%);
    justify-content: center;
    flex-direction: column;
    align-items: center;
}

/* ========================================
   Breathing Zones
   ======================================== */
.breathing-zone {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--salt-flat), var(--morning-fog));
    overflow: hidden;
}

.breathing-word {
    font-family: var(--font-heading);
    font-size: clamp(5rem, 15vw, 12rem);
    font-weight: 400;
    color: var(--morning-fog);
    letter-spacing: -0.02em;
    line-height: 1;
    transform: rotate(6deg);
    opacity: 0.05;
    will-change: transform;
    user-select: none;
}

/* ========================================
   Geometric Compositions
   ======================================== */
.geo-composition {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* --- Harbor Cranes (Chapter 1) --- */
.crane-composition {
    opacity: 0;
    transition: opacity 2s ease;
}

.crane-composition.visible {
    opacity: 1;
}

.crane {
    position: absolute;
    background: var(--harbor-steel);
    opacity: 0.25;
}

.crane-1 {
    width: 8px;
    height: 220px;
    bottom: 20%;
    left: 65%;
    transform: rotate(-3deg);
}

.crane-2 {
    width: 6px;
    height: 180px;
    bottom: 22%;
    left: 72%;
    transform: rotate(2deg);
}

.crane-3 {
    width: 10px;
    height: 260px;
    bottom: 18%;
    left: 80%;
    transform: rotate(-5deg);
}

.crane-arm {
    position: absolute;
    background: var(--harbor-steel);
    opacity: 0.2;
}

.crane-arm-1 {
    width: 120px;
    height: 4px;
    bottom: calc(20% + 210px);
    left: calc(65% - 40px);
    transform: rotate(-8deg);
    transform-origin: right center;
}

.crane-arm-2 {
    width: 150px;
    height: 3px;
    bottom: calc(18% + 250px);
    left: calc(80% - 60px);
    transform: rotate(5deg);
    transform-origin: left center;
}

.crane-cable {
    position: absolute;
    width: 1px;
    background: var(--harbor-steel);
    opacity: 0.15;
}

.crane-cable-1 {
    height: 100px;
    bottom: calc(20% + 110px);
    left: calc(65% + 30px);
    transform: rotate(2deg);
}

.crane-cable-2 {
    height: 130px;
    bottom: calc(18% + 120px);
    left: calc(80% + 40px);
    transform: rotate(-1deg);
}

/* --- Breakwater Blocks (Chapter 2) --- */
.breakwater-composition {
    opacity: 0.12;
}

.breakwater-block {
    position: absolute;
    background: var(--deep-water);
    opacity: 0.8;
}

.bw-1 {
    width: 60px;
    height: 60px;
    top: 25%;
    right: 10%;
    transform: rotate(15deg);
}

.bw-2 {
    width: 45px;
    height: 45px;
    top: 32%;
    right: 15%;
    transform: rotate(-8deg);
}

.bw-3 {
    width: 55px;
    height: 55px;
    top: 40%;
    right: 8%;
    transform: rotate(22deg);
}

.bw-4 {
    width: 35px;
    height: 35px;
    top: 35%;
    right: 20%;
    transform: rotate(-15deg);
}

.bw-5 {
    width: 50px;
    height: 50px;
    top: 50%;
    right: 12%;
    transform: rotate(10deg);
}

.bw-6 {
    width: 40px;
    height: 40px;
    top: 55%;
    right: 18%;
    transform: rotate(-20deg);
}

.bw-7 {
    width: 65px;
    height: 65px;
    top: 45%;
    right: 5%;
    transform: rotate(6deg);
}

/* --- Material Slabs (Chapter 3) --- */
.material-composition {
    opacity: 0.15;
}

.material-slab {
    position: absolute;
    background: var(--drift-wood);
    opacity: 0.6;
}

.ms-1 {
    width: 200px;
    height: 80px;
    top: 30%;
    left: 5%;
    transform: rotate(3deg);
}

.ms-2 {
    width: 160px;
    height: 60px;
    top: 45%;
    left: 8%;
    transform: rotate(-2deg);
}

.ms-3 {
    width: 180px;
    height: 50px;
    top: 55%;
    left: 3%;
    transform: rotate(1deg);
}

.material-grain {
    position: absolute;
    border: 1px solid var(--drift-wood);
    opacity: 0.3;
}

.mg-1 {
    width: 220px;
    height: 100px;
    top: 35%;
    left: 2%;
    transform: rotate(2deg);
}

.mg-2 {
    width: 180px;
    height: 70px;
    top: 50%;
    left: 6%;
    transform: rotate(-1deg);
}

/* --- Angle Shapes (Chapter 4 — interactive) --- */
.angle-composition {
    pointer-events: all;
    transition: transform 0.6s var(--bounce-subtle);
}

.angle-composition:hover .angle-shape {
    transform: rotate(calc(var(--base-rotate) + 6deg));
    transition: transform 0.8s var(--bounce-subtle);
}

.angle-composition:hover .angle-line {
    transform: rotate(calc(var(--base-rotate) + 6deg));
    transition: transform 0.8s var(--bounce-subtle);
}

.angle-shape {
    position: absolute;
    background: var(--sea-glass);
    opacity: 0.2;
    transition: transform 0.8s var(--bounce-subtle);
}

.as-1 {
    --base-rotate: 6deg;
    width: 120px;
    height: 120px;
    top: 20%;
    right: 15%;
    transform: rotate(6deg);
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.as-2 {
    --base-rotate: -6deg;
    width: 80px;
    height: 80px;
    top: 35%;
    right: 25%;
    transform: rotate(-6deg);
    background: var(--deep-water);
    opacity: 0.12;
}

.as-3 {
    --base-rotate: 12deg;
    width: 100px;
    height: 60px;
    top: 45%;
    right: 10%;
    transform: rotate(12deg);
    background: var(--harbor-steel);
    opacity: 0.15;
}

.as-4 {
    --base-rotate: -12deg;
    width: 60px;
    height: 100px;
    top: 55%;
    right: 30%;
    transform: rotate(-12deg);
    background: var(--drift-wood);
    opacity: 0.18;
}

.as-5 {
    --base-rotate: 6deg;
    width: 90px;
    height: 90px;
    top: 30%;
    right: 8%;
    transform: rotate(6deg);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    background: var(--signal-red);
    opacity: 0.1;
}

.angle-line {
    position: absolute;
    height: 2px;
    background: var(--deep-water);
    opacity: 0.1;
    transition: transform 0.8s var(--bounce-subtle);
}

.al-1 {
    --base-rotate: 6deg;
    width: 200px;
    top: 40%;
    right: 5%;
    transform: rotate(6deg);
}

.al-2 {
    --base-rotate: -6deg;
    width: 150px;
    top: 50%;
    right: 20%;
    transform: rotate(-6deg);
}

.al-3 {
    --base-rotate: 6deg;
    width: 180px;
    top: 60%;
    right: 12%;
    transform: rotate(6deg);
}

/* --- Skyline (Chapter 5) --- */
.skyline-composition {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 30%;
    gap: 4px;
    opacity: 0.2;
}

.skyline-block {
    background: var(--harbor-steel);
    width: 20px;
}

.sb-1 { height: 80px; opacity: 0.9; }
.sb-2 { height: 120px; opacity: 0.7; background: var(--sea-glass); }
.sb-3 { height: 60px; opacity: 0.8; }
.sb-4 { height: 160px; opacity: 0.6; }
.sb-5 { height: 90px; opacity: 0.85; background: var(--drift-wood); }
.sb-6 { height: 140px; opacity: 0.65; }
.sb-7 { height: 70px; opacity: 0.75; background: var(--sea-glass); }
.sb-8 { height: 110px; opacity: 0.55; }

/* ========================================
   Chapter 6 — Signal Type Display
   ======================================== */
.signal-heading {
    font-size: clamp(1.8rem, 4vw, 3.2rem);
}

.signal-type-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.signal-letter {
    font-family: var(--font-heading);
    color: var(--deep-water);
    line-height: 1;
}

.signal-letter-large {
    font-size: clamp(4rem, 10vw, 8rem);
    opacity: 0.8;
}

.signal-letter-medium {
    font-size: clamp(3rem, 7vw, 5.5rem);
    opacity: 0.5;
    color: var(--sea-glass);
}

.signal-letter-small {
    font-size: clamp(2rem, 5vw, 4rem);
    opacity: 0.3;
    color: var(--harbor-steel);
}

/* ========================================
   Chapter 7 — The Departure
   ======================================== */
.departure-word {
    font-family: var(--font-heading);
    font-size: clamp(4rem, 12vw, 10rem);
    font-weight: 400;
    color: var(--drift-wood);
    letter-spacing: -0.02em;
    line-height: 1;
    transition: opacity 4s ease, transform 4s ease;
}

.departure-word.fading {
    opacity: 0.05;
    transform: translateY(-40px);
}

/* ========================================
   Scroll-based content reveal
   ======================================== */
.chapter-content .section-label,
.chapter-content .section-heading,
.chapter-content .section-body,
.chapter-content .signal-type-display {
    opacity: 0;
    transform: translateY(20px) rotate(2deg);
    transition: opacity 0.5s var(--bounce), transform 0.5s var(--bounce);
}

.chapter-content.revealed .section-label {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
    transition-delay: 0ms;
}

.chapter-content.revealed .section-heading {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
    transition-delay: 80ms;
}

.chapter-content.revealed .section-body {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
}

.chapter-content.revealed .section-body:nth-of-type(1) {
    transition-delay: 160ms;
}

.chapter-content.revealed .section-body:nth-of-type(2) {
    transition-delay: 240ms;
}

.chapter-content.revealed .signal-type-display {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
    transition-delay: 320ms;
}

/* ========================================
   Diagonal Shadow Play
   ======================================== */
.chapter-content {
    box-shadow: 20px 6px 40px rgba(196, 168, 130, 0.12);
}

.content-center {
    box-shadow: none;
}

/* ========================================
   Background temperature shift via scroll
   ======================================== */
body {
    transition: background-color 0.3s ease;
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (max-width: 768px) {
    .content-left,
    .content-right {
        margin-left: 5%;
        margin-right: 5%;
    }

    .chapter-indicator {
        bottom: 1rem;
        right: 1rem;
    }

    .wayfinding-top-left {
        top: 1rem;
        left: 1rem;
    }

    .wayfinding-top-right {
        top: 1rem;
        right: 1rem;
    }

    .wayfinding-bottom-left {
        bottom: 1rem;
        left: 1rem;
    }

    .crane-1, .crane-2, .crane-3 {
        display: none;
    }

    .crane-arm-1, .crane-arm-2 {
        display: none;
    }

    .crane-cable-1, .crane-cable-2 {
        display: none;
    }

    .skyline-block {
        width: 14px;
    }
}

@media (max-width: 480px) {
    .breathing-word {
        font-size: clamp(3rem, 12vw, 5rem);
    }

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