/* ─────────────────────────────────────────────────────────────
   menu.css — verticale glas-navigatierail + uitleg-pagina's
   Rail: groot scherm = icoon + tekst · kleiner = alleen iconen · mobiel = balk onder.
   Sluit aan op de variabelen uit style.css (--glass-*, --radius, accenten).
   ───────────────────────────────────────────────────────────── */

:root { --rail-w: 196px; }

/* Content krijgt ruimte naast de (fixed) rail. */
body { padding-left: var(--rail-w); }

/* Pagina-scrollbar onzichtbaar maken (scrollen blijft werken) — net als de EMS-pagina,
   zodat home/Davis/alle pagina's geen dikke OS-scrollbar tonen. */
html, body { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ── Rail ── */
.rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--rail-w);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 16px 12px;
  background: rgba(8, 14, 24, 0.66);
  border-right: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  overflow-y: auto;
  overflow-x: hidden;
}
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .rail { background: #0c1422; }
}

.rail-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 16px;
  font-size: 1.18rem; font-weight: 600; letter-spacing: 0.01em;
  color: var(--txt); text-decoration: none; white-space: nowrap;
}
.rail-brand .brand-dot { color: var(--grid-in); }
.rail-brand-mark { width: 28px; height: 28px; flex: none; color: var(--grid-in); display: inline-flex; }
.rail-brand-mark .logo-mark { width: 100%; height: 100%; }

.rail-nav { display: flex; flex-direction: column; gap: 4px; }

.rail-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--txt-dim);
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease;
}
.rail-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--txt); }
.rail-item.is-inactive { cursor: pointer; }   /* nog niet actief: klikbaar, maar geen navigatie */
.rail-ico { width: 22px; height: 22px; flex: none; color: var(--accent, var(--grid-in)); display: inline-flex; }
.rail-ico svg { width: 100%; height: 100%; }
.rail-lbl { font-size: 0.95rem; font-weight: 500; white-space: nowrap; }
.rail-item.is-active {
  color: var(--txt);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .rail-item.is-active { background: rgba(96, 165, 250, 0.16); }
}

/* Sub-items (children, bv. onder 'Uitleg') */
.rail-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 2px 18px; }
.rail-item.is-sub { min-height: 36px; padding: 7px 12px; }
.rail-item.is-sub .rail-ico { width: 18px; height: 18px; }
.rail-item.is-sub .rail-lbl { font-size: 0.88rem; }

.rail-foot { margin-top: auto; padding-top: 12px; }
.lang-btn {
  width: 100%;
  min-height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--txt);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.1); }

/* ── Uitleg-/contentpagina ── */
.page-body { min-height: 100vh; }
/* ÉÉN gedeeld frame voor ALLE pagina's (Zon/Net/EMS/Rapport/Davis/Uitleg): vaste
   max-breedte 1500px, gecentreerd — EXACT zoals de home-scène (.stage). Zo blijft de
   inhoud bij maximaliseren netjes in het midden staan (geen meeschuiven) en hebben
   alle pagina's identieke maten. Pagina-specifieke breedte-overrides bestaan NIET. */
.page { padding: clamp(16px, 3vw, 26px) 0 56px; }
.page-inner { max-width: 1500px; margin: 0 auto; }
/* Op smalle schermen wat ademruimte zodat content niet tegen de schermrand plakt. */
@media (max-width: 640px) { .page { padding-left: 12px; padding-right: 12px; } }
/* Lange uitleg-tekst houdt een leesbare regelbreedte binnen het brede frame. */
.doc .md { max-width: 82ch; }

.doc {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  padding: clamp(22px, 4vw, 40px);
}
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .doc { background: #0e1828; }
}
.doc-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.doc-ico { width: 30px; height: 30px; color: var(--accent, var(--grid-in)); display: inline-flex; flex: none; }
.doc-ico svg { width: 100%; height: 100%; }
.doc-head h1, .doc-shead h2 { margin: 0; font-weight: 600; }
.doc-head h1 { font-size: clamp(1.5rem, 4vw, 2rem); }

.doc-section { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--glass-border); }
.doc-shead { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.doc-shead h2 { font-size: 1.3rem; }

/* Markdown-typografie */
.md { color: var(--txt); line-height: 1.7; font-size: 1rem; }
.md h2 { font-size: 1.25rem; font-weight: 600; margin: 1.4em 0 0.5em; }
.md h3 { font-size: 1.08rem; font-weight: 600; margin: 1.2em 0 0.4em; }
.md p, .md li { margin: 0.6em 0; color: #d4dceb; }
.md ul, .md ol { margin: 0.7em 0; padding-left: 1.4em; }
.md strong { color: var(--txt); font-weight: 600; }
.md em { font-style: italic; color: #c2cde0; }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; background: rgba(255, 255, 255, 0.08); padding: 1px 6px; border-radius: 6px; }
.md a { color: var(--grid-in); }
.md hr { border: 0; border-top: 1px solid var(--glass-border); margin: 1.6em 0; }
.doc-live { margin-top: 28px; }
.doc-live a { color: var(--grid-in); text-decoration: none; font-weight: 500; }
.doc-live a:hover { text-decoration: underline; }

/* ── EMS-pagina (Bwired Energie Management System) — read-only dashboard ── */
.ems { display: flex; flex-direction: column; gap: 18px; }
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .ems-card { background: #0e1828; }
}
/* EMS-kop in Davis-stijl: compacte titel + status-subregel, GEEN card/panel, geen
   icoon. Titel 1.4rem ≈ de Davis-titel (1.6rem @ root 14px). Scoped onder .ems-embed
   zodat de ems.css-reset (die ná menu.css laadt) de spacing niet nult. */
.ems-embed .ems-headbar { margin: 0 0 16px; padding: 0; }
.ems-embed .ems-headbar h1.ems-hero-title { margin: 0; font-size: 1.4rem; font-weight: 600; line-height: 1.2; }
.ems-embed .ems-head-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.ems-hero-title .hl { color: var(--grid-in); }   /* hoofdletters B·E·M·S blauw */
/* Het 3090-dashboardgrid capt zichzelf op 1400px gecentreerd → cards spronген in en
   stonden smaller dan de titel/home. Vol laten vullen + links uitlijnen op de titel. */
.ems-embed .main-grid { max-width: none; margin: 0; padding-left: 0; padding-right: 0; }
.ems-intro { margin: 0; color: #c2cde0; line-height: 1.6; max-width: 70ch; }

/* Read-only bron-status (vervangt de aan/uit-schakelaar op de EMS-pagina) */
.source-state-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.source-state-dot.is-on { background: #3fb950; box-shadow: 0 0 6px rgba(63, 185, 80, 0.6); }
.source-state-dot.is-off { background: #6e7681; }

/* EMS/Rapport gebruiken hetzelfde gedeelde frame als alle andere pagina's (.page).
   .ems-embed heeft een eigen donkere achtergrond die afweek van de pagina → gaf een
   zichtbaar kader ("lijn om alles heen"). Transparant maken zodat het naadloos is. */
/* Zelfde zij-ademruimte als Davis (.main 24px) en home, zodat EMS/rapport niet tegen
   de menulijn plakken als het scherm < 1500px wordt. Geldt voor titel én content. */
body[data-page="ems"] .ems-embed,
body[data-page="ems-rapport"] .ems-embed,
body[data-page="water"] .ems-embed { background: transparent; padding-left: 24px; padding-right: 24px; }
body[data-page="ems-rapport"] .ems-embed .rm { padding-top: 0; }

/* Davis = weerstation-dashboard in een geïsoleerde iframe; vult naadloos de breedte
   en de resterende hoogte. Geen radius/eigen achtergrond → geen zichtbaar paneelkader. */
.davis-page { width: 100%; }
.davis-frame { display: block; width: 100%; height: calc(100vh - clamp(16px, 3vw, 26px) - 56px); min-height: 460px; border: 0; border-radius: 0; background: transparent; }
@media (max-width: 640px) { .davis-frame { height: calc(100vh - clamp(16px, 3vw, 26px) - 56px - 60px); } }
/* Water heeft een bwired-kop bóven de iframe → iframe-hoogte minus de kop (~52px). */
.water-frame { height: calc(100vh - clamp(16px, 3vw, 26px) - 56px - 52px); }
@media (max-width: 640px) { .water-frame { height: calc(100vh - clamp(16px, 3vw, 26px) - 56px - 60px - 52px); } }

.ems-status { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ems-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border);
  border-radius: 999px; padding: 6px 13px; font-size: 0.9rem; color: var(--txt);
}
.ems-chip-lbl { color: var(--txt-dim); }
.ems-dryrun { background: rgba(251, 191, 36, 0.16); border-color: rgba(251, 191, 36, 0.45); color: var(--solar); font-weight: 600; }
.ems-live { display: inline-flex; align-items: center; gap: 7px; font-size: 0.85rem; color: var(--txt-dim); margin-left: auto; }
.ems-live .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; }
.ems-live.is-live .status-dot { background: var(--grid-out); box-shadow: 0 0 8px var(--grid-out); }

.ems-card {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
  padding: clamp(16px, 3vw, 24px);
}
.ems-card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.15rem; font-weight: 600; }
.ems-card-ico { width: 22px; height: 22px; color: var(--grid-in); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex: none; }
.ems-card-ico svg { width: 100%; height: 100%; }

.ems-p1 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ems-phase { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--glass-border); border-radius: 12px; padding: 12px; text-align: center; }
.ems-phase-lbl { display: block; color: var(--txt-dim); font-size: 0.82rem; margin-bottom: 4px; }
.ems-phase-val { font-size: 1.05rem; font-weight: 600; }
.ems-phase-val.is-import { color: var(--flow-import); }
.ems-phase-val.is-export { color: var(--grid-out); }
.ems-p1-total { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--glass-border); color: var(--txt-dim); }
.ems-p1-total strong { color: var(--txt); font-size: 1.1rem; }

.ems-price { display: flex; align-items: baseline; gap: 6px; }
.ems-price-val { font-size: 2rem; font-weight: 700; color: var(--solar); }
.ems-price-unit { color: var(--txt-dim); }

.ems-bats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.ems-bat { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--glass-border); border-radius: 14px; padding: 14px; }
.ems-bat-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ems-bat-name { font-weight: 600; }
.ems-bat-mode { font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: var(--txt-dim); }
.ems-mode-charge { background: rgba(74, 222, 128, 0.16); color: var(--bat-chg); }
.ems-mode-discharge { background: rgba(251, 146, 60, 0.16); color: var(--bat-dis); }
.ems-bat-soc { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ems-bat-socbar { flex: 1; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.ems-bat-socfill { display: block; height: 100%; background: var(--bat-chg); border-radius: 4px; transition: width 0.4s ease; }
.ems-bat-socval { font-weight: 600; min-width: 42px; text-align: right; }
.ems-bat-foot { display: flex; flex-direction: column; gap: 3px; }
.ems-bat-pw { font-weight: 600; color: var(--txt); }
.ems-bat-reason { font-size: 0.8rem; color: var(--txt-dim); line-height: 1.4; }
.ems-waiting { text-align: center; color: var(--txt-dim); padding: 20px; }
@media (max-width: 520px) {
  .ems-p1 { grid-template-columns: 1fr; }
  .ems-live { margin-left: 0; width: 100%; }
}

/* ── Tweetalig: toon de tekst van de actieve taal (html[lang] door i18n gezet) ── */
[data-lang-content] { display: none; }
html[lang="en"] [data-lang-content="en"] { display: block; }
html:not([lang="en"]) [data-lang-content="nl"] { display: block; }

/* ── Responsive: kleiner scherm → alleen iconen ── */
@media (max-width: 1100px) {
  :root { --rail-w: 64px; }
  .rail { padding: 14px 8px; align-items: center; }
  .rail-brand { justify-content: center; gap: 0; padding: 2px 0 14px; }
  .rail-brand-full { display: none; }
  .rail-nav { align-self: stretch; }
  .rail-item { justify-content: center; gap: 0; padding: 11px 0; }
  .rail-lbl { display: none; }
  .rail-sub { margin-left: 0; }
}

/* ── Mobiel → navigatiebalk onderaan ── */
@media (max-width: 640px) {
  :root { --rail-w: 0px; }
  body { padding-left: 0; padding-bottom: 60px; }
  .rail {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; height: 60px;
    flex-direction: row; align-items: center;
    gap: 0; padding: 0 6px;
    border-right: 0; border-top: 1px solid var(--glass-border);
    overflow: visible;
  }
  .rail-brand { display: none; }
  .rail-nav { flex-direction: row; flex: 1; justify-content: space-around; gap: 0; }
  .rail-group, .rail-sub { display: contents; }
  .rail-item { flex-direction: column; gap: 3px; min-height: 0; padding: 6px 8px; }
  .rail-foot { margin: 0; padding: 0; }
  .lang-btn { width: auto; min-width: 44px; height: 44px; padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .rail-item, .lang-btn { transition: none; }
}
