/* ==========================================================================
   floorplan.css — the room as it really is (v2.1)

   Two screens share this file, because they must show the same room:

     .np-plan*   the drawing itself — one inline <svg> per zone. Rendered
                 identically by the POS tables sheet (pos.js) and by the
                 editor's preview (floorplan.js), so what the owner arranges
                 is literally what the waiter gets.
     .np-fp*     the editor chrome around it — toolbar, tray, stage,
                 inspector. Réglages › Plan de salle only.

   Three rules govern everything below.

   1. THE ROOM DOES NOT MIRROR (D-172). The plan is geometry, not text. In
      Arabic the toolbar, the tray and the inspector flip like any other
      chrome — logical properties everywhere — but the canvas keeps the bar on
      the wall the bar is actually on. `.np-plan__svg` is therefore pinned to
      `direction: ltr`, and only the label text inside it is allowed to run
      right-to-left.

   2. NO NEW COLOURS. Every value here is a token from tokens.css. The
      occupancy states reuse the same amber/red/ink the list tiles use
      (components.css :871 and :1741), so a table that is late looks late in
      both views.

   3. THE SVG IS THE HIT TARGET. Each table is a <g role="button" tabindex="0">
      carrying the same data-np-table attribute the list tiles carry, so
      pos.js's existing delegated click handler picks it up unchanged.
   ========================================================================== */

/* ==========================================================================
   1 · The drawing — shared by the POS and the editor
   ========================================================================== */

.np-plan {
  position: relative;
  inline-size: 100%;
  border-radius: var(--np-r-card);
  border: 1px solid var(--np-line);
  background: var(--np-cream);
  overflow: hidden;
}

.np-plan__svg {
  display: block;
  inline-size: 100%;
  block-size: auto;
  /* The room is a map. Mirroring it in Arabic would move the bar to the
     other wall and send a waiter the wrong way (D-172). */
  direction: ltr;
  -webkit-user-select: none;
  user-select: none;
}

/* touch-action belongs to the EDITOR alone, where a drag must not be read as a
   scroll. On the POS the plan fills most of a sheet that is 1900 px of content
   in a 690 px phone window: `touch-action: none` there made every pixel of
   every room dead to the finger and the sheet unscrollable (found in the
   adversarial round). The POS plan scrolls like anything else. */
.np-fp .np-plan__svg { touch-action: none; }

/* ---- the ground ---------------------------------------------------- */

.np-plan__ground { fill: var(--np-cream); }

.np-plan__grid line {
  stroke: var(--np-line);
  stroke-width: 0.5;
  opacity: 0.5;
}

/* ---- the room itself: walls, bar counters, the kitchen, doors ------- */
/* Drawn behind the tables, shared by every zone, never interactive in the POS. */

.np-plan__fix { pointer-events: none; }
.np-plan__fix--wall  { fill: var(--np-ink); }
.np-plan__fix--bar   { fill: var(--np-green-soft); stroke: var(--np-muted-line); stroke-width: 1; }
.np-plan__fix--block { fill: var(--np-lav-soft); stroke: var(--np-muted-line); stroke-width: 1; }
.np-plan__fix--door  { fill: none; stroke: var(--np-red); stroke-width: 4; stroke-linecap: round; }
.np-plan__fixlabel {
  fill: var(--np-mid);
  font-size: calc(11px * var(--np-plan-scale, 1));
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* ---- a table ------------------------------------------------------- */

.np-plan__table { cursor: pointer; }

/* The touch target: invisible, but PAINTED. `fill: none` would make it
   invisible to the pointer as well (the default pointer-events is
   visiblePainted), and leaving `fill` undeclared paints it BLACK — which is
   exactly what it did, putting a black box behind every table in the room. */
.np-plan__hit { fill: transparent; pointer-events: all; }

.np-plan__shape {
  fill: var(--np-surface);
  stroke: var(--np-line-input);
  stroke-width: 1.5;
}
/* A table wears its ZONE as its outline. Six zones share one room, and the
   colour is how a waiter tells Bar 1 from Bar 2 at a glance without the room
   being cut into six drawings (D-191). */
.np-plan__shape { stroke: var(--np-zone, var(--np-line-input)); }

/* EVERY font size in the drawing is multiplied by --np-plan-scale, which
   NP.plan.fit() sets to 1000 / rendered-width after the SVG is in the document.
   The viewBox is 1000 units wide whatever the container is, so without this a
   label is 15 units — six pixels in a 420 px sheet, twenty on a 1920 till. With
   it, a name is 15 physical pixels everywhere. The fallback of 1 is what a
   1000 px-wide plan would use, so the drawing is still readable if fit() has
   not run yet. */
.np-plan__name {
  fill: var(--np-ink);
  font-size: calc(15px * var(--np-plan-scale, 1));
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.np-plan__line {
  fill: var(--np-dim);
  font-size: calc(10.5px * var(--np-plan-scale, 1));
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* A shape narrower than 120 rendered pixels shows its name and nothing else;
   the money, the covers and the server move to the tooltip and the long-press
   card. Decided per shape by fit(), in real pixels, so a phone and a 1920 till
   make the decision for themselves. */
.np-plan__table.is-tight .np-plan__line,
.np-plan__table.is-tight .np-plan__chip,
.np-plan__table.is-tight .np-plan__chiptext,
.np-plan__table.is-tight .np-plan__unsent { display: none; }
.np-plan__table.is-tight .np-plan__name {
  /* The name was lifted to make room for the chip; with the chip gone it goes
     back to the middle of the shape. */
  font-size: calc(13px * var(--np-plan-scale, 1));
  transform: translateY(11px);
}
.np-plan__table.is-tight:not(.is-busy):not(.is-current) .np-plan__name { transform: none; }
/* Arabic labels read right-to-left even though the room does not flip. The
   rule is on the <g>, not only on the text, because a browser takes an SVG
   tooltip's direction from the element that owns the <title> — without it the
   hover sentence was laid out left-to-right in Arabic while the identical
   sentence on a list tile was not. Direction affects text, never geometry, so
   the room still does not mirror. */
[dir="rtl"] .np-plan__table,
[dir="rtl"] .np-plan__name,
[dir="rtl"] .np-plan__line,
[dir="rtl"] .np-plan__fixlabel { direction: rtl; }

/* ---- occupancy: the same states, the same tokens, as the list tile --- */

.np-plan__table.is-busy .np-plan__shape { fill: var(--np-amber-soft); stroke: var(--np-amber-line); }
.np-plan__table.is-busy .np-plan__line  { fill: var(--np-amber-ink); }

.np-plan__table.is-current .np-plan__shape { fill: var(--np-ink); stroke: var(--np-ink); }
.np-plan__table.is-current .np-plan__name  { fill: var(--np-cream); }
.np-plan__table.is-current .np-plan__line  { fill: var(--np-onink-2); }

/* The elapsed chip. --np-amber-ink and --np-red both pass AA on their own
   soft backgrounds, which is why the fill changes with the state rather than
   only the pill behind it. */
.np-plan__chip { fill: var(--np-soft); }
.np-plan__chiptext {
  fill: var(--np-mid);
  font-size: calc(10.5px * var(--np-plan-scale, 1));
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.np-plan__table.is-warn  .np-plan__chip { fill: var(--np-amber-soft); }
.np-plan__table.is-warn  .np-plan__chiptext { fill: var(--np-amber-ink); }
.np-plan__table.is-alert .np-plan__chip { fill: var(--np-red-soft); }
.np-plan__table.is-alert .np-plan__chiptext { fill: var(--np-red); }
.np-plan__table.is-current .np-plan__chip { fill: var(--np-onink-fill); }
.np-plan__table.is-current .np-plan__chiptext { fill: var(--np-cream); }

/* An order not yet sent to the kitchen. */
.np-plan__unsent { fill: var(--np-red); }
.np-plan__table.is-current .np-plan__unsent { fill: var(--np-cream); }

/* Move / merge: the legal targets stay lit, the rest go quiet. Same words as
   the list — is-over outlines the table the order would land on. */
.np-plan__table.is-disabled { cursor: not-allowed; opacity: 0.42; }
.np-plan__table.is-over .np-plan__shape { stroke: var(--np-amber); stroke-width: 3; }

/* ---- attention, and the absence of it -------------------------------- */

/* A plan with holes in it is unreadable, so nothing is ever REMOVED from the
   room: a table that does not match the zone or the filter is dimmed, and a
   table that does match a search is outlined. The room keeps its shape,
   whatever the operator is looking for. */
.np-plan__table { transition: opacity 180ms ease; }
.np-plan__table.is-dim { opacity: 0.25; }

.np-plan__table.is-hit .np-plan__shape { stroke: var(--np-lav); stroke-width: 3.5; }
/* While something matches the search, the rest of the room steps back. */
.np-plan__svg.has-hit .np-plan__table:not(.is-hit) { opacity: 0.35; }

/* Selecting a table lifts it and drops the rest to 35 %: one table is the
   subject and the room is its context. */
.np-plan__svg.has-focus .np-plan__table:not(.is-focus) { opacity: 0.35; }
.np-plan__table.is-focus .np-plan__shape {
  stroke: var(--np-zone, var(--np-lav));
  stroke-width: 3.5;
  filter: drop-shadow(0 2px 6px rgba(22, 19, 15, 0.28));
}

/* Ask once, then stop. A room where something blinks for ever is a room
   nobody reads: the eye learns to ignore it within a minute, and then the one
   table that needed attention is invisible too. The lasting signal is the
   static colour of the time chip; these are the moment it CHANGES. */
@keyframes np-plan-pulse {
  0%   { stroke-width: 1.5; }
  40%  { stroke-width: 6; }
  100% { stroke-width: 1.5; }
}
.np-plan__table.is-pulse  .np-plan__shape { animation: np-plan-pulse 700ms ease-out 1; }
.np-plan__table.is-pulse2 .np-plan__shape { animation: np-plan-pulse 650ms ease-out 2; }

/* Something another device changed, for 600 ms, so the operator sees WHAT
   moved rather than noticing later that something did. */
@keyframes np-plan-flash {
  0%, 100% { stroke: var(--np-zone, var(--np-line-input)); }
  50%      { stroke: var(--np-lav); stroke-width: 5; }
}
.np-plan__table.is-flash .np-plan__shape { animation: np-plan-flash 600ms ease-in-out 1; }

/* The operator asked for no movement. Opacity still changes — that is
   information, not decoration — but nothing eases, pulses or flies. */
@media (prefers-reduced-motion: reduce) {
  .np-plan__table { transition: none; }
  .np-plan__table.is-pulse .np-plan__shape,
  .np-plan__table.is-pulse2 .np-plan__shape,
  .np-plan__table.is-flash .np-plan__shape { animation: none; }
}

/* ---- the card beside the selected table ------------------------------- */

.np-fc {
  position: absolute;
  z-index: 3;
  inline-size: min(232px, calc(100% - 16px));
  padding: var(--np-s3);
  border-radius: var(--np-r-card);
  border: 1px solid var(--np-line);
  border-inline-start: 3px solid var(--np-zone, var(--np-ink));
  background: var(--np-surface);
  box-shadow: var(--np-sh-toast);
  display: flex;
  flex-direction: column;
  gap: var(--np-s2);
}
.np-fc__head { display: flex; align-items: center; gap: var(--np-s2); }
.np-fc__name { font-size: 17px; font-weight: 700; }
.np-fc__zone { font-size: var(--np-fs-label); color: var(--np-dim); }
.np-fc__x { margin-inline-start: auto; }
.np-fc__stats { display: flex; flex-wrap: wrap; gap: var(--np-s3); }
.np-fc__stat { display: flex; flex-direction: column; min-inline-size: 0; }
.np-fc__stat b { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.np-fc__stat small { font-size: var(--np-fs-label); color: var(--np-dim); }
.np-fc__who { font-size: var(--np-fs-secondary); color: var(--np-mid); }
.np-fc__acts { display: flex; gap: var(--np-s2); }
.np-fc__acts .np-btn { flex: 1; }

/* The search field says so when nothing matched, instead of emptying the room. */
.np-search input.is-miss,
input.is-miss { border-color: var(--np-amber); background: var(--np-amber-soft); }

/* Focus has to be visible on an SVG too. Composed with the shape's own
   stroke rather than replacing it, and never !important (a11y.js checks). */
.np-plan__table:focus { outline: none; }
/* The ring's own rect is invisible until the shape is focused — and `fill` has
   to be declared HERE, not only in the :focus-visible rule below. An SVG shape
   with no fill declared is painted BLACK, so leaving it out covered every table
   in the room with a black box (found in the first atlas pass). */
.np-plan__focus { fill: none; stroke: none; pointer-events: none; }
.np-plan__table:focus-visible .np-plan__shape {
  stroke: var(--np-lav);
  stroke-width: 3;
}
.np-plan__table:focus-visible .np-plan__focus {
  stroke: var(--np-lav);
  stroke-width: 2;
  stroke-dasharray: 3 3;
}

/* ---- tables with no place on the plan ------------------------------- */
/* Never invisible: they fall back to chips under the canvas (job sheet §9.11). */

.np-plan__loose {
  display: flex;
  flex-wrap: wrap;
  gap: var(--np-s2);
  align-items: center;
  padding: var(--np-s2) 0 0;
}
.np-plan__loose-label { font-size: var(--np-fs-label); color: var(--np-dim); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- the empty state ------------------------------------------------ */

.np-plan__none {
  display: flex;
  flex-direction: column;
  gap: var(--np-s1);
  align-items: center;
  justify-content: center;
  padding: var(--np-s6) var(--np-s4);
  color: var(--np-dim);
  font-size: var(--np-fs-secondary);
  text-align: center;
}

/* ==========================================================================
   2 · The POS tables sheet — the Plan / Liste switch
   ========================================================================== */

.np-tables-views { display: flex; align-items: center; gap: var(--np-s2); }
/* The switch is a .np-seg (components.css :355); it only needs to stop the
   zone picker from crowding it on a narrow sheet. */
.np-tables-views .np-seg { flex: none; }
.np-tables-zones .np-chip { gap: 6px; }
.np-chip__dot {
  inline-size: 8px;
  block-size: 8px;
  border-radius: 3px;
  background: var(--np-zone, var(--np-line));
  flex: none;
}

.np-plan-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--np-s2);
}

/* A wide zone on a wide sheet would otherwise be 600 px tall and push every
   other zone off the screen. `meet` letterboxes the drawing inside whatever box
   it is given, so a max height scales the room down rather than cropping it.
   The POS never scrolls as a page (CLAUDE.v2 rule 8) — only the sheet body. */
.np-plan-wrap .np-plan__svg { max-block-size: 46vh; }

/* The room is one bounded canvas: pan and zoom move the viewBox, so the
   element never grows and the sheet body never has to scroll through it.
   touch-action is only taken once the operator has zoomed IN — at fit there is
   nothing to pan, and stealing the drag there would make the sheet unscrollable
   on a phone, which is exactly the bug the adversarial round found (D-186). */
.np-plan-wrap .np-plan__svg { max-block-size: 52vh; }
.np-plan-wrap .np-plan.is-zoomed { cursor: grab; }
.np-plan-wrap .np-plan.is-zoomed .np-plan__svg { touch-action: none; }
.np-plan-wrap__bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--np-s1);
  padding-block-start: var(--np-s1);
}

/* ==========================================================================
   3 · The editor — Réglages › Plan de salle
   ========================================================================== */

.np-fp {
  display: flex;
  flex-direction: column;
  gap: var(--np-s3);
}

/* ---- toolbar -------------------------------------------------------- */

.np-fp__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--np-s2);
  padding: var(--np-s2);
  border-radius: var(--np-r-card);
  border: 1px solid var(--np-line);
  background: var(--np-surface-alt);
}
.np-fp__bar-group {
  display: flex;
  align-items: center;
  gap: var(--np-s1);
  padding-inline-end: var(--np-s2);
  border-inline-end: 1px solid var(--np-line);
}
.np-fp__bar-group:last-child { border-inline-end: 0; padding-inline-end: 0; }
.np-fp__spacer { flex: 1 1 auto; }

/* Icon-only buttons still carry a text label for screen readers; they are
   40 px on a PC and 48 px wherever the pointer is coarse. */
.np-fp__icon {
  inline-size: var(--np-touch);
  block-size: var(--np-touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
@media (pointer: coarse) { .np-fp__icon { inline-size: 48px; block-size: 48px; } }

/* Undo and redo are the two glyphs in this app that mean a DIRECTION rather
   than a thing. In Arabic the buttons swap places but the arrows kept pointing
   the same way, so the pair ended up pointing at each other. */
[dir="rtl"] .np-fp__icon--dir svg { transform: scaleX(-1); }

/* ---- the working area ----------------------------------------------- */

.np-fp__work {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: var(--np-s3);
  align-items: start;
}
@media (max-width: 1099px) { .np-fp__work { grid-template-columns: 1fr; } }

.np-fp__stage {
  position: relative;
  border-radius: var(--np-r-card);
  border: 1px solid var(--np-line);
  background: var(--np-surface);
  overflow: hidden;
}
/* Zoomed in, the room is larger than its box, so the box has to be scrollable
   — otherwise the outer half of the plan is clipped away with no way back but
   Ajuster, which undoes the zoom you asked for. */
.np-fp__stage.is-zoomed { overflow: auto; }
.np-fp__stage.is-zoomed .np-plan__svg { max-inline-size: none; }
.np-fp__stage .np-plan { border: 0; border-radius: 0; }
.np-fp__stage.is-locked { opacity: 0.72; }

.np-fp__banner {
  display: flex;
  align-items: center;
  gap: var(--np-s2);
  padding: var(--np-s2) var(--np-s3);
  background: var(--np-amber-soft);
  color: var(--np-amber-banner-ink);
  font-size: var(--np-fs-secondary);
  font-weight: 600;
}

/* ---- editor-only overlays on the canvas ------------------------------ */

.np-fp .np-plan__table { cursor: grab; }
.np-fp .np-plan__table.is-sel .np-plan__shape { stroke: var(--np-lav); stroke-width: 3; }
.np-fp .np-plan__table.is-drag { cursor: grabbing; }

/* Resize corner and rotation grip. Drawn in the SVG so they scale with the
   room instead of drifting away from it. */
.np-fp__handle {
  fill: var(--np-surface);
  stroke: var(--np-lav);
  stroke-width: 2;
  cursor: nwse-resize;
}
.np-fp__rot { fill: var(--np-lav); cursor: grab; }
.np-fp__rotline { stroke: var(--np-lav); stroke-width: 1.5; stroke-dasharray: 2 2; }

/* The alignment guide that appears while a table lines up with a neighbour. */
.np-fp__guide { stroke: var(--np-lav); stroke-width: 1; stroke-dasharray: 4 3; pointer-events: none; }

/* Rubber-band selection. */
.np-fp__marquee {
  fill: var(--np-lav-soft);
  fill-opacity: 0.45;
  stroke: var(--np-lav);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

/* ---- tray: the tables that have no place yet ------------------------- */

.np-fp__tray {
  display: flex;
  flex-wrap: wrap;
  gap: var(--np-s2);
  padding: var(--np-s3);
  border-radius: var(--np-r-card);
  border: 1px dashed var(--np-muted-line);
  background: var(--np-surface-alt);
  min-block-size: 64px;
  align-content: flex-start;
}
.np-fp__tray.is-over { border-color: var(--np-lav); background: var(--np-lav-soft); }

.np-fp__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--np-s1);
  min-block-size: var(--np-touch);
  padding: 0 var(--np-s3);
  border-radius: var(--np-r-pill);
  border: 1px solid var(--np-line-input);
  background: var(--np-surface);
  color: var(--np-ink);
  font-size: var(--np-fs-body);
  font-weight: 600;
  cursor: grab;
}
@media (pointer: coarse) { .np-fp__chip { min-block-size: 48px; } }
.np-fp__chip.is-drag { opacity: 0.5; }
.np-fp__chip small { color: var(--np-dim); font-weight: 500; }

/* ---- inspector: exact numbers for the operator who wants them -------- */

.np-fp__insp {
  display: flex;
  flex-direction: column;
  gap: var(--np-s3);
  padding: var(--np-s3);
  border-radius: var(--np-r-card);
  border: 1px solid var(--np-line);
  background: var(--np-surface);
}
.np-fp__insp-title { font-size: var(--np-fs-label); text-transform: uppercase; letter-spacing: 0.04em; color: var(--np-dim); }
.np-fp__nums { display: grid; grid-template-columns: 1fr 1fr; gap: var(--np-s2); }
.np-fp__num { display: flex; flex-direction: column; gap: 2px; }
.np-fp__num label { font-size: var(--np-fs-label); color: var(--np-dim); }
.np-fp__num input {
  min-block-size: var(--np-touch);
  padding: 0 var(--np-s2);
  border-radius: var(--np-r-input);
  border: 1px solid var(--np-line-input);
  background: var(--np-surface);
  color: var(--np-ink);
  font-size: var(--np-fs-body);
  font-variant-numeric: tabular-nums;
  inline-size: 100%;
}
@media (pointer: coarse) { .np-fp__num input { min-block-size: 48px; } }

.np-fp__shapes { display: flex; flex-wrap: wrap; gap: var(--np-s1); }

/* ==========================================================================
   4 · Print — a staff briefing sheet
   ========================================================================== */

@media print {
  /* Black on white, names only: colour cartridges are not what a briefing
     needs, and an amber fill prints as a grey smear. */
  .np-plan { border: 1px solid #000; background: #fff; break-inside: avoid; }
  .np-plan__ground { fill: #fff; }
  .np-plan__grid { display: none; }
  .np-plan__shape { fill: #fff !important; stroke: #000 !important; stroke-width: 1 !important; }
  .np-plan__name { fill: #000 !important; }
  .np-plan__line,
  .np-plan__chip,
  .np-plan__chiptext,
  .np-plan__unsent { display: none; }
  .np-plan__fix--wall { fill: #000; }
  .np-plan__fix--bar,
  .np-plan__fix--block { fill: #fff; stroke: #000; }
  .np-plan__fix--door { stroke: #000; }
  .np-plan__fixlabel { fill: #000; }
  .np-plan__table.is-dim,
  .np-plan__table.is-disabled { opacity: 1; }

  /* None of the editor's furniture belongs on paper. */
  .np-fp__bar,
  .np-fp__tray,
  .np-fp__insp,
  .np-fp__handle,
  .np-fp__rot,
  .np-fp__rotline,
  .np-fp__guide,
  .np-fp__marquee,
  .np-fp__banner,
  .np-fp .np-savebar,
  .np-tables-views { display: none !important; }
  .np-fp__work { grid-template-columns: 1fr; }
  .np-fp__stage { border: 0; }

  /* The section rail is a menu, not a briefing. `is-plan` is put on the hub by
     floorplan.js while its section is on screen and taken off again when the
     operator leaves, so printing any OTHER settings section is untouched. */
  .np-settings.is-plan .np-settings__nav { display: none !important; }
  .np-settings.is-plan .np-settings { grid-template-columns: 1fr; }

  /* A room map with no name on it is a puzzle. This line exists only on paper. */
  .np-fp__printhead { display: block !important; }
  .np-fp__printhead h2 { font-size: 16pt; margin: 0 0 2mm; }
  .np-fp__printhead p { font-size: 9pt; color: #000; margin: 0 0 3mm; }
}

/* …and is invisible on screen. */
.np-fp__printhead { display: none; }
