/* EnergieHub Horst-Noord: the one stylesheet of the site.
   Climate report style (cream paper, deep forest green, amber accent, Fraunces headings) with the
   floating layout: the map fills the screen and small panels lie on top. */

/* ---------- Tokens ---------- */
:root {
  /* page */
  --background: #f4efe4; --card: #fffdf8; --foreground: #13281f; --muted: #ece6d8; --muted-foreground: #5e6b62;
  --border: #e2dccd; --primary: #13392b; --accent: #f2b544; --radius: 14px;
  --font-head: "Fraunces", Georgia, serif; --font-num: "Fraunces", Georgia, serif;
  /* energy */
  --elec: #2563eb; --heat: #ea6a1a; --store: #14965a; --grid: #d6403a; --cable: #8a938d;
  /* map (--m-*), used by the SVG that app.js draws */
  --m-ink: #13281f; --m-hub: #13392b; --m-paper: #fff; --m-accent: #f2b544; --m-label: #2f3d35;
  --m-muted: #6b746e; --m-muted2: #9aa19b; --m-slate: #5d6670; --m-border: #e2e5df; --m-danger: #a32024;
  --m-base: #f1ecdf; --m-outside: #e9e2d2; --m-field: #ece6d6; --m-field-line: #e4ddca;
  --m-prov-lim: #faf6ec; --m-prov-lim-line: #13392b; --m-prov-other: #eee8da; --m-prov-other-line: #c9cec5;
  --m-muni-line: #d8d1bf; --m-talk: rgba(242,181,68,.30);
  --m-glass: #e6eadc; --m-glass-line: #ccd6c2; --m-town: #e6dfd0; --m-water: #c8dce4; --m-forest-text: #5b8f6a;
  --m-highway: #d3d8dd; --m-road-edge: #dfe3dc; --m-cable11: #7d8781; --m-cable12: #a593c9;
  --m-sun: #e0a100; --m-ring-bg: #f3c9cb;
  /* everything that floats: three radii (panel, inner, pill) and soft, short shadows that fit in
     the room the containers leave around them */
  --r-panel: 20px; --r-inner: 12px; --r-pill: 999px;
  --glass: rgba(255, 253, 248, .86); --glass-line: rgba(255, 255, 255, .75);
  --hi: inset 0 1px 0 rgba(255, 255, 255, .8);
  --sh-panel: 0 1px 2px rgba(19,40,31,.05), 0 6px 14px -8px rgba(19,40,31,.14), 0 16px 30px -14px rgba(19,40,31,.24);
  --sh-dark: 0 1px 2px rgba(13,42,31,.12), 0 4px 10px -5px rgba(13,42,31,.26), 0 12px 24px -12px rgba(13,42,31,.32);
  --sh-pill: 0 1px 2px rgba(19,40,31,.06), 0 5px 12px -6px rgba(19,40,31,.24);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* the page is exactly one screen high */
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; font-family: "Instrument Sans", Inter, system-ui, sans-serif; background: var(--background); color: var(--foreground); font-size: 14px; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, .detail h2 { font-family: var(--font-head); }

/* ---------- Top bar ---------- */
.topbar { flex: none; height: 50px; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--primary); color: #f4efe4; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand .mark svg { stroke: var(--primary); }
.topbar .who { margin-left: auto; color: #b9c9bd; font-size: 12px; }
.seg { display: inline-flex; background: var(--muted); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-weight: 500; color: var(--muted-foreground); }
.seg button.on { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.small button { padding: 3px 9px; font-size: 11.5px; }
.topbar .seg { background: #1d4a39; }
.topbar .seg button { color: #b9c9bd; }
.topbar .seg button.on { background: #f4efe4; color: var(--primary); }
/* the Uitleg button (guide.js brings its own teal) in the accent of the site */
.topbar .g-help, .topbar .g-help:hover { border-color: var(--accent); color: var(--primary); background: var(--accent); }
.topbar .g-help i { background: var(--primary); color: var(--accent); }

/* ---------- Stage: the map fills the screen ---------- */
.app { position: relative; flex: 1; min-height: 0; }
.stage { position: absolute; inset: 0; display: flex; flex-direction: column; }
.map-wrap { position: relative; flex: 1; min-height: 0; background: var(--m-base); overflow: hidden; }
.map-wrap::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 40% 45%, transparent 55%, rgba(19,57,43,.16) 100%); }
#map { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none; }
#map.panning { cursor: grabbing; }
.app[data-mode="overview"] .puzzle-only { display: none !important; }
.app[data-mode="puzzle"] .overview-only { display: none !important; }

/* chrome on the map: pills that float */
.legend, .zbtn, .map-badge {
  border: 1px solid var(--glass-line); background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: var(--r-pill); box-shadow: var(--hi), var(--sh-pill);
}
.legend { position: absolute; left: 14px; bottom: 14px; padding: 7px 14px; display: flex; gap: 14px; font-size: 12px; color: var(--muted-foreground); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { height: 0; border-top: 2px dashed var(--cable); }
.legend i.dot { width: 10px; height: 10px; border-radius: 50%; }
.legend i.sq { width: 12px; height: 12px; border-radius: 3px; }
.app[data-level="detail"] .legend-geo, .app:not([data-level="detail"]) .legend-detail { display: none; }
.mapnote { position: absolute; right: 350px; top: 14px; font-size: 10.5px; color: var(--muted-foreground); background: rgba(255,253,248,.7); padding: 3px 10px; border-radius: 999px; }
.map-badge { position: absolute; left: 14px; top: 14px; padding: 7px 12px; font-weight: 600; font-size: 13px; }
.map-badge.dark { background: var(--primary); color: #f4efe4; border-color: #23503f; box-shadow: inset 0 1px 0 rgba(255,255,255,.10), var(--sh-pill); }
.app:not([data-level="detail"]) .map-badge { display: none; }
.zoombar { position: absolute; right: 350px; bottom: 14px; display: flex; gap: 6px; }
.zbtn { height: 36px; min-width: 36px; font-size: 16px; font-weight: 500; }
.zbtn.wide { font-size: 12px; padding: 0 12px; }
/* In the puzzle the legend and zoom buttons sit 12px above the day chart. The chart scales with its
   width (viewBox 1100 by 150, dock width 100vw minus 364px, minus 38px padding and border), so the
   distance does too: 14px gap + about 68px for header and player + the chart + 12px. */
.app[data-mode="puzzle"] .legend, .app[data-mode="puzzle"] .zoombar { bottom: calc(94px + (100vw - 402px) * 150 / 1100); }

/* ---------- Map drawing ---------- */
#detailLayer, #hubMarker { transition: opacity .2s; }
.g-lbl { paint-order: stroke; stroke: var(--m-paper); stroke-linejoin: round; stroke-width: calc(var(--u) * 3.5px); fill: var(--m-label); font-size: calc(var(--u) * 11px); pointer-events: none; }
.g-country { font-size: calc(var(--u) * 15px); letter-spacing: .3em; fill: #a3aaa4; font-weight: 600; stroke: none; }
.g-prov { font-size: calc(var(--u) * 16px); letter-spacing: .35em; fill: #7f8b81; font-weight: 700; }
.g-prov-other { fill: #a9b0aa; font-size: calc(var(--u) * 13px); }
.g-muni { fill: #7d867f; font-size: calc(var(--u) * 10.5px); }
.g-muni.talking { fill: #3f5a00; font-weight: 600; }
.g-sub { font-size: calc(var(--u) * 9.5px); font-weight: 500; }
.g-city { font-size: calc(var(--u) * 12.5px); font-weight: 600; fill: #3a433d; }
.g-town { font-size: calc(var(--u) * 11px); fill: #5d6670; }
.g-hub { font-size: calc(var(--u) * 14px); font-weight: 700; fill: var(--m-ink); }
.g-hubsub { font-size: calc(var(--u) * 11.5px); fill: #3f5a00; font-weight: 500; }
#map[data-level="province"] .g-muni { opacity: 0; }
#map[data-level="province"] .g-muni.talking { opacity: 1; }
#map[data-level="detail"] .g-place:not(.g-village), #map[data-level="detail"] .g-muni, #map[data-level="detail"] .g-prov, #map[data-level="detail"] .g-country { opacity: 0; }
#map[data-level="region"] .g-prov { opacity: .5; }
.g-muni, .g-prov, .g-place { transition: opacity .2s; }
.g-village .g-lbl { font-size: calc(var(--u) * 10.5px); fill: var(--m-muted); }
.g-drawn { opacity: var(--drawn, 1); }
#map[data-level="province"] .g-village { opacity: 0; }
#villages { pointer-events: none; }
.hub-marker .pulse { transform-box: fill-box; transform-origin: center; animation: pulse 2.2s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
.flow-anim { animation: dash 1.1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -24; } }
.node { cursor: pointer; }
.node:hover .halo { opacity: 1; }
.maplabel { paint-order: stroke; stroke: var(--m-paper); stroke-width: 4px; stroke-linejoin: round; }
/* depth on the map itself */
#map .node > circle:nth-of-type(2) { filter: drop-shadow(0 3px 4px rgba(19,40,31,.28)); }
#map .hub-dot { filter: drop-shadow(0 4px 8px rgba(13,42,31,.45)); }

/* ---------- Side column ---------- */
/* The side column scrolls, and a scroll container clips everything outside its box. So the column
   itself reaches the screen edge and holds its panels in padding: the shadows fall inside it. The
   padding does not catch clicks on the map. A short fade at the bottom shows there is more to scroll. */
.side {
  position: absolute; top: 0; right: 0; width: 360px; max-height: 100%; z-index: 5; overflow: auto;
  display: flex; flex-direction: column; padding: 14px 14px 36px 24px; scrollbar-width: none; pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
}
.side > * { pointer-events: auto; }
.side::-webkit-scrollbar { display: none; }

/* panels: glass over the map */
.card {
  background: var(--glass); backdrop-filter: blur(16px) saturate(1.15); -webkit-backdrop-filter: blur(16px) saturate(1.15);
  border: 1px solid var(--glass-line); border-radius: var(--r-panel); padding: 16px 18px; box-shadow: var(--hi), var(--sh-panel);
}
/* Panels stacked in the side column are almost opaque: frosted glass would blur the shadow of the
   panel above into a muddy band along the top edge of the panel below. */
.side .card { background: rgba(255, 253, 248, .97); }
/* the result panels: the one bold forest-green block */
#ovStat, #pzResult {
  background: radial-gradient(130% 120% at 0% 0%, #22594a 0%, #13392b 55%, #0d2a1f 100%); color: #f4efe4;
  border: 1px solid #23503f; box-shadow: inset 0 1px 0 rgba(255,255,255,.10), var(--sh-dark);
}
#ovStat .stat-sub, #pzResult .stat-sub { color: #c5d3c8; }
#ovStat .big, #pzResult .big { color: #f4efe4 !important; font-weight: 600; }
#ovStat .bar, #pzResult .bar { background: rgba(255,255,255,.18); }
#ovStat .missing { border-color: var(--accent); color: #f4efe4; }
#pzResult .suggest { background: #1d4a39; border-color: #2b5e4a; color: #f4efe4; }
#pzResult .suggest .btn { background: var(--accent); color: var(--primary); border-color: var(--accent); }
#pzResult .seg { background: #1d4a39; }
#pzResult .seg button { color: #b9c9bd; }
#pzResult .seg button.on { background: #f4efe4; color: var(--primary); }
.side .seg, .side .seg button { border-radius: var(--r-pill); }
.side .seg button { padding: 4px 11px; }

/* type and figures */
.eyebrow { font-size: 11.5px; font-weight: 600; color: #b07a10; }
h1 { font-size: 21px; font-weight: 600; line-height: 1.1; margin: 3px 0 6px; letter-spacing: -.01em; }
.lead { color: var(--muted-foreground); font-size: 12.5px; line-height: 1.5; margin: 0; }
.big { font-family: var(--font-num); font-size: 50px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.big small { font-size: 22px; font-weight: 600; }
.stat-sub { color: var(--muted-foreground); font-size: 12.5px; margin-top: 6px; line-height: 1.45; }
.bar { height: 5px; border-radius: 6px; overflow: hidden; display: flex; margin-top: 10px; }
.bar b { display: block; height: 100%; }
.missing { border-left: 3px solid var(--grid); padding: 2px 0 2px 12px; font-size: 12.5px; line-height: 1.5; margin-top: 10px !important; }
.stats2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats2 .card { padding: 13px 15px; }
.stats2 .n { font-family: var(--font-num); font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.stats2 .t { color: var(--muted-foreground); font-size: 11.5px; line-height: 1.4; margin-top: 2px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--muted-foreground); margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: rgba(255,255,255,.7); border-radius: 999px; padding: 4px 10px 4px 6px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.chip:hover { border-color: #c3c8c0; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); }
.tag.new { background: #e9f7c4; color: #3f5a00; }
.tag.warn { background: #fde8e8; color: #a32024; }

/* buttons: pills */
.btn { border: 1px solid var(--border); background: var(--card); border-radius: var(--r-pill); padding: 9px 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn.primary { background: var(--accent); color: var(--primary); border-color: var(--accent); font-weight: 600; }
.btn.primary svg { stroke: var(--primary); }
.btn.block { width: 100%; padding: 11px 14px; box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 1px 2px rgba(120,80,8,.18), 0 8px 18px -8px rgba(176,122,16,.6); }
.btn.sm { padding: 6px 13px; font-size: 12px; }
.btn.xs { padding: 3px 9px; font-size: 11.5px; }

/* ---------- Detail panel of a company, next to the side column ---------- */
/* Closed means faded out and out of reach (sliding it away would leave it under the side column). */
.detail {
  position: absolute; right: 350px; top: 14px; bottom: 14px; width: 300px; padding: 18px; overflow: auto; scrollbar-width: thin;
  background: rgba(255,253,248,.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-line); border-radius: var(--r-panel); box-shadow: var(--hi), var(--sh-panel);
  transform: translateX(16px); opacity: 0; visibility: hidden; transition: transform .25s ease, opacity .2s ease, visibility 0s .25s;
}
.detail.open { transform: none; opacity: 1; visibility: visible; transition: transform .25s ease, opacity .2s ease; }
.detail .x { position: absolute; top: 12px; right: 12px; border: 0; background: rgba(19,40,31,.06); width: 28px; height: 28px; border-radius: var(--r-pill); }
.detail h2 { font-size: 18px; margin: 4px 0 2px; }
.detail .role { color: var(--muted-foreground); font-size: 13px; }
.detail ul { padding-left: 18px; margin: 8px 0 0; line-height: 1.5; color: #39443e; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.kv div { background: var(--muted); border-radius: var(--r-inner); padding: 10px; }
.kv .n { font-family: var(--font-num); font-weight: 700; font-size: 16px; }
.kv .t { font-size: 11px; color: var(--muted-foreground); }
/* the two actions stack as full-width pills, so their labels stay on one line */
.detail div:has(> .btn[data-act]) { flex-direction: column; }
.detail .btn[data-act] { white-space: nowrap; padding: 10px 14px; }

/* ---------- Puzzle ---------- */
.result .big { font-size: 44px; font-weight: 650; letter-spacing: -.02em; }
.result .big small { font-size: 16px; font-weight: 600; margin-left: 1px; }
#puzzleSide .stat-sub { margin-top: 4px; }
#puzzleSide .bar { height: 4px; }
.suggest { border: 1px solid #dcebc8; background: #f3f8ec; border-radius: var(--r-inner); padding: 10px 10px 10px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; font-size: 12.5px; line-height: 1.45; }
.suggest.bad { background: #fdf2f2; border-color: #f4d3d4; }

/* who takes part: chips that switch on and off */
.list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.item { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 5px; border-radius: 999px; border: 1px dashed #c9c1ad; background: transparent; text-align: left; }
.item .ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: transparent; flex: none; }
.item .ico svg { width: 13px; height: 13px; stroke: #6b746e; }
.item .grow { flex: none; }
.item .nm { font-size: 12.5px; font-weight: 500; color: var(--muted-foreground); display: flex; align-items: center; gap: 5px; }
.item .tag { font-size: 9.5px; padding: 0 5px; }
.item.on { background: var(--primary); border: 1px solid var(--primary); }
.item.on .nm { color: #f4efe4; }
.item.on .ico { background: rgba(255,255,255,.12); }
.item.on .ico svg { stroke: #f4efe4; }
.item.fixed { opacity: .85; cursor: default; }
.item.warn .nm::after { content: "!"; display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: var(--grid); color: #fff; font-size: 10px; font-weight: 700; }
#pzControls .label { margin-top: 10px !important; }
.slider { padding: 4px 2px; font-size: 12.5px; }
.slider .top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.slider input { width: 100%; height: 4px; accent-color: var(--store); }

/* the day chart: a floating strip along the bottom of the map */
.chart-dock { display: none; position: absolute; left: 14px; right: 350px; bottom: 14px; z-index: 4; padding: 11px 18px 9px; }
.app[data-mode="puzzle"] .chart-dock { display: block; }
.chart-head { display: flex; align-items: center; gap: 12px; margin-bottom: 2px; }
.chart-head b { font-family: var(--font-head); font-size: 15px; font-weight: 600; }
.chart-head .readout { margin-left: auto; font-size: 11px; color: var(--muted-foreground); }
.chart-legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted-foreground); }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart-legend i.sw { background: color-mix(in srgb, var(--c) 25%, white); box-shadow: inset 0 2px 0 var(--c); border-radius: 1px; }
.chart-legend i.hatch { background: repeating-linear-gradient(45deg, rgba(214,64,58,.6) 0 1.5px, rgba(214,64,58,.08) 1.5px 4px); border-radius: 2px; }
.chart-legend i.ln { height: 2px; width: 14px; background: var(--foreground); border-radius: 1px; vertical-align: 3px; }
.chart-legend i.dots { height: 0; width: 14px; border-top: 2px dotted var(--accent); border-radius: 0; vertical-align: 3px; }
.player { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.player input { flex: 1; height: 3px; accent-color: #16201b; }
.player .hour { font-size: 12px; color: var(--muted-foreground); width: 38px; text-align: right; }
