/* ============================================================
   yami.wiki — Circuit Forest Editorial Stylesheet
   Palette: #0d1a0f #162b1a #1e4026 #2d6e3e #4aad67 #a8f5c2 #8bc49a #f0ede0
   Fonts: Patrick Hand, Josefin Sans 200, Libre Baskerville, Caveat, Space Mono
   ============================================================ */

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

:root {
    --abyss: #0d1a0f;
    --undergrowth: #162b1a;
    --canopy-shadow: #1e4026;
    --fern: #2d6e3e;
    --phosphor: #4aad67;
    --ghost-bloom: #a8f5c2;
    --circuit-patina: #8bc49a;
    --parchment: #f0ede0;
    --body-text-color: #e8f5e0;

    --font-display: 'Patrick Hand', cursive;
    --font-geometric: 'Josefin Sans', sans-serif;
    --font-body: 'Libre Baskerville', serif;
    --font-annotation: 'Caveat', cursive;
    --font-code: 'Space Mono', monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--abyss);
    color: var(--body-text-color);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.75;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ─── Mycelia Background ─── */
#mycelia-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ─── Entry Overlay ─── */
#entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--abyss);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transition: opacity 0.8s ease;
}

#entry-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#entry-overlay.hidden {
    display: none;
}

#entry-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 640px;
    padding: 0 24px;
}

/* Circuit Tree SVG */
#circuit-tree {
    width: 100%;
    max-width: 600px;
    height: auto;
    opacity: 0;
    transition: opacity 0.4s ease;
}

#circuit-tree.tree-visible {
    opacity: 1;
}

#circuit-tree .tree-path,
#circuit-tree .ground {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    fill: none;
}

#circuit-tree .tree-node,
#circuit-tree .tree-node-ring,
#circuit-tree .tree-component {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Hero Text */
#entry-text {
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    margin-top: -20px;
}

#entry-text.visible {
    opacity: 1;
    transform: translateY(0);
}

#hero-title {
    font-family: var(--font-display);
    font-size: clamp(72px, 12vw, 120px);
    color: var(--ghost-bloom);
    letter-spacing: 0.02em;
    line-height: 1.0;
    text-shadow: 0 0 40px rgba(74, 173, 103, 0.3), 0 0 80px rgba(74, 173, 103, 0.1);
}

#hero-subtitle {
    font-family: var(--font-geometric);
    font-weight: 200;
    font-size: clamp(16px, 2.5vw, 24px);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--phosphor);
    margin-top: 8px;
}

/* Entry Scroll Hint */
#entry-scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 32px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#entry-scroll-hint.visible {
    opacity: 1;
}

.entry-arrow {
    width: 24px;
    height: 40px;
    animation: scroll-bounce 2s ease-in-out infinite;
}

@keyframes scroll-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

.entry-label {
    font-family: var(--font-annotation);
    font-size: 14px;
    color: var(--circuit-patina);
    letter-spacing: 0.05em;
}

/* ─── Main Content ─── */
#main-content {
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#main-content.visible {
    opacity: 1;
}

/* ─── Navigation ─── */
#site-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 48px;
    background-color: rgba(13, 26, 15, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--canopy-shadow);
}

.nav-brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.nav-logo {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--ghost-bloom);
    text-shadow: 0 0 16px rgba(74, 173, 103, 0.4);
}

.nav-domain {
    font-family: var(--font-geometric);
    font-weight: 200;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--circuit-patina);
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-links a {
    font-family: var(--font-geometric);
    font-weight: 200;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--circuit-patina);
    text-decoration: none;
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: var(--ghost-bloom);
}

/* ─── Section Shared Styles ─── */
section {
    position: relative;
    padding: 80px 48px;
}

.section-full {
    min-height: 80vh;
}

.section-dense {
    background-color: var(--undergrowth);
    padding: 80px 48px;
}

.section-inset {
    padding: 80px 48px 80px 80px;
}

.section-archive {
    padding: 80px 48px;
    background-color: rgba(22, 43, 26, 0.5);
}

/* Section Markers (bioluminescent nodes) */
.section-marker {
    display: flex;
    justify-content: center;
    margin-bottom: 48px;
}

.bioluminescent-node {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--phosphor);
    box-shadow: 0 0 4px 4px rgba(74, 173, 103, 0.6),
                0 0 16px 8px rgba(45, 110, 62, 0.3);
    animation: node-pulse 3s ease-in-out infinite;
}

@keyframes node-pulse {
    0%, 100% { box-shadow: 0 0 4px 4px rgba(74, 173, 103, 0.6), 0 0 16px 8px rgba(45, 110, 62, 0.3); }
    50% { box-shadow: 0 0 6px 6px rgba(74, 173, 103, 1.0), 0 0 24px 16px rgba(45, 110, 62, 0.5); }
}

/* ─── Typography ─── */
.section-tag {
    font-family: var(--font-geometric);
    font-weight: 200;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--phosphor);
    margin-bottom: 12px;
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(40px, 5vw, 72px);
    color: var(--ghost-bloom);
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 32px;
}

.body-text {
    font-family: var(--font-body);
    font-size: 17px;
    color: var(--body-text-color);
    line-height: 1.75;
    max-width: 680px;
    margin-bottom: 24px;
}

.pull-quote {
    border-left: 2px solid var(--phosphor);
    padding: 16px 24px;
    margin: 32px 0;
    background-color: rgba(22, 43, 26, 0.4);
}

.pull-quote blockquote {
    font-family: var(--font-body);
    font-size: 20px;
    font-style: italic;
    color: var(--ghost-bloom);
    line-height: 1.6;
}

/* Annotations / Marginalia */
.annotation {
    font-family: var(--font-annotation);
    font-size: 13px;
    color: var(--circuit-patina);
    display: block;
    transform: rotate(var(--rotate, 0deg));
    transform-origin: center;
    line-height: 1.4;
}

.annotation-arrow {
    width: 20px;
    height: auto;
    margin: 4px auto;
    display: block;
}

/* Code Blocks */
.code-block {
    background-color: var(--undergrowth);
    border: 1px solid var(--canopy-shadow);
    padding: 16px 20px;
    margin-top: 24px;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.code-label {
    font-family: var(--font-geometric);
    font-weight: 200;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--circuit-patina);
}

code {
    font-family: var(--font-code);
    font-size: 14px;
    color: var(--phosphor);
    background: transparent;
}

/* ─── Editorial Layout ─── */
.editorial-layout {
    display: grid;
    grid-template-columns: 120px 1fr 200px;
    gap: 40px;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
}

.editorial-layout--reversed {
    grid-template-columns: 200px 1fr;
}

.marginalia-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    gap: 8px;
}

.marginalia-col--inline {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin: 24px 0;
    padding-left: 16px;
    border-left: 1px solid var(--canopy-shadow);
}

.content-col {
    /* main content column */
}

.illustration-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ─── Specimen Illustrations ─── */
.specimen-illustration {
    width: 100%;
    max-width: 140px;
    height: auto;
    cursor: pointer;
    transition: filter 0.3s ease;
}

.specimen-illustration:hover .circuit-vein,
.specimen-illustration:hover .specimen-component {
    filter: drop-shadow(0 0 3px rgba(74, 173, 103, 0.8));
}

.specimen-illustration .circuit-vein {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.2s ease;
}

.specimen-illustration.circuit-active .circuit-vein {
    stroke-dashoffset: 0;
}

/* Hover current-flow animation */
.specimen-illustration:hover .circuit-vein {
    animation: current-flow 2s linear infinite;
}

@keyframes current-flow {
    0% { stroke-dashoffset: 300; opacity: 1; }
    80% { stroke-dashoffset: 0; opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: 0.6; }
}

/* ─── Node Grid ─── */
.node-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 40px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.node-card {
    background-color: var(--undergrowth);
    border: 1px solid var(--canopy-shadow);
    padding: 24px;
    border-radius: 2px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.node-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--phosphor), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.node-card:hover {
    border-color: var(--fern);
    box-shadow: 0 0 20px rgba(45, 110, 62, 0.2);
}

.node-card:hover::before {
    opacity: 1;
}

.node-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.node-id {
    font-family: var(--font-code);
    font-size: 11px;
    color: var(--circuit-patina);
    letter-spacing: 0.05em;
}

.node-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--phosphor);
    box-shadow: 0 0 6px 2px rgba(74, 173, 103, 0.5);
    animation: node-pulse 3s ease-in-out infinite;
}

.node-title {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--ghost-bloom);
    letter-spacing: 0.02em;
    line-height: 1.2;
    margin-bottom: 12px;
}

.node-body {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--body-text-color);
    line-height: 1.7;
    margin-bottom: 16px;
}

.node-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.node-tag {
    font-family: var(--font-geometric);
    font-weight: 200;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--fern);
    border: 1px solid var(--canopy-shadow);
    padding: 3px 8px;
}

/* ─── Circuit Divider ─── */
.circuit-divider {
    padding: 0 48px;
    position: relative;
}

.divider-circuit {
    width: 100%;
    height: 60px;
}

.divider-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.divider-path.drawn {
    animation: draw-divider 1.5s ease forwards;
}

@keyframes draw-divider {
    to { stroke-dashoffset: 0; }
}

/* ─── Archive ─── */
.archive-header {
    max-width: 1200px;
    margin: 0 auto 48px;
}

.archive-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
}

.archive-entry {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 32px;
    padding: 32px 0;
    border-bottom: 1px solid var(--canopy-shadow);
    align-items: start;
    transition: background-color 0.2s ease;
}

.archive-entry:hover {
    background-color: rgba(22, 43, 26, 0.4);
    padding-left: 16px;
    padding-right: 16px;
}

.archive-date {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding-top: 4px;
}

.archive-year {
    font-family: var(--font-code);
    font-size: 11px;
    color: var(--fern);
    letter-spacing: 0.05em;
}

.archive-day {
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--circuit-patina);
    letter-spacing: 0.05em;
}

.archive-title {
    font-family: var(--font-display);
    font-size: 24px;
    color: var(--ghost-bloom);
    letter-spacing: 0.02em;
    line-height: 1.2;
    margin-bottom: 12px;
}

.archive-excerpt {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--body-text-color);
    line-height: 1.75;
    margin-bottom: 16px;
}

/* ─── Reveal Animation System ─── */
.reveal-item {
    opacity: 0;
    transform: translateY(32px);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.4s ease;
    transition-delay: calc(var(--reveal-index, 0) * 0.12s);
}

.reveal-item.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Footer ─── */
#site-footer {
    position: relative;
    padding: 32px 48px 48px;
    border-top: 1px solid var(--canopy-shadow);
    background-color: var(--undergrowth);
}

.footer-circuit {
    margin-bottom: 24px;
}

.footer-circuit svg {
    width: 100%;
    max-width: 400px;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-brand {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--ghost-bloom);
}

.footer-tag {
    font-family: var(--font-annotation);
    font-size: 14px;
    color: var(--circuit-patina);
}

.footer-code {
    font-family: var(--font-code);
    font-size: 11px;
    color: var(--fern);
    letter-spacing: 0.05em;
    margin-top: 8px;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    section {
        padding: 60px 24px;
    }

    #site-nav {
        padding: 14px 24px;
    }

    .editorial-layout {
        grid-template-columns: 1fr;
    }

    .editorial-layout--reversed {
        grid-template-columns: 1fr;
    }

    .marginalia-col {
        display: none;
    }

    .illustration-col {
        order: -1;
        flex-direction: row;
        align-items: center;
        gap: 16px;
    }

    .specimen-illustration {
        max-width: 80px;
    }

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

    .circuit-divider {
        padding: 0 24px;
    }

    .archive-entry {
        grid-template-columns: 80px 1fr;
        gap: 16px;
    }

    #site-footer {
        padding: 24px;
    }

    .nav-links {
        gap: 16px;
    }
}

@media (max-width: 600px) {
    #hero-title {
        font-size: 72px;
    }

    .node-grid {
        grid-template-columns: 1fr;
    }

    .nav-links {
        display: none;
    }
}
