/* ============================================
   concurrent.day - Cottagecore Greenhouse + Sci-Fi HUD
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.75;
    color: #2B4A2B;
    background-color: #F4F1E8;
    overflow-x: hidden;
    position: relative;
    /* Background grid */
    background-image:
        linear-gradient(#2D5F2D 1px, transparent 1px),
        linear-gradient(90deg, #2D5F2D 1px, transparent 1px);
    background-size: 60px 60px;
    background-position: center center;
    background-attachment: fixed;
}

/* Grid at very low opacity via pseudo-element to control opacity separately */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(#2D5F2D 1px, transparent 1px),
        linear-gradient(90deg, #2D5F2D 1px, transparent 1px);
    background-size: 60px 60px;
    background-position: center center;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

/* Remove the body background-image since we use the pseudo */
body {
    background-image: none;
}

/* --- Color Temperature Overlay --- */
#color-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(200, 230, 192, 0.08),
        rgba(230, 210, 170, 0.08)
    );
    pointer-events: none;
    z-index: 1;
    opacity: 1;
}

/* --- Spore Particles --- */
#spore-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.spore {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #A8E06B;
    opacity: 0.18;
    animation: spore-float linear infinite;
}

.spore:nth-child(1)  { left: 5%;  width: 3px; height: 3px; animation-duration: 22s; animation-delay: 0s; opacity: 0.15; }
.spore:nth-child(2)  { left: 12%; width: 4px; height: 4px; animation-duration: 18s; animation-delay: 2s; opacity: 0.20; }
.spore:nth-child(3)  { left: 20%; width: 3px; height: 3px; animation-duration: 25s; animation-delay: 5s; opacity: 0.17; }
.spore:nth-child(4)  { left: 28%; width: 4px; height: 4px; animation-duration: 20s; animation-delay: 1s; opacity: 0.22; }
.spore:nth-child(5)  { left: 35%; width: 3px; height: 3px; animation-duration: 28s; animation-delay: 8s; opacity: 0.15; }
.spore:nth-child(6)  { left: 42%; width: 3px; height: 3px; animation-duration: 19s; animation-delay: 3s; opacity: 0.25; }
.spore:nth-child(7)  { left: 50%; width: 4px; height: 4px; animation-duration: 23s; animation-delay: 6s; opacity: 0.18; }
.spore:nth-child(8)  { left: 57%; width: 3px; height: 3px; animation-duration: 26s; animation-delay: 10s; opacity: 0.20; }
.spore:nth-child(9)  { left: 63%; width: 4px; height: 4px; animation-duration: 21s; animation-delay: 4s; opacity: 0.16; }
.spore:nth-child(10) { left: 70%; width: 3px; height: 3px; animation-duration: 24s; animation-delay: 7s; opacity: 0.22; }
.spore:nth-child(11) { left: 76%; width: 3px; height: 3px; animation-duration: 27s; animation-delay: 12s; opacity: 0.18; }
.spore:nth-child(12) { left: 82%; width: 4px; height: 4px; animation-duration: 20s; animation-delay: 9s; opacity: 0.15; }
.spore:nth-child(13) { left: 88%; width: 3px; height: 3px; animation-duration: 22s; animation-delay: 14s; opacity: 0.20; }
.spore:nth-child(14) { left: 15%; width: 4px; height: 4px; animation-duration: 26s; animation-delay: 11s; opacity: 0.17; }
.spore:nth-child(15) { left: 38%; width: 3px; height: 3px; animation-duration: 19s; animation-delay: 13s; opacity: 0.23; }
.spore:nth-child(16) { left: 55%; width: 4px; height: 4px; animation-duration: 25s; animation-delay: 0.5s; opacity: 0.16; }
.spore:nth-child(17) { left: 72%; width: 3px; height: 3px; animation-duration: 21s; animation-delay: 6.5s; opacity: 0.19; }
.spore:nth-child(18) { left: 92%; width: 3px; height: 3px; animation-duration: 23s; animation-delay: 3.5s; opacity: 0.21; }

@keyframes spore-float {
    0% {
        transform: translateY(calc(100vh + 20px)) translateX(0);
        opacity: 0;
    }
    5% {
        opacity: var(--spore-opacity, 0.18);
    }
    95% {
        opacity: var(--spore-opacity, 0.18);
    }
    100% {
        transform: translateY(-20px) translateX(30px);
        opacity: 0;
    }
}

/* --- HUD Frame --- */
#hud-frame {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 1px solid rgba(74, 140, 63, 0.15);
    pointer-events: none;
    z-index: 100;
}

.hud-corner {
    position: absolute;
    width: 20px;
    height: 20px;
}

.hud-corner-tl {
    top: -1px;
    left: -1px;
    border-top: 2px solid rgba(74, 140, 63, 0.4);
    border-left: 2px solid rgba(74, 140, 63, 0.4);
}

.hud-corner-tr {
    top: -1px;
    right: -1px;
    border-top: 2px solid rgba(74, 140, 63, 0.4);
    border-right: 2px solid rgba(74, 140, 63, 0.4);
}

.hud-corner-bl {
    bottom: -1px;
    left: -1px;
    border-bottom: 2px solid rgba(74, 140, 63, 0.4);
    border-left: 2px solid rgba(74, 140, 63, 0.4);
}

.hud-corner-br {
    bottom: -1px;
    right: -1px;
    border-bottom: 2px solid rgba(74, 140, 63, 0.4);
    border-right: 2px solid rgba(74, 140, 63, 0.4);
}

/* --- HUD Status Panel --- */
#hud-panel {
    position: fixed;
    top: 40px;
    right: 40px;
    background: #1A2E1A;
    border-radius: 2px;
    padding: 12px 16px;
    z-index: 200;
    min-width: 140px;
    border: 1px solid rgba(74, 140, 63, 0.3);
}

.hud-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: #6DBF5B;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(74, 140, 63, 0.2);
}

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.hud-key {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: #4A8C3F;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.hud-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: #6DBF5B;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.hud-sparkline {
    margin-top: 8px;
    height: 20px;
    border-top: 1px solid rgba(74, 140, 63, 0.2);
    padding-top: 6px;
}

.hud-sparkline svg {
    width: 100%;
    height: 100%;
}

/* Sparkline animation */
#sparkline {
    animation: sparkline-shift 2s ease-in-out infinite alternate;
}

@keyframes sparkline-shift {
    0% {
        points: 0,15 8,10 16,14 24,6 32,11 40,4 48,13 56,7 64,12 72,5 80,9;
    }
    100% {
        points: 0,10 8,14 16,8 24,12 32,5 40,11 48,6 56,14 64,8 72,13 80,6;
    }
}

/* --- Vine Spine SVG --- */
#vine-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

#vine-main {
    filter: url(#vine-wobble);
}

/* Vine leaves */
.vine-leaf {
    fill: #4A8C3F;
    transform-origin: center bottom;
    transform: scale(0);
    transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vine-leaf.visible {
    transform: scale(1);
}

/* Vine branch lines */
.vine-branch {
    stroke: #3B7A3B;
    stroke-width: 1;
    fill: none;
}

/* --- Growth Stage Sections --- */
.growth-stage {
    position: relative;
    min-height: 100vh;
    padding: 80px 40px;
    z-index: 5;
}

#stage-germination {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding-top: 120px;
}

#stage-roots {
    min-height: 200vh;
}

#stage-canopy {
    min-height: 200vh;
}

#stage-fruition {
    min-height: 100vh;
}

#stage-harvest {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* --- Stage Content Layout --- */
.stage-content {
    position: relative;
    margin-bottom: 60px;
    opacity: 0;
    transition: opacity 600ms ease, transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stage-content.visible {
    opacity: 1;
    transform: translateX(0) !important;
}

.panel-left {
    margin-right: auto;
    margin-left: 0;
    max-width: 55%;
    padding-left: calc(30% + 40px);
    transform: translateX(-40px);
}

.panel-right {
    margin-left: auto;
    margin-right: 0;
    max-width: 65%;
    padding-left: calc(30% + 40px);
    transform: translateX(40px);
}

.panel-center {
    margin: 0 auto;
    max-width: 70%;
    padding-left: 0;
    transform: translateY(30px);
}

.panel-center.visible {
    transform: translateY(0) !important;
}

/* --- Content Panels (Field Notebook Pages) --- */
.panel {
    background-color: #F4F1E8;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
    border-left: 3px solid #8B7355;
    box-shadow: 4px 4px 0 #C5B899;
    padding: 32px 28px;
    position: relative;
}

.panel-overlap {
    margin-top: -30px;
    z-index: 6;
}

.panel-final {
    border-left: 3px solid #4A8C3F;
    box-shadow: 4px 4px 0 rgba(74, 140, 63, 0.3);
    text-align: center;
    max-width: 62ch;
    margin: 0 auto;
}

/* HUD bracket decorations on panels */
.hud-bracket {
    position: absolute;
    top: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    border-top: 1px solid rgba(74, 140, 63, 0.3);
    border-right: 1px solid rgba(74, 140, 63, 0.3);
}

/* Branch connector (pseudo-element from vine to panel) */
.panel-left .panel::before,
.panel-right .panel::before {
    content: '';
    position: absolute;
    top: 50%;
    width: 30px;
    height: 0;
    border-top: 1px solid #3B7A3B;
}

.panel-left .panel::before {
    left: -30px;
}

.panel-right .panel::before {
    left: -30px;
}

/* --- Typography --- */
.stage-heading {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: clamp(28px, 4vw, 52px);
    letter-spacing: -0.02em;
    color: #1A3A1A;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sub-heading {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: clamp(18px, 2.5vw, 28px);
    letter-spacing: -0.02em;
    color: #1A3A1A;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

p {
    max-width: 62ch;
    margin-bottom: 16px;
    color: #2B4A2B;
}

.epigraph {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(20px, 3vw, 36px);
    color: #5C4A32;
    line-height: 1.5;
    margin-bottom: 28px;
    max-width: 52ch;
}

/* --- Visualization Containers --- */
.stage-viz {
    position: relative;
    margin: 40px auto;
    max-width: 500px;
    z-index: 5;
    opacity: 0;
    transition: opacity 600ms ease;
}

.stage-viz.visible {
    opacity: 1;
}

.viz-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: clamp(16px, 2vw, 22px);
    letter-spacing: -0.02em;
    color: #1A3A1A;
    margin-bottom: 16px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.botanical-diagram {
    width: 100%;
    height: auto;
    display: block;
}

/* Diagram labels */
.diagram-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    fill: #4A8C3F;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* --- SVG Animation Paths --- */
.anim-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 1200ms ease-in-out;
}

.anim-path.drawn {
    stroke-dashoffset: 0;
}

/* Data points (leaf markers, circles) */
.data-point {
    opacity: 0;
    transform-origin: center;
    transition: opacity 300ms ease, transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.data-point.pop {
    opacity: 1;
    transform: scale(1);
}

.seed-shape {
    opacity: 0;
    transition: opacity 400ms ease;
}

.seed-shape.pop {
    opacity: 1;
}

/* Fruit node pulse */
.fruit-node.pop {
    animation: fruit-pulse 2s ease-in-out infinite;
}

@keyframes fruit-pulse {
    0%, 100% { r: 8; opacity: 1; }
    50% { r: 10; opacity: 0.8; }
}

/* --- Thread Diagram --- */
.thread-diagram {
    margin: 20px 0;
    padding: 16px;
    background: #1A2E1A;
    border-radius: 2px;
    border: 1px solid rgba(74, 140, 63, 0.2);
}

.thread-diagram .diagram-label {
    fill: #C8E6C0;
}

.thread-diagram p,
.thread-diagram .sub-heading {
    color: #C8E6C0;
}

.thread-diagram .thread-line {
    stroke: #4A8C3F;
}

.thread-diagram .anim-path:nth-child(2) { stroke: #2D5F2D; }
.thread-diagram .anim-path:nth-child(3) { stroke: #4A8C3F; }
.thread-diagram .anim-path:nth-child(4) { stroke: #6DBF5B; }
.thread-diagram .anim-path:nth-child(5) { stroke: #A8E06B; }

/* --- Inline Sparkline --- */
.inline-sparkline {
    margin: 16px 0;
    height: 40px;
}

.inline-sparkline svg {
    width: 100%;
    height: 40px;
}

/* --- Process Garden --- */
.garden-svg {
    background: #E8F5E2;
    border-radius: 2px;
    border: 1px solid rgba(74, 140, 63, 0.15);
}

.process-plant {
    transition: transform 300ms ease;
}

/* --- Convergence Diagram --- */
.convergence-diagram {
    margin: 24px auto;
    max-width: 400px;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    .growth-stage {
        padding: 60px 20px;
    }

    .panel-left,
    .panel-right {
        max-width: 100%;
        padding-left: 20px;
        margin-left: 0;
        margin-right: 0;
    }

    .panel-center {
        max-width: 100%;
        padding-left: 0;
    }

    .panel-left .panel::before,
    .panel-right .panel::before {
        display: none;
    }

    .panel-overlap {
        margin-top: 0;
    }

    #hud-panel {
        top: 10px;
        right: 10px;
        padding: 8px 10px;
        min-width: 100px;
    }

    .hud-sparkline {
        display: none;
    }

    .hud-row:nth-child(3),
    .hud-row:nth-child(4) {
        display: none;
    }

    #hud-frame {
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .stage-heading {
        font-size: clamp(24px, 5vw, 36px);
    }

    #stage-germination {
        align-items: center;
    }

    .stage-viz {
        max-width: 100%;
    }

    .garden-svg {
        height: 250px;
    }
}

/* --- Selection color --- */
::selection {
    background: rgba(74, 140, 63, 0.3);
    color: #1A3A1A;
}

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

::-webkit-scrollbar-track {
    background: #F4F1E8;
}

::-webkit-scrollbar-thumb {
    background: #4A8C3F;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6DBF5B;
}
