/*
 * Rekenpagina. De terreinkleuren zijn gevalideerd op kleurenblindheid tegen --surface-1
 * (dataviz-palet, slots oranje/aqua/blauw); aqua heeft minder dan 3:1 contrast, daarom staan
 * er altijd labels en een tabel naast.
 */
:root {
    color-scheme: light;
    --surface-0: #f4f3f0;
    --surface-1: #fcfcfb;
    --border: #dddcd6;
    --grid: #ebeae5;
    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --text-muted: #7a7974;
    --accent: #2a78d6;
    --terrain-uphill: #eb6834;
    --terrain-flat: #1baf7a;
    --terrain-downhill: #2a78d6;
    --terrain-unknown: #a3a29c;
    --raw: #a3a29c;
    --error-bg: #fbeaea;
    --error-border: #e34948;
    --warning-bg: #fdf4e0;
    --warning-border: #eda100;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--surface-0);
}

body { margin: 0; }

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.35rem; margin: 32px 0 4px; }
h3 { font-size: 1.1rem; margin: 28px 0 8px; }
.lead { color: var(--text-secondary); max-width: 70ch; margin: 0 0 20px; }
.subtitle { color: var(--text-secondary); margin: 0 0 16px; }

.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

/* Formulier */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field-row { display: flex; flex-wrap: wrap; gap: 0 24px; margin-left: 26px; }
.field-row .field { width: 170px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0 24px; }
.input-unit { display: flex; align-items: center; gap: 6px; }
.input-unit input { width: 100px; }
.unit { color: var(--text-secondary); }
input[type="number"], input[type="file"] {
    font: inherit;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
}
.help { color: var(--text-muted); font-size: 0.87rem; margin: 4px 0 0; max-width: 75ch; }
.has-error input { border-color: var(--error-border); }
.field-error { color: #b3261e; font-size: 0.87rem; margin: 4px 0 0; }

fieldset.methods { border: 0; padding: 0; margin: 20px 0 8px; }
fieldset.methods legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.method { margin-bottom: 6px; }
.radio, .checkbox { display: flex; align-items: baseline; gap: 8px; cursor: pointer; }
.formula { color: var(--text-secondary); font-size: 0.9rem; }

details.advanced {
    margin: 16px 0;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
details > summary { cursor: pointer; font-weight: 600; }
details.advanced[open] > summary { margin-bottom: 8px; }
details .checkbox { margin-top: 4px; }

button[type="submit"] {
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    padding: 9px 20px;
    cursor: pointer;
}
button[type="submit"]:hover { filter: brightness(0.92); }
button[type="submit"].secondary {
    color: var(--accent);
    background: var(--surface-1);
    border: 1px solid var(--accent);
    padding: 6px 14px;
}
button[type="submit"].secondary:hover { filter: none; background: #eef4fc; }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }

/* Meldingen */
.message { border-left: 4px solid; border-radius: 4px; padding: 10px 14px; margin: 20px 0; }
.message ul { margin: 4px 0 0; padding-left: 20px; }
.message.error { background: var(--error-bg); border-color: var(--error-border); }
.message.warning { background: var(--warning-bg); border-color: var(--warning-border); }

/* Samenvatting */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tile {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
}
.tile-label { color: var(--text-secondary); font-size: 0.87rem; }
.tile-value { font-size: 1.45rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile.hero .tile-value { font-size: 2rem; }
.tile-note { color: var(--text-muted); font-size: 0.87rem; }
.disclaimer { color: var(--text-muted); font-size: 0.87rem; margin: 8px 0 20px; }

/* Tabellen */
table { border-collapse: collapse; background: var(--surface-1); font-variant-numeric: tabular-nums; }
th, td { padding: 5px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
thead th { font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; border-bottom: 1px solid var(--border); }
tfoot th { border-top: 1px solid var(--border); border-bottom: 0; }
.num { text-align: right; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-scroll table { width: 100%; }
.terrain-totals { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 20px; }
tr.boundary td { background: #f0f5fc; }

.swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: baseline;
}
.terrain-UPHILL { background: var(--terrain-uphill); }
.terrain-FLAT { background: var(--terrain-flat); }
.terrain-DOWNHILL { background: var(--terrain-downhill); }
.terrain-UNKNOWN { background: var(--terrain-unknown); }
.swatch.raw { background: var(--raw); height: 2px; vertical-align: middle; }

/* Grafiek */
.chart {
    margin: 0;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px 10px;
}
.chart figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.chart-title { font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-secondary); font-size: 0.9rem; }
.chart-canvas { position: relative; height: 320px; }

.diagnostics { margin-top: 24px; }
.diagnostics .table-scroll { max-height: 600px; overflow-y: auto; margin-top: 8px; }
