/* Configurator 3 buckles — mockup, wit thema
   Fonts staan lokaal in /fonts (alleen latin-subset, dus geen Vietnamees/Cyrillisch).
   Heb je andere tekens nodig, haal dan de latin-ext-bestanden erbij. */

@font-face { font-family: "Big Shoulders Display"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/big-shoulders-display-600.woff2") format("woff2"); }
@font-face { font-family: "Big Shoulders Display"; font-weight: 800; font-style: normal; font-display: swap;
  src: url("../fonts/big-shoulders-display-800.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/instrument-sans-400.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("../fonts/instrument-sans-500.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/instrument-sans-600.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/jetbrains-mono-400.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("../fonts/jetbrains-mono-500.woff2") format("woff2"); }

/* Eén vast, wit thema. color-scheme: light voorkomt dat de browser formulieren
   en scrollbalken donker kleurt bij een donker besturingssysteem. */
html { color-scheme: light; }
body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }

:root {
  --ground: #FFFFFF;
  --surface: #FFFFFF;
  --tint: #F6F7F4;        /* submenu's en hover: net genoeg om van wit los te komen */
  --ink: #17201B;
  --muted: #5C675F;
  --line: #E2E6E1;
  --line-strong: #C3CBC4;
  --brass: #94701F;       /* accent; donker genoeg voor kleine tekst op wit (≈4.9:1) */
  --brass-wash: #F7F0DF;
  --enamel: #6D1F24;
  --cta: #6F5214;
  --on-cta: #FFFFFF;
  --stage-a: #FAFAF8;
  --stage-b: #E6E9E3;
  --stage-ink: #46514A;

  --f-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --f-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --gutter: clamp(16px, 2vw, 28px);
  --r: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--ground); color: var(--ink);
  font: 15px/1.5 var(--f-body);
  padding-inline: var(--gutter);
  display: grid; grid-template-rows: minmax(0, 1fr);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---------- Split: viewer links, harmonica rechts ---------- */
.app {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr); gap: var(--gutter);
  padding-block: var(--gutter); min-height: 0;
}

.stage {
  position: relative; min-height: 0; border-radius: 16px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, var(--stage-a) 0%, var(--stage-b) 100%);
  color: var(--stage-ink);
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.stage canvas:active { cursor: grabbing; }
.stage-top, .stage-bottom {
  position: absolute; left: 16px; right: 16px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; pointer-events: none;
}
.stage-top { top: 16px; }
.stage-bottom { bottom: 16px; justify-content: center; }
.stage-top > *, .stage-bottom > * { pointer-events: auto; }
.chip {
  font: 500 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 8px 10px; border-radius: 99px; background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(8px); border: 1px solid var(--line);
}
.chip b { font-weight: 500; color: var(--ink); }
/* Maatchip en knoppen horen rechts, ook als de statusmelding links verborgen is */
.dim { font-variant-numeric: tabular-nums; }
.stage-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Knoppen rechtsboven: draaien, schermvullend, foto. Zelfde pil als de camerastanden
   onderin, zodat het één familie leest; alleen icoon, de naam staat in title/aria-label. */
.tools {
  display: flex; gap: 2px; padding: 3px; border-radius: 99px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px); border: 1px solid var(--line);
}
.tool {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 99px; background: transparent; color: var(--muted); cursor: pointer;
}
.tool svg { width: 18px; height: 18px; }
.tool:hover { color: var(--ink); background: var(--tint); }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
/* Schermvullend is een toestand, geen keuze: het icoon wisselt, de knop wordt niet donker. */
#tool-fullscreen[aria-pressed="true"] { background: transparent; color: var(--muted); }
#tool-fullscreen[aria-pressed="true"]:hover { color: var(--ink); background: var(--tint); }
.tool .icon-collapse, .tool[aria-pressed="true"] .icon-expand { display: none; }
.tool[aria-pressed="true"] .icon-collapse { display: block; }
.tool:disabled { opacity: .45; cursor: progress; }

/* Schermvullend. :fullscreen voor de echte API; .is-fullscreen is de terugval voor browsers
   die een element niet schermvullend kunnen maken (Safari op de iPhone): dan vult de viewer
   het venster. */
.stage:fullscreen { border-radius: 0; }
.stage.is-fullscreen {
  position: fixed; inset: 0; z-index: 100; height: auto; min-height: 0; border-radius: 0;
}
body.has-fullscreen-stage { overflow: hidden; }
/* Vormkiezer onder de viewer, in het midden. Zelfde pil als de knoppen rechtsboven. Past hij
   niet (smal scherm, of later meer vormen), dan scrollt hij zijwaarts in plaats van af te breken. */
.shape-picker {
  display: flex; gap: 2px; padding: 4px; border-radius: 99px; max-width: 100%;
  overflow-x: auto; scrollbar-width: none;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px); border: 1px solid var(--line);
  box-shadow: 0 6px 20px -12px rgba(23, 32, 27, .35);
}
.shape-picker::-webkit-scrollbar { display: none; }
.shape-picker button {
  flex: none; display: flex; align-items: baseline; gap: 7px;
  border: 0; background: transparent; padding: 8px 16px; border-radius: 99px; cursor: pointer;
  font-weight: 500; font-size: 14px; color: var(--muted); white-space: nowrap;
}
.shape-picker .shape-no { font: 500 10px/1 var(--f-mono); letter-spacing: .06em; color: var(--brass); }
.shape-picker button:hover { color: var(--ink); background: var(--tint); }
.shape-picker button[aria-checked="true"] { background: var(--ink); color: var(--ground); }
.shape-picker button[aria-checked="true"] .shape-no { color: #D9BE86; }
.stage-fallback {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px;
  font-size: 14px; line-height: 1.5;
}

/* ---------- Paneel ---------- */
.panel {
  min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
.panel-scroll { overflow-y: auto; flex: 1; padding: 24px 24px 8px; }
.intro { display: grid; gap: 4px; padding-bottom: 18px; }
.crumb { font: 400 12px/1 var(--f-mono); color: var(--muted); letter-spacing: .04em; }
.intro h1 {
  margin: 6px 0 0; font: 800 clamp(34px, 3.4vw, 46px)/.95 var(--f-display);
  text-transform: uppercase; letter-spacing: .01em; text-wrap: balance;
}
.intro p { margin: 6px 0 0; color: var(--muted); max-width: 52ch; }

/* Niveau 1: harmonica — één stap tegelijk open */
.acc { border-top: 1px solid var(--line); }
.acc:last-child { border-bottom: 1px solid var(--line); }
.acc h2, .sub h3 { margin: 0; }
.acc-head {
  width: 100%; display: grid; grid-template-columns: 28px 1fr auto 18px; align-items: center; gap: 12px;
  padding: 16px 2px; border: 0; background: transparent; cursor: pointer; text-align: left;
}
.step { font: 500 12px/1 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.acc-title { font: 600 22px/1 var(--f-display); text-transform: uppercase; letter-spacing: .03em; }
.acc-value {
  font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch;
}
.chev { width: 18px; height: 18px; transition: transform .3s ease; color: var(--muted); }
.is-open > h2 .chev, .is-open > h3 .chev { transform: rotate(180deg); }
.acc.is-open > h2 .step { color: var(--brass); }

.acc-panel, .sub-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s ease; }
.is-open > .acc-panel, .is-open > .sub-panel { grid-template-rows: 1fr; }
.acc-inner, .sub-inner { overflow: hidden; min-height: 0; }
.acc-body { padding: 0 2px 20px 40px; display: grid; gap: 10px; }

/* Niveau 2: submenu */
.sub { border: 1px solid var(--line); border-radius: var(--r); background: var(--tint); }
.sub.is-open { border-color: var(--line-strong); }
.sub-head {
  width: 100%; display: grid; grid-template-columns: 1fr auto 16px; align-items: center; gap: 10px;
  padding: 12px 14px; border: 0; background: transparent; cursor: pointer; text-align: left;
}
.sub-title { font-weight: 600; }
.sub-head .chev { width: 16px; height: 16px; }
.sub-body { padding: 2px 14px 14px; display: grid; gap: 10px; }

/* Optietegels (radio's) */
.tiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.tiles.three { grid-template-columns: repeat(3, 1fr); }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tile { position: relative; }
.tile input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.tile label {
  display: grid; gap: 6px; height: 100%; padding: 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.tile label:hover { border-color: var(--line-strong); }
.tile input:checked + label { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); background: var(--brass-wash); }
.tile input:focus-visible + label { outline: 2px solid var(--brass); outline-offset: 2px; }
.tile-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.tile-meta { font: 400 11px/1.3 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.tile svg { width: 100%; height: 46px; color: var(--ink); }
.tile .price { font: 500 11px/1 var(--f-mono); color: var(--brass); }

.field { display: grid; gap: 6px; }
.field-top { display: flex; justify-content: space-between; font-size: 13px; }
.field-top span:last-child { font: 400 11px/1.6 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.field input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  font: 600 16px/1 var(--f-display); letter-spacing: .12em; text-transform: uppercase;
}
.field input:focus { border-color: var(--brass); outline: none; box-shadow: 0 0 0 3px var(--brass-wash); }
.note { font-size: 12px; color: var(--muted); margin: 0; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--enamel); flex: none; }
.drop {
  display: grid; place-items: center; gap: 4px; padding: 20px; text-align: center; border-radius: 8px;
  border: 1.5px dashed var(--line-strong); color: var(--muted); font-size: 13px; background: var(--surface);
}
.drop b { color: var(--ink); }

/* Vaste voet met prijs */
.panel-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface);
}
.total { margin-right: auto; display: grid; gap: 2px; }
.total small { font: 400 11px/1 var(--f-mono); color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.total strong { font: 800 30px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.btn {
  border-radius: 99px; padding: 12px 20px; cursor: pointer; font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--cta); border-color: var(--cta); color: var(--on-cta); }
.btn.primary:hover { filter: brightness(1.12); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--ground); padding: 10px 16px; border-radius: 99px; font-size: 13px;
}

/* Statusmelding in de viewer (laden, of een fout met de echte oorzaak) */
/* Een foutmelding is een zin, geen label: geen hoofdletters, en niet breder dan de helft. */
#status.is-error {
  border-color: #B4443A; color: #8A2F27; text-transform: none;
  font-family: var(--f-body); letter-spacing: 0; max-width: 55%;
}
.stage-fallback { display: grid; gap: 6px; align-content: center; }
.stage-fallback b { font-size: 15px; }
.stage-fallback span { color: var(--muted); max-width: 40ch; }

/* Miniatuur op een embleemtegel. Leeg tot het embleem één keer geladen is —
   met lazy loading bestaat er daarvoor nog geen model om af te beelden. */
.thumb { display: none; }
.thumb.has-thumb {
  display: block; height: 46px; border-radius: 6px;
  background-size: contain; background-position: center; background-repeat: no-repeat;
}

/* ---------- Emblemen: positie → categorie → tegels ---------- */
.pos-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.pos-picker button {
  display: grid; gap: 1px; min-width: 112px; padding: 7px 12px; text-align: left; cursor: pointer;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface);
}
.pos-picker button span { font-weight: 600; font-size: 13px; }
.pos-picker button small {
  font-size: 11px; color: var(--muted); max-width: 16ch;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pos-picker button:hover { border-color: var(--ink); }
.pos-picker button[aria-pressed="true"] { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); background: var(--brass-wash); }

.tiles.emblem-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.emblem-tile label { padding: 6px; gap: 4px; align-content: start; }
/* De previews zijn transparant en allemaal in hetzelfde goud
   (tools/normalize-emblem-images.py), dus ze staan zonder trucs op elke tegelkleur. */
.emblem-tile img {
  display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain;
}
.emblem-tile .thumb.has-thumb { height: auto; aspect-ratio: 1; }
.emblem-tile .tile-name { font-size: 12px; font-weight: 500; line-height: 1.25; text-align: center; }
.btn-small { justify-self: start; padding: 7px 14px; font-size: 13px; }

/* ---------- Monitor (?debug) ---------- */
.stats { position: absolute !important; top: 16px; left: 16px; z-index: 5; }
.monitor {
  position: absolute; left: 16px; bottom: 64px; width: 290px; z-index: 5;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
  font: 400 11px/1.5 var(--f-mono); color: var(--ink);
}
.monitor h2 {
  margin: 0 0 4px; font: 500 10px/1 var(--f-mono); letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.monitor h2 + * { margin-bottom: 10px; }
.monitor dl { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; margin: 0; }
.monitor dt { color: var(--muted); }
.monitor dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.monitor .net { width: 100%; border-collapse: collapse; }
.monitor .net td { padding: 1px 0; vertical-align: top; }
.monitor .net td:nth-child(2), .monitor .net td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.monitor .net td:first-child { color: var(--muted); }
/* Let op: de root-class van lil-gui heet 'lil-root', niet 'root'. */
/* Onder de maatchip, anders dekt het paneel hem af. */
.debug-gui.lil-gui { position: absolute; top: 58px; right: 16px; z-index: 10; max-height: calc(100% - 74px); }
.monitor .net-total { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); }

@media (max-width: 900px) {
  .monitor { display: none; }
}

/* Telefoon/tablet: onder elkaar, viewer op vaste hoogte */
@media (max-width: 900px) {
  body { height: auto; display: block; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto; }
  .stage { height: min(62vh, 520px); min-height: 320px; }
  .panel { overflow: visible; }
  .panel-scroll { overflow: visible; padding: 20px 16px 8px; }
  .panel-foot { position: sticky; bottom: 0; padding: 12px 16px; border-radius: 0 0 16px 16px; }
  .acc-body { padding-left: 0; }
}
@media (max-width: 420px) {
  /* Vier vormen moeten op 358 px passen: nummer weg, knoppen krapper. */
  .shape-picker .shape-no { display: none; }
  .shape-picker button { padding: 7px 11px; font-size: 13px; }
  .tiles.three { grid-template-columns: 1fr 1fr; }
  .acc-value { max-width: 12ch; }
}
@media (prefers-reduced-motion: reduce) {
  .acc-panel, .sub-panel, .chev { transition: none; }
}
