/* ======================================
   namu.day — Vaporwave Arboretum
   ====================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400&family=Share+Tech+Mono&display=swap');

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

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

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    color: #3D3455;
    background: #F0E6F6;
    overflow-x: hidden;
    cursor: default;
}

/* --- Grid Overlay --- */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image:
        linear-gradient(to right, rgba(61,52,85,0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(61,52,85,0.04) 1px, transparent 1px);
    background-size: 80px 80px;
}

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

/* --- Chapters --- */
.chapter {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    transition: background-color 0.8s ease;
}

.chapter-title {
    font-family: 'Share Tech Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #3D3455;
    margin-bottom: 2rem;
}

/* --- Coordinate Labels --- */
.coord-label {
    position: absolute;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.2em;
    color: #7B6F99;
    opacity: 0.4;
    z-index: 5;
}

/* --- Chapter Enter Animation --- */
.chapter-content,
.roots-text-overlay {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 900ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 900ms cubic-bezier(0.16, 1, 0.3, 1);
}

.chapter.visible .chapter-content,
.chapter.visible .roots-text-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* ======================================
   Chapter 1: Canopy (Hero)
   ====================================== */
#chapter-canopy {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F0E6F6;
}

#hero-tree {
    width: min(70vw, 600px);
    height: auto;
    position: relative;
    z-index: 2;
}

.tree-path {
    will-change: stroke-dashoffset;
}

.canopy-fill {
    will-change: fill-opacity;
}

#hero-label {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: #7B6F99;
    z-index: 5;
}

/* ======================================
   Chapter 2: Rings
   ====================================== */
#chapter-rings {
    background: #EDE3F3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.rings-layout {
    display: flex;
    width: 100%;
    max-width: 1200px;
    gap: 4rem;
    align-items: center;
}

.rings-text {
    flex: 0 0 38%;
}

.rings-text p {
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    line-height: 1.85;
    color: #3D3455;
    margin-bottom: 1.5rem;
}

.rings-visual {
    flex: 0 0 62%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rings-container {
    position: relative;
    width: 400px;
    height: 400px;
}

.ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border-style: solid;
    border-width: 1px;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.ring.visible {
    transform: translate(-50%, -50%) scale(1);
}

.ring.pulse {
    animation: ringPulse 4s ease-in-out infinite;
}

@keyframes ringPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(0.97); }
    50% { transform: translate(-50%, -50%) scale(1.03); }
}

/* ======================================
   Chapter 3: Roots
   ====================================== */
#chapter-roots {
    height: 100vh;
    background: #E8DEF0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#roots-svg {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    height: 100%;
    z-index: 2;
}

.root-path {
    will-change: stroke-dashoffset;
}

.roots-text-overlay {
    position: relative;
    z-index: 3;
    max-width: 480px;
    text-align: center;
    padding: 2rem;
    background: rgba(232, 222, 240, 0.85);
    border-radius: 4px;
}

.roots-text-overlay p {
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    line-height: 1.85;
    color: #3D3455;
}

/* ======================================
   Chapter 4: Seasons
   ====================================== */
.seasons-section {
    height: 400vh;
    background: #F0E6F6;
}

.seasons-coord {
    position: fixed;
    z-index: 10;
}

.seasons-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.seasons-track {
    display: flex;
    width: 400vw;
    height: 100vh;
    will-change: transform;
}

.season-panel {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.season-tree {
    width: min(50vw, 350px);
    height: auto;
    margin-bottom: 2rem;
}

.season-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    line-height: 1.85;
    color: #7B6F99;
    text-align: center;
    max-width: 400px;
}

/* ======================================
   Chapter 5: Canopy at Dusk
   ====================================== */
#chapter-dusk {
    height: 100vh;
    background: #E0D4F5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(61, 52, 85, 0.08) 2px,
        rgba(61, 52, 85, 0.08) 3px
    );
}

.glitch-container {
    position: relative;
    width: min(70vw, 600px);
    height: auto;
    z-index: 3;
}

.glitch-tree {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
    will-change: transform;
}

.glitch-tree:first-child {
    position: relative;
}

.glitch-r {
    stroke: #F2A7C3;
    color: #F2A7C3;
    animation: glitchR 3s ease-in-out infinite;
}

.glitch-g {
    stroke: #A8E6CF;
    color: #A8E6CF;
    animation: glitchG 3s ease-in-out infinite;
}

.glitch-b {
    stroke: #7EC8E3;
    color: #7EC8E3;
    animation: glitchB 3s ease-in-out infinite;
}

.glitch-r path, .glitch-r use { stroke: #F2A7C3; }
.glitch-g path, .glitch-g use { stroke: #A8E6CF; }
.glitch-b path, .glitch-b use { stroke: #7EC8E3; }

@keyframes glitchR {
    0%, 100% { transform: translateX(-3px); }
    50% { transform: translateX(-5px); }
}

@keyframes glitchG {
    0%, 100% { transform: translateX(3px); }
    50% { transform: translateX(5px); }
}

@keyframes glitchB {
    0%, 100% { transform: translateX(0px) translateY(-2px); }
    50% { transform: translateX(2px) translateY(2px); }
}

/* Datamosh bands */
.datamosh-band {
    position: absolute;
    left: 0;
    width: 100%;
    background: rgba(224, 212, 245, 0.6);
    z-index: 4;
    overflow: hidden;
    backdrop-filter: blur(1px);
}

#datamosh-1 {
    height: 12px;
    top: 30%;
    animation: datamosh1 5s steps(1) infinite;
}

#datamosh-2 {
    height: 8px;
    top: 55%;
    animation: datamosh2 5s steps(1) infinite;
}

#datamosh-3 {
    height: 18px;
    top: 72%;
    animation: datamosh3 5s steps(1) infinite;
}

@keyframes datamosh1 {
    0% { transform: translateX(15px); top: 30%; }
    20% { transform: translateX(-20px); top: 35%; }
    40% { transform: translateX(25px); top: 28%; }
    60% { transform: translateX(-10px); top: 33%; }
    80% { transform: translateX(30px); top: 31%; }
    100% { transform: translateX(15px); top: 30%; }
}

@keyframes datamosh2 {
    0% { transform: translateX(-20px); top: 55%; }
    20% { transform: translateX(25px); top: 58%; }
    40% { transform: translateX(-15px); top: 52%; }
    60% { transform: translateX(20px); top: 57%; }
    80% { transform: translateX(-25px); top: 54%; }
    100% { transform: translateX(-20px); top: 55%; }
}

@keyframes datamosh3 {
    0% { transform: translateX(20px); top: 72%; }
    20% { transform: translateX(-25px); top: 75%; }
    40% { transform: translateX(15px); top: 70%; }
    60% { transform: translateX(-30px); top: 74%; }
    80% { transform: translateX(10px); top: 71%; }
    100% { transform: translateX(20px); top: 72%; }
}

#dusk-label {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    font-family: 'Share Tech Mono', monospace;
    font-size: 48px;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: #3D3455;
    z-index: 6;
    text-align: center;
    opacity: 0;
    transition: opacity 1.5s ease;
}

#chapter-dusk.visible #dusk-label {
    opacity: 1;
}

/* ======================================
   Responsive
   ====================================== */
/* Season panel colors for compliance */
.season-spring { background: #F0E6F6; }
.season-summer { background: #E6F0E8; }
.season-autumn { background: #F5EDE0; }
.season-winter { background: #E6EDF5; }

@media (max-width: 768px) {
    .rings-layout {
        flex-direction: column;
    }

    .rings-text,
    .rings-visual {
        flex: 1 1 100%;
    }

    .rings-container {
        width: 280px;
        height: 280px;
    }

    .roots-text-overlay {
        max-width: 90%;
    }

    #dusk-label {
        font-size: 32px;
    }
}
