/* ============================================================
   ncbd.dev — Next-Gen Central Business District HUD
   Neomorphic warm terracotta palette
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    --sandstone: #dac4a0;
    --papaya: #e8b87a;
    --terra-rosa: #c86e5a;
    --dusk-amber: #d4956a;
    --burnt-umber: #3d1f0a;
    --clay: #9e6b4a;
    --camel: #b8835e;
    --warm-tan: #d4a07a;
    --deep-brown: #5c3a20;
    --mid-brown: #7a5238;
    --dark-clay: #8b5e3c;
    --blush: #c47a6e;
    --muted-gray: #e0e0e0;
    --warm-gold: #e8a44a;

    --neo-bg: #d4a07a;
    --neo-light: #e8c4a4;
    --neo-dark: #a07050;
    --neo-radius: 16px;

    --font-display: 'Libre Baskerville', Georgia, serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-mono: 'Space Mono', 'Courier New', monospace;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    color: var(--burnt-umber);
    background: var(--neo-bg);
}

body.ncbd {
    position: relative;
}

/* ---------- Gradient Mesh Backdrop ---------- */
.mesh-backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 30%, #e8b87a 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 75% 20%, #c86e5a 0%, transparent 55%),
        radial-gradient(ellipse 70% 50% at 50% 70%, #dac4a0 0%, transparent 60%),
        radial-gradient(ellipse 50% 70% at 10% 80%, #d4956a 0%, transparent 50%),
        radial-gradient(ellipse 90% 40% at 80% 60%, #d4a07a 0%, transparent 55%),
        radial-gradient(ellipse 40% 90% at 40% 10%, #b8835e 0%, transparent 50%),
        radial-gradient(ellipse 60% 60% at 60% 50%, #9e6b4a 0%, transparent 45%),
        linear-gradient(135deg, #d4a07a 0%, #c86e5a 50%, #e8b87a 100%);
    animation: meshShift 30s ease-in-out infinite alternate;
}

@keyframes meshShift {
    0% {
        filter: hue-rotate(0deg) brightness(1);
    }
    33% {
        filter: hue-rotate(-8deg) brightness(1.05);
    }
    66% {
        filter: hue-rotate(5deg) brightness(0.95);
    }
    100% {
        filter: hue-rotate(-3deg) brightness(1.02);
    }
}

/* ---------- Scanlines Overlay ---------- */
.hud-scanlines {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 3px,
        rgba(61, 31, 10, 0.03) 3px,
        rgba(61, 31, 10, 0.03) 4px
    );
    mix-blend-mode: multiply;
}

/* ---------- HUD Corner Brackets ---------- */
.hud-corner {
    position: fixed;
    z-index: 10;
    width: 40px;
    height: 40px;
    pointer-events: none;
}

.hud-corner-tl {
    top: 12px;
    left: 12px;
    border-top: 2px solid var(--burnt-umber);
    border-left: 2px solid var(--burnt-umber);
    opacity: 0.4;
}

.hud-corner-tr {
    top: 12px;
    right: 12px;
    border-top: 2px solid var(--burnt-umber);
    border-right: 2px solid var(--burnt-umber);
    opacity: 0.4;
}

.hud-corner-bl {
    bottom: 12px;
    left: 12px;
    border-bottom: 2px solid var(--burnt-umber);
    border-left: 2px solid var(--burnt-umber);
    opacity: 0.4;
}

.hud-corner-br {
    bottom: 12px;
    right: 12px;
    border-bottom: 2px solid var(--burnt-umber);
    border-right: 2px solid var(--burnt-umber);
    opacity: 0.4;
}

/* ---------- Top HUD Bar ---------- */
.hud-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: linear-gradient(to bottom, rgba(212, 160, 122, 0.85), rgba(212, 160, 122, 0.2));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(61, 31, 10, 0.1);
}

.brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    color: var(--burnt-umber);
    letter-spacing: 0.02em;
}

.status {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--clay);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(218, 196, 160, 0.5);
    box-shadow:
        3px 3px 6px rgba(122, 82, 56, 0.2),
        -3px -3px 6px rgba(232, 196, 164, 0.5);
}

.clock {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--deep-brown);
    letter-spacing: 0.08em;
}

/* ---------- Left Navigation Rail ---------- */
.nav-left {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--neo-radius);
    background: var(--neo-bg);
    color: var(--clay);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: all 0.3s ease;
    box-shadow:
        5px 5px 10px var(--neo-dark),
        -5px -5px 10px var(--neo-light);
}

.nav-pill:hover {
    color: var(--burnt-umber);
    transform: translateX(4px);
}

.nav-pill.active {
    background: linear-gradient(135deg, var(--papaya), var(--warm-tan));
    color: var(--burnt-umber);
    box-shadow:
        inset 3px 3px 6px rgba(122, 82, 56, 0.3),
        inset -3px -3px 6px rgba(232, 196, 164, 0.4);
}

.nav-icon {
    flex-shrink: 0;
}

.nav-label {
    white-space: nowrap;
}

/* ---------- Bottom HUD Bar ---------- */
.hud-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 28px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--clay);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(to top, rgba(212, 160, 122, 0.85), rgba(212, 160, 122, 0.2));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(61, 31, 10, 0.1);
}

/* ---------- Content Viewport ---------- */
.content-viewport {
    position: fixed;
    top: 60px;
    left: 180px;
    right: 24px;
    bottom: 46px;
    z-index: 10;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--camel) transparent;
}

.content-viewport::-webkit-scrollbar {
    width: 6px;
}

.content-viewport::-webkit-scrollbar-thumb {
    background: var(--camel);
    border-radius: 3px;
}

.content-viewport::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------- Content Panels ---------- */
.content-panel {
    display: none;
    animation: panelFadeIn 0.4s ease-out;
}

.content-panel.active {
    display: block;
}

@keyframes panelFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Panel Cards (Neomorphic) ---------- */
.panel-card {
    background: var(--neo-bg);
    border-radius: var(--neo-radius);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow:
        8px 8px 16px var(--neo-dark),
        -8px -8px 16px var(--neo-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel-card:hover {
    transform: translateY(-2px);
    box-shadow:
        10px 10px 20px var(--neo-dark),
        -10px -10px 20px var(--neo-light);
}

/* ---------- Typography ---------- */
.panel-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 3.5rem);
    color: var(--burnt-umber);
    letter-spacing: 0.02em;
    line-height: 1.2;
    margin-bottom: 12px;
}

.panel-subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    font-weight: 300;
    color: var(--clay);
    line-height: 1.6;
    max-width: 600px;
    margin-bottom: 28px;
}

.card-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--burnt-umber);
    letter-spacing: 0.02em;
    margin-bottom: 20px;
}

/* ---------- Hero Stats Tiles ---------- */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.stat-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px;
    border-radius: 14px;
    background: var(--neo-bg);
    box-shadow:
        inset 4px 4px 8px var(--neo-dark),
        inset -4px -4px 8px var(--neo-light);
    transition: transform 0.2s ease;
}

.stat-tile:hover {
    transform: scale(1.03);
}

.stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--terra-rosa);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--clay);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---------- Activity Feed ---------- */
.activity-list {
    list-style: none;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--deep-brown);
    border-radius: 10px;
    transition: background 0.2s ease;
    margin-bottom: 4px;
}

.activity-item:hover {
    background: rgba(218, 196, 160, 0.3);
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-dot.green {
    background: #6b9e4a;
    box-shadow: 0 0 6px rgba(107, 158, 74, 0.5);
}

.activity-dot.amber {
    background: var(--papaya);
    box-shadow: 0 0 6px rgba(232, 184, 122, 0.5);
}

.activity-dot.red {
    background: var(--terra-rosa);
    box-shadow: 0 0 6px rgba(200, 110, 90, 0.5);
}

/* ---------- District Grid ---------- */
.district-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.district-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 16px;
    border-radius: var(--neo-radius);
    background: var(--neo-bg);
    box-shadow:
        5px 5px 10px var(--neo-dark),
        -5px -5px 10px var(--neo-light);
    cursor: pointer;
    transition: all 0.3s ease;
}

.district-tile:hover {
    transform: translateY(-4px);
    box-shadow:
        8px 8px 16px var(--neo-dark),
        -8px -8px 16px var(--neo-light);
}

.district-tile:active {
    box-shadow:
        inset 4px 4px 8px var(--neo-dark),
        inset -4px -4px 8px var(--neo-light);
    transform: translateY(0);
}

.district-icon {
    opacity: 0.85;
}

.district-name {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--burnt-umber);
}

.district-status {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    border-radius: 12px;
}

.district-status.online {
    color: #4a7a2e;
    background: rgba(107, 158, 74, 0.15);
}

.district-status.maintenance {
    color: var(--terra-rosa);
    background: rgba(200, 110, 90, 0.15);
}

/* ---------- Metrics ---------- */
.metrics-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.metric-bar-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metric-label {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--deep-brown);
}

.metric-bar {
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: var(--neo-bg);
    box-shadow:
        inset 3px 3px 6px var(--neo-dark),
        inset -3px -3px 6px var(--neo-light);
    overflow: hidden;
}

.metric-fill {
    height: 100%;
    width: var(--fill-width, 0%);
    border-radius: 6px;
    background: linear-gradient(90deg, var(--warm-gold), var(--papaya), var(--terra-rosa));
    transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}

.metric-fill::after {
    content: attr(data-value);
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--burnt-umber);
    font-weight: 700;
}

/* ---------- Chart Area ---------- */
.chart-area {
    width: 100%;
    height: 140px;
    border-radius: 12px;
    background: var(--neo-bg);
    box-shadow:
        inset 3px 3px 6px var(--neo-dark),
        inset -3px -3px 6px var(--neo-light);
    padding: 12px;
    overflow: hidden;
}

.mini-chart {
    width: 100%;
    height: 100%;
}

/* ---------- Systems List ---------- */
.systems-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.system-node {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 14px;
    background: var(--neo-bg);
    box-shadow:
        4px 4px 8px var(--neo-dark),
        -4px -4px 8px var(--neo-light);
    transition: transform 0.2s ease;
}

.system-node:hover {
    transform: translateX(4px);
}

.node-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.node-indicator.pulse-green {
    background: #6b9e4a;
    animation: pulse 2s ease-in-out infinite;
}

.node-indicator.pulse-amber {
    background: var(--papaya);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 4px rgba(107, 158, 74, 0.3);
    }
    50% {
        box-shadow: 0 0 12px rgba(107, 158, 74, 0.7);
    }
}

.node-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.node-name {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--burnt-umber);
}

.node-detail {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--clay);
    letter-spacing: 0.03em;
}

.node-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 12px;
    border-radius: 12px;
    color: #4a7a2e;
    background: rgba(107, 158, 74, 0.15);
    white-space: nowrap;
}

.node-badge.warning {
    color: var(--terra-rosa);
    background: rgba(200, 110, 90, 0.15);
}

/* ---------- Shake Animation ---------- */
@keyframes microShake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-1px, 0.5px); }
    50% { transform: translate(0.5px, -1px); }
    75% { transform: translate(-0.5px, -0.5px); }
}

.shake {
    animation: microShake 0.15s ease-in-out;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .nav-left {
        left: 8px;
        top: auto;
        bottom: 50px;
        transform: none;
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        width: calc(100% - 16px);
        padding: 8px 0;
    }

    .nav-pill {
        padding: 8px 12px;
        border-radius: 12px;
        flex-shrink: 0;
    }

    .nav-label {
        display: none;
    }

    .content-viewport {
        left: 12px;
        right: 12px;
        bottom: 110px;
        top: 56px;
        padding: 12px;
    }

    .hud-bottom {
        bottom: 60px;
    }

    .panel-card {
        padding: 20px;
    }

    .hero-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .district-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .hero-stats {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .district-grid {
        grid-template-columns: 1fr;
    }

    .hud-top {
        padding: 10px 16px;
    }

    .hud-bottom {
        padding: 8px 16px;
        font-size: 0.6rem;
    }
}
