/* Belegt! – Spielfeld-Prototyp. Mobile first, Desktop ab 900px zweispaltig. */

/* Schriften lokal (offline-fähig), Latin-Subset von Google Fonts. Bebas Neue: OFL, Special Elite: Apache 2.0 */
@font-face {
  font-family: 'Bebas Neue';
  font-display: swap;
  src: url(../fonts/bebas-neue-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Special Elite';
  font-display: swap;
  src: url(../fonts/special-elite-latin.woff2) format('woff2');
}

:root {
  --bg: #1e1612;
  --panel: #2a201a;
  --panel-2: #342821;
  --line: #45362c;
  --text: #f3e9dc;
  --muted: #b3a393;
  --paper: #fff8ec;
  --ink: #221a15;
  --mustard: #f5b82e;
  --ketchup: #d7261e;
  --radius: 14px;
  --art-w: clamp(120px, 40vw, 170px); /* Breite der Burger-Grafik */
  --scale: 1.3;   /* Höhe der Zutatengrafik je viewBox-Einheit */
  --display: 'Bebas Neue', 'Oswald', 'Arial Narrow', Impact, sans-serif;
  --type: 'Special Elite', 'Courier New', ui-monospace, monospace;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; } /* sonst überschreibt z. B. .modal { display: flex } das hidden-Attribut */

/* Die Seite selbst scrollt nie (nur #slots, Theke, Ergebnis). overscroll-behavior muss am html stehen,
   sonst lädt Chrome auf Android beim Runterziehen die Seite neu (Pull-to-Refresh). */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.35 var(--ui);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* sonst macht die scrollende Theken-Reihe die Seite breit */
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
}

.logo {
  font: 28px/1 var(--display);
  letter-spacing: .04em;
  color: var(--mustard);
}

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 13px;
}
.btn:active, .icon-btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; border-color: var(--mustard); color: var(--mustard); }
.btn-primary { background: var(--mustard); border-color: var(--mustard); color: var(--ink); font-weight: 800; }

.topbar-actions { display: flex; gap: 8px; }

/* ---------- Spielfeld ---------- */

.board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 8px;
  min-height: 0;
}

.bon {
  flex-shrink: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 6px 14px 12px;
  border-radius: 6px 6px 0 0;
  /* Kassenbon-Zacken unten */
  --zz: 7px;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--zz)) 100%;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--zz)) 100%;
}

.bon-no { font: 12px var(--type); color: var(--ketchup); }

.bon-name {
  margin: 0;
  font: 32px/1 var(--display);
  letter-spacing: .02em;
}

.controls {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bun-pick { display: flex; align-items: center; gap: 6px; }

.bun-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }

.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}
.chip.on { background: var(--mustard); border-color: var(--mustard); color: var(--ink); }

.toolbar { display: flex; gap: 6px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

/* Burger in Explosionsansicht: drei Ablagen untereinander, der Bereich scrollt */
.slots {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px;
  scrollbar-width: thin;
}

.slot {
  flex-shrink: 0;
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.slot.active { border-color: var(--mustard); box-shadow: 0 0 0 3px rgba(245, 184, 46, .15); }
.slot.drop-target { border-color: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .2); }
.slot.flash { animation: flash .35s ease-out; }
@keyframes flash { from { background: #4a3a2c; } to { background: var(--panel); } }

/* Titel links oben in der Ablage, ohne eigene Zeile zu belegen */
.slot-head {
  position: absolute;
  left: 10px;
  top: 7px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  font: 17px/1 var(--display);
  letter-spacing: .05em;
  color: var(--muted);
  pointer-events: none;
}
.slot.active .slot-head { color: var(--mustard); }
.slot-count { font: 600 11px var(--ui); }

.stack {
  display: flex;
  flex-direction: column-reverse; /* Patty & Unterseite wachsen nach oben */
  padding: 8px 8px 6px;
}
.slot[data-slot="top"] .stack { flex-direction: column; } /* Oberseite hängt unter dem Deckel */
.slot[data-slot="top"] .stack { padding-top: 26px; }
.slot[data-slot="patty"] .stack,
.slot[data-slot="bottom"] .stack { padding-top: 26px; }

/* Jede Zeile: [frei] [Grafik] [Beschriftung] – Grafik mittig, Werkzeuge liegen links darüber */
.base, .layer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--art-w) minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
}
.art { grid-column: 2; }
.art svg { display: block; width: 100%; pointer-events: none; }
.tag {
  grid-column: 3;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
  hyphens: auto;
  pointer-events: none;
}

.base .tag { color: var(--muted); font-weight: 400; font-size: 11px; }
.base-top svg { height: 38px; }
.base-bottom svg { height: 26px; }
.base-patty svg { height: 18px; }

.layer {
  padding: 2px 0;
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.layer.lifting { opacity: .3; }
.layer .art svg { height: calc(var(--h) * var(--scale) * 1px); }
.layer.selected { background: rgba(245, 184, 46, .14); outline: 1.5px solid var(--mustard); }
.layer.selected .tag { color: var(--mustard); }
.layer.drop-in { animation: drop .25s cubic-bezier(.3, 1.4, .6, 1); }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

/* Markierungen nach dem Servieren */
.mk { font-weight: 900; }
.mark-ok .mk { color: #6fcf6a; }
.mark-bad .mk { color: #ff6a5c; }
.layer.mark-bad, .base.mark-bad { background: rgba(215, 38, 30, .16); box-shadow: inset 0 0 0 1.5px rgba(255, 106, 92, .7); border-radius: 8px; }
.mark-bad .tag { color: #ffb3aa; }

.layer-tools {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  display: flex;
  gap: 2px;
}
.layer-tools button {
  width: 23px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: var(--mustard);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  padding: 0;
}
.layer-tools button[data-act="minus"] { background: var(--ketchup); color: #fff; font-size: 16px; }
.layer-tools button[data-act="plus"] { background: #6fcf6a; font-size: 16px; }

.empty-hint {
  width: min(100%, var(--art-w));
  margin: 4px auto;
  padding: 7px 4px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

/* ---------- Zutaten-Theke ---------- */

.pantry {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 8px 12px 8px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tabs { display: flex; gap: 6px; margin-bottom: 8px; }

.tab {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: 8px 4px;
  background: var(--panel-2);
  color: var(--muted);
  font: 17px/1 var(--display);
  letter-spacing: .05em;
}
.tab.on { background: var(--mustard); color: var(--ink); }

/* Handy: eine flache Reihe, die nur waagerecht scrollt. Senkrechtes Ziehen einer Kachel
   scrollt deshalb nicht, sondern legt die Zutat auf den Burger (siehe press() in app.js). */
.grid {
  display: flex;
  gap: 6px;
  margin: 0 -12px;
  padding: 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  /* Kacheln verblassen am Rand – zeigt, dass es seitlich weitergeht */
  --fade: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  mask-image: var(--fade);
  -webkit-mask-image: var(--fade);
}

.tile {
  flex: 0 0 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 4px 5px;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform .1s;
}
.tile:active { transform: scale(.95); }
.tile.lifting { opacity: .45; }
.tile-icon svg { display: block; width: 38px; height: 38px; pointer-events: none; }
.tile-name {
  max-width: 100%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  hyphens: auto;
  pointer-events: none;
}

.pantry-hint { margin: 6px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

.legend {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
}
.legend b { color: var(--text); font-weight: 700; white-space: nowrap; }

/* ---------- Prüf-Ergebnis ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 6, 4, .6);
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }

.modal-card {
  width: min(100%, 520px);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px 18px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

.res-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: #fff;
}
.res-head.ok { background: #2f8a3b; }
.res-head.bad { background: var(--ketchup); }
.res-head h2 { margin: 0; font: 30px/1 var(--display); letter-spacing: .03em; }
.res-head p { margin: 2px 0 0; font: 13px var(--type); opacity: .9; }

.res-badge {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  font: 28px/1 var(--display);
}
.res-head.ok .res-badge { color: #2f8a3b; }
.res-head.bad .res-badge { color: var(--ketchup); }

.res-body { padding: 4px 16px 8px; }

.res-sec h3 {
  margin: 12px 0 4px;
  font: 18px/1 var(--display);
  letter-spacing: .05em;
  color: var(--ketchup);
}
.res-sec h3 small { font: 11px var(--ui); color: #8a7a6c; letter-spacing: 0; margin-left: 4px; }

.res-sec ol { list-style: none; margin: 0; padding: 0; }

.res-sec li {
  display: grid;
  grid-template-columns: 20px 20px 1fr auto;
  align-items: baseline;
  gap: 4px;
  padding: 6px 4px;
  border-bottom: 1px dashed #e4d8c6;
  font-size: 14px;
}
.res-sec li .st { font-weight: 900; }
.res-sec li .pos { color: #8a7a6c; font: 12px var(--type); }
.res-sec li .nm { font-weight: 600; }
.res-sec li .nm small { font-weight: 400; color: #6d5f53; }
.res-sec li em { display: block; font-style: normal; font-size: 12px; font-weight: 600; }
.res-sec li .amt { font: 12px var(--type); color: #6d5f53; white-space: nowrap; }
.res-sec li.ok .st { color: #2f8a3b; }
.res-sec li.bad { background: #fde8e4; }
.res-sec li.bad .st, .res-sec li.bad em { color: var(--ketchup); }
.res-sec li.skip { color: #8a7a6c; }
.res-sec li.skip em { color: #8a7a6c; font-weight: 400; }

.res-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--paper);
  border-top: 1px solid #e4d8c6;
}
.res-foot .btn { padding: 10px 18px; font-size: 14px; }
.res-foot .btn:not(.btn-primary) { background: transparent; border-color: #cdbfae; color: var(--ink); }

/* ---------- Drag-Ghost ---------- */

.ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  width: 64px;
  height: 64px;
  margin: -40px 0 0 -32px; /* etwas über dem Finger */
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5));
}
.ghost svg { width: 100%; height: 100%; }

/* Einfügestelle beim Ziehen */
.drop-line {
  position: fixed;
  z-index: 99;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: var(--mustard);
  box-shadow: 0 0 0 2px rgba(30, 22, 18, .8), 0 0 12px rgba(245, 184, 46, .8);
  pointer-events: none;
}
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- Niedrige Handys: Kopf verdichten, damit der Burger Platz hat ---------- */

@media (max-width: 899px) and (max-height: 780px) {
  .topbar { padding: 4px 12px; }
  .logo { font-size: 22px; }
  .btn { padding: 5px 12px; }
  .bon { padding: 4px 12px 10px; }
  .bon-name { font-size: 26px; }
  .chip { padding: 5px 10px; }
  .icon-btn { width: 32px; height: 32px; }
  .tab { padding: 6px 4px; }
  .tile-icon svg { width: 32px; height: 32px; }
  .pantry-hint { display: none; }
}

/* ---------- Desktop / Tablet quer ---------- */

@media (min-width: 900px) {
  :root { --art-w: 260px; --scale: 1.7; }
  .app {
    grid-template-columns: 1fr 380px;
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 16px;
  }
  .topbar { grid-column: 1 / -1; padding: 12px 16px; }
  .board { padding: 0 0 16px 16px; }
  .pantry {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin: 0 16px 16px 0;
  }
  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    align-content: start;
    flex: 1;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: auto;
    scrollbar-width: thin;
    mask-image: none;
    -webkit-mask-image: none;
  }
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; }
  .tile-icon svg { width: 52px; height: 52px; }
  .bon-name { font-size: 44px; }
  .base-top svg { height: 52px; }
  .base-bottom svg { height: 34px; }
  .tag { font-size: 13px; }
  .slot-head { font-size: 20px; }
}
