/* ============ Seating: table shapes, drag feedback and the export panel ============ */

/* ---- table shapes ---- */
/* a table's box is only there to place things: clicks and drops go to what is drawn */
.table-el{pointer-events:none}
.table-el .table-body, .table-el .seat{pointer-events:auto}
/* every table body is placed by the script, whatever its shape */
.table-el .table-body{transform:none; right:auto; bottom:auto}
.table-el.shape-oval .table-body{border-radius:50%}
.table-el.shape-square .table-body{border-radius:12px}
.table-el .table-name{max-width:100%}

/* a seated name is one line of a set thickness, so tables can be sized to keep names apart */
.seat.occupied{line-height:1.3}
/* which way a seated name runs from its seat */
.seat.occupied.d-r{transform:translate(-13px, -50%)}
.seat.occupied.d-l{transform:translate(calc(-100% + 13px), -50%)}
.seat.occupied.d-cu{transform:translate(-50%, calc(-100% - 17px))}
.seat.occupied.d-cd{transform:translate(-50%, 17px)}
.seat.occupied.d-dr{transform:translate(-13px, 17px)}
.seat.occupied.d-dl{transform:translate(calc(-100% + 13px), 17px)}
.seat.occupied.d-u, .seat.occupied.d-d{
  writing-mode:vertical-rl; max-width:none; max-height:108px; padding:9px 4px;
}
.seat.occupied.d-u{transform:translate(-50%, -100%)}
.seat.occupied.d-d{transform:translate(-50%, 0)}

/* the add-table row and the extra table tools */
.add-table-label{font-size:12px; color:var(--ink-soft); letter-spacing:.04em}
.table-bar select{font-weight:600}
.tb-check{display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--ink-soft); white-space:nowrap; cursor:pointer}
.table-bar .tb-check input{flex:none; min-width:0; max-width:none; width:16px; height:16px; padding:0; accent-color:var(--accent-deep)}

/* while a name or a table is being carried */
body.seat-dragging, body.seat-dragging *{cursor:grabbing !important}

@media (pointer:coarse){
  .table-bar select{font-size:16px; min-height:38px}
  .tb-check{min-height:38px}
  .table-bar .tb-check input{width:20px; height:20px}
}
@media (max-width:760px){
  .add-table-label{width:100%}
}

/* ---- the export panel ---- */
.seat-export{display:flex; flex-direction:column; min-width:0}

/* the way in: a button in the heading and a card that says what it does.
   Beside the plan the card sits under the names, so the floor keeps its full width. */
.btn.seat-export-open{
  display:inline-flex; align-items:center; gap:8px; position:relative; margin-left:12px;
  border-color:var(--accent-deep); background:var(--card); color:var(--accent-deep); font-weight:700;
}
.seat-export-open::before{content:''; position:absolute; left:-13px; top:5px; bottom:5px; width:1px; background:var(--line)}
.seat-export-open svg{flex:none}
.btn.seat-export-open:hover{background:var(--accent-tint); border-color:var(--accent-deep)}
.sx-rail{
  width:100%; border:1px solid var(--accent); border-radius:11px; background:var(--accent-tint);
  color:var(--ink); text-align:left; padding:13px 14px; font:inherit;
  display:grid; grid-template-columns:auto minmax(0, 1fr); gap:6px 11px; align-items:start;
}
.sx-rail:hover{background:color-mix(in srgb, var(--accent) 22%, var(--card))}
.sx-rail:focus-visible, .seat-export-open:focus-visible{outline:2.5px solid var(--accent-deep); outline-offset:2px}
.sx-rail-icon{
  width:36px; height:36px; border-radius:50%; background:var(--card); color:var(--accent-deep);
  display:flex; align-items:center; justify-content:center; border:1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
}
.sx-rail-text{display:flex; flex-direction:column; gap:3px; min-width:0}
.sx-rail-text strong{font-family:var(--serif); font-size:17.5px; font-weight:600; line-height:1.15; color:var(--ink)}
.sx-rail-hint{font-size:12px; line-height:1.4; color:var(--ink-soft)}
.sx-rail-go{
  grid-column:2; justify-self:start; margin-top:4px; padding:6px 16px; border-radius:8px;
  background:var(--accent-deep); color:#fdfcf7; font-size:12.5px; font-weight:700; letter-spacing:.02em;
}
@media (min-width:1101px){
  .seating-wrap{display:grid; grid-template-columns:268px minmax(0, 1fr) auto; grid-template-rows:minmax(0, 1fr) auto; gap:12px 18px}
  /* the sample's banner takes a strip off the top: allow for it, so the foot of the plan stays on screen */
  body:has(#sample-banner:not([hidden])) .seating-wrap{height:calc(100dvh - 319px)}
  .seating-wrap:not(.export-open){grid-template-columns:268px minmax(0, 1fr)}
  .seat-side{grid-column:1; grid-row:1 / span 2; min-height:0}
  .seating-wrap:not(.export-open) .seat-side{grid-row:1}
  .seat-canvas-wrap{grid-column:2; grid-row:1 / span 2; min-width:0}
  .seat-export{grid-column:3; grid-row:1 / span 2; min-height:0}
  /* closed: the panel takes no room of its own and its card drops into the names column */
  .seat-export:not(.open){display:contents}
  .seat-export:not(.open) .sx-rail{grid-column:1; grid-row:2}
}
.sx-body{
  display:none; width:340px; background:var(--card); border:1px solid var(--line); border-radius:11px;
  padding:14px; flex-direction:column; gap:14px; overflow-y:auto; flex:1; min-height:0;
}
.sx-body > *{flex-shrink:0}
.seat-export.open .sx-rail{display:none}
.seat-export.open .sx-body{display:flex}
/* the heading and the preview stay put while the choices scroll under them */
.sx-stage{
  position:sticky; top:-14px; z-index:3; background:var(--card);
  display:flex; flex-direction:column; gap:10px; padding:14px 14px 10px; margin:-14px -14px -10px;
}
.sx-head{display:flex; align-items:center; justify-content:space-between}
.sx-head h3{margin-bottom:0}
.sx-preview-wrap{
  display:flex; justify-content:center; align-items:center; min-height:120px;
  background:color-mix(in srgb, var(--ink) 6%, var(--paper)); border-radius:8px; padding:10px;
}
.sx-preview{display:block; max-width:100%; box-shadow:0 8px 22px -10px rgba(46,44,38,.55); cursor:zoom-in; background:#fff}
.sx-pager{display:flex; align-items:center; justify-content:center; gap:10px; font-size:12.5px; color:var(--ink-soft)}
.sx-pager .btn{min-width:34px; font-size:16px; line-height:1; padding:4px 8px}
.sx-group{display:flex; flex-direction:column; gap:8px; padding-top:12px; border-top:1px solid var(--line-soft)}
.sx-label{font-size:10.5px; letter-spacing:.12em; text-transform:uppercase; font-weight:700; color:var(--ink-soft)}
.sx-row{display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.sx-row select{flex:1 1 auto; min-width:0}
.sx-seg{display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; background:#fff; align-self:flex-start; max-width:100%}
.sx-seg button{
  border:none; background:none; padding:7px 11px; font-size:12.5px; font-weight:600; color:var(--ink-soft);
  border-left:1px solid var(--line); white-space:nowrap;
}
.sx-seg button:first-child{border-left:none}
.sx-seg button:hover{background:var(--accent-tint); color:var(--ink)}
.sx-seg button.on{background:var(--accent-deep); color:#fdfcf7}
.sx-themes{display:grid; grid-template-columns:repeat(auto-fill, minmax(56px, 1fr)); gap:8px 6px}
.sx-theme{
  border:none; background:none; padding:0; display:flex; flex-direction:column; align-items:center; gap:4px;
  font-size:10.5px; line-height:1.2; color:var(--ink-soft); text-align:center;
}
.sx-swatch{
  display:block; width:100%; aspect-ratio:5 / 3.4; border-radius:5px; border:1px solid var(--line);
  position:relative; overflow:hidden;
}
.sx-swatch canvas{position:absolute; inset:0; width:100%; height:100%; display:block}
.sx-theme:hover .sx-swatch{border-color:var(--accent)}
.sx-theme.on .sx-swatch{outline:2.5px solid var(--accent-deep); outline-offset:2px}
.sx-theme.on{color:var(--ink); font-weight:700}
.sx-photo-thumb{width:44px; height:44px; object-fit:cover; border-radius:6px; border:1px solid var(--line)}
.sx-range{display:flex; align-items:center; gap:10px; font-size:12.5px; color:var(--ink-soft)}
.sx-range input{flex:1; min-width:0; padding:0; border:none; background:none; accent-color:var(--accent-deep)}
.sx-fields{display:flex; flex-direction:column; gap:6px}
.sx-fields input{width:100%}
.sx-toggle input{width:16px; height:16px; accent-color:var(--accent-deep)}
.sx-out .btn{width:100%}
.sx-out .sx-row .btn{flex:1 1 auto; width:auto}
.sx-out .sx-row select{flex:0 0 auto}
/* unpaid: what is free and what the export costs, said once above the buttons */
.sx-pay{
  display:flex; flex-direction:column; gap:3px; padding:10px 12px; border-radius:8px;
  background:var(--accent-tint); border:1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  font-size:12.5px; line-height:1.4; color:var(--ink-soft);
}
.sx-pay[hidden]{display:none}
.sx-pay strong{font-size:13.5px; color:var(--ink)}
.sx-note:empty{display:none}
.sx-note{color:var(--accent-deep); font-weight:600}
.seat-export.busy .sx-preview{opacity:.6}
.btn.seat-export-open[aria-expanded="true"]{background:color-mix(in srgb, var(--accent) 26%, var(--card))}

/* narrower windows and phones: the panel sits under the plan, full width */
@media (max-width:1100px){
  /* the card runs across the page: icon, words, then its button at the end */
  .sx-rail{grid-template-columns:auto minmax(0, 1fr) auto; align-items:center}
  .sx-rail-go{grid-column:3; margin-top:0}
  .sx-body{width:100%; overflow:visible; flex:none}
  .sx-stage{top:44px; padding-top:10px; margin-top:-10px}
  .sx-themes{grid-template-columns:repeat(auto-fill, minmax(62px, 1fr))}
}
@media (max-width:760px){
  /* phones: the button in the heading gets a row to itself */
  .btn.seat-export-open{flex:1 1 100%; justify-content:center; margin-left:0}
  .seat-export-open::before{display:none}
  .sx-rail{grid-template-columns:auto minmax(0, 1fr)}
  .sx-rail-go{grid-column:2; margin-top:4px}
}
@media (pointer:coarse){
  .sx-seg button{min-height:40px; padding:8px 12px; font-size:13.5px}
  .sx-theme{font-size:11.5px}
  .sx-rail{min-height:44px}
  .sx-rail-go{padding:9px 18px; font-size:13.5px}
  .sx-toggle input{width:20px; height:20px}
  .sx-range input{min-height:34px}
}

/* ---- printing: only the export sheets, one to a page ---- */
#seat-print{display:none}
@media print{
  html.sx-printing, html.sx-printing body{background:#fff !important; margin:0 !important; padding:0 !important; min-height:0 !important; display:block !important}
  html.sx-printing body > *:not(#seat-print){display:none !important}
  html.sx-printing #seat-print{display:block !important}
  #seat-print .sx-sheet{overflow:hidden; break-after:page; page-break-after:always; break-inside:avoid}
  #seat-print .sx-sheet:last-child{break-after:auto; page-break-after:auto}
  #seat-print .sx-sheet img{display:block; width:100%; height:100%}
}
