/* ========================================
   op9.rs - Digital Herbarium / Electric Taxonomy
   Nocturnal Botanical Archive
   ======================================== */

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

:root {
    --bg-void: #0A0E1A;
    --bg-sidebar: #0D1220;
    --neon-cyan: #00FFD4;
    --neon-magenta: #FF0099;
    --neon-yellow: #CCFF00;
    --text-primary: #E8E4DC;
    --text-secondary: #8A9BAA;
    --border-ghost: #1A2840;
    --cyan-haze: rgba(0,255,212,0.15);
    --magenta-haze: rgba(255,0,153,0.15);
}

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

body {
    background: var(--bg-void);
    color: var(--text-primary);
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-void);
}

::-webkit-scrollbar-thumb {
    background: var(--neon-cyan);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--neon-magenta);
}

/* --- Layout Grid --- */
.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-ghost);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 32px 24px 24px;
    border-bottom: 0.5px solid var(--neon-cyan);
}

.sidebar-title {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--neon-cyan);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.sidebar-subtitle {
    display: block;
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.specimen-list {
    list-style: none;
}

.specimen-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    border-bottom: 0.5px solid var(--border-ghost);
    cursor: pointer;
    transition: background 0.3s ease;
    position: relative;
}

.specimen-entry:hover {
    background: rgba(0,255,212,0.05);
}

.specimen-entry.active {
    background: var(--cyan-haze);
    animation: sidebarGlow 3s ease-in-out infinite;
}

@keyframes sidebarGlow {
    0%, 100% {
        box-shadow: inset 3px 0 12px rgba(0,255,212,0.2);
    }
    50% {
        box-shadow: inset 3px 0 12px rgba(255,0,153,0.2);
    }
}

.fish-bullet {
    flex-shrink: 0;
}

.entry-num {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--neon-cyan);
    min-width: 28px;
}

.entry-name {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.specimen-entry.active .entry-name {
    color: var(--neon-cyan);
    text-shadow: 0 0 8px rgba(0,255,212,0.4);
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 0.5px solid var(--border-ghost);
}

.sidebar-code {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    opacity: 0.6;
    line-height: 1.8;
}

/* --- Sidebar Toggle (Mobile) --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    background: var(--bg-sidebar);
    border: 1px solid var(--neon-cyan);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    padding: 8px;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(0,255,212,0.2);
}

/* --- Main Plates Container --- */
.plates-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
}

/* --- Plate Base --- */
.plate {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    background: var(--bg-void);
}

/* Grid overlay */
.plate-grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--border-ghost) 0.25px, transparent 0.25px),
        linear-gradient(90deg, var(--border-ghost) 0.25px, transparent 0.25px);
    background-size: 80px 80px;
    opacity: 0.15;
    pointer-events: none;
    z-index: 1;
}

/* Corner markers */
.plate-corner {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    color: var(--text-secondary);
    opacity: 0.4;
    z-index: 2;
    pointer-events: none;
}

.plate-corner.tl { top: 12px; left: 12px; }
.plate-corner.tr { top: 12px; right: 12px; }
.plate-corner.bl { bottom: 12px; left: 12px; }
.plate-corner.br { bottom: 12px; right: 12px; }

/* --- Diagram Mode --- */
.diagram-mode .plate-content {
    display: grid;
    grid-template-columns: 60% 40%;
    height: 100%;
    position: relative;
    z-index: 3;
}

.illustration-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.botanical-svg {
    width: 100%;
    max-width: 600px;
    height: auto;
}

.annotation-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 48px 60px 24px;
    gap: 12px;
}

/* --- Immersion Mode --- */
.immersion-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.immersion-bg .botanical-svg.full {
    width: 100%;
    height: 100%;
    opacity: 0.6;
}

.immersion-text-overlay {
    position: absolute;
    bottom: 60px;
    right: 60px;
    max-width: 480px;
    z-index: 5;
}

.root-overlay {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    right: 80px;
}

.neon-text-block {
    background: rgba(10,14,26,0.88);
    border: 1px solid var(--neon-cyan);
    padding: 32px;
    box-shadow:
        0 0 15px rgba(0,255,212,0.15),
        inset 0 0 15px rgba(0,255,212,0.05);
}

.neon-text-block.magenta-border {
    border-color: var(--neon-magenta);
    box-shadow:
        0 0 15px rgba(255,0,153,0.15),
        inset 0 0 15px rgba(255,0,153,0.05);
}

/* --- Typography --- */
.plate-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    letter-spacing: 0.04em;
    color: var(--text-primary);
    line-height: 1.15;
}

.plate-title em {
    font-style: italic;
}

.neon-text-block .plate-title {
    font-size: clamp(1.6rem, 3vw, 2.8rem);
}

.plate-subtitle {
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: lowercase;
}

.specimen-meta {
    display: flex;
    gap: 12px;
    align-items: baseline;
}

.meta-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    text-transform: uppercase;
    min-width: 90px;
}

.meta-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--neon-cyan);
}

.plate-description {
    font-family: 'Instrument Sans', sans-serif;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    font-weight: 400;
    line-height: 1.65;
    color: var(--text-secondary);
    margin-top: 8px;
    max-width: 420px;
}

.neon-text-block .plate-description {
    max-width: 100%;
}

.fish-margin {
    margin-top: 24px;
    opacity: 0.7;
}

/* --- Warm Plate Variant --- */
.plate.warm {
    background: linear-gradient(135deg, #0A0E1A 0%, #150A1A 100%);
}

/* --- Aquarium Plate --- */
.aquarium .aquarium-scene {
    position: absolute;
    inset: 0;
    z-index: 2;
}

.fish-school {
    width: 100%;
    height: 100%;
}

.aquarium-text {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 5;
}

.aquarium-ref {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--neon-cyan);
    margin-bottom: 12px;
}

.aquarium-line {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 500px;
}

/* --- Fish Glitch Animation --- */
@keyframes glitch {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.fish.glitching {
    animation: glitch 150ms ease-in-out;
}

/* --- Seal Plate --- */
.seal-plate {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-void);
}

.seal-content {
    text-align: center;
    position: relative;
    z-index: 3;
}

.seal-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.04em;
    color: var(--text-primary);
    text-shadow:
        0 0 20px rgba(0,255,212,0.15),
        0 0 40px rgba(0,255,212,0.05);
}

.seal-rule {
    width: 200px;
    height: 1px;
    background: var(--neon-cyan);
    margin: 24px auto;
    box-shadow: 0 0 8px rgba(0,255,212,0.3);
}

.seal-text {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    text-transform: lowercase;
}

.drifting-fish {
    position: absolute;
    top: 50%;
    left: -80px;
    animation: drift 20s linear infinite;
    opacity: 0.6;
}

@keyframes drift {
    0% { left: -80px; }
    100% { left: calc(100vw + 80px); }
}

/* --- Roots SVG --- */
.roots {
    opacity: 0.5;
}

/* --- Mobile Responsive --- */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        transition: left 0.3s ease;
        z-index: 150;
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .diagram-mode .plate-content {
        grid-template-columns: 1fr;
        grid-template-rows: 55% 45%;
    }

    .annotation-panel {
        padding: 24px 32px;
    }

    .illustration-panel {
        padding: 24px;
    }

    .immersion-text-overlay {
        bottom: 24px;
        right: 24px;
        left: 24px;
        max-width: 100%;
    }

    .root-overlay {
        top: auto;
        bottom: 24px;
        transform: none;
        right: 24px;
        left: 24px;
    }

    .neon-text-block {
        padding: 20px;
    }

    .plate-title {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .seal-title {
        font-size: clamp(2.5rem, 8vw, 5rem);
    }
}

@media (max-width: 600px) {
    .plate-corner {
        display: none;
    }

    .plate-description {
        font-size: 0.85rem;
    }

    .meta-label {
        min-width: 70px;
    }

    .aquarium-text {
        bottom: 32px;
        left: 24px;
        right: 24px;
        transform: none;
    }
}
