/* ============================================
   logic.quest - Wabi-Sabi Logic Experience
   ============================================ */

/* --- Custom Properties --- */
:root {
    --bg-primary: #F5EDE0;
    --bg-secondary: #2C1810;
    --accent-primary: #8B3A3A;
    --accent-secondary: #4A1C1C;
    --text-primary: #3D2E23;
    --text-secondary: #6B4C3B;
    --highlight: #D4C4A8;
    --subtle-wash: #E8DBC8;
    --bg-warm: #E8DBC8;
    --bg-parchment: #F2E8D5;
}

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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: 18px;
    line-height: 1.75;
    overflow-x: hidden;
}

::selection {
    background-color: var(--accent-primary);
    color: var(--bg-parchment);
}

/* --- Typography --- */
.display-heading {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: clamp(56px, 8vw, 96px);
    font-weight: 700;
    color: var(--accent-secondary);
    letter-spacing: 0.06em;
    line-height: 1.05;
}

.section-heading {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: clamp(42px, 6vw, 72px);
    font-weight: 700;
    color: var(--accent-secondary);
    letter-spacing: 0.06em;
    line-height: 1.05;
    margin-bottom: 40px;
}

.section-heading-light {
    color: var(--bg-parchment);
}

.body-text {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: clamp(16px, 1.8vw, 20px);
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 1.5em;
}

.body-text-light {
    color: var(--highlight);
}

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

.annotation {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 14px;
    color: var(--accent-primary);
    opacity: 0.7;
}

.annotation-light {
    color: var(--highlight);
    opacity: 0.8;
}

/* --- Chamber Layout --- */
.chamber {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
    scroll-snap-align: start;
}

.chamber-light {
    background-color: var(--bg-primary);
}

.chamber-warm {
    background-color: var(--bg-warm);
}

.chamber-dark {
    background-color: var(--bg-secondary);
}

/* --- Parallax Layers --- */
.parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.parallax-mid {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 8%;
}

.parallax-fg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* --- Chamber Content --- */
.chamber-content {
    position: relative;
    max-width: 680px;
    margin-left: 38%;
    transform: translateX(-50%);
}

.axiom-content {
    margin-left: 38%;
    text-align: left;
}

.axiom-subtitle {
    margin-top: 24px;
    max-width: 520px;
    opacity: 0.85;
}

.premise-content {
    margin-left: 30%;
    transform: translateX(-20%);
}

.inference-content {
    margin-left: 35%;
    transform: translateX(-30%);
}

.paradox-content {
    margin-left: 32%;
    transform: translateX(-18%);
}

.paradox-heading {
    transform: rotate(-1.5deg);
    transform-origin: left center;
}

.paradox-body {
    transform: rotate(0.5deg);
}

.coda-content {
    margin-left: 38%;
    transform: translateX(-50%);
    text-align: left;
}

.coda-reflection {
    max-width: 560px;
    font-size: clamp(18px, 2vw, 22px);
    line-height: 1.85;
}

.text-block {
    max-width: 620px;
}

/* --- Organic Blob Shapes --- */
.blob {
    position: absolute;
    border-radius: 42% 58% 63% 37% / 55% 40% 60% 45%;
    pointer-events: none;
}

.blob-bg {
    opacity: 0.06;
}

/* Chamber 1 blobs */
.blob-1 {
    width: 600px;
    height: 550px;
    background-color: var(--accent-primary);
    top: 10%;
    right: 5%;
    border-radius: 48% 52% 57% 43% / 52% 45% 55% 48%;
}

.blob-2 {
    width: 450px;
    height: 480px;
    background-color: var(--accent-secondary);
    bottom: 5%;
    left: 8%;
    border-radius: 38% 62% 53% 47% / 60% 35% 65% 40%;
}

/* Chamber 2 blobs */
.blob-3 {
    width: 700px;
    height: 600px;
    background-color: var(--accent-primary);
    top: 15%;
    left: -5%;
    border-radius: 55% 45% 48% 52% / 42% 58% 42% 58%;
}

.blob-4 {
    width: 500px;
    height: 520px;
    background-color: var(--accent-secondary);
    bottom: 10%;
    right: 2%;
    border-radius: 44% 56% 61% 39% / 50% 44% 56% 50%;
}

/* Chamber 3 blobs */
.blob-7 {
    width: 650px;
    height: 700px;
    background-color: var(--bg-parchment);
    top: 5%;
    left: 10%;
    border-radius: 50% 50% 45% 55% / 48% 52% 48% 52%;
    opacity: 0.04;
}

.blob-8 {
    width: 400px;
    height: 450px;
    background-color: var(--highlight);
    bottom: 15%;
    right: 8%;
    border-radius: 62% 38% 55% 45% / 40% 60% 40% 60%;
    opacity: 0.05;
}

/* Chamber 4 blobs (jagged) */
.blob-jagged {
    border-radius: 30% 70% 25% 75% / 65% 20% 80% 35%;
}

.blob-9 {
    width: 550px;
    height: 500px;
    background-color: var(--accent-primary);
    top: 8%;
    right: -3%;
    opacity: 0.07;
}

.blob-10 {
    width: 480px;
    height: 520px;
    background-color: var(--accent-secondary);
    bottom: 5%;
    left: 5%;
    border-radius: 25% 75% 35% 65% / 70% 30% 70% 30%;
    opacity: 0.06;
}

/* Chamber 5 blobs */
.blob-13 {
    width: 800px;
    height: 750px;
    background-color: var(--bg-parchment);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 46% 54% 52% 48% / 53% 47% 53% 47%;
    opacity: 0.03;
}

/* Medium interactive blobs */
.blob-medium {
    width: 150px;
    height: 160px;
    opacity: 0.08;
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    pointer-events: auto;
}

.blob-5 {
    background-color: var(--accent-primary);
    top: 25%;
    right: 12%;
    border-radius: 52% 48% 56% 44% / 45% 55% 45% 55%;
}

.blob-6 {
    background-color: var(--accent-secondary);
    bottom: 20%;
    left: 6%;
    width: 180px;
    height: 170px;
    border-radius: 46% 54% 42% 58% / 58% 42% 58% 42%;
}

.blob-11 {
    background-color: var(--accent-primary);
    top: 18%;
    right: 8%;
    width: 170px;
    height: 155px;
    border-radius: 35% 65% 40% 60% / 60% 35% 65% 40%;
    opacity: 0.09;
}

.blob-12 {
    background-color: var(--text-secondary);
    bottom: 22%;
    left: 10%;
    width: 140px;
    height: 150px;
    opacity: 0.07;
}

/* --- Enso Circles --- */
.enso {
    position: absolute;
    pointer-events: none;
}

.enso-1 {
    width: 400px;
    height: 400px;
    top: 20%;
    right: 15%;
}

.enso-2 {
    width: 300px;
    height: 300px;
    top: 10%;
    left: 5%;
    opacity: 0.8;
}

.enso-3 {
    width: 60%;
    max-width: 600px;
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.enso-4 {
    width: 350px;
    height: 350px;
    top: 15%;
    right: 10%;
}

.enso-5 {
    width: 300px;
    height: 300px;
    bottom: 20%;
    left: 15%;
}

.enso-path {
    stroke-linecap: round;
    stroke-linejoin: round;
}

.enso-draw {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 4s ease-in-out;
}

.enso-draw.drawn {
    stroke-dashoffset: 0;
}

/* --- Kintsugi Lines --- */
.kintsugi-line {
    position: absolute;
    pointer-events: none;
}

.kintsugi-1 {
    width: 60px;
    height: 100%;
    left: 8%;
    top: 0;
}

.kintsugi-2 {
    width: 60px;
    height: 100%;
    right: 12%;
    top: 0;
}

.kintsugi-3 {
    width: 140px;
    height: 100%;
    left: 15%;
    top: 0;
}

.kintsugi-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 3s ease-in-out;
}

.kintsugi-path.drawn {
    stroke-dashoffset: 0;
}

.kintsugi-branch {
    transition-delay: 1.5s;
    transition-duration: 2s;
}

/* --- Crack Overlay (Chamber 4) --- */
.crack-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    opacity: 0.07;
    background-image:
        repeating-linear-gradient(
            37deg,
            transparent,
            transparent 120px,
            var(--text-primary) 120px,
            var(--text-primary) 120.5px,
            transparent 120.5px,
            transparent 300px
        ),
        repeating-linear-gradient(
            -53deg,
            transparent,
            transparent 180px,
            var(--text-primary) 180px,
            var(--text-primary) 180.4px,
            transparent 180.4px,
            transparent 400px
        ),
        repeating-linear-gradient(
            78deg,
            transparent,
            transparent 250px,
            var(--text-primary) 250px,
            var(--text-primary) 250.3px,
            transparent 250.3px,
            transparent 500px
        ),
        repeating-linear-gradient(
            -15deg,
            transparent,
            transparent 90px,
            var(--text-primary) 90px,
            var(--text-primary) 90.6px,
            transparent 90.6px,
            transparent 350px
        );
}

/* --- Moss Dot Clusters --- */
.moss-cluster {
    position: absolute;
    pointer-events: none;
}

.moss-dot {
    position: absolute;
    border-radius: 50%;
    background-color: var(--text-secondary);
    opacity: 0;
    transform: scale(0);
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
}

.moss-dot.grown {
    opacity: 0.2;
    transform: scale(1);
}

.moss-dot-light {
    background-color: var(--highlight);
}

.moss-dot-light.grown {
    opacity: 0.25;
}

/* Cluster 1 - Chamber 1 bottom-left */
.moss-cluster-1 {
    bottom: 8%;
    left: 4%;
}

.moss-cluster-1 .moss-dot:nth-child(1) { width: 8px; height: 8px; top: 0; left: 0; }
.moss-cluster-1 .moss-dot:nth-child(2) { width: 6px; height: 6px; top: -12px; left: 18px; }
.moss-cluster-1 .moss-dot:nth-child(3) { width: 10px; height: 10px; top: 8px; left: 28px; }
.moss-cluster-1 .moss-dot:nth-child(4) { width: 5px; height: 5px; top: -5px; left: 42px; }
.moss-cluster-1 .moss-dot:nth-child(5) { width: 7px; height: 7px; top: 14px; left: 12px; }

/* Cluster 2 - Chamber 2 left margin */
.moss-cluster-2 {
    top: 60%;
    left: 2%;
}

.moss-cluster-2 .moss-dot:nth-child(1) { width: 7px; height: 7px; top: 0; left: 0; }
.moss-cluster-2 .moss-dot:nth-child(2) { width: 9px; height: 9px; top: 15px; left: 10px; }
.moss-cluster-2 .moss-dot:nth-child(3) { width: 5px; height: 5px; top: -8px; left: 22px; }
.moss-cluster-2 .moss-dot:nth-child(4) { width: 8px; height: 8px; top: 28px; left: 5px; }
.moss-cluster-2 .moss-dot:nth-child(5) { width: 6px; height: 6px; top: 10px; left: 32px; }
.moss-cluster-2 .moss-dot:nth-child(6) { width: 4px; height: 4px; top: 35px; left: 20px; }

/* Cluster 3 - Chamber 3 right area */
.moss-cluster-3 {
    bottom: 12%;
    right: 5%;
}

.moss-cluster-3 .moss-dot:nth-child(1) { width: 6px; height: 6px; top: 0; left: 0; }
.moss-cluster-3 .moss-dot:nth-child(2) { width: 8px; height: 8px; top: 12px; left: 15px; }
.moss-cluster-3 .moss-dot:nth-child(3) { width: 5px; height: 5px; top: -6px; left: 28px; }
.moss-cluster-3 .moss-dot:nth-child(4) { width: 7px; height: 7px; top: 20px; left: 8px; }

/* Cluster 4 - Chamber 4 left area */
.moss-cluster-4 {
    bottom: 6%;
    left: 3%;
}

.moss-cluster-4 .moss-dot:nth-child(1) { width: 6px; height: 6px; top: 0; left: 0; }
.moss-cluster-4 .moss-dot:nth-child(2) { width: 8px; height: 8px; top: -10px; left: 14px; }
.moss-cluster-4 .moss-dot:nth-child(3) { width: 5px; height: 5px; top: 12px; left: 8px; }
.moss-cluster-4 .moss-dot:nth-child(4) { width: 9px; height: 9px; top: 5px; left: 30px; }
.moss-cluster-4 .moss-dot:nth-child(5) { width: 4px; height: 4px; top: -15px; left: 38px; }
.moss-cluster-4 .moss-dot:nth-child(6) { width: 7px; height: 7px; top: 20px; left: 22px; }
.moss-cluster-4 .moss-dot:nth-child(7) { width: 5px; height: 5px; top: 28px; left: 40px; }

/* Cluster 5 - Chamber 5 edges, spread wide */
.moss-cluster-5 {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.moss-cluster-edges .moss-dot:nth-child(1)  { width: 8px; height: 8px; top: 10%; left: 2%; }
.moss-cluster-edges .moss-dot:nth-child(2)  { width: 6px; height: 6px; top: 25%; left: 4%; }
.moss-cluster-edges .moss-dot:nth-child(3)  { width: 10px; height: 10px; top: 45%; right: 3%; left: auto; }
.moss-cluster-edges .moss-dot:nth-child(4)  { width: 5px; height: 5px; top: 60%; right: 5%; left: auto; }
.moss-cluster-edges .moss-dot:nth-child(5)  { width: 7px; height: 7px; bottom: 30%; left: 3%; top: auto; }
.moss-cluster-edges .moss-dot:nth-child(6)  { width: 9px; height: 9px; bottom: 15%; right: 4%; left: auto; top: auto; }
.moss-cluster-edges .moss-dot:nth-child(7)  { width: 6px; height: 6px; top: 15%; right: 6%; left: auto; }
.moss-cluster-edges .moss-dot:nth-child(8)  { width: 8px; height: 8px; bottom: 40%; left: 5%; top: auto; }
.moss-cluster-edges .moss-dot:nth-child(9)  { width: 5px; height: 5px; bottom: 8%; left: 6%; top: auto; }
.moss-cluster-edges .moss-dot:nth-child(10) { width: 7px; height: 7px; bottom: 20%; right: 2%; left: auto; top: auto; }

/* --- Navigation Line --- */
#nav-line {
    position: fixed;
    left: 3%;
    top: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.nav-track {
    position: relative;
    width: 2px;
    height: 60vh;
    background-color: var(--highlight);
    opacity: 0.4;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

.nav-marker {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--highlight);
    opacity: 0.5;
    transition: all 0.6s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    pointer-events: auto;
    cursor: pointer;
    position: relative;
    left: -3px;
}

.nav-marker.active {
    width: 12px;
    height: 12px;
    left: -5px;
    opacity: 1;
    background-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(139, 58, 58, 0.4);
}

/* --- Fade-in Animation --- */
.fade-in {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

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

.paradox-heading.visible {
    transform: translateY(0) rotate(-1.5deg);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .chamber-content {
        margin-left: 10%;
        transform: translateX(0);
        max-width: 85%;
    }

    .axiom-content,
    .premise-content,
    .inference-content,
    .paradox-content,
    .coda-content {
        margin-left: 8%;
        transform: translateX(0);
    }

    .enso-1 {
        width: 250px;
        height: 250px;
        right: 5%;
    }

    .enso-3 {
        width: 85%;
    }

    .blob-bg {
        opacity: 0.04;
    }

    #nav-line {
        display: none;
    }
}

@media (max-width: 600px) {
    .display-heading {
        font-size: 42px;
    }

    .section-heading {
        font-size: 36px;
    }

    .parallax-mid {
        padding: 40px 5%;
    }

    .chamber-content {
        margin-left: 5%;
        max-width: 90%;
    }

    .axiom-content,
    .premise-content,
    .inference-content,
    .paradox-content,
    .coda-content {
        margin-left: 5%;
    }
}