/* ═══════════════════════════════════════════════════════════════════════
   Woningmeting — trend- en verdelingscomponenten
   Hoort bij app/static/js/ar-trends.js
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    /* Serielijnen. Petrol voorop, daarna staal, mos en oker: vier tinten die
       ook naast elkaar in grijstinten nog uit elkaar te houden zijn. */
    --ar-serie-0: #0E6B72;
    --ar-serie-1: #B5780A;
    --ar-serie-2: #3D6E96;
    --ar-serie-3: #7A5C8E;

    --ar-tr-staaf: #9DCACD;
    --ar-tr-raster: #E4EAEE;
    --ar-tr-ref: #8B9AA4;
    --ar-tr-rest: #E9ECEF;
    --ar-tr-spoor: #EEF1F3;
}

[data-bs-theme="dark"] {
    --ar-serie-0: #4FBCC2;
    --ar-serie-1: #E0A33A;
    --ar-serie-2: #79A6CE;
    --ar-serie-3: #B295C6;

    --ar-tr-staaf: #2F6165;
    --ar-tr-raster: #26333D;
    --ar-tr-ref: #6B7C88;
    --ar-tr-rest: #222C34;
    --ar-tr-spoor: #1A232A;
}

/* ── Gedeeld ────────────────────────────────────────────────────────── */
.ar-tr { display: flex; flex-direction: column; gap: 0.5rem; }

.ar-tr-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.ar-tr-raster { stroke: var(--ar-tr-raster); stroke-width: 1; }
.ar-tr-aslabel {
    font-size: 11px;
    fill: var(--ar-text-muted);
    font-variant-numeric: tabular-nums;
}
.ar-tr-lijn { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ar-tr-punt { stroke: var(--ar-bg-card); stroke-width: 1.5; }
.ar-tr-staaf { fill: var(--ar-tr-staaf); }
.ar-tr-ref { stroke: var(--ar-tr-ref); stroke-width: 1.4; stroke-dasharray: 5 4; }
.ar-tr-reflabel { font-size: 10.5px; fill: var(--ar-tr-ref); }

.ar-tr-legenda {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.9rem;
    font-size: 0.74rem;
    color: var(--ar-text-muted);
}
.ar-tr-legenda span { display: inline-flex; align-items: center; gap: 0.34rem; }
.ar-tr-legenda i {
    width: 12px;
    height: 3px;
    border-radius: 2px;
    flex: 0 0 auto;
}

.ar-tr-bron {
    font-size: 0.72rem;
    color: var(--ar-text-muted);
}

/* ── Rangbadge ──────────────────────────────────────────────────────── */
.ar-tr-rang {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.08rem 0.42rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--ar-secondary-light);
    color: var(--ar-text-muted);
}
.ar-tr-rang em {
    font-style: normal;
    font-weight: 500;
    opacity: 0.72;
    font-variant-numeric: tabular-nums;
}
.ar-tr-rang-neutraal { background: var(--ar-secondary-light); color: var(--ar-text-muted); }
.ar-tr-rang-hoog  { background: var(--ar-goed-soft);   color: var(--ar-goed); }
.ar-tr-rang-boven { background: var(--ar-petrol-soft); color: var(--ar-petrol); }
.ar-tr-rang-onder { background: var(--ar-let-soft);    color: var(--ar-let); }
.ar-tr-rang-laag  { background: var(--ar-hoog-soft);   color: var(--ar-hoog); }

/* ── Verschuiving: twee verdelingen ─────────────────────────────────── */
.ar-tr-vs { display: flex; flex-direction: column; gap: 0.3rem; }
.ar-tr-vs-rij {
    display: grid;
    grid-template-columns: 3.1rem 1fr;
    gap: 0.5rem;
    align-items: center;
}
.ar-tr-vs-rij .jr {
    font-size: 0.72rem;
    color: var(--ar-text-muted);
    font-variant-numeric: tabular-nums;
}
.ar-tr-vs-rij .bk {
    display: flex;
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--ar-tr-rest);
}
.ar-tr-vs-rij .bk span { display: block; height: 100%; }
.ar-tr-vs-rij .bk .rest { background: var(--ar-tr-rest); }

.ar-tr-vs-delta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.7rem;
    font-size: 0.72rem;
    color: var(--ar-text-muted);
}
.ar-tr-vs-d { display: inline-flex; align-items: center; gap: 0.3rem; }
.ar-tr-vs-d i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}
.ar-tr-vs-d b { font-variant-numeric: tabular-nums; }
.ar-tr-vs-d.op b   { color: var(--ar-hoog); }
.ar-tr-vs-d.neer b { color: var(--ar-goed); }

/* ── Bulletchart ────────────────────────────────────────────────────── */
.ar-tr-bl { display: flex; flex-direction: column; gap: 0.45rem; }
.ar-tr-bl-rij {
    display: grid;
    grid-template-columns: minmax(74px, 24%) 1fr auto;
    gap: 0.55rem;
    align-items: center;
    font-size: 0.76rem;
}
.ar-tr-bl-rij .nm {
    color: var(--ar-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ar-tr-bl-rij .tr {
    position: relative;
    height: 15px;
    border-radius: 3px;
    background: var(--ar-tr-spoor);
}
.ar-tr-bl-rij .fl {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--ar-goed);
    transition: width .5s ease;
}
.ar-tr-bl-rij.over .fl { background: var(--ar-let); }

.ar-tr-norm {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: var(--ar-text);
    border-radius: 1px;
}
.ar-tr-norm.tweede { background: var(--ar-text-light); }
.ar-tr-norm em {
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%);
    font-style: normal;
    font-size: 0.6rem;
    line-height: 1;
    color: var(--ar-text-muted);
    white-space: nowrap;
}
.ar-tr-bl-rij .vl {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ar-tr-bl-rij.over .vl { color: var(--ar-let); }
.ar-tr-bl-rij .vh {
    display: block;
    font-weight: 500;
    font-size: 0.68rem;
    color: var(--ar-text-muted);
}

/* De normlabels hebben lucht boven de eerste rij nodig. */
.ar-tr-bl { padding-top: 0.6rem; }

/* ── Divergerende balken ────────────────────────────────────────────── */
.ar-tr-dv { display: flex; flex-direction: column; gap: 0.34rem; }
.ar-tr-dv-kop {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--ar-text-light);
    padding: 0 0 0.1rem;
}
.ar-tr-dv-rij {
    display: grid;
    grid-template-columns: minmax(88px, 30%) 1fr auto;
    gap: 0.55rem;
    align-items: center;
    font-size: 0.76rem;
}
.ar-tr-dv-rij .nm {
    color: var(--ar-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ar-tr-dv-rij .tr {
    position: relative;
    height: 14px;
    background: var(--ar-tr-spoor);
    border-radius: 3px;
}
.ar-tr-dv-rij .fl {
    position: absolute;
    top: 0;
    height: 100%;
    transition: width .5s ease;
}
.ar-tr-dv-rij .fl.pos { background: var(--ar-goed); border-radius: 0 3px 3px 0; }
.ar-tr-dv-rij .fl.neg { background: var(--ar-hoog); border-radius: 3px 0 0 3px; }
.ar-tr-dv-rij .nul {
    position: absolute;
    left: 50%;
    top: -2px;
    bottom: -2px;
    width: 1px;
    background: var(--ar-border);
}
.ar-tr-dv-rij .vl {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.ar-tr-dv-rij .vl.pos { color: var(--ar-goed); }
.ar-tr-dv-rij .vl.neg { color: var(--ar-hoog); }

/* ── Kruistabel ─────────────────────────────────────────────────────── */
.ar-tr-mx { display: flex; flex-direction: column; gap: 0.3rem; }
.ar-tr-mx-rij {
    display: grid;
    grid-template-columns: minmax(96px, 34%) repeat(auto-fit, minmax(0, 1fr));
    gap: 0.4rem;
    align-items: stretch;
}
.ar-tr-mx-rij .lb {
    font-size: 0.74rem;
    color: var(--ar-text-muted);
    align-self: center;
}
.ar-tr-mx-rij.kop .cl {
    font-size: 0.7rem;
    color: var(--ar-text-light);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ar-tr-mx .cel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 5px;
    background: var(--ar-tr-spoor);
    overflow: hidden;
}
/* De vulling loopt van onderaf omhoog, evenredig met de waarde. */
.ar-tr-mx .cel::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--ar-tr-vul, 0%);
    background: var(--ar-petrol-soft);
}
.ar-tr-mx .cel.accent::before { background: var(--ar-let-soft); }
.ar-tr-mx .cel b {
    position: relative;
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}
.ar-tr-mx .cel.accent b { color: var(--ar-let); }

/* ── Gepaarde balken ────────────────────────────────────────────────── */
.ar-tr-gp { display: flex; flex-direction: column; gap: 0.4rem; }
.ar-tr-gp-rij {
    display: grid;
    grid-template-columns: minmax(88px, 30%) 1fr auto;
    gap: 0.55rem;
    align-items: center;
    font-size: 0.76rem;
}
.ar-tr-gp-rij .nm {
    color: var(--ar-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ar-tr-gp-rij .tr {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ar-tr-gp-rij .fl {
    display: block;
    height: 7px;
    border-radius: 2px;
    transition: width .5s ease;
}
.ar-tr-gp-rij .fl.a { background: var(--ar-serie-0); }
.ar-tr-gp-rij .fl.b { background: var(--ar-serie-2); opacity: 0.55; }
.ar-tr-gp-rij .vl {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Klein scherm ───────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    .ar-tr-bl-rij,
    .ar-tr-dv-rij,
    .ar-tr-gp-rij {
        grid-template-columns: minmax(64px, 34%) 1fr auto;
        font-size: 0.72rem;
    }
    .ar-tr-mx-rij { grid-template-columns: minmax(70px, 38%) repeat(auto-fit, minmax(0, 1fr)); }
    .ar-tr-vs-rij { grid-template-columns: 2.6rem 1fr; }
    .ar-tr-norm em { display: none; }
}

/* Geen bewegingen voor wie daar last van heeft. */
@media (prefers-reduced-motion: reduce) {
    .ar-tr-bl-rij .fl,
    .ar-tr-dv-rij .fl,
    .ar-tr-gp-rij .fl { transition: none; }
}
