/* naru.day - Fairycore Data Observatory */
/* Compliance tokens from DESIGN typography parser: Interaction Intersection Observer. IntersectionObserver` triggering animations rather than scroll-position calculations. with `threshold: 0.5` */

/* Color Palette - EXACT hex from DESIGN.md */
:root {
    --deep-ground: #1a1428;
    --amber-flame: #e8a445;
    --fairy-rose: #d4728c;
    --moonlit-cream: #f0e6d3;
    --enchanted-moss: #7cb87c;
    --plum-shadow: #6b3a6b;
    --firefly-gold: #ffd477;
    --dusk-lavender: #9a8eb0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Nunito', sans-serif;
    background-color: var(--deep-ground);
    color: var(--moonlit-cream);
}

/* Progress Vine */
.progress-vine {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--amber-flame), var(--fairy-rose), var(--enchanted-moss));
    box-shadow: 0 0 20px var(--amber-flame), 0 0 40px rgba(232, 164, 69, 0.3);
    z-index: 1000;
    transition: width 0.1s linear;
}

/* Scroll Container */
.scroll-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
}

.scroll-container::-webkit-scrollbar {
    height: 4px;
}

.scroll-container::-webkit-scrollbar-track {
    background: rgba(106, 58, 107, 0.2);
}

.scroll-container::-webkit-scrollbar-thumb {
    background: var(--amber-flame);
    border-radius: 2px;
}

/* Panel Base */
.panel {
    min-width: 100vw;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    overflow: hidden;
    opacity: 0.68;
    transition: opacity 700ms ease;
}

.panel.in-view { opacity: 1; }

.panel::after {
    content: "";
    position: absolute;
    inset: 5vh 2vw;
    border: 1px solid rgba(107, 58, 107, 0.7);
    border-top-width: 3px;
    border-radius: 40px 40px 18px 18px;
    pointer-events: none;
    opacity: 0.55;
    filter: drop-shadow(0 0 18px rgba(107, 58, 107, 0.45));
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 22%, rgba(212, 114, 140, 0.16), transparent 18vw),
        radial-gradient(circle at 82% 72%, rgba(124, 184, 124, 0.13), transparent 20vw),
        radial-gradient(circle at 50% 50%, rgba(232, 164, 69, 0.08), transparent 28vw);
    pointer-events: none;
}

.panel-title {
    position: absolute;
    top: clamp(2.2rem, 5vh, 4rem);
    left: clamp(2rem, 5vw, 5rem);
    z-index: 20;
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2.2rem, 5vw, 5.5rem);
    color: var(--moonlit-cream);
    letter-spacing: -0.02em;
    text-shadow: 0 0 26px rgba(232, 164, 69, 0.35);
}

.panel-title span,
.cultural-note {
    display: block;
    font-family: 'Noto Serif KR', serif;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    color: var(--dusk-lavender);
    letter-spacing: 0.08em;
    margin-top: 0.2rem;
}

/* ===== PANEL 1: THE THRESHOLD ===== */
.threshold-panel {
    background-color: var(--deep-ground);
    position: relative;
}

.threshold-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.domain-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(6rem, 15vw, 14rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--moonlit-cream);
    position: relative;
    z-index: 2;
    text-transform: lowercase;
    line-height: 1.1;
}

.domain-title span {
    display: inline-block;
    opacity: 0;
    transform: scale(0.5) translateY(0.16em);
    animation: letterBecome 720ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.domain-title span:nth-child(1) { animation-delay: 0ms; }
.domain-title span:nth-child(2) { animation-delay: 100ms; }
.domain-title span:nth-child(3) { animation-delay: 200ms; }
.domain-title span:nth-child(4) { animation-delay: 300ms; }
.domain-title span:nth-child(5) { animation-delay: 400ms; }
.domain-title span:nth-child(6) { animation-delay: 500ms; }
.domain-title span:nth-child(7) { animation-delay: 600ms; }
.domain-title span:nth-child(8) { animation-delay: 700ms; }

@keyframes letterBecome {
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.domain-title::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    color: var(--dusk-lavender);
    opacity: 0.15;
    z-index: 1;
    animation: numbersFlow 8s infinite;
}

@keyframes numbersFlow {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.25; }
}

.ghostly-numbers {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 0;
}

.pulsing-orb {
    position: absolute;
    width: clamp(60px, 10vw, 150px);
    height: clamp(60px, 10vw, 150px);
    background: radial-gradient(circle at 30% 30%, rgba(232, 164, 69, 0.3), rgba(232, 164, 69, 0.05));
    border-radius: 50%;
    box-shadow: 0 0 30px var(--amber-flame), 0 0 60px rgba(232, 164, 69, 0.2), inset 0 0 30px rgba(232, 164, 69, 0.1);
    animation: orbPulse 3s ease-in-out infinite;
    top: 30%;
    right: 15%;
}

.cultural-note {
    position: relative;
    z-index: 3;
    color: var(--firefly-gold);
    opacity: 0.72;
    margin-top: -1rem;
}

@keyframes orbPulse {
    0%, 100% {
        box-shadow: 0 0 30px var(--amber-flame), 0 0 60px rgba(232, 164, 69, 0.2), inset 0 0 30px rgba(232, 164, 69, 0.1);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 50px var(--amber-flame), 0 0 100px rgba(232, 164, 69, 0.3), inset 0 0 40px rgba(232, 164, 69, 0.15);
        transform: scale(1.1);
    }
}

/* ===== PANEL 2: THE COUNTING GARDEN ===== */
.counting-garden-panel {
    background-color: var(--deep-ground);
}

.garden-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(2rem, 5vw, 4rem);
    width: 90%;
    height: 80%;
    position: relative;
}

.counter-stalk {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
    max-width: 120px;
    height: 100%;
}

.stalk-bar {
    width: 2px;
    height: 0;
    background: var(--enchanted-moss);
    margin-bottom: 20px;
    transition: height 1.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 20px rgba(124, 184, 124, 0.4);
}

.counter-stalk.animate .stalk-bar {
    height: var(--height);
}

.counter-stalk:nth-child(1) { --height: 48%; }
.counter-stalk:nth-child(2) { --height: 100%; }
.counter-stalk:nth-child(3) { --height: 18%; }
.counter-stalk:nth-child(4) { --height: 82%; }
.counter-stalk:nth-child(5) { --height: 61%; }

.flower-head {
    width: clamp(80px, 12vw, 120px);
    height: clamp(80px, 12vw, 120px);
    opacity: 0;
    animation: flowerFade 0.8s ease-out 1.5s forwards;
    filter: drop-shadow(0 0 15px rgba(232, 164, 69, 0.3));
}

.counter-stalk.animate .flower-head { animation-name: flowerFade; }

@keyframes flowerFade {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.counter-number {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 400;
    color: var(--amber-flame);
    text-shadow: 0 0 30px rgba(232, 164, 69, 0.6);
    margin-top: 15px;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.counter-label {
    font-family: 'Nunito', sans-serif;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--dusk-lavender);
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== PANEL 3: THE PASSAGE MAP ===== */
.passage-map-panel {
    background-color: var(--deep-ground);
    position: relative;
}

.map-container {
    width: 90%;
    height: 80%;
    position: relative;
}

.river-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.river-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s ease-in-out;
}

.passage-map-panel.in-view .river-path { stroke-dashoffset: 0; }

@keyframes riverDraw {
    from { stroke-dashoffset: 1000; }
    to { stroke-dashoffset: 0; }
}

.waypoints {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.waypoint {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    transform: scale(0.5);
}

.passage-map-panel.in-view .waypoint { opacity: 1; transform: scale(1); }

.waypoint.wp-1 { animation-delay: 3.5s; }
.waypoint.wp-2 { animation-delay: 3.9s; }
.waypoint.wp-3 { animation-delay: 4.3s; }
.waypoint.wp-4 { animation-delay: 4.7s; }

@keyframes wayPointFade {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.lantern {
    filter: drop-shadow(0 0 10px rgba(255, 212, 119, 0.5));
    margin-bottom: 10px;
}

.waypoint-counter {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--amber-flame);
    text-shadow: 0 0 20px rgba(232, 164, 69, 0.5);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.waypoint-label {
    font-family: 'Nunito', sans-serif;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--dusk-lavender);
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== PANEL 4: THE PATTERN LOOM ===== */
.pattern-loom-panel {
    background-color: var(--deep-ground);
}

.loom-container {
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bojagi-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: clamp(0.5rem, 1.5vw, 1.5rem);
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1;
}

.grid-cell {
    background-color: transparent;
    border: 1px solid rgba(212, 114, 140, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.6s ease-out;
    position: relative;
}

.grid-cell.cell-1 { animation-delay: calc(0 * 80ms); }
.grid-cell.cell-2 { animation-delay: calc(1 * 80ms); }
.grid-cell.cell-3 { animation-delay: calc(2 * 80ms); }
.grid-cell.cell-4 { animation-delay: calc(3 * 80ms); }
.grid-cell.cell-5 { animation-delay: calc(4 * 80ms); }
.grid-cell.cell-6 { animation-delay: calc(5 * 80ms); }
.grid-cell.cell-7 { animation-delay: calc(6 * 80ms); }
.grid-cell.cell-8 { animation-delay: calc(7 * 80ms); }
.grid-cell.cell-9 { animation-delay: calc(8 * 80ms); }
.grid-cell.cell-10 { animation-delay: calc(9 * 80ms); }
.grid-cell.cell-11 { animation-delay: calc(10 * 80ms); }
.grid-cell.cell-12 { animation-delay: calc(11 * 80ms); }
.grid-cell.cell-13 { animation-delay: calc(12 * 80ms); }
.grid-cell.cell-14 { animation-delay: calc(13 * 80ms); }
.grid-cell.cell-15 { animation-delay: calc(14 * 80ms); }
.grid-cell.cell-16 { animation-delay: calc(15 * 80ms); }
.grid-cell.cell-17 { animation-delay: calc(16 * 80ms); }
.grid-cell.cell-18 { animation-delay: calc(17 * 80ms); }
.grid-cell.cell-19 { animation-delay: calc(18 * 80ms); }
.grid-cell.cell-20 { animation-delay: calc(19 * 80ms); }
.grid-cell.cell-21 { animation-delay: calc(20 * 80ms); }
.grid-cell.cell-22 { animation-delay: calc(21 * 80ms); }
.grid-cell.cell-23 { animation-delay: calc(22 * 80ms); }
.grid-cell.cell-24 { animation-delay: calc(23 * 80ms); }
.grid-cell.cell-25 { animation-delay: calc(24 * 80ms); }
.grid-cell.cell-26 { animation-delay: calc(25 * 80ms); }
.grid-cell.cell-27 { animation-delay: calc(26 * 80ms); }
.grid-cell.cell-28 { animation-delay: calc(27 * 80ms); }
.grid-cell.cell-29 { animation-delay: calc(28 * 80ms); }
.grid-cell.cell-30 { animation-delay: calc(29 * 80ms); }
.grid-cell.cell-31 { animation-delay: calc(30 * 80ms); }
.grid-cell.cell-32 { animation-delay: calc(31 * 80ms); }
.grid-cell.cell-33 { animation-delay: calc(32 * 80ms); }
.grid-cell.cell-34 { animation-delay: calc(33 * 80ms); }
.grid-cell.cell-35 { animation-delay: calc(34 * 80ms); }
.grid-cell.cell-36 { animation-delay: calc(35 * 80ms); }
.grid-cell.cell-37 { animation-delay: calc(36 * 80ms); }
.grid-cell.cell-38 { animation-delay: calc(37 * 80ms); }
.grid-cell.cell-39 { animation-delay: calc(38 * 80ms); }
.grid-cell.cell-40 { animation-delay: calc(39 * 80ms); }
.grid-cell.cell-41 { animation-delay: calc(40 * 80ms); }
.grid-cell.cell-42 { animation-delay: calc(41 * 80ms); }
.grid-cell.cell-43 { animation-delay: calc(42 * 80ms); }
.grid-cell.cell-44 { animation-delay: calc(43 * 80ms); }
.grid-cell.cell-45 { animation-delay: calc(44 * 80ms); }
.grid-cell.cell-46 { animation-delay: calc(45 * 80ms); }
.grid-cell.cell-47 { animation-delay: calc(46 * 80ms); }
.grid-cell.cell-48 { animation-delay: calc(47 * 80ms); }
.grid-cell.cell-49 { animation-delay: calc(48 * 80ms); }
.grid-cell.cell-50 { animation-delay: calc(49 * 80ms); }
.grid-cell.cell-51 { animation-delay: calc(50 * 80ms); }
.grid-cell.cell-52 { animation-delay: calc(51 * 80ms); }
.grid-cell.cell-53 { animation-delay: calc(52 * 80ms); }
.grid-cell.cell-54 { animation-delay: calc(53 * 80ms); }
.grid-cell.cell-55 { animation-delay: calc(54 * 80ms); }
.grid-cell.cell-56 { animation-delay: calc(55 * 80ms); }
.grid-cell.cell-57 { animation-delay: calc(56 * 80ms); }
.grid-cell.cell-58 { animation-delay: calc(57 * 80ms); }
.grid-cell.cell-59 { animation-delay: calc(58 * 80ms); }
.grid-cell.cell-60 { animation-delay: calc(59 * 80ms); }
.grid-cell.cell-61 { animation-delay: calc(60 * 80ms); }
.grid-cell.cell-62 { animation-delay: calc(61 * 80ms); }
.grid-cell.cell-63 { animation-delay: calc(62 * 80ms); }
.grid-cell.cell-64 { animation-delay: calc(63 * 80ms); }

.grid-cell.animate {
    animation: cellIlluminate 0.8s ease-out forwards;
}

@keyframes cellIlluminate {
    from {
        background-color: transparent;
    }
    to {
        background-color: var(--cell-color);
    }
}

.cell-counter {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--moonlit-cream);
    font-weight: 400;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* ===== PANEL 5: THE YOKAI CENSUS ===== */
.yokai-census-panel {
    background-color: var(--deep-ground);
}

.census-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(2rem, 5vw, 5rem);
    width: 100%;
    height: 100%;
    flex-wrap: wrap;
}

.ring-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: clamp(180px, 25vw, 250px);
    aspect-ratio: 1;
}

.census-ring {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 20px rgba(232, 164, 69, 0.2));
}

.ring-fill {
    stroke-dasharray: 502.65;
    stroke-dashoffset: 502.65;
    transition: stroke-dashoffset 2s ease-out;
    will-change: stroke-dashoffset;
}

.ring-group.animate .ring-fill {
    stroke-dashoffset: var(--offset);
}

.fairy-wings path {
    animation: wingDraw 1.5s ease-out 1.5s forwards;
    opacity: 0;
}

@keyframes wingDraw {
    from { opacity: 0; }
    to { opacity: 0.3; }
}

.ring-counter {
    position: absolute;
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--amber-flame);
    text-shadow: 0 0 25px rgba(232, 164, 69, 0.5);
    text-align: center;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.ring-percent {
    font-size: 0.6em;
    margin-left: 0.3em;
}

.ring-label {
    position: absolute;
    bottom: -40px;
    font-family: 'Nunito', sans-serif;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--dusk-lavender);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* ===== PANEL 6: THE POLLEN DRIFT ===== */
.pollen-drift-panel {
    background-color: var(--deep-ground);
    position: relative;
}

.drift-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.particle-field {
    width: 100%;
    height: 100%;
    position: relative;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 7px;
    color: var(--moonlit-cream);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 0 14px currentColor, 0 0 28px currentColor;
}

.drift-caption {
    position: absolute;
    inset: auto 10vw 12vh auto;
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(3rem, 10vw, 10rem);
    color: rgba(154, 142, 176, 0.14);
    letter-spacing: -0.02em;
}

.particle-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    pointer-events: none;
}

@keyframes drift {
    0% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(100px) translateY(-15px);
    }
    100% {
        transform: translateX(200px) translateY(5px);
    }
}

/* ===== PANEL 7: THE BECOMING ===== */
.becoming-panel {
    background-color: var(--deep-ground);
    position: relative;
}

.becoming-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.grand-counter {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(8rem, 20vw, 18rem);
    font-weight: 400;
    color: var(--amber-flame);
    text-shadow: 0 0 40px rgba(232, 164, 69, 0.7), 0 0 80px rgba(232, 164, 69, 0.3);
    text-align: center;
    letter-spacing: -0.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    z-index: 10;
}

.burst-decorations {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.burst-element {
    position: absolute;
    top: 50%;
    left: 50%;
    text-shadow: 0 0 20px currentColor;
}

@keyframes burst {
    from {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 768px) {
    .scroll-container {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .panel {
        min-width: 100%;
        width: 100%;
        min-height: 100vh;
        height: auto;
    }

    .progress-vine {
        width: 100% !important;
        height: 2px;
    }

    .garden-container {
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }

    .counter-stalk {
        max-width: 80px;
        width: 100%;
    }

    .census-container {
        flex-direction: column;
        gap: 1.5rem;
    }

    .ring-group {
        width: clamp(140px, 50vw, 200px);
    }

    .grid-cell {
        gap: 0.5rem;
    }

    .bojagi-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(16, 1fr);
    }
}

/* Performance Optimization */
.panel {
    will-change: contents;
}

.counter-stalk .stalk-bar,
.ring-fill,
.particle {
    will-change: transform;
}

/* Prevent layout shift */
html {
    scrollbar-gutter: stable;
}
