/* ==========================================================
   bada.casa — Corrupted Greenhouse Terminal
   ========================================================== */

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

:root {
    --deep-void: #0A0814;
    --midnight-indigo: #1A1830;
    --neon-mint: #00FFB2;
    --glitch-pink: #FF2D6B;
    --electric-violet: #8B5CF6;
    --frost-white: #E0E8F0;
    --mist: #B0BEC5;
    --slate-data: #7B8CA6;
    --pale-chlorophyll: #C9F0E0;
    --fern-shadow: #2D6B4F;
    --gradient-end: #0F1A2E;
    --footer-text: #4A5568;
    --warm-glitch: #FF6B35;
}

html {
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(135deg, var(--deep-void), var(--midnight-indigo), var(--gradient-end));
    color: var(--mist);
    font-family: 'Nunito Sans', sans-serif;
    font-size: 16px;
    line-height: 1.65;
    letter-spacing: 0.01em;
    overflow: hidden;
    min-height: 100vh;
}

.mono {
    font-family: 'Fira Code', monospace;
    font-feature-settings: "liga" 1;
    letter-spacing: 0.03em;
}

/* --- Scanline Overlay (fixed, always present) --- */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.08) 1px,
        rgba(0, 0, 0, 0.08) 2px
    );
}

/* --- Boot Screen --- */
#boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--deep-void);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#boot-screen.fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 800ms ease;
}

#boot-screen.hidden {
    display: none;
}

#boot-scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(0, 255, 178, 0.8);
    box-shadow: 0 0 12px rgba(0, 255, 178, 0.5), 0 0 40px rgba(0, 255, 178, 0.2);
    transform: translateY(-2px);
    opacity: 0;
    z-index: 2;
}

#boot-scanline.animate {
    opacity: 1;
    animation: scanDown 1.2s ease-in-out forwards;
}

@keyframes scanDown {
    0% { transform: translateY(0); }
    100% { transform: translateY(100vh); }
}

#boot-content {
    text-align: center;
    opacity: 0;
    z-index: 3;
}

#boot-content.visible {
    opacity: 1;
    transition: opacity 400ms ease;
}

#boot-title {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--frost-white);
    margin-bottom: 1.5rem;
    position: relative;
}

/* RGB split effect */
#boot-title.rgb-split::before,
#boot-title.rgb-split::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#boot-title.rgb-split::before {
    color: rgba(255, 0, 0, 0.7);
    transform: translateX(-2px);
    mix-blend-mode: screen;
    animation: rgbConverge 400ms ease forwards;
}

#boot-title.rgb-split::after {
    content: attr(data-text);
    color: rgba(0, 255, 255, 0.7);
    transform: translateX(2px);
    mix-blend-mode: screen;
    animation: rgbConverge 400ms ease forwards;
}

@keyframes rgbConverge {
    0% { opacity: 1; }
    100% { opacity: 0; transform: translateX(0); }
}

#boot-typewriter {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    color: var(--neon-mint);
    letter-spacing: 0.03em;
    min-height: 1.5em;
}

.cursor {
    animation: blink 530ms step-end infinite;
    color: var(--neon-mint);
}

.cursor.fade-out {
    animation: none;
    opacity: 0;
    transition: opacity 300ms ease;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Dashboard Layout --- */
#dashboard {
    display: grid;
    grid-template-columns: 220px 1fr 280px;
    grid-template-rows: 48px 1fr 32px;
    grid-template-areas:
        "status status status"
        "nav main panel"
        "footer footer footer";
    width: 100%;
    height: 100vh;
    opacity: 0;
    overflow: hidden;
}

#dashboard.visible {
    opacity: 1;
}

/* Stagger-fade panels */
#dashboard.stagger-in #status-bar { animation: panelFadeIn 600ms ease forwards 0ms; }
#dashboard.stagger-in #left-nav { animation: panelFadeIn 600ms ease forwards 100ms; }
#dashboard.stagger-in #central-viewport { animation: panelFadeIn 600ms ease forwards 200ms; }
#dashboard.stagger-in #right-panel { animation: panelFadeIn 600ms ease forwards 300ms; }
#dashboard.stagger-in #footer-strip { animation: panelFadeIn 600ms ease forwards 400ms; }

@keyframes panelFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

#dashboard > * {
    opacity: 0;
}

#dashboard.stagger-in > * {
    /* will be animated individually */
}

/* --- Top Status Bar --- */
#status-bar {
    grid-area: status;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(10, 8, 20, 0.85);
    border-bottom: 1px solid rgba(0, 255, 178, 0.15);
    z-index: 100;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--neon-mint);
    border-radius: 50%;
    animation: dotPulse 3s ease-in-out infinite;
    box-shadow: 0 0 6px var(--neon-mint);
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

.status-domain {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--frost-white);
}

.status-center {
    font-size: 12px;
    color: var(--slate-data);
}

.status-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.waveform {
    opacity: 0.7;
}

.status-label {
    font-size: 11px;
    color: var(--neon-mint);
}

/* --- Left Navigation --- */
#left-nav {
    grid-area: nav;
    background: rgba(10, 8, 20, 0.7);
    border-right: 1px solid rgba(0, 255, 178, 0.1);
    padding: 16px 12px;
    position: sticky;
    top: 48px;
    height: calc(100vh - 80px);
    overflow-y: auto;
    z-index: 50;
}

#left-nav::-webkit-scrollbar {
    width: 3px;
}

#left-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 178, 0.2);
    border-radius: 2px;
}

.nav-section-label {
    font-size: 10px;
    color: var(--slate-data);
    letter-spacing: 0.1em;
    margin-bottom: 12px;
    padding-left: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 178, 0.3);
    text-decoration: none;
    color: var(--mist);
    font-size: 13px;
    transition: background 300ms ease, border-color 300ms ease;
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(0, 255, 178, 0.08);
}

.nav-item:hover .nav-icon path,
.nav-item:hover .nav-icon circle,
.nav-item:hover .nav-icon ellipse,
.nav-item:hover .nav-icon line,
.nav-item:hover .nav-icon rect {
    stroke: var(--neon-mint);
    transition: stroke 300ms ease;
}

.nav-item.active {
    background: rgba(0, 255, 178, 0.06);
    border-color: rgba(0, 255, 178, 0.5);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--glitch-pink);
    border-radius: 0 2px 2px 0;
    animation: accentPulse 2s ease-in-out infinite;
}

@keyframes accentPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.nav-icon {
    flex-shrink: 0;
}

.nav-label {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    white-space: nowrap;
}

.nav-divider {
    height: 1px;
    background: rgba(0, 255, 178, 0.1);
    margin: 16px 0;
}

/* --- Central Viewport --- */
#central-viewport {
    grid-area: main;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-content: start;
}

#central-viewport::-webkit-scrollbar {
    width: 4px;
}

#central-viewport::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 178, 0.15);
    border-radius: 2px;
}

/* Parallax background */
#bg-botanical {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(circle at 20% 30%, var(--fern-shadow) 1px, transparent 1px),
        radial-gradient(circle at 60% 50%, var(--fern-shadow) 1px, transparent 1px),
        radial-gradient(circle at 80% 20%, var(--fern-shadow) 1px, transparent 1px),
        radial-gradient(circle at 40% 70%, var(--fern-shadow) 1px, transparent 1px);
    background-size: 80px 80px, 120px 120px, 60px 60px, 100px 100px;
}

/* --- Specimen Cards --- */
.specimen-card,
.content-section {
    border-radius: 16px;
    background: rgba(10, 8, 20, 0.65);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(0, 255, 178, 0.12);
    position: relative;
    z-index: 1;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 200ms ease, transform 300ms ease;
}

.specimen-card.revealed,
.content-section.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Content sections span full width */
.content-section {
    grid-column: 1 / -1;
}

/* Corner brackets */
.card-corners {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.corner {
    position: absolute;
    width: 16px;
    height: 16px;
    opacity: 0;
}

.revealed .corner {
    opacity: 0.5;
    transition: opacity 300ms ease 200ms;
}

.corner::before,
.corner::after {
    content: '';
    position: absolute;
    background: var(--neon-mint);
}

.corner.tl { top: 6px; left: 6px; }
.corner.tl::before { top: 0; left: 0; width: 16px; height: 2px; }
.corner.tl::after { top: 0; left: 0; width: 2px; height: 16px; }

.corner.tr { top: 6px; right: 6px; }
.corner.tr::before { top: 0; right: 0; width: 16px; height: 2px; }
.corner.tr::after { top: 0; right: 0; width: 2px; height: 16px; }

.corner.bl { bottom: 6px; left: 6px; }
.corner.bl::before { bottom: 0; left: 0; width: 16px; height: 2px; }
.corner.bl::after { bottom: 0; left: 0; width: 2px; height: 16px; }

.corner.br { bottom: 6px; right: 6px; }
.corner.br::before { bottom: 0; right: 0; width: 16px; height: 2px; }
.corner.br::after { bottom: 0; right: 0; width: 2px; height: 16px; }

/* Card inner layout */
.card-inner {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-inner {
    padding: 24px;
}

/* Card illustration area */
.card-illustration {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

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

/* SVG draw animation */
.botanical-svg .draw-path path,
.botanical-svg .draw-path circle,
.botanical-svg .draw-path ellipse,
.botanical-svg .draw-path line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.revealed .botanical-svg .draw-path path,
.revealed .botanical-svg .draw-path circle,
.revealed .botanical-svg .draw-path ellipse,
.revealed .botanical-svg .draw-path line {
    animation: drawStroke 800ms ease forwards 500ms;
}

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

/* Annotations fade in after draw */
.botanical-svg .annotations {
    opacity: 0;
}

.revealed .botanical-svg .annotations {
    animation: fadeInAnnotation 400ms ease forwards 1300ms;
}

@keyframes fadeInAnnotation {
    to { opacity: 0.4; }
}

/* HUD elements */
.botanical-svg .hud-element {
    opacity: 0;
}

.revealed .botanical-svg .hud-element {
    animation: fadeInAnnotation 400ms ease forwards 1000ms;
}

/* HUD readout box */
.hud-readout {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 6px 14px;
    border: 1px solid rgba(0, 255, 178, 0.2);
    border-radius: 4px;
    background: rgba(0, 255, 178, 0.04);
}

.hud-label {
    font-size: 10px;
    color: var(--slate-data);
}

.hud-value {
    font-size: 14px;
    color: var(--neon-mint);
    font-weight: 500;
}

.hud-unit {
    font-size: 10px;
    color: var(--slate-data);
}

/* Card content */
.card-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.specimen-title {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 3vw, 2rem);
    color: var(--frost-white);
    letter-spacing: 0.01em;
}

.specimen-name-latin {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    color: var(--pale-chlorophyll);
    letter-spacing: 0.04em;
}

.specimen-text {
    color: var(--mist);
    font-size: 15px;
    line-height: 1.65;
}

.specimen-text p {
    margin-bottom: 0.8em;
}

.specimen-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--slate-data);
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 255, 178, 0.08);
}

/* Section titles */
.section-title {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 3vw, 2rem);
    color: var(--frost-white);
    margin-bottom: 16px;
}

/* Log entries */
.log-entries {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    line-height: 1.6;
}

.log-entry {
    color: var(--slate-data);
    padding: 4px 0;
    border-bottom: 1px solid rgba(0, 255, 178, 0.05);
}

.log-time {
    color: var(--mist);
    margin-right: 8px;
}

.log-tag {
    margin-right: 6px;
    font-weight: 500;
}

.log-tag.ok { color: var(--neon-mint); }
.log-tag.warn { color: #FFB020; }
.log-tag.info { color: var(--electric-violet); }
.log-tag.err { color: var(--glitch-pink); }

.glitch-inline {
    color: var(--glitch-pink);
    opacity: 0.7;
}

/* --- Hover effects on cards --- */
.specimen-card:hover .hud-element {
    opacity: 0.9 !important;
    transition: opacity 200ms ease;
}

.specimen-card:hover .annotations {
    opacity: 0.7 !important;
    transition: opacity 200ms ease;
}

.specimen-card:hover .annotations line {
    stroke-dasharray: none;
}

/* Micro-glitch on hover exit handled by JS */
.specimen-card.glitch-out {
    animation: microGlitch 80ms steps(1) forwards;
}

@keyframes microGlitch {
    0% { clip-path: inset(0); }
    25% { clip-path: inset(30% 0 40% 0); transform: translateX(4px); }
    50% { clip-path: inset(60% 0 10% 0); transform: translateX(-3px); }
    75% { clip-path: inset(10% 0 70% 0); transform: translateX(5px); }
    100% { clip-path: inset(0); transform: translateX(0); }
}

/* --- Right Data Panel --- */
#right-panel {
    grid-area: panel;
    background: rgba(10, 8, 20, 0.7);
    border-left: 1px solid rgba(0, 255, 178, 0.1);
    padding: 16px 14px;
    position: sticky;
    top: 48px;
    height: calc(100vh - 80px);
    overflow-y: auto;
    z-index: 50;
}

#right-panel::-webkit-scrollbar {
    width: 3px;
}

#right-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 178, 0.2);
    border-radius: 2px;
}

.panel-section-label {
    font-size: 10px;
    color: var(--slate-data);
    letter-spacing: 0.1em;
    margin-bottom: 12px;
}

.panel-divider {
    height: 1px;
    background: rgba(0, 255, 178, 0.1);
    margin: 16px 0;
}

/* Telemetry rows */
.telemetry-row {
    display: flex;
    align-items: baseline;
    font-size: 11px;
    color: var(--slate-data);
    padding: 4px 0;
    line-height: 1.5;
}

.telem-label {
    flex-shrink: 0;
    color: var(--slate-data);
    white-space: nowrap;
}

.dot-leader {
    flex: 1;
    border-bottom: 1px dotted rgba(123, 140, 166, 0.3);
    margin: 0 6px;
    min-width: 10px;
    align-self: center;
    margin-bottom: 3px;
}

.telem-value {
    color: var(--neon-mint);
    font-weight: 500;
    flex-shrink: 0;
    min-width: 48px;
    text-align: right;
}

.telem-unit {
    color: var(--slate-data);
    font-size: 9px;
    margin-left: 4px;
    flex-shrink: 0;
    opacity: 0.7;
}

/* Glitch effect on telemetry row */
.telemetry-row.glitching .telem-value {
    color: var(--glitch-pink);
}

/* Status messages */
.status-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-msg {
    display: flex;
    align-items: center;
    gap: 8px;
}

.breathing-dot {
    width: 6px;
    height: 6px;
    background: var(--neon-mint);
    border-radius: 50%;
    animation: breathe 4s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
}

.status-text {
    font-size: 11px;
    color: var(--slate-data);
}

/* --- Footer Strip --- */
#footer-strip {
    grid-area: footer;
    background: rgba(10, 8, 20, 0.85);
    border-top: 1px solid rgba(0, 255, 178, 0.1);
    overflow: hidden;
    display: flex;
    align-items: center;
}

.marquee-track {
    display: flex;
    white-space: nowrap;
    animation: marqueeScroll 60s linear infinite;
}

.marquee-content {
    font-size: 10px;
    color: var(--footer-text);
    padding-right: 0;
    flex-shrink: 0;
}

@keyframes marqueeScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- Glitch Animation System --- */
.glitch-effect {
    position: relative;
}

.glitch-effect::before,
.glitch-effect::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Warm glitch gradient for error states: #FF2D6B to #FF6B35 */
.log-tag.err {
    background: linear-gradient(90deg, var(--glitch-pink), var(--warm-glitch));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Zone glitch class applied by JS */
.zone-glitch {
    animation: zoneGlitch 200ms steps(3) forwards;
}

@keyframes zoneGlitch {
    0% {
        clip-path: inset(0);
        filter: none;
    }
    20% {
        clip-path: inset(15% 0 60% 0);
        transform: translateX(5px);
        filter: hue-rotate(90deg);
    }
    40% {
        clip-path: inset(50% 0 20% 0);
        transform: translateX(-3px);
        filter: saturate(200%) brightness(1.3);
    }
    60% {
        clip-path: inset(25% 0 45% 0);
        transform: translateX(8px);
        filter: hue-rotate(-60deg);
    }
    80% {
        clip-path: inset(70% 0 5% 0);
        transform: translateX(-6px);
    }
    100% {
        clip-path: inset(0);
        transform: translateX(0);
        filter: none;
    }
}

/* --- Typewriter --- */
.typewriter-block {
    position: relative;
}

.typewriter-block .typing-cursor {
    display: inline;
    animation: blink 530ms step-end infinite;
    color: var(--neon-mint);
    font-weight: 400;
}

.typewriter-block .typing-cursor.done {
    animation: none;
    opacity: 0;
    transition: opacity 300ms ease;
}

/* --- Responsive (tablet collapse) --- */
@media (max-width: 1024px) {
    #dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: 48px 1fr 32px;
        grid-template-areas:
            "status"
            "main"
            "footer";
    }

    #left-nav,
    #right-panel {
        display: none;
    }

    #central-viewport {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    #central-viewport {
        padding: 12px;
        gap: 12px;
    }

    .card-inner {
        padding: 16px;
    }

    .botanical-svg {
        max-height: 200px;
    }
}

/* --- Utility: annotation text font --- */
.annotation-text {
    font-family: 'Cormorant Garamond', serif;
}
