/* Split layout for the booking page: plan on the left, a rail of details on the
   right, both visible at once. Loaded on top of style.css, which still supplies
   the colours, buttons, notices and hotspot states. */

:root { --rail: 380px; }

/* The whole page is one screen on a desktop: header, then the active stage
   stretched to fill whatever is left. No magic header height to keep in sync. */
.split-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nb-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 11px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* Brand on the left, the step trail in the middle, how to reach us on the right. */
.nb-head .steps { order: 2; margin-left: auto; margin-bottom: 0; }
.nb-head .head-links { order: 3; margin-left: 12px; }

.stage { display: none; }
.stage.active { display: block; flex: 1 1 auto; min-height: 0; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail);
  gap: 16px;
  padding: 14px 20px;
  height: 100%;
}

.pane-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.pane-left.scrolls { overflow-y: auto; }
.pane-left h2 { margin: 0; font-size: 18px; }
.pane-left .intro-line { margin: 0; }

.pane-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.rail-scroll {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rail-foot { flex: 0 0 auto; display: flex; gap: 8px; }
.rail-foot .primary { flex: 1; }

/* ---- The plan ---- */
.plan-holder {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* The frame shrink-wraps the drawing so the hotspot percentages stay true; its
   width is set in script to the largest that fits the holder. */
.plan-frame {
  position: relative;
  max-width: 100%;
  line-height: 0;
  overflow: hidden;
  background: var(--surface);
  user-select: none;
  /* Not `none`: a thumb landing on the plan must still scroll the page. This is
     the customer's page — nothing here is dragged. `manipulation` keeps
     pinch-zoom and only drops the double-tap zoom delay. */
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

/* The drawing is never the thing you tap — the boxes over it are — so keeping it
   out of hit testing stops Android offering to save the image on a long press. */
.plan-frame img { display: block; width: 100%; height: auto; pointer-events: none; }
.plan-holder .empty-state { border: none; background: none; padding: 0; }

.legend-inline { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend-inline span { display: flex; align-items: center; gap: 5px; }

/* On the checkout stage the plan is only there to be looked at. */
#checkout-plan { margin-top: 4px; }
#checkout-plan .hot-box { cursor: default; }

.pane-left .item-grid { margin-bottom: 0; }

/* On a wide screen there's a whole pane for the pictures, so they can be worth
   looking at. On a phone they stay small — more of them fit above the sheet. */
@media (min-width: 861px) {
  .pane-left .item-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .pane-left .item-card img { max-width: 116px; }
  .pane-left .item-card .item-name { font-size: 14px; }
}

/* ---- Cards in the rail ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.card h3 { margin: 0 0 8px; font-size: 14px; }
.card h3 .badge { float: right; }
.card.accent { border-left: 3px solid var(--accent); }
.card .muted-line { margin: 8px 0 0; font-size: 13px; }
.card > label.stack:last-child { margin-bottom: 0; }

.mini-row { display: flex; gap: 8px; }
.mini-row label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

label.stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.mini-row input, .mini-row select, label.stack input {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.card .checkbox-line { font-size: 13px; }

/* ---- The quantity, which is the whole question on the goods screen ---- */
.qty-card { border-left-width: 4px; }
.qty-label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 9px; }
.qty-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.qty-row input {
  width: 130px;
  flex: 0 0 auto;
  padding: 9px 11px;
  border: 2px solid var(--accent);
  border-radius: 7px;
  font-family: inherit;
  font-size: 22px;
  font-weight: 600;
  text-align: right;
  background: var(--surface);
  color: var(--text);
}

.qty-unit { font-size: 14px; color: var(--muted); min-width: 0; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.facts div { display: flex; flex-direction: column; }
.facts span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.facts strong { font-size: 15px; }

.detail-btn { width: 100%; margin-top: 10px; }

.pick-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.pick-row:last-of-type { border-bottom: none; }
.pick-row .sub { color: var(--muted); font-size: 12px; }

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 2px solid var(--border);
  font-weight: 600;
}

.total-row .big { font-size: 20px; }

.rail-scroll .notice { margin: 0; font-size: 13px; }
.rail-scroll .hold-timer:not(:empty) { margin-bottom: 0; }
.rail-scroll .error { margin: 0 2px; }

/* ---- The space list, for thumbs that miss on a hand-drawn plan ---- */
.space-list { display: none; }

.space-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--good);
  border-radius: var(--radius);
}

.space-row + .space-row { margin-top: 7px; }
.space-row { scroll-margin-bottom: calc(var(--bar-h, 0px) + 10px); }
.space-row.added { border-left-color: var(--accent); background: #f5f8ff; }
.space-row.gone { border-left-color: var(--warn); opacity: 0.6; }
.space-row .who { flex: 1; min-width: 0; }
.space-row .nm { font-weight: 600; font-size: 14px; }
.space-row .mt { font-size: 12px; color: var(--muted); }
.space-row .pr { text-align: right; font-size: 13px; white-space: nowrap; }
.space-row button { padding: 5px 11px; font-size: 13px; }

.centred {
  height: 100%;
  display: flex;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

/* Centred by auto margins rather than align-items. With align-items: center, the
   moment the content is taller than this box its top is pushed above the scroll
   area and cannot be scrolled back to — the confirmation heading disappeared
   under the header as soon as the payment details made the panel tall. Auto
   margins centre a short panel exactly the same way and leave a tall one
   scrollable from its first line. */
.centred > * { margin: auto; }

.centred .empty-state { max-width: 560px; }

.foot-total { display: none; }

@media (max-width: 860px) {
  /* Two columns can't survive a phone, and a bottom sheet is worse: it swallows
     the screen, leaving a sliver of the plan you're supposed to be picking from.
     So the panes dissolve and their cards run down one column in reading order,
     with nothing fixed but a slim bar carrying the total and the button. */
  .split-body { height: auto; overflow: visible; display: block; }
  .stage.active { display: block; }

  .split {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: auto;
    padding: 10px 12px 84px;
  }

  .pane-left, .pane-right, .rail-scroll { display: contents; }

  /* Dates before the plan, the tapped space's facts right under it, the list
     under that — the order a thumb works down the screen. */
  #stage-pick .card.dates { order: 1; }
  #stage-pick .legend-inline { order: 2; }
  #stage-pick .plan-holder { order: 3; }
  #stage-pick #space-detail { order: 4; }
  #stage-pick .space-list { order: 5; }
  #stage-pick #picks-card { order: 6; }
  #stage-pick .rail-foot { order: 7; }

  /* The countdown first, then what you're paying for, then the form that ends
     it. The plan is confirmation, so it goes last rather than between them. */
  #stage-checkout #hold-timer { order: 1; }
  #stage-checkout h2 { order: 2; }
  #stage-checkout #order-summary { order: 3; }
  #stage-checkout .rail-scroll .card { order: 4; }
  #stage-checkout #pay-error { order: 5; }
  #stage-checkout .info-notice { order: 6; }
  #stage-checkout #checkout-plan { order: 7; }
  #stage-checkout .rail-foot { order: 8; }

  .plan-holder { height: auto; padding: 8px; }
  /* Sized by width on a phone — fixing the height instead forces the frame
     wider than the viewport. */
  .plan-frame { width: 100%; }

  .space-list { display: block; }

  .rail-foot {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    align-items: center;
    padding: 9px 12px calc(9px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.1);
  }

  .rail-foot button { flex: 0 0 auto; }
  .rail-foot .primary { flex: 1 1 auto; }

  .foot-total:not(:empty) {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    line-height: 1.3;
  }

  .foot-total strong { display: block; font-size: 15px; }
  .foot-total span {
    display: block;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .centred { height: auto; }

  /* Three pills wrap onto two lines at this width and eat the screen. Nor does
     the header earn a permanent 100px on a phone — it scrolls away instead. */
  .nb-head { padding: 9px 12px; gap: 8px; position: static; }
  .nb-head h1 { font-size: 16px; }

  /* Every pixel here is a pixel of plan you can't see. */
  .card { padding: 10px 12px; }
  .card.dates .muted-line { margin-top: 6px; }
  .mini-row input, .mini-row select, label.stack input { padding: 6px 8px; }
  /* Everything in the header shares one left edge. Right-aligning the contact
     chips while the brand and the steps start at the left reads as a mistake. */
  .nb-head .head-links { order: 2; margin-left: 0; gap: 6px; }
  .nb-head .head-call, .nb-head .head-wa { font-size: 12px; padding: 5px 9px; }
  .nb-head .steps { order: 3; margin-left: 0; width: 100%; gap: 6px; flex-wrap: nowrap; }
  .steps li {
    font-size: 11px;
    padding: 4px 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
