/* Drop Ceiling - Public Viewer Styles */
/* Mobile-first, minimal aesthetic */

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

:root {
    --bg-color: #0a0a0c;
    --text-color: #ffffff;
    --text-muted: #666666;
    --accent-color: #4a9eff;
    --panel-bg: rgba(20, 20, 25, 0.9);
    --input-engaged: #ffaa44;
    --input-passing: #66ee88;
    --output-avg: #7cd3ff;
    --output-band: rgba(124, 211, 255, 0.25);
    --trends-height: 46vh;
    --trends-height-desktop: 38vh;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Header */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 20px;
    text-align: center;
    background: linear-gradient(to bottom, var(--bg-color) 0%, transparent 100%);
    pointer-events: none;
}

#header h1 {
    font-size: 28px;
    font-weight: 300;
    letter-spacing: 8px;
    text-transform: uppercase;
    color: var(--text-color);
    opacity: 0.9;
}

#behavior-status {
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-color);
    opacity: 0.6;
    margin-top: 8px;
    min-height: 20px;
}

/* 3D Container */
#container {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
}

#viewer {
    width: 100%;
    height: 100%;
    display: block;
}

/* Responsive adjustments */
@media (min-width: 768px) {
    #header h1 {
        font-size: 36px;
        letter-spacing: 12px;
    }
}

/* Animation for status */
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* About button */
.about-title {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(20, 20, 25, 0.5);
    cursor: pointer;
    text-align: left;
    font-size: 11px;
    letter-spacing: 2px;
    line-height: 1;
    text-decoration: none;
    color: inherit;
}

.about-title:hover {
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.35);
}


/* About overlay */
#about-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 12, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

#about-overlay.hidden {
    display: none;
}

#about-modal {
    position: relative;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 40px;
    background: var(--panel-bg);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#about-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s ease;
}

#about-close:hover {
    color: var(--text-color);
}

#about-modal h2 {
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 30px;
    color: var(--text-color);
}

.about-content p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-color);
    opacity: 0.85;
    margin-bottom: 20px;
}

.about-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.about-content a:hover {
    text-decoration: underline;
}

.design-team {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.design-team h3 {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.design-team p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 0;
}

.about-links {
    margin-top: 18px;
    display: flex;
    gap: 10px;
}

.about-links a {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-radius: 20px;
    background: rgba(20, 20, 25, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-color);
    text-decoration: none;
}

/* Trends Button */
#trends-btn {
    position: fixed;
    left: 20px;
    bottom: 100px;
    z-index: 100;
    padding: 8px 16px;
    font-size: 12px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: var(--panel-bg);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#trends-btn:hover {
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Trends Panel */
#trends-panel {
    position: fixed;
    left: 20px;
    bottom: 140px;
    width: 220px;
    max-height: 500px;
    z-index: 100;
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

#trends-panel.hidden {
    display: none;
}

#trends-panel.collapsed #trends-content {
    display: none;
}

#trends-panel.collapsed {
    max-height: 48px;
}

#trends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
}

#trends-header h3 {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

#trends-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

#trends-panel:not(.collapsed) #trends-toggle {
    transform: rotate(180deg);
}

#trends-content {
    padding: 12px;
}

/* Section Labels */
.section-label {
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-color);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(74, 158, 255, 0.2);
}

/* Realtime Section */
#realtime-section {
    margin-bottom: 16px;
}

#realtime-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}

.stat-row .stat-label {
    font-size: 10px;
    color: var(--text-muted);
}

.stat-row .stat-value {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-color);
    font-family: 'Space Grotesk', monospace;
}

/* Daily Section */
#daily-section {
    margin-top: 8px;
}

/* Trends Summary Stats */
#trends-summary {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-item .stat-label {
    display: block;
    font-size: 8px;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.stat-item .stat-value {
    display: block;
    font-size: 16px;
    font-weight: 300;
    color: var(--text-color);
}

/* Trends Chart */
#trends-chart {
    width: 100%;
    height: 80px;
    position: relative;
}

#hourly-chart {
    width: 100%;
    height: 100%;
}

/* Hide trends panel on very small screens */
@media (max-width: 400px) {
    #trends-panel {
        width: calc(100% - 40px);
    }
}

/* =============================================================================
   TRENDS OVERLAY - Bottom of screen time visualization
   ============================================================================= */


#trends-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--trends-height);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px 12px;
    background: linear-gradient(180deg, rgba(10, 10, 12, 0.55) 0%, rgba(10, 10, 12, 0.75) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: auto;
    backdrop-filter: blur(10px);
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

#trends-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.trends-title {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: flex-start;
}

.trends-title .title {
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-color);
    opacity: 0.9;
}

.trends-title .subtitle {
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-color);
}

.trends-title .subtitle.connected {
    color: #72e0ff;
}

.trends-title .subtitle.error {
    color: #ff6b6b;
}

.trends-title .subtitle.connecting {
    animation: pulse 1.5s ease-in-out infinite;
}

.trends-now {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.trends-now .now-label {
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}

.trends-now .now-value {
    font-size: 22px;
    font-weight: 500;
    letter-spacing: 1px;
}

.trends-now .now-meta {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.trends-now .now-meta.daily-total {
    color: rgba(255, 255, 255, 0.4);
}

#trends-panels {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}
.behavior-panel {
    gap: 10px;
}

.trend-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(18, 20, 26, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    flex-shrink: 0;
}

.panel-label {
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

#trends-input-canvas {
    width: 100%;
    height: 120px;
    display: block;
}
.behavior-note {
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}
.behavior-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
}

.behavior-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(100, 255, 160, 0.2);
    box-shadow: 0 0 0 rgba(100, 255, 160, 0.3);
    transition: box-shadow 0.3s ease, background 0.3s ease;
}

.behavior-pulse.active {
    background: rgba(100, 255, 160, 0.8);
    box-shadow: 0 0 10px rgba(100, 255, 160, 0.7);
}

.panel-legend {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.engaged {
    background: var(--input-engaged);
}

.legend-dot.passing {
    background: var(--input-passing);
}

.legend-dot.output {
    background: var(--output-avg);
}

.legend-dot.band {
    background: rgba(124, 211, 255, 0.35);
}

.legend-label {
    color: rgba(255, 255, 255, 0.5);
    margin-right: 4px;
}

@media (min-width: 900px) {
    #trends-overlay {
        height: var(--trends-height-desktop);
        padding: 16px 24px 14px;
    }

    #trends-panels {
        flex-direction: row;
    }

    .trend-panel {
        flex: 1;
        min-width: 0;
        flex-shrink: 1;
    }

    #trends-input-canvas {
        height: 100%;
        min-height: 80px;
    }
}

@media (max-width: 600px) {
    #container {
        top: -12vh;
        height: 100vh;
    }

    #trends-overlay {
        height: 48vh;
        padding: 12px 12px 10px;
    }

    .trend-panel {
        padding: 8px;
    }

    .trends-title .title {
        font-size: 11px;
        letter-spacing: 1px;
    }

    .trends-now .now-value {
        font-size: 18px;
    }
}


.behavior-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 10px;
    color: var(--text-muted);
}

.behavior-status {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}

.behavior-status.on {
    color: #b2ffb2;
    background: rgba(100, 255, 160, 0.15);
}

.behavior-trends {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.trend-row {
    display: grid;
    grid-template-columns: 40px 1fr 28px;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
}

.trend-tag {
    letter-spacing: 2px;
}

.trend-tag-value {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    letter-spacing: 1px;
    margin-left: 6px;
}

.trend-bar {
    position: relative;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    display: flex;
}

.trend-seg {
    height: 100%;
}

.trend-seg.engaged {
    background: var(--input-engaged);
}

.trend-seg.passing {
    background: var(--input-passing);
    opacity: 0.7;
}

.trend-count {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.75);
}

.behavior-params {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
}

.param-item {
    display: grid;
    grid-template-columns: 28px 1fr 28px;
    align-items: center;
    gap: 4px;
}

.param-label {
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.param-bar {
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.param-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, rgba(100, 200, 255, 0.6), rgba(100, 255, 200, 0.7));
    transition: width 0.3s ease;
}

.param-fill-global {
    background: linear-gradient(90deg, rgba(255, 180, 100, 0.6), rgba(255, 220, 130, 0.7));
}

.param-val {
    font-size: 8px;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.5);
    min-width: 28px;
    text-align: right;
}

/* Param section labels */
.params-section-label {
    font-size: 8px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 4px;
}

/* Tune summary (Score / Regime / Momentum / Budget / Strategy) */
.tune-summary {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tune-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.tune-stat-label {
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

.tune-stat-value {
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.85);
}

.tune-stat-value.low {
    color: #ff6b6b;
}

/* Top deltas (recent param changes) */
.tune-deltas {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    min-height: 0;
}

.delta-item {
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

.delta-item.delta-up {
    color: rgba(100, 255, 180, 0.85);
    background: rgba(100, 255, 180, 0.1);
}

.delta-item.delta-down {
    color: rgba(255, 140, 100, 0.85);
    background: rgba(255, 140, 100, 0.1);
}

/* V6 gradient indicators (dimmer than deltas) */
.delta-item.grad-item {
    opacity: 0.65;
    font-style: italic;
}

/* =============================================================================
   V6.5 PASSIVE TIER BADGE (quiet / flow / busy)
   Reflects the sidewalk passive traffic tier broadcast by the controller.
   ============================================================================= */

.passive-tier-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.45);
    vertical-align: middle;
}

/* quiet: <2 passive/min — cool blue, subdued */
.passive-tier-badge.tier-quiet {
    color: rgba(130, 175, 225, 0.85);
    background: rgba(90, 140, 220, 0.12);
}

/* flow: 2–10 passive/min — green, matches passing track color */
.passive-tier-badge.tier-flow {
    color: rgba(100, 230, 140, 0.85);
    background: rgba(80, 200, 110, 0.12);
}

/* busy: ≥10 passive/min — amber, V6.5 AWARE mode color */
.passive-tier-badge.tier-busy {
    color: rgba(255, 200, 70, 0.90);
    background: rgba(210, 160, 40, 0.14);
}
