/* ============================================================
   p9r.st - Terminal-Pastoral Design
   A terminal left running in a field of wildflowers
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: #0A1628;
    color: #B8D4E3;
    font-family: 'Varela Round', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- CRT Scanline Overlay (z-3) --- */
.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(10, 22, 40, 0.04) 2px,
        rgba(10, 22, 40, 0.04) 4px
    );
}

/* --- Vignette Overlay (z-3) --- */
.vignette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    background: radial-gradient(
        ellipse at center,
        transparent 50%,
        rgba(10, 22, 40, 0.4) 100%
    );
}

/* --- Particle Canvas (z-0) --- */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* --- Botanical Foreground Layer (z-2) --- */
.botanical-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

/* --- Scroll Container --- */
.scroll-container {
    position: relative;
    z-index: 2;
}

/* --- Sections --- */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.section-transition {
    min-height: 50vh;
}

.section-meadow {
    min-height: 60vh;
}

.section-finale {
    min-height: 100vh;
}

/* --- Opening Section --- */
.section-opening {
    flex-direction: column;
    background: radial-gradient(
        ellipse at center,
        #0A1628 0%,
        #162A45 100%
    );
}

.opening-content {
    text-align: center;
    z-index: 3;
}

.site-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: #F0E6D3;
    letter-spacing: 0.04em;
    opacity: 0;
    text-shadow: 0 0 8px rgba(91, 164, 217, 0.4);
    animation: fadeInTitle 2s ease-out forwards;
}

.opening-tagline {
    font-family: 'Varela Round', sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.15rem);
    color: #B8D4E3;
    margin-top: 1.2rem;
    opacity: 0;
    animation: fadeInTagline 1.5s ease-out 0.8s forwards;
}

.cursor-blink {
    display: inline-block;
    color: #5BA4D9;
    animation: blinkCursor 1s steps(2, start) infinite;
    text-shadow: 0 0 6px rgba(91, 164, 217, 0.5);
}

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

@keyframes fadeInTagline {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Fern in opening section */
.fern-opening {
    position: absolute;
    bottom: 5%;
    right: 8%;
    width: 120px;
    height: 240px;
    opacity: 0.15;
    z-index: 1;
}

.fern-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: drawFern 4s cubic-bezier(0.25, 0.1, 0.25, 1) 1.5s forwards;
}

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

/* --- Terminal Panels --- */
/* Panel base: #0D2137 at 85% opacity */
.terminal-panel {
    background: #0D2137;
    background: rgba(13, 33, 55, 0.85);
    border: 1px solid rgba(91, 164, 217, 0.4);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    max-width: 600px;
    width: 85%;
    z-index: 3;
    box-shadow: 0 8px 32px rgba(10, 22, 40, 0.5);
}

.panel-left {
    margin-right: auto;
    margin-left: 10%;
    transform: rotate(-0.4deg);
}

.panel-right {
    margin-left: auto;
    margin-right: 10%;
    transform: rotate(0.5deg);
}

.panel-center {
    margin: 0 auto;
    transform: rotate(0deg);
}

.panel-distant {
    transform: scale(0.95) rotate(-0.3deg);
    opacity: 0.92;
}

/* Warm panels (later sessions) */
.panel-warm {
    border-color: rgba(91, 164, 217, 0.3);
    box-shadow:
        0 8px 32px rgba(10, 22, 40, 0.5),
        0 0 1px rgba(255, 181, 194, 0.15);
}

.panel-warm .terminal-titlebar {
    border-bottom-color: rgba(91, 164, 217, 0.2);
}

/* --- Terminal Title Bar --- */
.terminal-titlebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    background: rgba(10, 22, 40, 0.3);
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(91, 164, 217, 0.15);
}

.titlebar-dots {
    display: flex;
    gap: 7px;
}

.dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    animation: dotPulse 4s ease-in-out infinite;
}

.dot-close {
    background: #FFB5C2;
    background: rgba(255, 181, 194, 0.6);
    animation-delay: 0s;
}

.dot-minimize {
    background: rgba(184, 212, 227, 0.6);
    animation-delay: 1.3s;
}

.dot-maximize {
    background: #A8E6CF;
    background: rgba(168, 230, 207, 0.6);
    animation-delay: 2.6s;
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.85; }
}

.titlebar-filename {
    font-family: 'Inconsolata', monospace;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: #5BA4D9;
    opacity: 0.75;
}

/* --- Terminal Body --- */
.terminal-body {
    padding: 2rem;
    padding-left: 2.5rem;
    box-shadow: inset 0 2px 8px rgba(10, 22, 40, 0.3);
}

.terminal-line {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.2rem;
}

.terminal-line:last-child {
    margin-bottom: 0;
}

.prompt-bubble {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(91, 164, 217, 0.6);
    margin-top: 0.55rem;
}

.line-text {
    font-family: 'Varela Round', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: #B8D4E3;
}

.closing-line {
    color: #5BA4D9;
    font-family: 'Inconsolata', monospace;
    font-size: 14px;
    letter-spacing: 0.04em;
}

/* --- Stagger Reveal Animation --- */
.stagger-reveal .terminal-titlebar,
.stagger-reveal .terminal-line {
    opacity: 0;
    transform: translateY(16px);
}

.stagger-reveal.revealed .terminal-titlebar {
    animation: staggerIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.stagger-reveal.revealed .terminal-body {
    animation: staggerBodyIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) 400ms forwards;
}

.stagger-reveal.revealed .terminal-line:nth-child(1) {
    animation: staggerIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) 550ms forwards;
}

.stagger-reveal.revealed .terminal-line:nth-child(2) {
    animation: staggerIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) 700ms forwards;
}

.stagger-reveal.revealed .terminal-line:nth-child(3) {
    animation: staggerIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) 850ms forwards;
}

.stagger-reveal.revealed .terminal-line:nth-child(4) {
    animation: staggerIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) 1000ms forwards;
}

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

@keyframes staggerBodyIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Phosphor Bloom on headings --- */
.site-title,
.finale-title {
    animation-name: fadeInTitle;
}

.site-title {
    text-shadow: 0 0 8px rgba(91, 164, 217, 0.4);
}

.revealed .site-title,
.finale-title {
    animation: phosphorBloom 3s ease-in-out infinite alternate;
}

@keyframes phosphorBloom {
    0% { text-shadow: 0 0 6px rgba(91, 164, 217, 0.35); }
    100% { text-shadow: 0 0 12px rgba(91, 164, 217, 0.55); }
}

/* --- Vine Decorations --- */
/* Botanical illustrations use #8EC5FC ("Forget-me-not") as primary stroke */
.vine-decoration {
    position: absolute;
    z-index: 4;
    pointer-events: none;
    color: #8EC5FC;
}

.vine-right {
    right: 3%;
    top: 5%;
    width: 80px;
    height: 340px;
    opacity: 0.5;
}

.vine-left {
    left: 3%;
    top: 5%;
    width: 80px;
    height: 340px;
    opacity: 0.5;
}

.vine-dense {
    width: 100px;
    height: 360px;
    opacity: 0.55;
}

.vine-path {
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    transition: stroke-dashoffset 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.vine-visible .vine-path {
    stroke-dashoffset: 0;
}

/* --- Bubble Clusters (transition zones) --- */
.bubble-cluster {
    position: relative;
    width: 100%;
    height: 100%;
}

.cluster-bubble {
    position: absolute;
    border-radius: 50%;
    background: rgba(184, 212, 227, 0.12);
    border: 1px solid rgba(184, 212, 227, 0.08);
    animation: bubbleFloat 6s ease-in-out infinite alternate;
}

.cluster-bubble:nth-child(1) { animation-delay: 0s; animation-duration: 7s; }
.cluster-bubble:nth-child(2) { animation-delay: 1s; animation-duration: 5s; }
.cluster-bubble:nth-child(3) { animation-delay: 0.5s; animation-duration: 8s; }
.cluster-bubble:nth-child(4) { animation-delay: 1.5s; animation-duration: 6s; }
.cluster-bubble:nth-child(5) { animation-delay: 0.8s; animation-duration: 7.5s; }
.cluster-bubble:nth-child(6) { animation-delay: 2s; animation-duration: 6.5s; }

@keyframes bubbleFloat {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-15px) scale(1.05); }
}

/* --- Botanical Transitions --- */
.botanical-transition {
    position: absolute;
    bottom: 10%;
    left: 10%;
    width: 60%;
    height: auto;
    opacity: 0.25;
}

/* --- Meadow Interlude --- */
.section-meadow {
    background: radial-gradient(
        ellipse at center,
        #1A2F42 0%,
        #162A45 60%,
        #0A1628 100%
    );
    flex-direction: column;
    gap: 2rem;
}

.meadow-flora {
    display: flex;
    gap: 4rem;
    align-items: flex-end;
    z-index: 3;
}

.meadow-flower {
    opacity: 0.35;
}

.flower-1 {
    width: 50px;
    height: 70px;
    animation: flowerSway 5s ease-in-out infinite alternate;
}

.flower-2 {
    width: 40px;
    height: 55px;
    animation: flowerSway 6s ease-in-out 0.5s infinite alternate;
}

.flower-3 {
    width: 35px;
    height: 50px;
    animation: flowerSway 4.5s ease-in-out 1s infinite alternate;
}

@keyframes flowerSway {
    0% { transform: rotate(-2deg); }
    100% { transform: rotate(2deg); }
}

.meadow-fern {
    position: absolute;
    left: 10%;
    bottom: 5%;
    width: 200px;
    height: 340px;
    z-index: 1;
}

/* --- Butterfly --- */
.butterfly {
    position: absolute;
    width: 36px;
    height: 28px;
    z-index: 6;
    animation: butterflyPath 20s linear infinite;
}

@keyframes butterflyPath {
    0% {
        top: 60%;
        left: 70%;
        transform: rotate(0deg) scale(1);
    }
    10% {
        top: 50%;
        left: 75%;
        transform: rotate(10deg) scale(1.05);
    }
    25% {
        top: 35%;
        left: 65%;
        transform: rotate(-5deg) scale(1);
    }
    40% {
        top: 40%;
        left: 50%;
        transform: rotate(15deg) scale(0.95);
    }
    55% {
        top: 30%;
        left: 55%;
        transform: rotate(-10deg) scale(1.05);
    }
    70% {
        top: 45%;
        left: 60%;
        transform: rotate(5deg) scale(1);
    }
    85% {
        top: 55%;
        left: 68%;
        transform: rotate(-8deg) scale(0.95);
    }
    100% {
        top: 60%;
        left: 70%;
        transform: rotate(0deg) scale(1);
    }
}

/* Butterfly wing flap */
.butterfly path:nth-child(1),
.butterfly path:nth-child(3) {
    animation: wingFlap 0.4s ease-in-out infinite alternate;
    transform-origin: 20px 15px;
}

.butterfly path:nth-child(2),
.butterfly path:nth-child(4) {
    animation: wingFlapRight 0.4s ease-in-out infinite alternate;
    transform-origin: 20px 15px;
}

@keyframes wingFlap {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0.7); }
}

@keyframes wingFlapRight {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0.7); }
}

/* --- Warm Section Background --- */
.section-warm {
    background: radial-gradient(
        ellipse at center,
        rgba(26, 47, 66, 0.3) 0%,
        transparent 70%
    );
}

/* --- Closing Section --- */
.section-closing .terminal-panel {
    transition: opacity 1.5s ease-out, transform 1.5s ease-out;
}

.section-closing.fading .terminal-panel {
    opacity: 0;
    transform: translateY(-20px) scale(0.97);
}

/* --- Finale Section --- */
.section-finale {
    background: radial-gradient(
        ellipse at center,
        #1A3050 0%,
        #162A45 50%,
        #0A1628 100%
    );
}

.finale-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: #B8D4E3;
    opacity: 0;
    letter-spacing: 0.04em;
    text-shadow: 0 0 8px rgba(91, 164, 217, 0.3);
    transition: opacity 2s ease-out;
    z-index: 3;
}

.finale-title.visible {
    opacity: 0.5;
}

/* --- Interactive Bubble Hover Effect (applied via JS) --- */
.particle-interactive {
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 300ms ease;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .terminal-panel {
        width: 92%;
        max-width: none;
    }

    .panel-left {
        margin-left: 4%;
        transform: rotate(-0.2deg);
    }

    .panel-right {
        margin-right: 4%;
        transform: rotate(0.3deg);
    }

    .vine-decoration {
        display: none;
    }

    .vine-dense {
        display: none;
    }

    .terminal-body {
        padding: 1.5rem;
        padding-left: 2rem;
    }

    .meadow-flora {
        gap: 2rem;
    }

    .fern-opening {
        width: 80px;
        height: 160px;
        right: 5%;
    }
}

@media (max-width: 480px) {
    .terminal-panel {
        width: 96%;
    }

    .panel-left {
        margin-left: 2%;
    }

    .panel-right {
        margin-right: 2%;
    }

    .terminal-body {
        padding: 1.2rem;
        padding-left: 1.5rem;
    }

    .terminal-line {
        gap: 0.5rem;
    }

    .prompt-bubble {
        width: 6px;
        height: 6px;
        margin-top: 0.6rem;
    }

    .butterfly {
        display: none;
    }
}

/* --- Selection Color --- */
::selection {
    background: rgba(91, 164, 217, 0.3);
    color: #F0E6D3;
}

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

::-webkit-scrollbar-track {
    background: #0A1628;
}

::-webkit-scrollbar-thumb {
    background: rgba(91, 164, 217, 0.25);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(91, 164, 217, 0.4);
}
