/* ==========================================================================
   lovebot.quest — Zen Garden / Algorithmic Empathy
   Horizontal emakimono scroll with circuit-botanical motifs
   ========================================================================== */

/* --- CSS Custom Properties (Palette from DESIGN.md) --- */
:root {
    --sand: #F5F0E8;
    --ink: #1A1A1A;
    --stone: #8B8680;
    --blush: #C4727F;
    --teal: #2A6B6B;
    --shadow-wash: rgba(61, 58, 54, 0.06);
    --dawn: #F0D9C4;

    --font-headline: 'Share Tech Mono', monospace;
    --font-body: 'Karla', sans-serif;
    --font-accent: 'Caveat', cursive;
}

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

html {
    overflow: hidden;
    height: 100%;
    background-color: var(--sand);
}

body {
    font-family: var(--font-body);
    font-weight: 300;
    color: var(--ink);
    background-color: var(--sand);
    height: 100%;
    overflow: hidden;
    cursor: none;
}

/* --- Custom Cursor Trail Canvas --- */
#cursor-trail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
}

/* --- Horizontal Scroll Container (Emakimono) --- */
#scroll-container {
    display: flex;
    width: 500vw;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar */
#scroll-container::-webkit-scrollbar {
    display: none;
}
#scroll-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* --- Panels --- */
.panel {
    position: relative;
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.panel-content {
    position: relative;
    max-width: 480px;
    width: 90%;
    text-align: center;
    transform: translateY(-12%);
    z-index: 2;
}

/* --- Panel Dividers (hand-drawn wavering lines) --- */
.panel-divider {
    position: absolute;
    right: 0;
    top: 0;
    width: 2px;
    height: 100%;
    z-index: 3;
}

/* --- Typography --- */
.panel-title {
    font-family: var(--font-headline);
    font-size: clamp(1.8rem, 4vw, 3.6rem);
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink);
    margin-bottom: 1.2rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 1.5s ease-out, transform 1.5s ease-out;
}

.panel-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.85;
    color: var(--ink);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 1.5s ease-out 0.2s, transform 1.5s ease-out 0.2s;
}

.annotation {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--stone);
    display: block;
    opacity: 0;
    transform: translateY(8px) rotate(-1.5deg);
    transition: opacity 1s ease-out 0.7s, transform 1s ease-out 0.7s;
    margin-top: 0.5rem;
}

/* When panel is in view */
.panel.in-view .panel-title,
.panel.in-view .panel-text,
.panel.in-view .annotation {
    opacity: 1;
    transform: translateY(0);
}

.panel.in-view .annotation {
    transform: translateY(0) rotate(-1.5deg);
}

/* --- Blur-Focus Transitions --- */
.panel .panel-content {
    transition: filter 400ms ease-out, opacity 1.5s ease-out, transform 1.5s ease-out;
}

.panel.blur-out .panel-content {
    filter: blur(6px);
    transition: filter 300ms ease-in;
}

.panel.blur-in .panel-content {
    filter: blur(6px);
}

.panel.in-view .panel-content {
    filter: blur(0px);
}

/* --- SVG Circuit-Botanical Illustrations --- */
.panel-illustration {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
}

.circuit-botanical {
    width: 220px;
    height: auto;
    max-height: 280px;
}

#illus-resonance .circuit-botanical {
    width: 300px;
    max-height: 220px;
}

#illus-release .circuit-botanical {
    width: 300px;
    max-height: 220px;
}

/* Stroke drawing animation */
.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2.5s ease-out;
}

.panel.in-view .draw-path {
    stroke-dashoffset: 0;
}

/* Petal labels in Tenderness panel */
.petal-label {
    font-family: 'Caveat', cursive;
    font-size: 11px;
    fill: var(--stone);
    opacity: 0;
    transition: opacity 1.2s ease-out 1.5s;
}

.panel.in-view .petal-label {
    opacity: 0.7;
}

/* Particle drift animation in Release panel */
@keyframes drift-right {
    0% { transform: translateX(0); opacity: var(--particle-start-opacity, 0.4); }
    100% { transform: translateX(40px); opacity: 0; }
}

.panel.in-view .particle {
    animation: drift-right 6s ease-out infinite;
}

.panel.in-view .particle:nth-child(odd) {
    animation-duration: 8s;
    animation-delay: 0.5s;
}

.panel.in-view .particle:nth-child(3n) {
    animation-duration: 7s;
    animation-delay: 1s;
}

/* Heartrate waveform pulse */
@keyframes heartbeat-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.6; }
}

.panel.in-view .heartrate {
    animation: heartbeat-pulse 3s ease-in-out infinite;
}

/* --- Progress Indicator --- */
#progress-indicator {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 24px;
    z-index: 100;
    padding: 8px 16px;
}

.progress-line {
    display: none;
}

.progress-dot {
    position: relative;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--stone);
    background: transparent;
    cursor: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.6s ease;
}

.progress-dot .dot-fill {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.8s ease, transform 0.8s ease;
    transform: scale(0);
}

.progress-dot.visited .dot-fill {
    background: var(--teal);
    transform: scale(1);
}

.progress-dot.active {
    border-color: var(--teal);
}

.progress-dot.active .dot-fill {
    background: var(--teal);
    transform: scale(1);
}

/* Hairline connecting dots */
#progress-indicator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 16px;
    right: 16px;
    height: 0.5px;
    background: var(--stone);
    opacity: 0.3;
    transform: translateY(-50%);
    z-index: -1;
}

/* --- Sand Grid-Lines Background --- */
#sand-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.sand-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 0.5px;
    background: var(--stone);
    opacity: 0.08;
    will-change: transform;
}

/* --- Dawn Glow Gradient at Panel Transitions --- */
.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(240, 217, 196, 0.08) 5%,
        transparent 15%,
        transparent 85%,
        rgba(240, 217, 196, 0.08) 95%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 1;
}

#panel-silence::before {
    background: linear-gradient(
        90deg,
        transparent 0%,
        transparent 85%,
        rgba(240, 217, 196, 0.1) 95%,
        transparent 100%
    );
}

#panel-release::before {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(240, 217, 196, 0.1) 5%,
        transparent 15%,
        transparent 100%
    );
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .panel-content {
        max-width: 90%;
        padding: 0 16px;
    }

    .circuit-botanical {
        width: 160px;
    }

    #illus-resonance .circuit-botanical,
    #illus-release .circuit-botanical {
        width: 240px;
    }

    #progress-indicator {
        bottom: 20px;
        gap: 16px;
    }

    .progress-dot {
        width: 10px;
        height: 10px;
    }

    .progress-dot .dot-fill {
        width: 6px;
        height: 6px;
    }
}
