/* ─────────────────────────────────────────────────────────────
   bwired.nl showcase — hoofdstijl (overlay over de huisfoto)
   Externe CSS, volledig responsive (980 / 640 / 420 px breakpoints).
   ───────────────────────────────────────────────────────────── */

:root {
  --solar:    #fbbf24;   /* geel  — zon */
  --grid-in:  #60a5fa;   /* blauw — neutraal net-accent (brand, widget-rand, cards) */
  --grid-out: #34d399;
  --house:    #fb923c;
  --bat-chg:  #4ade80;   /* groen — batterij-accent */
  --bat-dis:  #fb923c;
  --ev:       #3b82f6;   /* blauw — auto */
  --txt:      #f1f5f9;
  --txt-dim:  #aebacb;

  /* Flow-lijn kleuren (energiestroom over de foto) */
  --flow-solar:   #fbbf24; /* geel  — zon → huis */
  --flow-import:  #ef4444; /* rood  — afname van het net */
  --flow-export:  #22c55e; /* groen — teruglevering aan het net */
  --flow-battery: #22c55e; /* groen — batterij laden/ontladen */
  --flow-ev:      #3b82f6; /* blauw — huis → auto */

  --glass-bg:     rgba(12, 20, 33, 0.42);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-blur:   14px;
  --radius:       16px;
  --shadow:       0 8px 32px rgba(0, 0, 0, 0.32);

  --page-bg:  #070c16;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--page-bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, 'Segoe UI', Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Verborgen 'easter-egg' knop (linksboven): klik = volgende achtergrond.
   Onzichtbaar en zonder cursor-hint, maar wel klikbaar. */
#bgCycle {
  position: fixed;
  top: 0; left: 0;
  width: 140px; height: 50px;   /* dekt strak het 'Bwired.nl'-logo → klik op het logo cyclet */
  margin: 0; padding: 0; border: 0;
  background: transparent;
  opacity: 0;
  z-index: 50;
  cursor: pointer;              /* subtiele hint dat het logo klikbaar is */
  -webkit-tap-highlight-color: transparent;
}

/* Lichte anti-rip drempel: data-waarden niet selecteerbaar (cosmetisch) */
.widget, .totals, .topbar {
  -webkit-user-select: none;
  user-select: none;
}

/* ── Stage: de full-screen foto-hero ── */
.stage {
  position: relative;
  width: calc(100% - 32px);
  max-width: 1500px;
  margin: 16px auto 0;
}
/* De foto + overlay (widgets + flows) in vaste 16:9-verhouding; schaalt responsive mee */
.photo {
  position: relative;
  aspect-ratio: 1672 / 941;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 1.2s ease;
  will-change: opacity;
}
.bg-next { opacity: 0; }

/* De achtergrondfoto wordt door JS gezet (public/js/background.js), op basis van
   de centrale config (config/backgrounds.js). De juiste foto wordt server-side
   ge-preload (zie <link rel="preload"> in index.html) voor een snelle weergave. */

/* Tint voor leesbaarheid (donkerder boven + onder) */
.scene-tint {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(4,8,16,0.45) 0%, rgba(4,8,16,0) 22%),
    linear-gradient(to top,    rgba(4,8,16,0.55) 0%, rgba(4,8,16,0) 30%);
  pointer-events: none;
}

.flow-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ── Topbar ── */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;            /* merk + rechterblok bovenaan uitlijnen */
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
}
.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.brand-dot { color: var(--grid-in); }
.topbar-right {
  display: flex;
  flex-direction: column;            /* regel 1 · dunne lijn · strategie-regel */
  align-items: flex-end;
  gap: 6px;
}
.topbar-row1 {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sun-info {
  font-size: 13px;
  color: var(--txt);
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  white-space: nowrap;
}
.sun-ico { color: var(--solar); }

/* Buitenweer in de topbar (zelfde stijl als sun-info) */
.weather-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--txt);
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.wx-item { display: inline-flex; align-items: center; gap: 5px; }
.wx-ico  { font-size: 13px; line-height: 1; }
.wx-uv-ico { color: var(--solar); }

/* Sky-indicator: subtiel bewolking/regen-oordeel in de topbar (sky-analyzer). */
.sky-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--txt-dim);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(10, 20, 36, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.10);
  white-space: nowrap;
}
.sky-indicator.is-empty { display: none; }
.sky-indicator .sky-ico { font-size: 13px; line-height: 1; }

/* Huidige tijd in de topbar (tussen UV en zonsopkomst) */
.clock-info {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--txt);
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.clock-ico { font-size: 12px; line-height: 1; }
.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
}
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #64748b;
  transition: background 0.3s;
}
.status.live .status-dot {
  background: var(--bat-chg);
  box-shadow: 0 0 8px var(--bat-chg);
  animation: pulse 2s infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }

.lang-btn {
  min-width: 38px;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background 0.2s;
}
.lang-btn:hover { background: rgba(30, 44, 66, 0.6); }

/* ── Strategie-regel (2e regel rechtsboven, onder de dunne lijn): Plan + Batterij/Zon/Net inline ── */
.topbar-strategy {
  align-self: stretch;                 /* lijn loopt over de breedte van het rechterblok */
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);  /* de dunne lijn, verdwijnt mét de regel */
  padding-top: 6px;
  font-size: 12px;
  color: var(--txt);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.topbar-strategy.is-empty { display: none; }
.ems-plan { font-weight: 700; color: var(--txt); }
.ems-metric { display: inline-flex; align-items: center; gap: 4px; }
/* scheidingspunt vóór elke metric (na het Plan en tussen de metrics onderling) */
.ems-metric::before { content: '·'; color: var(--txt-dim); margin-right: 4px; }
.ems-row-ico { display: inline-flex; align-items: center; }
.ems-row-ico svg { width: 13px; height: 13px; vertical-align: -2px; }
.ems-grid-ico  { color: var(--grid-in); }  /* net-icoon blauw, net als de andere grid-iconen */
.ems-solar-ico { color: var(--solar); }    /* zon-icoon geel, net als de zon-widget/kaart */
.ems-row-val { font-weight: 600; white-space: nowrap; }

/* ── Zwevende glas-widgets ── */
.widgets {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.widget {
  position: absolute;
  left: calc(var(--ax, 0.5) * 100%);
  top:  calc(var(--ay, 0.5) * 100%);
  /* --ws (door app.js gezet) laat de widget proportioneel met de foto meeschalen */
  transform: translate(-50%, -50%) scale(var(--ws, 1));
  width: 165px;            /* vaste breedte → box springt niet bij wisselende waarde (W ↔ kW) */
  padding: 12px 15px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  pointer-events: auto;
  transition: opacity 0.4s, border-color 0.4s;
}
.widget-dim { opacity: 0.55; }
.w-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--txt-dim);
  text-transform: uppercase;
}
.w-ico { font-size: 14px; }
/* Verticaal batterij-icoon in de batterij-widget */
.w-ico-batt { display: inline-flex; align-items: center; }
.w-ico-batt svg { width: auto; height: 16px; display: block; }
/* SVG-icoontjes in de zon/net-widget (kleur via currentColor van #w-solar/#w-grid) */
.w-ico-svg { display: inline-flex; align-items: center; }
.w-ico-svg svg { width: 15px; height: 15px; display: block; }
.w-value {
  margin-top: 5px;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;       /* waarde nooit afbreken binnen de vaste breedte */
  display: flex;
  align-items: center;
  gap: 8px;
}
.w-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--txt-dim);
  font-variant-numeric: tabular-nums;
}
/* Capaciteitsregel batterij: compact, vlak onder de status */
.w-cap { margin-top: 1px; font-size: 11px; opacity: 0.9; }

/* Accent-randen gas/water-widgets */
#w-gas   { border-top: 2px solid var(--house); }
#w-water { border-top: 2px solid var(--grid-in); }
/* accent-randen per widget */
#w-solar   { border-top: 2px solid var(--solar); }
#w-grid    { border-top: 2px solid var(--grid-in); }
#w-house   { border-top: 2px solid var(--house); }
#w-battery { border-top: 2px solid var(--bat-chg); }
#w-car     { border-top: 2px solid var(--ev); }
#w-solar   .w-ico { color: var(--solar); }
#w-grid    .w-ico { color: var(--grid-in); }
#w-house   .w-ico { color: var(--house); }
#w-battery .w-ico { color: var(--bat-chg); }
#w-car     .w-ico { color: var(--ev); }

/* SOC-balkje in batterij-widget */
.w-soc-bar {
  display: inline-block;
  width: 46px; height: 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  overflow: hidden;
}
.w-soc-fill {
  display: block; height: 100%;
  width: 0%;
  background: var(--bat-chg);
  border-radius: 4px;
  transition: width 0.6s ease, background 0.4s;
}

/* ── Totalen als icon-cards over de foto onderaan (Franse stijl, diffuus glas) ── */
.totals {
  position: absolute;
  left: 0; right: 0; bottom: 16px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 0 18px;
}
.total {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 186px;
  padding: 9px 14px 9px 11px;
  background: rgba(10, 20, 36, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(13px) saturate(140%);
  -webkit-backdrop-filter: blur(13px) saturate(140%);
}
.total-ico {
  flex: 0 0 auto;
  width: 33px;
  height: 33px;
}
.total-ico svg { width: 100%; height: 100%; display: block; }
.total-solar   .total-ico { color: var(--solar); }
.total-grid    .total-ico { color: var(--grid-in); }
.total-battery .total-ico { color: var(--bat-chg); }
.total-house   .total-ico { color: var(--house); }
/* Batterij-kaart: zelfde verticale icoon als het widget; aspect behouden + centreren */
.total-battery .total-ico { display: flex; align-items: center; justify-content: center; }
.total-battery .total-ico svg { width: auto; height: 100%; }
.total-txt { display: flex; flex-direction: column; min-width: 0; }

/* Dubbele kaart: twee regels (label links, waarde rechts) strak onder elkaar */
.total-txt-dual { flex-direction: column; gap: 0; }
.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  line-height: 1.05;
}
.total-row .total-lbl { line-height: 1.1; }
.total-val-sm { margin-top: 0; font-size: 15px; line-height: 1.1; }
.total-lbl {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--txt-dim);
  line-height: 1.25;
}
.total-val {
  margin-top: 3px;
  font-size: 20px;
  font-weight: 700;
  color: var(--txt);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── 24u-grafiek ── */
.chart-card {
  background: var(--page-bg); /* gelijk aan de pagina-achtergrond, zodat de kleur naast de grafiek matcht met naast de foto */
  padding: 8px 0 26px;        /* geen zij-padding: het frame lijnt exact met de foto erboven */
}
/* Titel als overlay op de legenda-regel; JS zet 'left' exact op de plot-start
   (chartArea.left) en 'height' op de legenda-band (chartArea.top). */
.chart-title {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--txt-dim);
  pointer-events: none;
  z-index: 2;
}
/* Sjiek frame om de grafiek — exact dezelfde maten/positie als de foto-stage erboven */
.chart-frame {
  width: calc(100% - 32px);
  max-width: 1500px;
  margin: 0 auto;
  padding: 14px 16px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: rgba(12, 20, 33, 0.45);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.chart-wrap {
  position: relative;
  height: 340px; /* vult het bredere frame mooi uit */
}

/* ─────────────────────────────────────────────────────────────
   Responsive — 1180 (totals onder foto) / 980 / 640 / 420
   ───────────────────────────────────────────────────────────── */

/* 1061–1180px: kaarten iets compacter zodat ze in één rij over de foto blijven passen. */
@media (max-width: 1180px) {
  .total { padding: 9px 12px; gap: 9px; }
  .total-ico { width: 28px; height: 28px; }
  .total-val { font-size: 18px; }
  .total-val-sm { font-size: 14px; }
  .total-lbl { font-size: 10px; }
}

/* Onder ~1060px passen ook de compacte kaarten niet meer over de foto
   → onder de foto plaatsen (ook op desktop), gecentreerd; de kaarten wrappen. */
@media (max-width: 1060px) {
  .totals {
    position: static;
    left: auto; right: auto; bottom: auto;
    margin: 6px auto 0;
    padding: 0 16px;
  }
}

@media (max-width: 980px) {
  :root { --glass-blur: 10px; }
  /* widgets schalen vloeiend mee via --ws (geen harde sprong meer hier) */
  .brand { font-size: 19px; }
  .sun-info { display: none; }
  .weather-info { gap: 9px; font-size: 12px; }
  .topbar-strategy { font-size: 11.5px; }
  .chart-wrap { height: 260px; }
}

/* Onder 760px wordt de topbar krap → buitenweer + strategie-regel verbergen */
@media (max-width: 760px) {
  .weather-info { display: none; }
  .topbar-strategy { display: none; }
  .sky-indicator { display: none; }
}

/* Onder 640px: overlay → foto-banner + verticale kaartstack */
@media (max-width: 640px) {
  .stage { width: 100%; max-width: none; margin: 0; }
  .photo { border-radius: 0; }
  .clock-info { display: none; }

  /* Overlay blijft in de foto, maar de widgets gaan naar de vier hoeken + midden
     (geen overlap met de topbar of met elkaar op een klein scherm). Flows blijven. */
  .widget { width: 104px; padding: 6px 9px; border-radius: 10px;
            transform: none; left: auto; top: auto; right: auto; bottom: auto; }
  #w-solar   { top: 46px; left: 8px; }
  #w-battery { top: 46px; right: 8px; }
  #w-grid    { bottom: 8px; left: 8px; }
  #w-car     { bottom: 8px; right: 8px; }
  #w-house   { top: 52%; left: 50%; transform: translate(-50%, -50%); }
  .w-head { font-size: 9px; gap: 4px; }
  .w-ico { font-size: 10px; }
  .w-value { font-size: 14px; gap: 5px; margin-top: 2px; }
  .w-sub { font-size: 9px; margin-top: 0; }
  #w-gas, #w-water { display: none; } /* secundair — verbergen op smal scherm */
  .w-soc-bar { width: 30px; height: 5px; }

  /* Totaal-cards ONDER de foto (tussen foto en grafiek), full-width nette rij */
  .totals { position: static; gap: 9px; padding: 12px 14px 16px; }
  .total { min-width: 0; flex: 1 1 100%; padding: 12px 15px; gap: 13px; }
  .total-ico { width: 30px; height: 30px; }
  .total-txt { flex: 1; flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }
  /* Dubbele kaarten blijven twee regels strak onder elkaar, ook op mobiel */
  .total-txt-dual { flex-direction: column; align-items: stretch; gap: 0; }
  .total-lbl { font-size: 11px; line-height: 1.2; }
  .total-val { margin-top: 0; font-size: 19px; white-space: nowrap; flex: 0 0 auto; }
  .total-val-sm { font-size: 16px; }
  /* 24u-grafiek: titel + kaart + frame meeschalen op mobiel */
  .chart-card { padding: 10px 0 18px; }
  .chart-frame { padding: 10px 12px 8px; border-radius: 12px; }
  .chart-title { font-size: 11px; }
  .chart-wrap { height: 240px; }
}

@media (max-width: 420px) {
  .topbar { padding: 10px 12px; }
  .brand { font-size: 16px; }
  .chart-card { padding: 8px 0 14px; }
  .chart-frame { padding: 8px 10px 6px; }
  .chart-title { font-size: 10px; letter-spacing: 0.02em; }
  .chart-wrap { height: 200px; }
}

/* Toegankelijkheid: respecteer reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .bg-layer, .w-soc-fill, .widget { transition: none; }
  .status.live .status-dot { animation: none; }
}
