/* ==========================================================================
   algoha.com - Street-Style Knowledge Bazaar
   Colors: #F5EDE0, #EDE3D3, #2D2926, #3D3632, #A0522D, #C67D4A, #4A6670, #2E4A3E, #E8EDDE, #1A1210
   Fonts: Nunito 800, Quicksand 600, Nunito Sans 400/600, Caveat 400, Fira Code 400
   ========================================================================== */

/* --- 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: 17px;
    line-height: 1.65;
    color: #3D3632;
    background-color: #F5EDE0;
    overflow-x: hidden;
    position: relative;
}

/* --- Paper Texture Overlay (CSS-only noise) --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image:
        repeating-radial-gradient(circle at 17% 32%, #3D3632 0px, transparent 1px),
        repeating-radial-gradient(circle at 63% 68%, #3D3632 0px, transparent 1px),
        repeating-radial-gradient(circle at 41% 11%, #3D3632 0px, transparent 1px),
        repeating-radial-gradient(circle at 89% 52%, #3D3632 0px, transparent 1px);
    background-size: 150px 150px, 170px 170px, 130px 130px, 190px 190px;
}

/* --- Dot Grid Pattern (graph paper) --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.05;
    background-image: radial-gradient(circle, #3D3632 0.5px, transparent 0.5px);
    background-size: 24px 24px;
}

/* ==========================================================================
   Book Spine Navigation
   ========================================================================== */
#book-spine {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 48px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to right, #EDE3D3, #E8EDDE);
    border-left: 2px solid rgba(45, 41, 38, 0.12);
    box-shadow: -4px 0 12px rgba(26, 18, 16, 0.06);
}

.spine-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 0%;
    background: #C67D4A;
    transition: height 0.3s ease;
    border-radius: 0 2px 2px 0;
}

.spine-tabs {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spine-tab {
    width: 44px;
    height: 64px;
    background: #F5EDE0;
    border: 1.5px solid rgba(45, 41, 38, 0.15);
    border-right: none;
    border-radius: 4px 0 0 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    right: -2px;
}

.spine-tab:hover {
    background: #EDE3D3;
    transform: translateX(-4px);
}

.spine-tab.active {
    background: #C67D4A;
    border-color: #A0522D;
    transform: translateX(-6px);
}

.spine-tab.active .tab-label {
    color: #F5EDE0;
}

.tab-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #3D3632;
}

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

.parallax-bg {
    z-index: 1;
}

.bg-cityscape {
    width: 100%;
    height: 300%;
    position: absolute;
    top: 0;
    left: 0;
}

.parallax-fg {
    z-index: 100;
}

.fg-bookmark {
    position: absolute;
    top: 20%;
    right: 56px;
    width: 24px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.fg-bookmark.visible {
    opacity: 1;
}

/* ==========================================================================
   Parallax Sections
   ========================================================================== */
.parallax-section {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 60px;
    padding-right: 108px; /* space for spine */
}

.section-opening {
    min-height: 100vh;
    background: #F5EDE0;
}

.section-philosophy {
    min-height: 120vh;
    background: linear-gradient(180deg, #F5EDE0 0%, #EDE3D3 100%);
}

.section-showcase {
    min-height: 80vh;
    background: #EDE3D3;
    padding-top: 80px;
    padding-bottom: 80px;
}

.section-community {
    min-height: 100vh;
    background: linear-gradient(180deg, #EDE3D3 0%, #F5EDE0 100%);
}

.section-closing {
    min-height: 100vh;
    background: #F5EDE0;
}

.section-content {
    width: 100%;
    max-width: 1100px;
    position: relative;
}

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

.torn-edge-1 {
    clip-path: polygon(
        0% 60%, 2% 45%, 5% 70%, 8% 35%, 11% 55%, 14% 30%,
        17% 65%, 20% 40%, 23% 55%, 26% 25%, 29% 50%, 32% 35%,
        35% 60%, 38% 30%, 41% 50%, 44% 20%, 47% 55%, 50% 35%,
        53% 60%, 56% 25%, 59% 50%, 62% 40%, 65% 60%, 68% 30%,
        71% 55%, 74% 35%, 77% 65%, 80% 40%, 83% 55%, 86% 25%,
        89% 50%, 92% 35%, 95% 60%, 98% 30%, 100% 55%,
        100% 100%, 0% 100%
    );
    background: #EDE3D3;
}

.torn-edge-2 {
    clip-path: polygon(
        0% 50%, 3% 35%, 6% 60%, 9% 25%, 12% 55%, 15% 40%,
        18% 70%, 21% 30%, 24% 50%, 27% 20%, 30% 55%, 33% 35%,
        36% 65%, 39% 25%, 42% 55%, 45% 30%, 48% 60%, 51% 35%,
        54% 55%, 57% 20%, 60% 50%, 63% 30%, 66% 60%, 69% 40%,
        72% 55%, 75% 25%, 78% 50%, 81% 35%, 84% 65%, 87% 30%,
        90% 55%, 93% 40%, 96% 60%, 99% 25%, 100% 45%,
        100% 100%, 0% 100%
    );
    background: #EDE3D3;
}

.torn-edge-3 {
    clip-path: polygon(
        0% 55%, 4% 30%, 7% 60%, 10% 35%, 13% 55%, 16% 25%,
        19% 50%, 22% 40%, 25% 65%, 28% 30%, 31% 50%, 34% 20%,
        37% 55%, 40% 35%, 43% 60%, 46% 25%, 49% 50%, 52% 30%,
        55% 55%, 58% 40%, 61% 65%, 64% 20%, 67% 50%, 70% 35%,
        73% 60%, 76% 30%, 79% 55%, 82% 25%, 85% 50%, 88% 40%,
        91% 60%, 94% 30%, 97% 55%, 100% 35%,
        100% 100%, 0% 100%
    );
    background: #F5EDE0;
}

.torn-edge-4 {
    clip-path: polygon(
        0% 40%, 3% 55%, 6% 30%, 9% 50%, 12% 25%, 15% 60%,
        18% 35%, 21% 55%, 24% 20%, 27% 50%, 30% 30%, 33% 60%,
        36% 25%, 39% 55%, 42% 35%, 45% 60%, 48% 20%, 51% 50%,
        54% 35%, 57% 55%, 60% 25%, 63% 50%, 66% 30%, 69% 60%,
        72% 35%, 75% 55%, 78% 20%, 81% 50%, 84% 30%, 87% 55%,
        90% 25%, 93% 50%, 96% 35%, 100% 55%,
        100% 100%, 0% 100%
    );
    background: #F5EDE0;
}

/* ==========================================================================
   Typography
   ========================================================================== */
.section-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 56px;
    line-height: 1.1;
    letter-spacing: 0.02em;
    color: #2D2926;
    margin-bottom: 40px;
}

.accent-word {
    color: #A0522D;
}

.sub-heading {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 28px;
    letter-spacing: 0.04em;
    color: #4A6670;
    margin-bottom: 20px;
}

.body-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.65;
    color: #3D3632;
    margin-bottom: 20px;
    max-width: 65ch;
}

.body-text .highlight-underline {
    position: relative;
    display: inline;
}

.body-text .highlight-underline::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0%;
    height: 3px;
    background: #A0522D;
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.body-text .highlight-underline.drawn::after {
    width: 100%;
}

.caveat-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 20px;
    line-height: 1.5;
    color: #3D3632;
}

.code-text {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.6;
    color: #2E4A3E;
}

/* ==========================================================================
   Opening Scene
   ========================================================================== */
.desk-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.book-illustration {
    width: min(60vw, 500px);
    height: auto;
    margin-bottom: 32px;
}

.site-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(80px, 12vw, 160px);
    letter-spacing: 0.02em;
    color: #2D2926;
    line-height: 1;
    margin-bottom: 12px;
}

.site-subtitle {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(16px, 2.5vw, 24px);
    letter-spacing: 0.04em;
    color: #4A6670;
    margin-bottom: 40px;
}

.desk-elements {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 60px;
    margin-top: 20px;
}

.desk-item {
    opacity: 0.7;
}

.glasses {
    width: 100px;
}

.pencil {
    width: 120px;
    transform: rotate(-12deg);
}

.coffee-ring {
    width: 70px;
}

/* ==========================================================================
   Zoom Focus Animation
   ========================================================================== */
.zoom-focus {
    opacity: 0;
    transform: scale(1.4);
    filter: blur(4px);
    transition: opacity 0.8s cubic-bezier(0.33, 0, 0.2, 1),
                transform 0.8s cubic-bezier(0.33, 0, 0.2, 1),
                filter 0.8s cubic-bezier(0.33, 0, 0.2, 1);
    will-change: transform, opacity, filter;
}

.zoom-focus.in-view {
    opacity: 1;
    transform: scale(1);
    filter: blur(0px);
}

/* Staggered zoom-focus for desk items */
.desk-item.glasses { transition-delay: 200ms; }
.desk-item.pencil { transition-delay: 400ms; }
.desk-item.coffee-ring { transition-delay: 600ms; }

.desk-item.in-view {
    opacity: 0.7;
}

/* ==========================================================================
   Philosophy Section - Content Panels
   ========================================================================== */
.section-philosophy .section-content {
    display: flex;
    flex-direction: column;
    gap: 60px;
    padding: 100px 0;
    position: relative;
}

.content-panel {
    background: #F5EDE0;
    border-radius: 4px;
    box-shadow: 4px 6px 20px rgba(26, 18, 16, 0.08),
                1px 1px 4px rgba(26, 18, 16, 0.04);
    padding: 48px 56px;
    width: 85%;
    position: relative;
    transition: transform 0.3s ease;
}

.content-panel.panel-notebook {
    align-self: flex-start;
    border-left: 4px solid #C67D4A;
}

.content-panel.panel-zine {
    align-self: flex-end;
    border-right: 4px solid #4A6670;
    background: #EDE3D3;
}

.panel-inner {
    position: relative;
}

/* Street overlay elements */
.street-overlay {
    position: absolute;
    top: 40px;
    left: -30px;
    pointer-events: none;
}

.spray-quotes {
    width: 50px;
    height: 70px;
}

/* ==========================================================================
   Annotations
   ========================================================================== */
.annotation {
    position: relative;
    margin-top: 16px;
    padding-left: 20px;
    opacity: 0;
    transform: translateY(10px) rotate(-1deg);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.annotation.visible {
    opacity: 1;
    transform: translateY(0) rotate(-1deg);
}

.annotation-1 { transform: translateY(10px) rotate(-1.5deg); }
.annotation-1.visible { transform: translateY(0) rotate(-1.5deg); }

.annotation-2 { transform: translateY(10px) rotate(0.5deg); }
.annotation-2.visible { transform: translateY(0) rotate(0.5deg); }

.annotation-3 {
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(10px) rotate(-2deg);
}
.annotation-3.visible { transform: translateY(0) rotate(-2deg); }

.annotation-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 18px;
    color: #A0522D;
}

.annotation-star {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.annotation-community {
    text-align: center;
    margin-top: 24px;
    transform: translateY(10px) rotate(-0.5deg);
}
.annotation-community.visible { transform: translateY(0) rotate(-0.5deg); }

/* ==========================================================================
   Algorithm Showcase Section
   ========================================================================== */
.section-showcase .section-content {
    text-align: center;
}

.algo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    margin-bottom: 48px;
}

.algo-card {
    background: #F5EDE0;
    border-radius: 8px;
    padding: 32px 24px;
    box-shadow: 3px 4px 16px rgba(26, 18, 16, 0.07);
    text-align: center;
}

.algo-card .sub-heading {
    font-size: 22px;
    margin-bottom: 16px;
}

.algo-diagram {
    margin-bottom: 16px;
}

.sorting-svg,
.graph-svg,
.search-svg {
    width: 100%;
    max-width: 280px;
    height: auto;
}

.algo-caption {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: 14px;
    color: #3D3632;
    line-height: 1.5;
    opacity: 0.8;
}

/* Sorting animation */
.sort-bar {
    transition: all 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.sorting-diagram.sorted .sort-bar:nth-child(1) { height: 40px; y: 140px; }
.sorting-diagram.sorted .sort-bar:nth-child(2) { height: 60px; y: 120px; }
.sorting-diagram.sorted .sort-bar:nth-child(3) { height: 80px; y: 100px; }
.sorting-diagram.sorted .sort-bar:nth-child(4) { height: 100px; y: 80px; }
.sorting-diagram.sorted .sort-bar:nth-child(5) { height: 120px; y: 60px; }
.sorting-diagram.sorted .sort-bar:nth-child(6) { height: 140px; y: 40px; }
.sorting-diagram.sorted .sort-bar:nth-child(7) { height: 160px; y: 20px; }

/* Graph traversal animation */
.graph-node {
    transition: fill 0.4s ease, stroke 0.4s ease;
}

.graph-edge {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.8s ease;
}

.graph-diagram.traversed .graph-edge {
    stroke-dashoffset: 0;
    stroke: #A0522D;
}

.graph-diagram.traversed .graph-node {
    fill: #A0522D;
    stroke: #A0522D;
}

/* Graph node traversal stagger */
.graph-diagram.traversed .graph-node:nth-child(8) { transition-delay: 0ms; }
.graph-diagram.traversed .graph-node:nth-child(9) { transition-delay: 300ms; }
.graph-diagram.traversed .graph-node:nth-child(10) { transition-delay: 300ms; }
.graph-diagram.traversed .graph-node:nth-child(11) { transition-delay: 600ms; }
.graph-diagram.traversed .graph-node:nth-child(12) { transition-delay: 600ms; }
.graph-diagram.traversed .graph-node:nth-child(13) { transition-delay: 900ms; }
.graph-diagram.traversed .graph-node:nth-child(14) { transition-delay: 900ms; }

.graph-diagram.traversed .graph-edge:nth-child(1) { transition-delay: 0ms; }
.graph-diagram.traversed .graph-edge:nth-child(2) { transition-delay: 200ms; }
.graph-diagram.traversed .graph-edge:nth-child(3) { transition-delay: 400ms; }
.graph-diagram.traversed .graph-edge:nth-child(4) { transition-delay: 400ms; }
.graph-diagram.traversed .graph-edge:nth-child(5) { transition-delay: 600ms; }
.graph-diagram.traversed .graph-edge:nth-child(6) { transition-delay: 600ms; }

/* Code sample */
.code-sample {
    background: #E8EDDE;
    border-radius: 4px;
    padding: 24px 32px;
    text-align: left;
    display: inline-block;
    max-width: 100%;
    box-shadow: 2px 3px 10px rgba(26, 18, 16, 0.06);
}

.code-sample pre {
    margin: 0;
    overflow-x: auto;
}

/* ==========================================================================
   Community Section
   ========================================================================== */
.section-community .section-content {
    padding: 80px 0;
    text-align: center;
}

.community-panels {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    margin-top: 40px;
    margin-bottom: 40px;
}

.postcard-panel {
    background: #F5EDE0;
    border: 1.5px solid rgba(45, 41, 38, 0.1);
    border-radius: 4px;
    padding: 36px 44px;
    max-width: 600px;
    width: 100%;
    box-shadow: 3px 4px 14px rgba(26, 18, 16, 0.06);
    position: relative;
}

.postcard-panel::before {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 50px;
    height: 50px;
    border: 1.5px solid rgba(160, 82, 45, 0.2);
    border-radius: 2px;
}

.postcard-content {
    text-align: left;
}

.postcard-author {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 16px;
    color: #A0522D;
    display: block;
    margin-top: 12px;
}

.community-scene {
    width: 100%;
    max-width: 800px;
    margin: 40px auto 0;
    display: block;
}

/* ==========================================================================
   Closing Scene
   ========================================================================== */
.closing-desk-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.closed-book {
    width: 200px;
    height: auto;
    margin-bottom: 24px;
}

.folded-glasses {
    width: 80px;
    height: auto;
    margin-bottom: 40px;
    opacity: 0.6;
}

.closing-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(32px, 5vw, 56px);
    line-height: 1.15;
    letter-spacing: 0.02em;
    color: #2D2926;
    text-align: center;
    margin-bottom: 16px;
    max-width: 700px;
}

.closing-subtext {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(14px, 2vw, 18px);
    letter-spacing: 0.04em;
    color: #4A6670;
    text-align: center;
    max-width: 500px;
}

/* Ivy vine */
.ivy-vine {
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 120px;
    height: auto;
}

.vine-main,
.vine-leaf {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.ivy-vine.growing .vine-main,
.ivy-vine.growing .vine-leaf {
    stroke-dashoffset: 0;
}

.vine-leaf {
    transition-delay: 0.5s;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
    .parallax-section {
        padding: 0 24px;
        padding-right: 72px;
    }

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

    .sub-heading {
        font-size: 22px;
    }

    .content-panel {
        width: 100%;
        padding: 32px 28px;
    }

    .algo-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .desk-elements {
        gap: 30px;
    }

    .glasses { width: 70px; }
    .pencil { width: 90px; }
    .coffee-ring { width: 50px; }

    .postcard-panel {
        padding: 24px 28px;
    }

    #book-spine {
        width: 36px;
    }

    .spine-tab {
        width: 32px;
        height: 50px;
    }

    .tab-label {
        font-size: 8px;
    }
}

@media (max-width: 600px) {
    .parallax-section {
        padding: 0 16px;
        padding-right: 52px;
    }

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

    .body-text {
        font-size: 15px;
    }

    .book-illustration {
        width: 80vw;
    }

    .desk-elements {
        flex-wrap: wrap;
        gap: 20px;
    }

    .community-panels {
        gap: 20px;
    }
}
