/* ==========================================================================
   bada.city — generative celestial dreamscape
   Horizontal voyage through fictional districts
   Interaction: Interaction*: Interaction**: Implement using CSS `overflow-x: scroll`; IntersectionObserver` trigger. Duration: 1.5s; `threshold: 0.3`; bounce uses keyframe:; Interventions: Interventions*: Interventions**: boundaries and hover states
   ========================================================================== */

:root {
    --void: #0c0610;
    --parchment: #f5efe6;
    --ink: #5a0a1e;
    --star-gold: #c4a882;
    --mist: #d4c5b0;
    --glitch-magenta: #d42f8a;
    --constellation-blue: #7b8ec4;
    --shadow: #1a0b20;
    --deep-burgundy: #3a1520;

    --district-width: 100vw;
    --avenue-width: 50vw;
    --num-districts: 8;

    --glitch-intensity: 0;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--void);
    color: var(--parchment);
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 300;
    cursor: default;
}

body {
    position: relative;
}

/* ===== Star Canvas (fixed background) ===== */
#star-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* ===== Domain mark (top-left fixed) ===== */
.domain-mark {
    position: fixed;
    top: 24px;
    left: 28px;
    z-index: 20;
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: lowercase;
    color: var(--parchment);
    opacity: 0.4;
    mix-blend-mode: difference;
    pointer-events: none;
    transition: opacity 600ms ease;
}

/* ===== Scroll Container ===== */
.scroll-container {
    position: relative;
    z-index: 1;
    width: 100vw;
    height: 100vh;
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    display: flex;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.scroll-container::-webkit-scrollbar {
    display: none;
}

/* ===== District Panel ===== */
.district {
    position: relative;
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: grid;
    grid-template-rows: 15vh 60vh 25vh;
    overflow: hidden;
    margin-right: 50vw; /* interstitial "avenue" */
    isolation: isolate;
    transition: background-color 800ms ease;
}

.district:last-child {
    margin-right: 0;
}

/* Scan lines overlay for CRT texture */
.district::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(12, 6, 16, 0.08) 2px,
        rgba(12, 6, 16, 0.08) 3px
    );
    mix-blend-mode: multiply;
    opacity: 0.7;
}

/* Night-mode districts */
.district[data-mode="void"] {
    background:
        radial-gradient(circle at 70% 18%, rgba(123, 142, 196, 0.11), transparent 28vw),
        linear-gradient(90deg, rgba(12, 6, 16, 0.96), rgba(26, 11, 32, 0.92) 54%, rgba(12, 6, 16, 0.96));
    color: var(--parchment);
}

/* Day-mode districts */
.district[data-mode="parchment"] {
    background:
        radial-gradient(circle at 22% 22%, rgba(196, 168, 130, 0.22), transparent 26vw),
        linear-gradient(90deg, rgba(245, 239, 230, 0.96), rgba(212, 197, 176, 0.9) 52%, rgba(245, 239, 230, 0.96));
    color: var(--deep-burgundy);
}

.district[data-mode="parchment"]::after {
    background-image: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(90, 10, 30, 0.05) 2px,
        rgba(90, 10, 30, 0.05) 3px
    );
}

/* ===== Sky Row ===== */
.sky-row {
    position: relative;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 4vw;
    z-index: 2;
}

.sky-row .constellation {
    position: absolute;
    top: 0;
    left: 4vw;
    width: 55vw;
    height: 100%;
    pointer-events: none;
}

.sky-row .constellation path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.5s ease-out;
}

.district.in-view .sky-row .constellation path {
    stroke-dashoffset: 0;
}

.sky-row .constellation circle {
    opacity: 0;
    transition: opacity 1.2s ease-out 0.6s;
}

.district.in-view .sky-row .constellation circle {
    opacity: 0.85;
    animation: star-pulse 4s ease-in-out infinite alternate;
}

.sky-row .constellation circle:nth-child(3) { animation-delay: 0.4s; }
.sky-row .constellation circle:nth-child(5) { animation-delay: 1.1s; }
.sky-row .constellation circle:nth-child(7) { animation-delay: 1.9s; }

.district-caption {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 600;
    font-size: clamp(0.65rem, 0.8vw, 0.78rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--star-gold);
    position: relative;
    z-index: 2;
}

.district[data-mode="parchment"] .district-caption {
    color: var(--ink);
}

/* ===== Content Row ===== */
.content-row {
    position: relative;
    grid-row: 2;
    display: flex;
    align-items: center;
    z-index: 3;
}

.content-block {
    max-width: 36vw;
    width: 36vw;
}

.content-block.align-left {
    margin-left: 12vw;
}

.content-block.align-right {
    margin-right: 12vw;
    margin-left: auto;
    text-align: right;
}

/* Accent Label */
.accent-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 600;
    font-size: clamp(0.65rem, 0.8vw, 0.78rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--star-gold);
    margin-bottom: 2.2rem;
    opacity: 0;
    transform: translateY(20px);
}

.district[data-mode="parchment"] .accent-label {
    color: var(--ink);
}

.star-marker {
    width: 10px;
    height: 10px;
    transition: transform 8s linear;
}

.accent-label:hover .star-marker {
    transform: rotate(360deg);
}

/* District Name */
.district-name {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 200;
    font-size: clamp(2.4rem, 5vw, 5.6rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    line-height: 1.05;
    color: var(--parchment);
    margin-bottom: 2.4rem;
    opacity: 0;
    transform: translateY(40px) scale(0.92);
    position: relative;
}

.district[data-mode="parchment"] .district-name {
    color: var(--ink);
}

/* Body Text */
.district-body {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--mist);
    max-width: 34vw;
    opacity: 0;
    transform: translateY(40px) scale(0.92);
}

.content-block.align-right .district-body {
    margin-left: auto;
}

.district[data-mode="parchment"] .district-body {
    color: var(--deep-burgundy);
}

/* Crescent divider */
.crescent-divider {
    width: 14px;
    height: 14px;
    display: block;
    margin: 1.8rem 0;
    opacity: 0;
    transform: translateY(40px) scale(0.92);
}

.content-block.align-right .crescent-divider {
    margin-left: auto;
    margin-right: 0;
}

/* ===== Ground Row ===== */
.ground-row {
    position: relative;
    grid-row: 3;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    z-index: 1;
}

.skyline {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.85;
}

.district[data-mode="void"] .skyline .skyline-shapes rect {
    fill: var(--ink);
    opacity: 0.15;
}

.district[data-mode="parchment"] .skyline .skyline-shapes rect {
    fill: var(--void);
    opacity: 0.08;
}

/* ===== Ghost Numeral ===== */
.ghost-numeral {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 100;
    font-size: clamp(6rem, 18vw, 22rem);
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--parchment);
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
    user-select: none;
}

.district[data-mode="parchment"] .ghost-numeral {
    color: var(--ink);
    opacity: 0.045;
}

/* ===== Bounce-Enter Animations ===== */
@keyframes bounceEnter {
    0% { opacity: 0; transform: translateY(40px) scale(0.92); }
    50% { opacity: 0.8; transform: translateY(-8px) scale(1.02); }
    70% { transform: translateY(3px) scale(0.99); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.district.in-view .accent-label {
    animation: bounceEnter 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 80ms;
}

.district.in-view .district-name {
    animation: bounceEnter 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 160ms;
}

.district.in-view .district-body:nth-of-type(1) {
    animation: bounceEnter 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 240ms;
}

.district.in-view .crescent-divider {
    animation: bounceEnter 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 320ms;
}

.district.in-view .district-body:nth-of-type(2) {
    animation: bounceEnter 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 400ms;
}

/* ===== Glitch Effect ===== */
@keyframes rgbSplit {
    0% {
        text-shadow:
            0 0 0 var(--glitch-magenta),
            0 0 0 var(--constellation-blue);
    }
    30% {
        text-shadow:
            3px 0 0 var(--glitch-magenta),
            -3px 0 0 var(--constellation-blue);
    }
    60% {
        text-shadow:
            -2px 0 0 var(--glitch-magenta),
            2px 0 0 var(--constellation-blue);
    }
    100% {
        text-shadow:
            0 0 0 var(--glitch-magenta),
            0 0 0 var(--constellation-blue);
    }
}

.glitchable {
    cursor: pointer;
    transition: text-shadow 200ms ease;
    position: relative;
}

.glitchable:hover {
    animation: rgbSplit 280ms ease-in-out;
}

.district.glitching .district-name,
.district.glitching .accent-label {
    animation: rgbSplit 280ms ease-in-out;
}

/* Star pulsing */
@keyframes star-pulse {
    from { opacity: 0.35; }
    to { opacity: 0.95; }
}

/* ===== Threshold (Entrance) ===== */
.threshold {
    background: var(--void);
}

.threshold-content {
    justify-content: center;
    flex-direction: column;
    display: flex;
    align-items: center;
    text-align: center;
    position: relative;
}

.threshold-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: var(--parchment);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    box-shadow: 0 0 16px var(--parchment), 0 0 40px var(--star-gold);
    animation: threshold-pulse 1400ms ease-out forwards;
    z-index: 2;
}

@keyframes threshold-pulse {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    55% { transform: translate(-50%, -50%) scale(2.5); opacity: 0.9; }
    80% { transform: translate(-50%, -50%) scale(5); opacity: 0.3; }
    100% { transform: translate(-50%, -50%) scale(8); opacity: 0; }
}

.constellation-text {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 200;
    font-size: clamp(3rem, 9vw, 9rem);
    letter-spacing: 0.25em;
    text-transform: lowercase;
    color: var(--parchment);
    position: relative;
    z-index: 3;
    display: flex;
    gap: 0.05em;
    margin: 0 0 2rem;
}

.constellation-text .letter,
.constellation-text .dot {
    display: inline-block;
    opacity: 0;
    transform: translateY(0) scale(0.8);
    animation: letter-form 800ms ease-out forwards;
    position: relative;
}

.constellation-text .letter::before,
.constellation-text .dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: var(--star-gold);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px var(--star-gold);
    opacity: 1;
    animation: star-to-letter 1200ms ease-out forwards;
}

@keyframes letter-form {
    0% { opacity: 0; transform: translateY(10px) scale(0.8); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes star-to-letter {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

.constellation-text .letter:nth-child(1) { animation-delay: 600ms; }
.constellation-text .letter:nth-child(2) { animation-delay: 680ms; }
.constellation-text .letter:nth-child(3) { animation-delay: 760ms; }
.constellation-text .letter:nth-child(4) { animation-delay: 840ms; }
.constellation-text .dot { animation-delay: 920ms; }
.constellation-text .letter:nth-child(6) { animation-delay: 1000ms; }
.constellation-text .letter:nth-child(7) { animation-delay: 1080ms; }
.constellation-text .letter:nth-child(8) { animation-delay: 1160ms; }
.constellation-text .letter:nth-child(9) { animation-delay: 1240ms; }

.constellation-text .letter:nth-child(1)::before { animation-delay: 200ms; }
.constellation-text .letter:nth-child(2)::before { animation-delay: 280ms; }
.constellation-text .letter:nth-child(3)::before { animation-delay: 360ms; }
.constellation-text .letter:nth-child(4)::before { animation-delay: 440ms; }
.constellation-text .dot::before { animation-delay: 520ms; }
.constellation-text .letter:nth-child(6)::before { animation-delay: 600ms; }
.constellation-text .letter:nth-child(7)::before { animation-delay: 680ms; }
.constellation-text .letter:nth-child(8)::before { animation-delay: 760ms; }
.constellation-text .letter:nth-child(9)::before { animation-delay: 840ms; }

.threshold-sub {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    color: var(--mist);
    opacity: 0;
    animation: fade-slide-up 1200ms ease-out 1700ms forwards;
    max-width: 36vw;
    margin-bottom: 3rem;
    font-style: italic;
}

.threshold-hint {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 600;
    font-size: clamp(0.7rem, 0.85vw, 0.82rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--star-gold);
    display: flex;
    align-items: center;
    gap: 0.8em;
    opacity: 0;
    animation: fade-slide-up 1200ms ease-out 2200ms forwards;
}

.hint-arrow {
    display: inline-block;
    animation: arrow-nudge 1800ms ease-in-out infinite;
    font-size: 1.2em;
}

@keyframes arrow-nudge {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(8px); }
}

@keyframes fade-slide-up {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 0.8; transform: translateY(0); }
}

/* ===== Progress Track ===== */
.progress-track {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 3px;
    background: rgba(196, 168, 130, 0.08);
    z-index: 15;
    pointer-events: none;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--star-gold);
    transition: width 160ms ease-out;
    box-shadow: 0 0 8px var(--star-gold);
}

.progress-markers {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.progress-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: var(--star-gold);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    opacity: 0.55;
    transition: opacity 300ms ease, transform 300ms ease;
}

.progress-marker.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5);
    box-shadow: 0 0 8px var(--star-gold);
}

/* ===== Corruption Layer ===== */
.corruption-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 14;
    overflow: hidden;
}

.corruption-block {
    position: absolute;
    width: 40px;
    height: 8px;
    background: var(--glitch-magenta);
    opacity: 0;
    animation: corruption-flash 120ms ease-out forwards;
    mix-blend-mode: screen;
}

@keyframes corruption-flash {
    0% { opacity: 0; transform: scaleX(0.3); }
    30% { opacity: 0.9; transform: scaleX(1); }
    60% { opacity: 0.7; transform: scaleX(1.2); }
    100% { opacity: 0; transform: scaleX(0); }
}

/* Small clip-path glitch band on district entry */
@keyframes clip-band {
    0%, 100% { clip-path: inset(0 0 0 0); }
    30% { clip-path: inset(30% 0 50% 0); }
    60% { clip-path: inset(55% 0 25% 0); }
}

.district.glitching .content-block {
    animation: clip-band 260ms steps(3) 0s 1;
}

/* Edges / dust overlay — subtle parchment vignette on parchment panels */
.district[data-mode="parchment"] .content-block {
    color: var(--deep-burgundy);
}

.district[data-mode="parchment"] .threshold-sub {
    color: var(--deep-burgundy);
}

/* Reduce-motion overrides — none, per instructions */

/* Prevent selection flashing weird colors */
::selection {
    background: var(--glitch-magenta);
    color: var(--parchment);
}
