/* assets/css/app.css – qBoard
   Aufbau: Grundlagen · Seiten (Übersicht, Handy, Freigabe) · Board am Beamer.
   Kategoriefarben kommen je Feld als --c (aus qbd_categories). */

@font-face {
  font-family: 'Nunito';
  src: local('Nunito'), url('/assets/fonts/nunito.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --ink: #14213d;
  --bg: #f4f6fb;
  --card: #fff;
  --line: #dde2ec;
  --muted: #667085;
  --accent: #f59e0b;
  --ok: #059669;
  --err: #dc2626;
  --none: #94a3b8;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

a { color: inherit; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 15px; }
.grow { flex: 1; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px; background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand-name { font-weight: 900; font-size: 20px; letter-spacing: .3px; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 10px); gap: 3px; }
.brand-mark i { width: 10px; height: 10px; border-radius: 3px; display: block; background: transparent; border: 2px solid; }
.brand-mark i:nth-child(1) { border-color: #e5e7eb; }
.brand-mark i:nth-child(2) { border-color: #60a5fa; }
.brand-mark i:nth-child(3) { border-color: #f87171; }
.brand-mark i:nth-child(4) { border-color: #34d399; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 15px; }
.tb-role { opacity: .7; }
.tb-link { color: #fff; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 16px 60px; }

/* ---------- Bausteine ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 20px;
}
.card h1, .card h2 { margin-top: 0; }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  line-height: 1.3;
}
.btn:hover { border-color: #b8c0d0; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--err); }
.btn.small { padding: 6px 12px; font-size: 15px; }
.btn.big { padding: 14px 22px; font-size: 19px; width: 100%; }
.btn.on { background: #e8f5ee; border-color: var(--ok); color: var(--ok); }

.flash { padding: 12px 16px; border-radius: 10px; margin: 0 0 16px; background: #eef2ff; }
.flash.error { background: #fef2f2; color: #991b1b; }
.flash.ok { background: #ecfdf3; color: #067647; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%; padding: 10px 12px; font: inherit; border: 1px solid #c5ccd8;
  border-radius: 10px; background: #fff; color: inherit;
}
.field textarea { resize: vertical; }
.counter { display: block; text-align: right; color: var(--muted); font-size: 14px; }
.counter.low { color: var(--err); }

.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row-form .field { margin-bottom: 0; }
form.inline { display: inline; }

.hero { padding: 40px 0; }
.hero h1 { font-size: 38px; line-height: 1.15; margin: 0 0 12px; }
.lead { font-size: 20px; max-width: 640px; }

/* ---------- Übersicht ---------- */
table.boards { width: 100%; border-collapse: collapse; font-size: 16px; }
.boards th, .boards td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.boards th { font-size: 14px; color: var(--muted); font-weight: 700; }
.boards td.warn { color: var(--err); font-weight: 700; }
.boards td.mono { white-space: nowrap; }
.phase-tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 1px 7px; border-radius: 999px;
             background: #eef2ff; color: #3730a3; margin-left: 6px; vertical-align: middle; }
.phase-tag.ph-sammeln { background: #fef3c7; color: #92400e; }
.phase-tag.ph-fertig { background: #bbf7d0; color: #14532d; }
.phase-choice { display: flex; gap: 6px; margin-bottom: 10px; }
.boards select, .row-form select { padding: 10px; font: inherit; border: 1px solid #c5ccd8; border-radius: 10px; background: #fff; }
.boards td.actions { white-space: nowrap; text-align: right; }
.boards a { text-decoration: none; }

/* ---------- Mitmachen / Handy ---------- */
.joinbox, .phone { max-width: 520px; margin: 0 auto; }
.code-input { font-size: 30px !important; text-align: center; letter-spacing: .15em; }
.phone-title { font-size: 24px; line-height: 1.25; }

/* Auswahl der Aussageart: Radio versteckt, Geschwister-Span gestaltet
   (nur input:checked + span, keine zweite Markierung vom Server) */
.cat-choice { border: 0; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.cat-choice legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.cat-choice label { display: block; cursor: pointer; }
.cat-choice input { position: absolute; opacity: 0; pointer-events: none; }
.cat-choice span {
  display: block; padding: 11px 14px; border-radius: 12px; background: #fff;
  border: 3px solid var(--c, var(--none)); font-weight: 700;
}
.cat-choice span.none { border-style: dashed; color: var(--muted); }
.cat-choice input:checked + span { background: var(--c, #e2e8f0); color: #fff; }
.cat-choice input:checked + span.none { background: #e2e8f0; color: var(--ink); }
.cat-choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.cat-choice.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cat-choice.compact span { padding: 7px 10px; font-size: 15px; }

.mine h2 { font-size: 19px; margin-top: 28px; }
.mine ul, .moderate { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.mine li, .moderate li {
  background: #fff; border: 3px solid var(--c); border-radius: var(--radius); padding: 10px 14px;
}
.mine li p, .moderate li p { margin: 0 0 6px; white-space: pre-wrap; }
.mine li.st-placed { opacity: .75; }
.mine-photo { display: block; max-width: 100%; max-height: 240px; border-radius: 10px; margin-bottom: 6px; }

/* Text oder Foto (K16): Umschalter ohne Skript */
.art-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-bottom: 14px;
              border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; }
.art-choice label { cursor: pointer; }
.art-choice input { position: absolute; opacity: 0; pointer-events: none; }
.art-choice span { display: block; text-align: center; padding: 11px; font-weight: 800; background: #fff; }
.art-choice input:checked + span { background: var(--ink); color: #fff; }
.art-choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -5px; }
.idea-form:has(input[name="art"][value="foto"]:checked) .only-text,
.idea-form:has(input[name="art"][value="text"]:checked) .only-foto { display: none; }

.photo-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-pick-btn {
  display: block; text-align: center; padding: 26px 14px; border: 3px dashed #b8c0d0; border-radius: 12px;
  background: #fff; font-weight: 800; cursor: pointer;
}
.photo-pick input:focus-visible + .photo-pick-btn { outline: 3px solid var(--accent); }
.photo-preview { display: block; max-width: 100%; max-height: 300px; margin: 10px auto 6px; border-radius: 10px; }
.moderate { margin-top: 14px; }
.mine-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px;
             color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.switches { display: inline-block; margin: 0 6px 12px 0; }
.empty { color: var(--muted); padding: 20px 0; }

/* ======================================================================
   Board am Beamer – Vollbild, kein Scrollen
   ====================================================================== */

body.board-page {
  height: 100vh; overflow: hidden; display: flex; flex-direction: column;
  background: #e9edf4;
}
body.board-page > main { flex: 1; display: contents; }

.board-bar {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px;
  background: var(--ink); color: #fff; flex: none;
}
.board-title {
  margin: 0; font-size: 20px; font-weight: 800; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text;
}
.join-chip {
  display: flex; align-items: baseline; gap: 10px; background: #fff; color: var(--ink);
  border: 0; border-radius: 10px; padding: 5px 12px; font: inherit; font-size: 15px; cursor: pointer;
}
.join-chip strong { font-size: 22px; }
.tools { display: flex; align-items: center; gap: 6px; }
.tools .sep { width: 1px; height: 24px; background: rgba(255,255,255,.25); margin: 0 4px; }
.tool {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35);
  border-radius: 8px; padding: 6px 11px; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.tool:hover { border-color: #fff; }
.tool[aria-pressed="true"] { background: #fff; color: var(--ink); border-color: #fff; }
.tool:disabled { opacity: .35; cursor: default; }

/* Phasen: drei Knöpfe als eine Gruppe; „Fertig" gedrückt = grün */
.phase-group { display: inline-flex; }
.phase-group .tool { border-radius: 0; margin-left: -1px; }
.phase-group .tool:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.phase-group .tool:last-child { border-radius: 0 8px 8px 0; }
.phase-group [data-phase="fertig"][aria-pressed="true"] { background: #bbf7d0; border-color: #bbf7d0; color: #14532d; }

/* Abgeschlossen: nichts greifbar, klar erkennbar */
body.locked .item, body.locked .card[data-id], body.locked .link { cursor: default; }
body.locked .handle, body.locked .card-actions { display: none; }
body.locked .board-title::after {
  content: 'abgeschlossen'; margin-left: 10px; font-size: 13px; font-weight: 800; vertical-align: middle;
  background: #bbf7d0; color: #14532d; padding: 2px 8px; border-radius: 999px;
}
.tool:disabled:hover { border-color: rgba(255,255,255,.35); }

.workspace { flex: 1; display: flex; min-height: 0; }

/* ---------- Eingang ---------- */
.inbox {
  width: 250px; flex: none; background: #f8fafc; border-right: 1px solid var(--line);
  padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
}
.inbox h2 { margin: 0; font-size: 17px; }
.inbox h3 { margin: 8px 0 2px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.inbox-hint, .inbox-empty { margin: 0; font-size: 14px; color: var(--muted); }
.inbox-pending, .inbox-list { display: flex; flex-direction: column; gap: 8px; }
.inbox-foot { margin-top: auto; font-size: 13px; color: var(--muted); padding-top: 10px; }

.card[data-id] {
  background: #fff; border: 3px solid var(--c, var(--none)); border-radius: 12px;
  padding: 7px 10px; font-size: 15px; line-height: 1.35; cursor: grab;
  touch-action: none; user-select: none; position: relative;
}
.card.cat-none { border-style: dashed; }
.card.pending { background: #fffbeb; }
.card.lifted { opacity: .35; }
.card-actions { display: flex; gap: 6px; margin-top: 6px; }
.card-actions button {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  font: inherit; font-weight: 800; padding: 3px 0; cursor: pointer;
}
.card-actions .ok { color: var(--ok); }
.card-actions .no { color: var(--err); }

/* ---------- Bühne ---------- */
.stage-wrap { flex: 1; position: relative; overflow: hidden; min-width: 0; }
.stage {
  position: absolute; width: 1600px; height: 1200px; transform-origin: 0 0;
  background: #fff; box-shadow: 0 2px 12px rgba(20, 33, 61, .12);
}
.stage-svg { position: absolute; inset: 0; }
.grid-rect { display: none; }
.stage.grid-on .grid-rect { display: inline; }
.grid-line { stroke: #e2e8f0; stroke-width: 1; }
.grid-rect { pointer-events: none; }
/* Die Feldebene deckt die ganze Bühne ab – ohne pointer-events: none kämen
   Klicks nie bei den Linien darunter an */
.stage-items { position: absolute; inset: 0; pointer-events: none; }
.stage-items .item { pointer-events: auto; }

/* ---------- Verbindungen ---------- */
.link { cursor: pointer; }
.link .hit { fill: none; stroke: transparent; stroke-width: 24; pointer-events: stroke; }
.link .line { fill: none; stroke-width: 3.5; stroke-linecap: round; pointer-events: none; }
.link.selected .line { stroke-width: 6; }
.link .label {
  font: 700 19px 'Nunito', system-ui, sans-serif; text-anchor: middle; dominant-baseline: middle;
  paint-order: stroke; stroke: #fff; stroke-width: 7px; stroke-linejoin: round; pointer-events: none;
}
.link-temp { fill: none; stroke: var(--accent); stroke-width: 4; stroke-dasharray: 10 8; pointer-events: none; }

.link-tools {
  position: absolute; transform: translateX(-50%); z-index: 99990; display: flex; gap: 6px;
}
.link-tools button {
  width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ink); background: #fff;
  font: 800 22px/1 'Nunito', system-ui, sans-serif; cursor: pointer; color: var(--ink);
}
.link-tools [data-link-del] { color: var(--err); border-color: var(--err); }

/* Griffpunkt am rechten Rand (K9): erscheint beim Überfahren und am gewählten
   Feld – bei Touch gibt es kein Überfahren, dort wählt ein Tipp das Feld */
.handle {
  position: absolute; right: -19px; top: 50%; width: 32px; height: 32px; margin-top: -16px;
  border-radius: 50%; background: var(--c, var(--none)); border: 4px solid #fff;
  box-shadow: 0 1px 4px rgba(20, 33, 61, .35); cursor: crosshair; opacity: 0;
  transition: opacity .12s;
}
.handle::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -6px;
  border: solid #fff; border-width: 3px 3px 0 0; transform: rotate(45deg);
}
.item:hover .handle, .item.selected .handle, .item.link-source .handle { opacity: 1; }
.item.selected { outline: 3px solid var(--accent); outline-offset: 4px; }
.item.link-target { outline: 4px solid var(--accent); outline-offset: 4px; }

/* Schrift in logischen Einheiten: am Mindestbildschirm 1024 × 768 wird die
   Bühne auf knapp die Hälfte verkleinert – 25px werden dort zu ~12px. */
.item {
  position: absolute; max-width: 340px; min-width: 100px;
  background: #fff; border: 5px solid var(--c, var(--none)); border-radius: 22px;
  padding: 12px 18px; font-size: 25px; line-height: 1.3; font-weight: 600;
  box-shadow: 0 1px 3px rgba(20, 33, 61, .15);
  cursor: grab; touch-action: none; user-select: none;
}
.item.cat-none { border-style: dashed; }
/* Fotofeld (K16): feste Breite, Höhe aus dem Seitenverhältnis. Rand 5 +
   Polsterung 8 – bildZeichnen() in board.js rechnet mit denselben Werten */
.item.photo { width: 300px; max-width: none; padding: 8px; }
.item.photo img, .card.photo img {
  display: block; width: 100%; height: auto; border-radius: 14px; pointer-events: none; user-select: none;
}
.card.photo { padding: 5px; }
.card.photo img { max-height: 160px; object-fit: cover; border-radius: 8px; }
.edit-photo { display: block; max-width: 100%; max-height: 55vh; margin: 0 auto 14px; border-radius: 12px; }
.item-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.item.dragging { cursor: grabbing; box-shadow: 0 8px 22px rgba(20, 33, 61, .25); }
.item.ghost {
  position: fixed; z-index: 9999; transform-origin: 0 0; pointer-events: none;
  box-shadow: 0 8px 22px rgba(20, 33, 61, .3);
}
.item.ghost.outside { opacity: .5; }

.legend {
  position: absolute; right: 16px; bottom: 14px; display: flex; gap: 10px;
  pointer-events: none; font-size: 19px; font-weight: 700; color: var(--muted);
}
.legend { align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 1200px; }
.legend .lg-cat { border: 4px solid var(--c); border-radius: 12px; padding: 2px 12px; background: #fff; }
.legend .lg-type { display: inline-flex; align-items: center; gap: 6px; background: #fff; padding: 2px 6px; }
.legend .lg-type svg { width: 46px; height: 14px; }

/* Kleiner Beamer (1024 × 768): schmalerer Eingang, damit die Bühne wächst */
@media (max-width: 1200px) {
  .inbox { width: 200px; padding: 10px 8px; }
  .card[data-id] { font-size: 14px; }
  .board-bar { gap: 8px; }
  .join-chip span { display: none; }
  .tool { padding: 5px 8px; font-size: 14px; }
}

/* ---------- Dialoge ---------- */
dialog {
  border: 0; border-radius: var(--radius); padding: 22px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); color: var(--ink);
}
dialog::backdrop { background: rgba(20, 33, 61, .45); }
.edit-dialog { width: min(620px, 94vw); }
.edit-dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link-ends { color: var(--muted); margin: -6px 0 14px; }

/* Aussagearten/Linien bearbeiten */
.kinds-dialog { width: min(720px, 96vw); }
.kinds-dialog h3 { margin: 16px 0 8px; font-size: 16px; }
.kinds-list { display: grid; gap: 6px; margin-bottom: 8px; }
.kind-row { display: flex; gap: 8px; align-items: center; }
.kind-row .k-name { flex: 1; min-width: 0; padding: 7px 10px; font: inherit; border: 1px solid #c5ccd8; border-radius: 8px; }
.kind-row .k-color { width: 42px; height: 36px; padding: 2px; border: 1px solid #c5ccd8; border-radius: 8px; background: #fff; }
.kind-row .k-dash { padding: 7px; font: inherit; font-size: 15px; border: 1px solid #c5ccd8; border-radius: 8px; }
.kind-row .k-arrow { white-space: nowrap; font-size: 15px; }
.kind-row .k-del { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
                   color: var(--err); font: 800 18px/1 'Nunito', sans-serif; cursor: pointer; }
.kinds-actions { margin-top: 18px; }
.plain-choice { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.plain-choice label, .plain-check { display: block; cursor: pointer; margin-bottom: 8px; }
.export-choice:disabled { opacity: .45; cursor: default; }
.type-choice { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 8px;
               grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.type-choice legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.type-choice label { cursor: pointer; }
.type-choice input { position: absolute; opacity: 0; pointer-events: none; }
.type-choice span {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
  border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 15px;
}
.type-choice input:checked + span { border-color: var(--ink); background: #eef2ff; }
.type-choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.export-choices { display: grid; gap: 10px; margin-bottom: 14px; }
.export-choice {
  display: block; text-align: left; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; font: inherit; color: inherit; text-decoration: none; cursor: pointer;
}
.export-choice:hover { border-color: var(--ink); }
.export-choice strong { display: block; font-size: 18px; }
.export-choice span { display: block; color: var(--muted); font-size: 15px; }
.import-form { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.import-form input[type="file"] { padding: 7px; }

.qr-dialog { text-align: center; }
.qr-box { width: min(60vh, 520px); margin: 0 auto; }
.qr-text { font-size: 26px; margin: 12px 0; }
.qr-text strong { font-size: 52px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ======================================================================
   Druck: A3 quer mit Titel, Datum und Legende (K14)

   Die Bühne (1600 × 1200) wird fest auf 0,8 verkleinert: 1280 × 960 px
   passen in die Druckfläche von A3 quer (400 × 277 mm ≈ 1512 × 1047 px bei
   10 mm Rand), der Kopf braucht ~50 px. Die Werte gelten nur, wenn im
   Druckdialog A3 quer gewählt ist – Chrome und Edge übernehmen das aus
   @page vor.
   Die Skalierung per JS (fit) setzt ein Inline-Transform, deshalb hier
   !important.
   ====================================================================== */
.print-head { display: none; }

@page { size: A3 landscape; margin: 10mm; }

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.board-page { height: auto; overflow: visible; display: block; background: #fff; }
  .board-bar, .inbox, .toast, dialog, .link-tools, .flash { display: none !important; }

  .print-head {
    display: flex; justify-content: space-between; align-items: baseline;
    width: 1280px; margin: 0 auto 10px; padding-bottom: 6px; border-bottom: 1px solid #cbd2dc;
  }
  .print-head strong { font-size: 26px; }
  .print-head span { font-size: 16px; color: var(--muted); }

  .workspace { display: block; }
  .stage-wrap { position: relative; width: 1280px; height: 960px; margin: 0 auto; overflow: hidden; }
  .stage {
    left: 0 !important; top: 0 !important; transform: scale(.8) !important;
    box-shadow: none; outline: 1px solid #cbd2dc;
  }
  .stage.grid-on .grid-rect { display: none; }
  .handle { display: none; }
  .item { box-shadow: none; }
  .item.selected { outline: none; }
  .link.selected .line { stroke-width: 3.5; }
}
