/* =========================================================
   DESIGN TOKENS (light/dark)
   ========================================================= */
:root {
    --bg: radial-gradient(circle at top, #f1f5f9 0%, #cbd5e1 70%);
    --panel: rgba(255, 255, 255, 0.35);
    --text: #0f172a;
    --muted: #475569;
    --border: rgba(148, 163, 184, 0.4);
    --shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
    --axis: rgba(15, 23, 42, 0.35);
    --tooltip-bg: rgba(15, 23, 42, 0.92);
}

body[data-theme="dark"] {
    --bg: radial-gradient(circle at top, #1f2937 0%, #020617 70%);
    --panel: rgba(2, 6, 23, 0.4);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.2);
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    --axis: rgba(203, 213, 225, 0.25);
    --tooltip-bg: rgba(15, 23, 42, 0.92);
}

/* =========================================================
   BASE LAYOUT
   ========================================================= */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    color: var(--text);
    transition: background 0.25s ease, color 0.25s ease;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1.4rem 0;
    overflow: hidden;
}


/* =========================================================
   TOGGLE TEMA
   ========================================================= */
.theme-icon {
    position: fixed;
    top: 14px;
    right: 18px;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    color: var(--text);
    opacity: 0.75;
    z-index: 50;
    transition: transform 0.1s ease, opacity 0.2s ease;
}

.theme-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* =========================================================
   CONTAINER
   ========================================================= */
#container {
    background: var(--panel);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.1rem 1.4rem 1.1rem;
    box-shadow: var(--shadow);
    width: min(100%, 1220px);
    margin: 0 1.2rem 1.2rem;
    position: relative;
}

#title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 0.35rem;
    letter-spacing: 0.03em;
}

#description {
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.7rem;
}

/* =========================================================
   SVG / MAPPA
   ========================================================= */
#chart {
    width: 100%;
    height: auto;
    border-radius: 16px;
}

svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 900px;
    margin-inline: auto;
}

#chart-container {
    width: 100%;
    max-width: 90vw;
    aspect-ratio: 3 / 2;
    margin-inline: auto;
    overflow: visible;
}


/* county */
.county {
    stroke: rgba(15, 23, 42, 0.04);
    stroke-width: 0.4px;
    transition: 0.1s ease-out;
}

.county:hover {
    stroke: rgba(15, 23, 42, 0.7);
    stroke-width: 1.1px;
}

/* bordi stato */
.state-boundary {
    fill: none;
    stroke: rgba(15, 23, 42, 0.5);
    stroke-width: 1px;
    pointer-events: none;
}

/* =========================================================
   TOOLTIP
   ========================================================= */
#tooltip {
    position: absolute;
    background: var(--tooltip-bg);
    color: #e2e8f0;
    padding: 0.55rem 0.7rem 0.45rem;
    border-radius: 8px;
    pointer-events: none;
    font-size: 0.7rem;
    line-height: 1.2;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.04);
    opacity: 0;
    transition: opacity 0.1s ease-out;
    z-index: 9999;
    min-width: 140px;
}

#tooltip strong {
    display: block;
    margin-bottom: 2px;
}

/* =========================================================
   LEGENDA
   ========================================================= */

#legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    margin-top: 0.6rem;
}

#legend svg {
    width: 100%;
    height: 45px;
    display: block;
    max-width: 500px;
    margin: 0.1rem auto 0;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1050px) {
    #container {
        margin: 0.4rem;
    }
}

@media (max-width: 540px) {

    html,
    body {
        overflow: auto;
    }

    #container {
        padding: 0.7rem 0.4rem 0.5rem;
    }

    #description {
        font-size: 0.7rem;
    }
}