/**
 * Civic Signals — City Health Metrics
 * Bloomberg Terminal aesthetic: clean, minimal, data-forward
 */

/* ============================================================================
   Page Layout
   ============================================================================ */

.signals-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

.signals-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.signals-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 0.5rem;
}

.signals-subtitle {
    font-size: 0.9rem;
    color: #718096;
    margin: 0;
    line-height: 1.5;
}

/* ============================================================================
   Loading State
   ============================================================================ */

.signals-loading {
    text-align: center;
    padding: 3rem 0;
    color: #718096;
}

.signals-loading-pulse {
    width: 40px;
    height: 4px;
    background: #e2e8f0;
    margin: 0 auto 1rem;
    border-radius: 2px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* ============================================================================
   Metric Cards
   ============================================================================ */

.signals-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: #e2e8f0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.metric-card {
    background: #fff;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    transition: background 0.15s;
}

.metric-card:hover {
    background: #f7fafc;
}

.metric-card.expanded {
    background: #f7fafc;
}

/* Card header row */
.metric-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.metric-label {
    flex: 1;
    min-width: 0;
}

.metric-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0;
}

.has-children-indicator {
    color: #a0aec0;
    font-size: 0.7rem;
    margin-left: 0.25rem;
    transition: transform 0.2s;
    display: inline-block;
}

.metric-card.expanded .has-children-indicator {
    transform: rotate(90deg);
}

.metric-category {
    font-size: 0.7rem;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* Big number */
.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a202c;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.metric-unit {
    font-size: 0.7rem;
    font-weight: 400;
    color: #a0aec0;
    margin-left: 0.25rem;
}

.metric-year {
    font-size: 0.7rem;
    color: #a0aec0;
    margin-left: 0.25rem;
}

/* Trend indicator — direction-aware coloring */
.metric-trend {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Direction-based: good = succeeding, bad = needs work */
.metric-trend.good { color: #38a169; }
.metric-trend.bad { color: #e53e3e; }
.metric-trend.neutral { color: #4a5568; }
.metric-trend.flat { color: #a0aec0; }

/* Legacy compat (remove after full deploy) */
.metric-trend.up { color: #e53e3e; }
.metric-trend.down { color: #38a169; }
.metric-trend.up.neutral { color: #4a5568; }
.metric-trend.down.neutral { color: #4a5568; }

.trend-arrow {
    font-size: 0.7rem;
}

/* Sparkline canvas */
.metric-sparkline {
    flex-shrink: 0;
}

.metric-sparkline canvas {
    display: block;
}

/* ============================================================================
   Expanded Detail
   ============================================================================ */

.metric-detail {
    display: none;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.metric-card.expanded .metric-detail {
    display: block;
}

.metric-description {
    font-size: 0.85rem;
    color: #4a5568;
    line-height: 1.6;
    margin: 0 0 1rem;
}

/* Full chart */
.metric-chart-container {
    position: relative;
    margin-bottom: 1rem;
}

.metric-chart-container canvas {
    display: block;
    width: 100%;
}

/* Chart tooltip */
.chart-tooltip {
    position: absolute;
    background: #1a202c;
    color: #fff;
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    transform: translate(-50%, -100%);
    margin-top: -8px;
    z-index: 10;
    display: none;
    font-variant-numeric: tabular-nums;
}

/* Source citation */
.metric-source {
    font-size: 0.75rem;
    color: #a0aec0;
    margin: 0;
}

.metric-source a {
    color: #718096;
    text-decoration: underline;
}

.metric-source a:hover {
    color: #4a5568;
}

/* ============================================================================
   Sub-metric (Children) Breakdown
   ============================================================================ */

.metric-children {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px dashed #e2e8f0;
}

.metric-children-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a0aec0;
    margin-bottom: 0.75rem;
}

.metric-children-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.metric-child-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.75rem;
}

.child-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.child-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a202c;
    font-variant-numeric: tabular-nums;
}

.child-trend {
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.child-trend.good { color: #38a169; }
.child-trend.bad { color: #e53e3e; }
.child-trend.neutral { color: #4a5568; }

/* ============================================================================
   Vote Links
   ============================================================================ */

.metric-votes {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px dashed #e2e8f0;
}

.metric-votes-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a0aec0;
    margin-bottom: 0.75rem;
}

.metric-votes-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-vote-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: border-color 0.15s;
}

.metric-vote-item:hover {
    border-color: #a0aec0;
}

.vote-impact-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.vote-impact-badge.impact-increase {
    background: #fed7d7;
    color: #c53030;
}

.vote-impact-badge.impact-decrease {
    background: #c6f6d5;
    color: #276749;
}

.vote-impact-badge.impact-funding {
    background: #e9d8fd;
    color: #553c9a;
}

.vote-impact-badge.impact-policy {
    background: #bee3f8;
    color: #2a4365;
}

.vote-info {
    flex: 1;
    min-width: 0;
}

.vote-title {
    font-weight: 500;
    color: #2d3748;
}

.vote-note {
    font-size: 0.75rem;
    color: #718096;
    margin-top: 2px;
}

.vote-amount {
    font-weight: 600;
    color: #2d3748;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.vote-fy {
    font-size: 0.7rem;
    color: #a0aec0;
    white-space: nowrap;
}

/* ============================================================================
   Error State
   ============================================================================ */

.signals-error {
    text-align: center;
    padding: 3rem 0;
    color: #e53e3e;
}

.signals-error a {
    color: #4a5568;
    text-decoration: underline;
}

/* ============================================================================
   Housing Ownership Map
   ============================================================================ */

.signals-map-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #e2e8f0;
}

.signals-map-heading {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 0.5rem;
}

.signals-map-desc {
    font-size: 0.875rem;
    color: #718096;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.signals-map-container {
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #0a0a0a;
}

.signals-map-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.signals-map-source {
    font-size: 0.7rem;
    color: #a0aec0;
    margin-top: 0.5rem;
}

/* Mobile stats view for map — hidden on desktop */
.signals-map-stats-mobile {
    display: none;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.signals-map-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #e2e8f0;
}

.signals-map-stat {
    background: #fff;
    padding: 1rem;
    text-align: center;
}

.signals-map-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a202c;
    font-variant-numeric: tabular-nums;
}

.signals-map-stat-label {
    display: block;
    font-size: 0.65rem;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

.signals-map-open-btn {
    display: block;
    text-align: center;
    padding: 0.875rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: #2d3748;
    text-decoration: none;
    transition: background 0.15s;
}
.signals-map-open-btn:hover {
    background: #1a202c;
    color: #fff;
    text-decoration: none;
}

/* ============================================================================
   Footer
   ============================================================================ */

.signals-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.signals-footer p {
    font-size: 0.75rem;
    color: #a0aec0;
    line-height: 1.6;
}

.signals-footer a {
    color: #718096;
    text-decoration: underline;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 600px) {
    .signals-page {
        padding: 0 1rem 2rem;
    }

    .metric-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .metric-label {
        width: 100%;
    }

    .metric-value {
        font-size: 1.5rem;
    }

    .metric-sparkline canvas {
        width: 100px;
        height: 30px;
    }

    .metric-chart-container canvas {
        height: 200px;
    }

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

    .metric-vote-item {
        flex-wrap: wrap;
    }

    .signals-map-stats-mobile {
        display: block;
    }
    .signals-map-container {
        display: none;
    }
}
