/* ============================================================
   bada.city - Municipal Operating System
   Color Palette:
     Void Indigo:    #0d0f1a (background)
     Meridian Blue:  #2a3f6e (horizon, structural lines)
     Signal Amber:   #d4a843 (interactive, current marker)
     Bright Gold:    #f0c94d (hover, active, cursor)
     Ash Silver:     #c8cdd5 (body text)
     Ice White:      #e8ecf2 (display headings)
     Slate Gray:     #3d4452 (muted, grid dots)
     Teal Signal:    #3a9e8f (data, coordinates)

   Fonts:
     Jost 400/600 - Display/Headings
     Space Mono 400/700 - Body/Terminal
     JetBrains Mono 300 - Data/Coordinates
   ============================================================ */

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

html {
    overflow: hidden;
    height: 100%;
}

body {
    background: #0d0f1a;
    color: #c8cdd5;
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.82rem, 1.6vw, 0.95rem);
    line-height: 1.8;
    letter-spacing: 0.04em;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* === Horizontal Scroll Container === */
.scroll-container {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    height: 100vh;
    width: 100vw;
    -webkit-overflow-scrolling: touch;
}

.scroll-container::-webkit-scrollbar {
    display: none;
}

.scroll-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* === District Panels === */
.district {
    min-width: 100vw;
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    background: #0d0f1a;
    /* Blur-focus default for non-active */
    filter: blur(6px);
    opacity: 0.4;
    transition: filter 400ms ease-out, opacity 400ms ease-out;
}

.district.in-focus {
    filter: blur(0);
    opacity: 1;
}

.district-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* === Tessellation Backgrounds === */
.tessellation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.3;
}

/* === Global Horizon Line === */
.global-horizon {
    position: fixed;
    top: 50vh;
    left: 0;
    width: 100%;
    height: 1px;
    background: #2a3f6e;
    z-index: 100;
    pointer-events: none;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 500ms ease-out;
}

.global-horizon.active {
    transform: scaleX(1);
}

/* === District 00 - Entry Terminal === */
#district-00 {
    filter: blur(0);
    opacity: 1;
}

#district-00 .horizon-line {
    position: absolute;
    top: 50vh;
    left: 0;
    width: 100%;
    height: 1px;
    background: #2a3f6e;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 500ms ease-out;
    z-index: 3;
}

#district-00 .horizon-line.drawn {
    transform: scaleX(1);
}

.entry-title {
    position: absolute;
    top: calc(50vh + 16px);
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Jost', sans-serif;
    font-weight: 600;
    font-size: clamp(2.8rem, 7vw, 6rem);
    color: #e8ecf2;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    white-space: nowrap;
    z-index: 5;
    display: flex;
    align-items: baseline;
}

.letter {
    opacity: 0;
    transition: opacity 120ms ease-out;
    transition-delay: calc(var(--i) * 60ms);
}

.entry-title.revealed .letter {
    opacity: 1;
}

/* Blinking Cursor */
.cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: #f0c94d;
    margin-left: 4px;
    opacity: 0;
    vertical-align: baseline;
}

.cursor.blink {
    animation: blink 1s step-end infinite;
}

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

/* Navigation Hint Arrows */
.nav-hint {
    position: absolute;
    right: 3vw;
    top: calc(50vh - 12px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    transition: opacity 400ms ease-out;
    z-index: 5;
}

.nav-hint.visible {
    opacity: 1;
}

.hint-arrow {
    display: block;
    width: 8px;
    height: 8px;
    background: #d4a843;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    animation: pulse-arrow 2s ease-in-out infinite;
    animation-delay: calc(var(--d) * 200ms);
}

@keyframes pulse-arrow {
    0%, 100% { transform: translateX(0); opacity: 0.6; }
    50% { transform: translateX(4px); opacity: 1; }
}

/* === District Labels (above horizon) === */
.above-horizon {
    position: absolute;
    z-index: 3;
}

.district-label {
    top: calc(50vh - 80px);
    left: 5vw;
    display: flex;
    gap: 24px;
    align-items: baseline;
}

.district-id {
    font-family: 'Jost', sans-serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: #e8ecf2;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.district-coord {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.65rem, 1.2vw, 0.78rem);
    color: #3a9e8f;
    letter-spacing: 0.08em;
    font-variant-ligatures: none;
}

.district-title {
    top: calc(50vh - 48px);
    left: 5vw;
    font-family: 'Jost', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.8vw, 1.2rem);
    color: #c8cdd5;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* === Below Horizon Content === */
.below-horizon {
    position: absolute;
    z-index: 3;
}

/* === District 01 - Sector Grid === */
.sector-grid {
    top: calc(50vh + 24px);
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    width: min(80vw, 600px);
    height: min(50vh, 400px);
}

.sector-cell {
    background: transparent;
    border: 1px solid #2a3f6e;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: default;
    filter: blur(3px);
    transition: filter 200ms ease-out, border-color 200ms ease-out;
}

.sector-cell:hover {
    filter: blur(0);
    border-color: #d4a843;
}

.sector-cell:hover .sector-glyph {
    stroke: #d4a843;
}

.sector-cell:hover .sector-coord-label {
    opacity: 1;
}

.sector-glyph {
    width: 60%;
    height: 60%;
    stroke: #2a3f6e;
    stroke-width: 1;
    fill: none;
    transition: stroke 200ms ease-out;
}

.sector-coord-label {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.55rem;
    color: #3a9e8f;
    letter-spacing: 0.08em;
    font-variant-ligatures: none;
    opacity: 0;
    transition: opacity 200ms ease-out;
    white-space: nowrap;
}

/* === Content Districts (02-05) === */
.content-block {
    max-width: 28ch;
    position: relative;
    padding: 24px;
}

.content-block.position-upper-left {
    top: calc(50vh + 20px);
    left: 5vw;
}

.content-block.position-lower-right {
    top: calc(50vh + 60px);
    right: 5vw;
    left: auto;
    text-align: right;
}

.content-text {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.82rem, 1.6vw, 0.95rem);
    color: #c8cdd5;
    line-height: 1.8;
    letter-spacing: 0.04em;
}

.content-coord {
    display: block;
    margin-top: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.65rem, 1.2vw, 0.78rem);
    color: #3a9e8f;
    letter-spacing: 0.08em;
    font-variant-ligatures: none;
}

/* === Bracket Frames === */
.bracket-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bracket {
    position: absolute;
    width: 24px;
    height: 24px;
}

.bracket-tl {
    top: 0;
    left: 0;
    border-top: 1px solid #2a3f6e;
    border-left: 1px solid #2a3f6e;
}

.bracket-br {
    bottom: 0;
    right: 0;
    border-bottom: 1px solid #2a3f6e;
    border-right: 1px solid #2a3f6e;
}

/* === Generative Pattern Areas === */
.generative-pattern {
    position: absolute;
    z-index: 2;
    top: calc(50vh + 20px);
    width: 45vw;
    height: 40vh;
}

.generative-pattern.pattern-right {
    right: 5vw;
}

.generative-pattern.pattern-left {
    left: 5vw;
}

/* === District 06 - Terminal Output === */
.terminal-block {
    top: calc(50vh + 16px);
    left: 50%;
    transform: translateX(-50%);
    width: min(80vw, 700px);
    height: calc(50vh - 60px);
    display: flex;
    flex-direction: column;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    border: 1px solid #2a3f6e;
    background: rgba(13, 15, 26, 0.8);
}

.terminal-output::-webkit-scrollbar {
    width: 2px;
}

.terminal-output::-webkit-scrollbar-track {
    background: #0d0f1a;
}

.terminal-output::-webkit-scrollbar-thumb {
    background: #2a3f6e;
}

.terminal-line {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.72rem, 1.3vw, 0.85rem);
    line-height: 1.9;
    white-space: nowrap;
    overflow: hidden;
}

.term-time {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    color: #3a9e8f;
    font-variant-ligatures: none;
    letter-spacing: 0.08em;
}

.term-cmd {
    color: #d4a843;
    font-weight: 700;
    margin-left: 8px;
}

.term-data {
    color: #c8cdd5;
    margin-left: 8px;
}

.terminal-cursor-line {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    border: 1px solid #2a3f6e;
    border-top: none;
    background: rgba(13, 15, 26, 0.8);
}

.term-prompt {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    color: #d4a843;
    font-size: clamp(0.72rem, 1.3vw, 0.85rem);
}

.terminal-cursor-line .cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #f0c94d;
    margin-left: 4px;
    animation: blink 1s step-end infinite;
    opacity: 1;
}

/* === Progress Bar === */
.progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: #3d4452;
    z-index: 200;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: #d4a843;
    transition: width 200ms ease-out;
}

.progress-ticks {
    position: absolute;
    top: -4px;
    left: 0;
    width: 100%;
    height: 4px;
    pointer-events: none;
}

.tick {
    position: absolute;
    left: calc(var(--pos) * (100% / 7));
    top: 0;
    width: 1px;
    height: 4px;
    background: #2a3f6e;
}

/* === District Indicator === */
.district-indicator {
    position: fixed;
    bottom: 12px;
    right: 16px;
    z-index: 200;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.indicator-label {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    color: #3d4452;
    letter-spacing: 0.08em;
    font-variant-ligatures: none;
}

.indicator-number {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.85rem;
    color: #d4a843;
    letter-spacing: 0.08em;
    font-variant-ligatures: none;
}

/* === Flow Lines === */
.flow-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.flow-line {
    stroke: #3a9e8f;
    stroke-width: 0.5;
    opacity: 0.4;
    fill: none;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 800ms ease-out;
}

.flow-line.animate {
    stroke-dashoffset: 0;
}

/* === Concentric Squares (click effect) === */
.concentric-square {
    position: fixed;
    pointer-events: none;
    z-index: 300;
    border: 1px solid #d4a843;
    opacity: 0;
    animation: concentric-expand 600ms ease-out forwards;
}

@keyframes concentric-expand {
    0% {
        transform: scale(0.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* === Target Reticle (interactive hotspot marker) === */
.reticle {
    width: 40px;
    height: 40px;
    position: relative;
}

.reticle svg {
    width: 100%;
    height: 100%;
}

/* === Responsive: Vertical on mobile === */
@media (max-width: 768px) {
    html {
        overflow: auto;
    }

    body {
        overflow: auto;
        height: auto;
    }

    .scroll-container {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        scroll-snap-type: y mandatory;
        height: auto;
        width: 100vw;
    }

    .district {
        min-width: 100vw;
        width: 100vw;
        min-height: 100vh;
        height: 100vh;
        scroll-snap-align: start;
    }

    .global-horizon {
        top: 0;
        left: 8vw;
        width: 1px;
        height: 100%;
        transform: scaleY(0);
        transform-origin: center;
    }

    .global-horizon.active {
        transform: scaleY(1);
    }

    #district-00 .horizon-line {
        top: 0;
        left: 8vw;
        width: 1px;
        height: 100%;
        transform: scaleY(0);
        transform-origin: center;
    }

    #district-00 .horizon-line.drawn {
        transform: scaleY(1);
    }

    .entry-title {
        top: 50vh;
        left: calc(8vw + 16px);
        transform: none;
    }

    .district-label {
        top: 20px;
        left: calc(8vw + 16px);
        flex-direction: column;
        gap: 4px;
    }

    .district-title {
        top: 70px;
        left: calc(8vw + 16px);
    }

    .sector-grid {
        top: calc(50vh - 30vh);
        left: calc(8vw + 16px);
        transform: none;
        width: calc(90vw - 8vw - 16px);
        grid-template-columns: repeat(4, 1fr);
    }

    .content-block.position-upper-left,
    .content-block.position-lower-right {
        top: calc(50vh + 10px);
        left: calc(8vw + 16px);
        right: auto;
        text-align: left;
    }

    .generative-pattern {
        display: none;
    }

    .terminal-block {
        left: calc(8vw + 16px);
        transform: none;
        width: calc(90vw - 8vw - 16px);
    }

    .nav-hint {
        right: 3vw;
        top: auto;
        bottom: 40px;
        flex-direction: row;
    }

    .hint-arrow {
        clip-path: polygon(0 0, 50% 100%, 100% 0);
    }

    @keyframes pulse-arrow {
        0%, 100% { transform: translateY(0); opacity: 0.6; }
        50% { transform: translateY(4px); opacity: 1; }
    }

    .progress-bar {
        display: none;
    }

    .district-indicator {
        bottom: 12px;
        right: 12px;
    }
}
