/* SeatingChart — planner widget + print stylesheet.
   Theme colors come from site.config.json (--primary teal / --accent amber).
   Print strategy: body > .sc-print (built by seatingchart.js on print) holds
   page 1 = the chart SVG cloned at content bounds, page 2 = an alphabetical
   guest→table list. Everything else is display:none on paper. */

.sc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  margin: 1.4rem 0 2rem;
  /* The tool lives inside .prose (46rem) but a seating room needs the full
     .wrap width (72rem). This breaks out rightward, capped by the viewport —
     no horizontal scroll since it never exceeds 100vw - 2rem. */
  width: min(calc(var(--wrap) - 2rem), calc(100vw - 2rem));
}

/* ---- event bar ---- */

.sc-eventbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.sc-eventbar .sc-f {
  flex: 1 1 12rem;
  min-width: 9rem;
}
.sc-ebtns {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.sc-ebtns button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--bg);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.8rem;
  min-height: 44px;
  cursor: pointer;
}
.sc-ebtns button:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--bg));
}

/* ---- shared field styling ---- */

.sc-f {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  min-width: 0;
}
.sc-f > span em {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.sc-f input,
.sc-f select,
.sc-panel textarea {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  min-height: 44px;
  width: 100%;
}
.sc-panel textarea {
  font-weight: 400;
  resize: vertical;
  min-height: 5.5rem;
}
.sc-f input:focus,
.sc-f select:focus,
.sc-panel textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.sc-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.sc-check input {
  accent-color: var(--primary);
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
}
.sc-row {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  flex-wrap: wrap;
}
.sc-row .sc-f {
  flex: 1 1 6.5rem;
}
.sc-grow {
  flex: 2 1 10rem;
}

/* ---- main layout ---- */

.sc-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 19rem;
  gap: 0.9rem;
  margin-top: 0.9rem;
}

/* ---- board ---- */

.sc-board {
  min-width: 0;
}
.sc-tools {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.sc-tools button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--bg);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}
.sc-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
  flex: 1 1 14rem;
}
/* On touch/narrow screens the tray sits ~a viewport away from the seats, so
   tray→seat drag can't complete — lead with the tap-assign path instead. */
.sc-hint-tap { display: none; }
@media (pointer: coarse), (max-width: 560px) {
  .sc-hint-drag { display: none; }
  .sc-hint-tap { display: inline; }
}
.sc-svg {
  display: block;
  width: 100%;
  aspect-ratio: 10 / 7;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background:
    repeating-conic-gradient(var(--surface-2) 0% 25%, var(--bg) 0% 50%) 0 0 /
    22px 22px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.sc-seat {
  cursor: pointer;
}
.sc-t .sc-tbl {
  cursor: grab;
}
.sc-status {
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  min-height: 1.3em;
}
.sc-count {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ---- side panels ---- */

.sc-side {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
}
.sc-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.8rem;
}
.sc-panel h2 {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.sc-panel .sc-row + .sc-row,
.sc-panel label + label,
.sc-panel .sc-f + .sc-check,
.sc-panel .sc-check + .sc-check,
.sc-panel .sc-check + .sc-row,
.sc-panel label + .sc-row {
  margin-top: 0.55rem;
}
.sc-editor {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
}
.sc-mini {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--bg);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.8rem;
  min-height: 44px;
  cursor: pointer;
}
.sc-mini:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--bg));
}
.sc-mini.danger {
  color: #b91c1c;
  border-color: #b91c1c;
}
.sc-mini.danger:hover {
  background: #fef2f2;
}
.sc-import summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 0.35rem 0;
}
.sc-import textarea {
  margin-top: 0.4rem;
}
.sc-import button {
  margin-top: 0.45rem;
}

/* ---- tray ---- */

.sc-traycount {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
}
.sc-tray-wrap {
  margin-top: 0.55rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  max-height: 14rem;
  overflow-y: auto;
}
.sc-tray {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.sc-g {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  min-height: 34px;
}
.sc-g:hover {
  border-color: var(--primary);
}
.sc-g:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.sc-g.sc-armed {
  background: #fef3c7;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}
.sc-badge {
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  background: var(--accent);
  border-radius: 3px;
  padding: 0.15rem 0.28rem;
}
.sc-note {
  color: var(--accent);
  font-size: 0.85rem;
}
.sc-empty {
  font-size: 0.84rem;
  color: var(--text-dim);
  padding: 0.5rem 0.6rem;
  list-style: none;
}

/* ---- drag chip ---- */

.sc-chip {
  position: fixed;
  z-index: 60;
  transform: translate(-50%, -130%);
  pointer-events: none;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  white-space: nowrap;
  max-width: 70vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- actions ---- */

.sc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}
.sc-actions .sc-btn {
  font: inherit;
  font-size: 0.94rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, var(--accent)));
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.62rem 1.15rem;
  min-height: 44px;
  cursor: pointer;
}
.sc-actions .sc-btn:hover {
  filter: brightness(1.08);
}
.sc-actions .sc-btn.ghost {
  color: var(--primary);
  background: var(--bg);
  border: 1.5px solid var(--primary);
}

/* ---- prose helpers ---- */

.privnote {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.92rem;
}
.prose table.fmt td:first-child,
.prose table.fmt th:first-child {
  min-width: 7rem;
}

/* ---- print ----
   Only body > .sc-print survives on paper: page 1 chart + page 2 guest list.
   Static because nothing here depends on run-time state — the JS just fills
   the holder and calls window.print(). */

.sc-print {
  display: none;
}

@media print {
  @page {
    margin: 10mm;
  }
  body > *:not(.sc-print) {
    display: none !important;
  }
  .sc-print {
    display: block !important;
    color: #000;
    font-family: system-ui, "Segoe UI", sans-serif;
  }
  .sc-print h1 {
    font-size: 18pt;
    margin: 0 0 1.5mm;
  }
  .sc-print .sc-pmeta {
    font-size: 9pt;
    color: #444;
    margin: 0 0 5mm;
  }
  .sc-print-chart {
    page-break-after: always;
    break-after: page;
  }
  .sc-print svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 250mm;
    border: 0.5pt solid #ccc;
  }
  .sc-print table {
    border-collapse: collapse;
    width: 100%;
    font-size: 10pt;
  }
  .sc-print th,
  .sc-print td {
    border-bottom: 0.4pt solid #bbb;
    text-align: left;
    padding: 1.5mm 2mm;
    vertical-align: top;
  }
  .sc-print th {
    font-size: 8pt;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #555;
  }
  .sc-print .sc-pun td {
    color: #777;
    font-style: italic;
  }
  .sc-print .sc-pnote {
    color: #555;
    font-size: 8.5pt;
  }
}

/* ---- small screens ---- */

@media (max-width: 900px) {
  .sc-main {
    grid-template-columns: 1fr;
  }
  /* board stays on top (it's first in DOM); panels stack below it */
}
@media (max-width: 560px) {
  .sc {
    padding: 0.7rem;
  }
  .sc-eventbar .sc-f {
    flex-basis: 100%;
  }
  .sc-actions .sc-btn {
    flex: 1 1 auto;
    text-align: center;
  }
}
