/* Kleuren komen uit een gevalideerd palet: de zes muntkleuren zijn getoetst op
   kleurenblindheid-scheiding en contrast in zowel licht als donker. Niet
   aanpassen zonder opnieuw te valideren. */

:root {
  color-scheme: light;

  --plane:          #f9f9f7;
  --surface:        #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);

  --up:             #006300;
  --down:           #d03b3b;
  --warning:        #fab219;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;

  --radius: 12px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:          #0d0d0d;
    --surface:        #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255, 255, 255, 0.10);
    --up:             #0ca30c;
    --down:           #d03b3b;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:          #0d0d0d;
  --surface:        #1a1a19;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255, 255, 255, 0.10);
  --up:             #0ca30c;
  --down:           #d03b3b;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 48px;
  background: var(--plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1080px; margin: 0 auto; }

/* ---------- Kop ---------- */

.topbar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 0 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar__sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.ghost-btn {
  appearance: none;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}

.ghost-btn:hover { color: var(--text-primary); border-color: var(--axis); }
.ghost-btn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* ---------- Meldingen ---------- */

.notice {
  margin: 0 0 var(--gap);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: stretch;
  margin-bottom: var(--gap);
}

.hero__primary,
.hero__stats {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.hero__stats {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.hero__value {
  margin: 6px 0 0;
  font-size: clamp(32px, 6vw, 44px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero__delta {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat { min-width: 0; }

.stat__label {
  margin: 0;
  font-size: 12px;
  font-weight: 550;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat__value {
  margin: 6px 0 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.stat__note {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Richting wordt nooit door kleur alleen gedragen: er staat altijd een
   driehoekje en een teken bij. */
.up   { color: var(--up); }
.down { color: var(--down); }

/* ---------- Grafiek ---------- */

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
}

.chart-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.chart-card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chart-card__sub {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.range-group {
  display: flex;
  gap: 2px;
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}

.range-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 6px 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-secondary);
  cursor: pointer;
}

.range-btn:hover { color: var(--text-primary); }
.range-btn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }

.range-btn.is-active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.chart-host {
  position: relative;
  width: 100%;
  height: 300px;
  touch-action: pan-y;
}

.chart-host svg { display: block; width: 100%; height: 100%; overflow: visible; }

.chart-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--text-muted);
}

.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.axis-text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }

.series-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }

.cursor-dot { stroke: var(--surface); stroke-width: 2; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  white-space: nowrap;
  transform: translate(-50%, -100%);
  z-index: 3;
}

.tooltip__time { color: var(--text-muted); font-size: 11px; margin-bottom: 2px; }
.tooltip__value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Munten ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.section-head__hint { margin: 0; font-size: 13px; color: var(--text-muted); }

.coin-list { display: grid; gap: 10px; margin-bottom: 28px; }

.coin {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(88px, 0.9fr) 84px repeat(4, minmax(52px, 0.55fr)) minmax(116px, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.coin:hover { border-color: var(--axis); }
.coin:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.coin.is-active { border-color: var(--axis); box-shadow: inset 3px 0 0 0 var(--coin-color); }

.coin__id { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* Het gekleurde blokje draagt de identiteit; de naam ernaast draagt de betekenis. */
.coin__chip {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--coin-color);
  flex: none;
}

.coin__name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coin__symbol { color: var(--text-muted); font-size: 12px; font-weight: 500; }

.coin__price { font-variant-numeric: tabular-nums; font-weight: 550; }

.coin__spark { width: 84px; height: 30px; }
.coin__spark svg { display: block; width: 100%; height: 100%; }

.coin__change {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.coin__change span {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.coin__holding { text-align: right; font-variant-numeric: tabular-nums; }
.coin__value { font-weight: 600; }
.coin__amount { font-size: 12px; color: var(--text-muted); }
.coin__pnl { font-size: 13px; }

/* ---------- Verdeling ---------- */

.alloc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid;
  gap: 12px;
}

.alloc__row {
  display: grid;
  grid-template-columns: minmax(110px, 160px) 1fr minmax(64px, auto);
  align-items: center;
  gap: 12px;
}

.alloc__name { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.alloc__track { background: var(--plane); border-radius: 4px; height: 12px; overflow: hidden; }
.alloc__bar { height: 100%; background: var(--coin-color); border-radius: 4px; }
.alloc__pct { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* ---------- Opstarten ---------- */

.boot {
  max-width: 1080px;
  margin: 48px auto;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.boot--error { border-left: 3px solid var(--down); text-align: left; }
.boot--error h2 { margin: 0 0 8px; font-size: 16px; color: var(--text-primary); }
.boot--error p { margin: 0 0 16px; color: var(--text-secondary); }

.footer {
  max-width: 1080px;
  margin: 32px auto 0;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- Smal scherm ---------- */

@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }

  .coin {
    grid-template-columns: 1fr auto;
    row-gap: 10px;
  }
  .coin__id { grid-column: 1; }
  .coin__price { grid-column: 2; text-align: right; }
  .coin__spark { grid-column: 1 / -1; width: 100%; height: 40px; }
  .coin__change { text-align: left; }
  .coin__holding {
    grid-column: 1 / -1;
    text-align: left;
    display: flex;
    gap: 10px;
    align-items: baseline;
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  .hero__stats { grid-template-columns: 1fr; }
  .chart-host { height: 240px; }
}
