/* ============================================================
   Freedom & Resilience Monitor — Stylesheet
   ============================================================ */

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

:root {
    --bg:           #F7F8FA;
    --white:        #FFFFFF;
    --navy:         #1B2A4A;
    --gold:         #C9A84C;
    --steel:        #3B7DD8;
    --text-primary: #1B2A4A;
    --text-secondary: #6B7280;
    --border:       #E5E7EB;
    --shadow:       0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg:    0 4px 24px rgba(0,0,0,0.08);

    --green:  #22A563;
    --amber:  #D4A017;
    --orange: #D97706;
    --red:    #DC2626;

    --font-body:  'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono:  'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    --radius: 12px;
    --radius-sm: 8px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

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

a { color: var(--navy); text-decoration: none; }

/* ----- Header ----- */
.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-link { display: flex; align-items: center; flex-shrink: 0; }
.logo { height: 40px; width: auto; }

.header-titles { display: flex; flex-direction: column; }

.org-name {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--text-secondary);
    text-transform: uppercase;
    line-height: 1.2;
}

.site-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.country-selector select {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--navy);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 32px 6px 12px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.last-update {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ----- Main Content ----- */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

/* ----- Gauges Section ----- */
.gauges-section {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 48px;
    margin-bottom: 32px;
    padding: 40px 24px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 0 1 280px;
}

.gauge-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.gauge-label--freedom { color: var(--gold); }
.gauge-label--resilience { color: var(--steel); }

.gauge-ring {
    position: relative;
    width: 180px;
    height: 180px;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 10;
}

.gauge-arc {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dasharray 1.2s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s;
}

.gauge-arc--freedom { stroke: var(--gold); }
.gauge-arc--resilience { stroke: var(--steel); }

.gauge-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gauge-score {
    font-family: var(--font-mono);
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--navy);
}

.gauge-status {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-top: 4px;
}

.gauge-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.gauge-divider {
    width: 1px;
    height: 200px;
    background: var(--border);
    align-self: center;
    flex-shrink: 0;
}

/* ----- Legend ----- */
.legend-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 28px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

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

/* ----- Trend Section ----- */
.trend-section {
    margin-bottom: 28px;
    padding: 24px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.trend-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}

.trend-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--navy);
    text-transform: uppercase;
}

.trend-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.trend-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.trend-deltas {
    display: flex;
    gap: 12px;
}

.trend-delta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
}

.trend-delta-label {
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--text-secondary);
}

.trend-delta-value.positive { color: var(--green); }
.trend-delta-value.negative { color: var(--red); }
.trend-delta-value.neutral  { color: var(--text-secondary); }

.trend-range-toggle {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg);
    border-radius: 6px;
}

.range-btn {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.range-btn:hover { color: var(--navy); }

.range-btn.active {
    color: var(--navy);
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.trend-chart-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.trend-chart-wrap canvas {
    width: 100%;
    height: auto;
    display: block;
}

@media (max-width: 768px) {
    .trend-header {
        flex-direction: column;
        gap: 12px;
    }

    .trend-controls {
        width: 100%;
        justify-content: space-between;
    }

    .trend-section { padding: 16px; }
}

/* ----- Tab Toggle ----- */
.tab-toggle {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 28px;
    padding: 4px;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.tab-btn {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    padding: 8px 24px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover { color: var(--navy); background: var(--bg); }
.tab-btn.active { color: var(--navy); background: var(--bg); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }

/* ----- Parameters Grid ----- */
.params-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.params-grid.single-freedom .params-column:not(#freedomColumn),
.params-grid.single-resilience .params-column:not(#resilienceColumn) {
    display: none;
}

.params-grid.single-freedom,
.params-grid.single-resilience {
    grid-template-columns: 1fr;
    max-width: 640px;
    margin: 0 auto;
}

.column-header {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-header--freedom { color: var(--gold); }
.column-header--resilience { color: var(--steel); }

.column-icon { font-size: 1rem; }

/* ----- Parameter Card ----- */
.param-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    overflow: hidden;
    border-left: 3px solid var(--border);
    transition: box-shadow 0.2s;
}

.param-card:hover { box-shadow: var(--shadow-lg); }

.param-card[data-level="sterk"]     { border-left-color: var(--green); }
.param-card[data-level="kwetsbaar"] { border-left-color: var(--amber); }
.param-card[data-level="zorgelijk"] { border-left-color: var(--orange); }
.param-card[data-level="kritiek"]   { border-left-color: var(--red); }

.param-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 10px;
    cursor: pointer;
    user-select: none;
}

.param-header:hover { background: rgba(247, 248, 250, 0.5); }

.param-icon { font-size: 1.2rem; flex-shrink: 0; line-height: 1; }

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

.param-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--navy);
    line-height: 1.3;
}

.param-weight {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.param-score {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    flex-shrink: 0;
    min-width: 40px;
    text-align: right;
}

.param-chevron {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: transform 0.3s;
}

.param-card.expanded .param-chevron {
    transform: rotate(180deg);
}

.param-progress-wrap {
    padding: 0 16px 12px;
}

.param-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.param-progress-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----- Sub-indicators ----- */
.param-subs {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.param-card.expanded .param-subs {
    max-height: 1200px;
}

.sub-list {
    padding: 0 16px 16px 44px;
    border-top: 1px solid var(--border);
    background: rgba(247, 248, 250, 0.6);
}

.sub-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(229, 231, 235, 0.5);
}

.sub-item:last-child { border-bottom: none; }

.sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.sub-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--navy);
}

.sub-score {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sub-progress {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 6px;
    overflow: hidden;
}

.sub-progress-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.sub-info {
    font-size: 0.78rem;
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ----- Methodology ----- */
.methodology-section {
    margin-top: 40px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.methodology-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
    background: transparent;
    border: none;
    cursor: pointer;
}

.methodology-toggle:hover { background: var(--bg); }

.methodology-toggle .chevron {
    transition: transform 0.3s;
}

.methodology-section.expanded .methodology-toggle .chevron {
    transform: rotate(180deg);
}

.methodology-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.methodology-section.expanded .methodology-content {
    max-height: 800px;
}

.methodology-inner {
    padding: 0 24px 24px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.methodology-inner h4 {
    color: var(--navy);
    font-size: 0.92rem;
    margin: 16px 0 6px;
}

.methodology-inner h4:first-child { margin-top: 0; }

.methodology-inner p { margin-bottom: 8px; }

.methodology-note {
    background: rgba(201, 168, 76, 0.08);
    border-left: 3px solid var(--gold);
    padding: 10px 14px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-top: 12px;
}

/* ----- Footer ----- */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--white);
    margin-top: 48px;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    text-align: center;
}

.footer-copyright {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 4px;
}

.footer-description {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.footer-contact {
    font-size: 0.78rem;
    margin-bottom: 8px;
}

.footer-contact a {
    color: var(--steel);
    font-weight: 500;
}

.admin-link {
    font-size: 0.68rem;
    color: var(--text-secondary);
    opacity: 0.4;
    transition: opacity 0.2s;
}

.admin-link:hover { opacity: 0.8; }

/* ----- Score Color Utility ----- */
.score-green  { color: var(--green); }
.score-amber  { color: var(--amber); }
.score-orange { color: var(--orange); }
.score-red    { color: var(--red); }

.bg-green  { background: var(--green); }
.bg-amber  { background: var(--amber); }
.bg-orange { background: var(--orange); }
.bg-red    { background: var(--red); }

/* ----- Loading ----- */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.loading-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--navy);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-right {
        align-items: flex-start;
        flex-direction: row;
        gap: 12px;
        align-items: center;
    }

    .site-title { font-size: 1rem; }

    .gauges-section {
        flex-direction: column;
        gap: 24px;
        padding: 24px 16px;
    }

    .gauge-divider {
        width: 80%;
        height: 1px;
        align-self: center;
    }

    .gauge-ring { width: 150px; height: 150px; }

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

    .main-content { padding: 20px 12px 32px; }

    .tab-btn { padding: 8px 16px; font-size: 0.75rem; }

    .legend-bar { gap: 12px; }
    .legend-item { font-size: 0.7rem; }

    .sub-list { padding-left: 16px; }
}

@media (max-width: 480px) {
    .gauge-ring { width: 130px; height: 130px; }
    .gauge-score { font-size: 2rem; }
    .param-name { font-size: 0.82rem; }
    .param-score { font-size: 1.2rem; }
}
