/* California Debt Clock - Styles */

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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --border-color: #2a2a3a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #666680;
    --debt-red: #ff4444;
    --debt-red-glow: rgba(255, 68, 68, 0.3);
    --neutral-blue: #4488ff;
    --gold: #ffd700;
    --state-blue: #3b82f6;
    --state-blue-glow: rgba(59, 130, 246, 0.3);
    --local-orange: #f59e0b;
    --local-orange-glow: rgba(245, 158, 11, 0.3);
    --font-mono: 'Courier New', 'Monaco', 'Consolas', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-bottom: 2px solid var(--gold);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.1em;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    margin-bottom: 0.5rem;
}

header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.header-counter {
    margin-top: 1.5rem;
    padding: 1rem 2rem;
    background: rgba(255, 68, 68, 0.1);
    border: 2px solid var(--debt-red);
    border-radius: 12px;
    display: inline-block;
    box-shadow: 0 0 30px var(--debt-red-glow);
}

.header-counter-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.header-counter-value {
    display: block;
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--debt-red);
    text-shadow: 0 0 20px var(--debt-red-glow);
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Debt Sections */
.debt-section {
    margin-bottom: 2rem;
}

.debt-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-left: 4px solid var(--gold);
    margin-bottom: 1rem;
}

.debt-section.primary h2 {
    font-size: 1.2rem;
    border-left-color: var(--debt-red);
}

/* State Government Section */
.debt-section.state-section h2 {
    border-left-color: var(--state-blue);
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, var(--bg-secondary) 100%);
}

.state-section .metric-box {
    border-color: rgba(59, 130, 246, 0.3);
}

.state-section .metric-box:hover {
    box-shadow: 0 4px 20px var(--state-blue-glow);
}

/* Local Government Section */
.debt-section.local-section h2 {
    border-left-color: var(--local-orange);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, var(--bg-secondary) 100%);
}

.local-section .metric-box {
    border-color: rgba(245, 158, 11, 0.3);
}

.local-section .metric-box:hover {
    box-shadow: 0 4px 20px var(--local-orange-glow);
}

/* Featured totals in state/local sections */
.state-section .metric-box.featured {
    border-color: var(--state-blue);
    box-shadow: 0 0 20px var(--state-blue-glow);
}

.local-section .metric-box.featured {
    border-color: var(--local-orange);
    box-shadow: 0 0 20px var(--local-orange-glow);
}

/* Grid Layout */
.grid,
.primary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

/* Metric Box */
.metric-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    min-width: 0;
}

.metric-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.metric-box.featured {
    border-color: var(--debt-red);
    box-shadow: 0 0 20px var(--debt-red-glow);
}

.metric-box .label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-box .value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    word-break: break-word;
    overflow-wrap: break-word;
}

.metric-box.featured .value {
    font-size: 2rem;
}

/* Value Colors */
.value.debt {
    color: var(--debt-red);
    text-shadow: 0 0 10px var(--debt-red-glow);
}

/* Animated Digits Effect */
.value {
    transition: color 0.1s ease;
}

.value.updating {
    opacity: 0.9;
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 1rem;
    margin-top: 2rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
}

footer .last-updated {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

footer .github-button {
    display: inline-block;
    margin-top: 0.75rem;
    transition: opacity 0.2s ease;
}

footer .github-button:hover {
    opacity: 0.8;
}

footer .github-button img {
    height: 24px;
}

footer .sources {
    margin-bottom: 1.5rem;
}

footer .sources h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

footer .sources ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

footer .sources a {
    color: var(--neutral-blue);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

footer .sources a:hover {
    color: var(--gold);
    text-decoration: underline;
}

footer .disclaimer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

footer .paid-for {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

footer .paid-for {
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer .paid-for a {
    color: var(--text-muted);
    text-decoration: underline;
    transition: color 0.2s ease;
}

footer .paid-for a:hover {
    color: var(--gold);
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.75rem;
    }

    header .subtitle {
        font-size: 0.9rem;
    }

    .header-counter {
        padding: 0.75rem 1.5rem;
    }

    .header-counter-label {
        font-size: 0.75rem;
    }

    .header-counter-value {
        font-size: 1.75rem;
    }

    main {
        padding: 1rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .primary-grid,
    .state-section .grid,
    .local-section .grid {
        grid-template-columns: 1fr;
    }

    .metric-box {
        padding: 0.75rem 1rem;
    }

    .metric-box .value {
        font-size: 1.25rem;
    }

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

    .debt-section h2 {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    footer .sources ul {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.4rem;
        letter-spacing: 0.05em;
    }

    .header-counter-value {
        font-size: 1.5rem;
    }

    .metric-box .label {
        font-size: 0.65rem;
    }

    .metric-box .value {
        font-size: 1rem;
    }

    .metric-box.featured .value {
        font-size: 1.15rem;
    }
}

@media (max-width: 360px) {
    header h1 {
        font-size: 1.2rem;
    }

    .header-counter-value {
        font-size: 1.25rem;
    }

    .metric-box .value {
        font-size: 0.9rem;
    }

    .metric-box.featured .value {
        font-size: 1rem;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .grid,
    .primary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .metric-box {
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .value.debt {
        color: black;
        text-shadow: none;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
a:focus,
button:focus {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Chart Section */
.chart-section {
    margin-top: 2rem;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    height: 400px;
    position: relative;
}

.chart-legend {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 24px;
    height: 4px;
    border-radius: 2px;
}

.legend-color.historical {
    background: var(--debt-red);
}

.legend-color.projected {
    background: #ff8844;
    background: repeating-linear-gradient(
        90deg,
        #ff8844 0px,
        #ff8844 8px,
        transparent 8px,
        transparent 12px
    );
}

.legend-item.current-ratio {
    font-weight: 600;
    color: var(--debt-red);
}

.legend-item.current-ratio span[data-metric] {
    font-family: var(--font-mono);
}

@media (max-width: 768px) {
    .chart-container {
        height: 300px;
        padding: 1rem;
    }

    .chart-legend {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .chart-container {
        height: 250px;
    }

    .chart-legend {
        flex-direction: column;
        gap: 0.5rem;
    }
}
