/* ============================================
   opensource.bar — Styles
   Surrealist Botanical-Technical Cabinet
   ============================================ */

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

:root {
    --bg: #F4EDE4;
    --text: #2C2416;
    --border: #7A6F5D;
    --accent-warm: #C4713B;
    --accent-cool: #5B7A6E;
    --illustration: #8B6D4F;
    --highlight: #D4A857;
    --deep: #3A3228;
    --spring-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    overflow-x: hidden;
    position: relative;
}

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

/* --- Navigation: Library Card Catalog Strip --- */
.nav-catalog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    transition: all 0.5s var(--spring-ease);
    padding: 0;
}

.nav-catalog.condensed {
    background: rgba(244, 237, 228, 0.95);
    backdrop-filter: blur(8px);
    border-bottom-color: var(--highlight);
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    top: 12px;
    border-radius: 24px;
    border: 1px solid var(--border);
    padding: 0 8px;
    box-shadow: 0 4px 20px rgba(58, 50, 40, 0.1);
}

.nav-inner {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 10px 24px;
    max-width: 1200px;
    margin: 0 auto;
    transition: gap 0.4s var(--spring-ease);
}

.condensed .nav-inner {
    gap: 20px;
    padding: 8px 16px;
}

.nav-label {
    font-family: 'Special Elite', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--border);
    cursor: pointer;
    transition: color 0.3s ease, opacity 0.3s ease;
    white-space: nowrap;
    position: relative;
}

.nav-label:hover {
    color: var(--accent-warm);
}

.nav-label.active {
    color: var(--text);
}

.nav-label.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-warm);
}

.condensed .nav-label:not(.active) {
    display: none;
}

/* --- Hero Module --- */
.module-hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 2px solid var(--border);
}

.hero-illustration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-tree {
    width: 90%;
    max-width: 1200px;
    height: auto;
    opacity: 0.85;
}

/* Leaf animation (gentle breeze) */
.leaf {
    animation: leafBreeze 4s ease-in-out infinite;
    transform-origin: center;
}

.leaf-1 { animation-delay: 0s; animation-duration: 3.5s; }
.leaf-2 { animation-delay: 0.5s; animation-duration: 4.2s; }
.leaf-3 { animation-delay: 1.0s; animation-duration: 3.8s; }
.leaf-4 { animation-delay: 0.3s; animation-duration: 4.5s; }
.leaf-5 { animation-delay: 0.8s; animation-duration: 3.3s; }
.leaf-6 { animation-delay: 1.2s; animation-duration: 4.0s; }
.leaf-7 { animation-delay: 0.2s; animation-duration: 4.3s; }
.leaf-8 { animation-delay: 0.7s; animation-duration: 3.6s; }
.leaf-9 { animation-delay: 1.1s; animation-duration: 3.9s; }
.leaf-10 { animation-delay: 0.4s; animation-duration: 4.1s; }
.leaf-11 { animation-delay: 0.9s; animation-duration: 3.7s; }

@keyframes leafBreeze {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-4px) rotate(2deg); }
    75% { transform: translateY(4px) rotate(-2deg); }
}

/* Falling leaf */
.falling-leaf {
    animation: fallingLeaf 8s ease-in-out infinite;
}

@keyframes fallingLeaf {
    0% {
        transform: translate(550px, 100px) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.7;
    }
    50% {
        transform: translate(520px, 450px) rotate(180deg);
        opacity: 0.5;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translate(580px, 780px) rotate(360deg);
        opacity: 0;
    }
}

/* Trunk & branch draw-in animation */
.trunk-line,
.branch-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: drawLine 2.5s ease-out forwards;
}

.branch-line {
    animation-delay: 0.8s;
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

/* Hero text */
.hero-text {
    position: relative;
    z-index: 10;
    text-align: center;
    pointer-events: none;
}

.hero-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    line-height: 0.9;
}

.title-large {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(5rem, 12vw, 10rem);
    letter-spacing: -0.02em;
    color: var(--text);
    text-transform: uppercase;
}

.title-small {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: -0.02em;
    color: var(--illustration);
}

.title-dot {
    font-family: 'Special Elite', monospace;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.12em;
    color: var(--accent-warm);
    margin-top: 8px;
}

/* Scroll hint */
.scroll-hint {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    animation: scrollBounce 2.5s ease-in-out infinite;
}

.scroll-leaf {
    width: 24px;
    height: 40px;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(10px); }
}

/* --- Section Shelves --- */
.section-shelf {
    padding: 80px 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Module Base --- */
.module {
    position: relative;
    background: var(--bg);
    border: 2px solid var(--border);
    overflow: visible;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.module:hover {
    border-color: var(--highlight);
    box-shadow: 0 0 0 1px rgba(212, 168, 87, 0.2);
    transform: scale(1.003);
}

/* Module reveal (scroll entry) */
.module-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s var(--spring-ease), transform 0.8s var(--spring-ease);
}

.module-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Module border grow animation */
.module-reveal.visible {
    animation: borderGrow 0.6s ease-out forwards;
}

@keyframes borderGrow {
    0% { clip-path: polygon(0 0, 0 0, 0 100%, 0 100%); }
    50% { clip-path: polygon(0 0, 100% 0, 100% 0, 0 100%); }
    100% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
}

/* Module corner ornaments */
.module-corner-ornament {
    position: absolute;
    width: 24px;
    height: 24px;
    pointer-events: none;
    z-index: 2;
}

.module-corner-ornament::before,
.module-corner-ornament::after {
    content: '';
    position: absolute;
    background: var(--border);
    opacity: 0.5;
}

.module-corner-ornament.top-left { top: 6px; left: 6px; }
.module-corner-ornament.top-left::before { width: 16px; height: 1.5px; top: 0; left: 0; }
.module-corner-ornament.top-left::after { width: 1.5px; height: 16px; top: 0; left: 0; }

.module-corner-ornament.top-right { top: 6px; right: 6px; }
.module-corner-ornament.top-right::before { width: 16px; height: 1.5px; top: 0; right: 0; }
.module-corner-ornament.top-right::after { width: 1.5px; height: 16px; top: 0; right: 0; }

.module-corner-ornament.bottom-left { bottom: 6px; left: 6px; }
.module-corner-ornament.bottom-left::before { width: 16px; height: 1.5px; bottom: 0; left: 0; }
.module-corner-ornament.bottom-left::after { width: 1.5px; height: 16px; bottom: 0; left: 0; }

.module-corner-ornament.bottom-right { bottom: 6px; right: 6px; }
.module-corner-ornament.bottom-right::before { width: 16px; height: 1.5px; bottom: 0; right: 0; }
.module-corner-ornament.bottom-right::after { width: 1.5px; height: 16px; bottom: 0; right: 0; }

/* Module labels (typewriter specimen tag) */
.module-label {
    position: absolute;
    top: 10px;
    left: 14px;
    font-family: 'Special Elite', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--border);
    z-index: 3;
    background: var(--bg);
    padding: 2px 6px;
}

/* --- Module Types --- */
.module-panoramic {
    padding: 80px 60px;
    text-align: center;
    min-height: 35vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

/* Manifesto quote */
.manifesto-quote {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.quote-large {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: -0.02em;
    color: var(--text);
    display: block;
}

.quote-emphasis {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 3.8rem);
    letter-spacing: -0.02em;
    color: var(--accent-cool);
    display: block;
}

/* --- Cabinet Grid --- */
.module-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
}

.cabinet-grid {
    grid-template-areas:
        "branch fork seed seed"
        "branch fork merge merge";
}

.cabinet-grid .module-square:nth-child(1) { grid-area: branch; }
.cabinet-grid .module-tall { grid-area: fork; }
.cabinet-grid .module-square:nth-child(3) { grid-area: seed; }
.cabinet-grid .module-wide { grid-area: merge; }

.module-square {
    aspect-ratio: 1 / 1;
}

.module-tall {
    aspect-ratio: auto;
    min-height: 400px;
}

.module-wide {
    aspect-ratio: auto;
    min-height: 250px;
}

.module-feature {
    grid-column: span 2;
    min-height: 380px;
}

/* --- Specimens Grid --- */
.specimens-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-areas:
        "community community license commit"
        "dependency dependency issue review";
}

.specimens-grid .module-feature { grid-area: community; }
.specimens-grid .module-square:nth-child(2) { grid-area: license; }
.specimens-grid .module-square:nth-child(3) { grid-area: commit; }
.specimens-grid .module-wide { grid-area: dependency; }
.specimens-grid .module-tall { grid-area: issue; }
.specimens-grid .module-square:nth-child(6) { grid-area: review; }

/* --- Vignette Content --- */
.vignette-content,
.specimen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px 20px;
    gap: 16px;
}

.vignette-horizontal {
    flex-direction: row;
    gap: 24px;
    padding: 40px 24px 20px;
}

.vignette-svg,
.specimen-svg {
    width: 80%;
    max-height: 60%;
    flex-shrink: 0;
}

.vignette-horizontal .vignette-svg,
.vignette-horizontal .specimen-svg {
    width: 55%;
    max-height: 80%;
}

.vignette-text,
.specimen-description {
    font-family: 'Source Sans 3', sans-serif;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    line-height: 1.65;
    color: var(--text);
    text-align: center;
    padding: 0 10px;
}

.specimen-centered {
    text-align: center;
}

.specimen-content {
    padding: 40px 20px 24px;
}

.specimen-text-block {
    text-align: left;
    padding: 0 20px;
}

.specimen-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.2;
}

.specimen-title em {
    color: var(--accent-cool);
    font-style: italic;
}

/* --- Living Wall --- */
.living-wall-module {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 50px 24px;
    border: 2px solid var(--border);
}

.living-wall-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.living-wall-svg {
    width: 100%;
    max-width: 1200px;
    height: auto;
}

/* Vine growth animation */
.vine {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease-out;
}

.vine.grown {
    stroke-dashoffset: 0;
}

/* Interactive leaves */
.interactive-leaf {
    cursor: pointer;
    transition: transform 0.3s var(--spring-ease);
}

.interactive-leaf:hover {
    transform: scale(1.3);
}

.interactive-leaf:hover ellipse {
    opacity: 0.7 !important;
    fill: var(--accent-warm);
    transition: all 0.3s ease;
}

.interactive-leaf:hover .leaf-label {
    opacity: 1 !important;
    transition: opacity 0.3s ease;
}

.leaf-label {
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* --- Root System (Footer) --- */
.section-roots {
    background: var(--deep);
    padding: 80px 24px;
    margin-top: 80px;
    position: relative;
}

.roots-container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.roots-svg {
    width: 100%;
    max-width: 1200px;
    height: auto;
    margin-bottom: 40px;
}

.root-seed {
    cursor: pointer;
    transition: transform 0.3s var(--spring-ease);
}

.root-seed:hover {
    transform: scale(1.2);
}

.root-seed:hover circle {
    stroke: var(--accent-warm);
    opacity: 0.8;
}

.root-seed:hover text {
    fill: var(--accent-warm);
    opacity: 1;
}

.roots-text {
    padding: 20px 0 40px;
}

.roots-tagline {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--highlight);
    line-height: 1.5;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.roots-domain {
    font-family: 'Special Elite', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--border);
    opacity: 0.6;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .module-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cabinet-grid {
        grid-template-areas:
            "branch fork"
            "seed merge";
    }

    .specimens-grid {
        grid-template-areas:
            "community community"
            "license commit"
            "dependency dependency"
            "issue review";
    }

    .module-feature {
        grid-column: span 2;
    }

    .nav-inner {
        gap: 16px;
    }

    .nav-label {
        font-size: 0.65rem;
    }
}

@media (max-width: 640px) {
    .module-grid {
        grid-template-columns: 1fr;
    }

    .cabinet-grid {
        grid-template-areas:
            "branch"
            "fork"
            "seed"
            "merge";
    }

    .specimens-grid {
        grid-template-areas:
            "community"
            "license"
            "commit"
            "dependency"
            "issue"
            "review";
    }

    .module-feature {
        grid-column: span 1;
    }

    .module-square {
        aspect-ratio: auto;
        min-height: 300px;
    }

    .module-tall {
        min-height: 350px;
    }

    .section-shelf {
        padding: 40px 12px;
    }

    .vignette-horizontal {
        flex-direction: column;
    }

    .vignette-horizontal .vignette-svg,
    .vignette-horizontal .specimen-svg {
        width: 80%;
    }

    .hero-title {
        padding: 0 16px;
    }

    .title-large {
        font-size: clamp(3.5rem, 15vw, 6rem);
    }

    .condensed .nav-label:not(.active) {
        display: none;
    }

    .nav-inner {
        gap: 8px;
        padding: 8px 12px;
    }
}

/* --- Vine leaf hover tooltip enhancement --- */
.interactive-leaf .leaf-label {
    font-weight: 600;
    text-shadow: 0 0 4px var(--bg), 0 0 8px var(--bg);
}

/* --- Frame-breaking vine decoration --- */
.module::after {
    content: '';
    position: absolute;
    pointer-events: none;
    z-index: 5;
}

/* Subtle vine escaping frame on select modules */
.module-panoramic::after {
    bottom: -20px;
    right: 40px;
    width: 40px;
    height: 40px;
    border-left: 1.5px solid var(--accent-cool);
    border-bottom: 1.5px solid var(--accent-cool);
    border-radius: 0 0 0 20px;
    opacity: 0.3;
}

.module-feature::after {
    top: -15px;
    left: 60px;
    width: 30px;
    height: 30px;
    border-right: 1.5px solid var(--accent-cool);
    border-top: 1.5px solid var(--accent-cool);
    border-radius: 0 15px 0 0;
    opacity: 0.3;
}

/* --- Selection color --- */
::selection {
    background: rgba(212, 168, 87, 0.3);
    color: var(--text);
}
