/**
 * BK ClinicQ: the patient and board layouts (Issue 5).
 *
 * The dashboard layout is the kernel console and is styled by admin.css. These two frames sit
 * beside it and read the same tokens from site.css: they differ in width, density and which step
 * of the type scale their text reads, never in colour. So a clinic's brand green, its dark theme
 * and its contrast are decided once, in site.css, for all three.
 * tests/unit/platform/test_ui_shell.py fails on a colour literal in this file.
 */

/* ── Shared flow utilities ──────────────────────────────────── */

/* Vertical rhythm: children of a stack are spaced by --stack-gap (default one step). */
.stack > * + * { margin-top: var(--stack-gap, var(--space-4)); }
/* A row of small things that wraps: badges, buttons, facts. */
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ── Patient: mobile-first, one column, big targets ─────────── */

.layout-patient {
  --layout-max: 30rem;
  font-size: var(--step-0);
}

.patient-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
}

.patient-main {
  flex: 1;
  width: min(100% - 2 * var(--gutter), var(--layout-max));
  margin-inline: auto;
  padding-block: var(--space-5) var(--space-7);
}
.patient-main h1 { font-size: var(--step-3); }
.patient-main .lead { margin-top: var(--space-2); color: var(--muted); font-size: var(--step-1); }

.patient-footer {
  display: flex; justify-content: center; gap: var(--space-5);
  padding: var(--space-5) var(--gutter) var(--space-6);
  font-size: var(--step--1);
  color: var(--muted);
}
.patient-footer a { color: var(--brand-deep); font-weight: 500; }
.patient-footer a:hover { text-decoration: underline; }

/* The number a patient holds: large enough to read at arm's length in a queue. */
.ticket-number {
  font-size: var(--step-4);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.03em;
  color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
}
.ticket-facts {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3);
  margin-top: var(--space-4);
}
.ticket-facts dt { color: var(--muted); font-size: var(--step--1); }
.ticket-facts dd { font-size: var(--step-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Board: kiosk, full screen, read from five metres ───────── */

.layout-board {
  height: 100dvh;
  overflow: hidden;
  /* Nothing to click: the pointer would only ever be a stray cursor on a TV. */
  cursor: none;
}

.board {
  display: grid;
  grid-template-columns: 3fr 2fr;
  grid-template-rows: auto 1fr auto;
  gap: clamp(1rem, 2.5vw, 3rem);
  height: 100dvh;
  padding: clamp(1rem, 3vw, 4rem);
}

.board-header {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-5);
  font-size: var(--step-3);
  font-weight: 600;
}
.board-clock { color: var(--muted); font-variant-numeric: tabular-nums; }

.board-now {
  display: grid; place-content: center; gap: var(--space-4);
  text-align: center;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--brand);
  color: var(--on-brand);
}
.board-now-label { font-size: var(--step-3); font-weight: 500; }
.board-now-number {
  font-size: var(--step-5);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.board-now-room { font-size: var(--step-3); font-weight: 600; }

.board-next {
  display: flex; flex-direction: column;
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  min-height: 0;
}
.board-next h2 { font-size: var(--step-3); color: var(--muted); font-weight: 500; }
.board-next ol { margin-top: var(--space-4); }
.board-next li {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--line-soft);
  font-size: clamp(1.75rem, 1rem + 2.6vw, 4.5rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.board-next li:last-child { border-bottom: 0; }
.board-next li span { color: var(--muted); font-size: var(--step-3); font-weight: 500; }

.board-footer {
  grid-column: 1 / -1;
  font-size: var(--step-2);
  color: var(--muted);
}

/* A portrait screen stacks the two panels instead of squeezing them side by side. */
@media (max-aspect-ratio: 1 / 1) {
  .board { grid-template-columns: 1fr; grid-template-rows: auto 1fr 1fr auto; }
}

@media (prefers-reduced-motion: reduce) {
  .board * { transition: none; animation: none; }
}

/* The patient's consent list (Issue 21): one question per row, each with its own switch. The
   whole row is the label, so a tap anywhere on the question toggles it: a 44px target on the
   cheapest phone, not a 20px checkbox. */
.consent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.consent-item + .consent-item { border-top: 1px solid var(--line-soft); padding-top: var(--space-4); }
.consent-label {
  display: flex; align-items: flex-start; gap: var(--space-3);
  min-height: 2.75rem; cursor: pointer;
}
.consent-label input[type="checkbox"] { width: 1.35rem; height: 1.35rem; margin-top: .15rem; flex: none; accent-color: var(--brand); }
.consent-question { color: var(--ink); }
.consent-version { color: var(--muted); font-size: var(--step--1); text-align: center; }

/* Accepting a staff invitation (Issue 22): a short form on the public narrow layout, which loads
   this file rather than the admin stylesheet, so it carries its own field styles. */
.invite-field label { display: block; font-size: var(--step--1); color: var(--muted); margin-bottom: .3rem; }
.invite-field input {
  width: 100%; min-height: 2.75rem; padding: 0 .75rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.invite-field input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.invite-hint { color: var(--muted); font-size: var(--step--1); margin-top: .35rem; }

/* ── Patient: the header's icons, the bottom bar and its sheets (Issue 255) ─ */

/* The one sprite every icon is drawn from: in the page, never shown itself. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.5rem; height: 1.5rem; flex: none; }

.patient-header-actions { display: flex; align-items: center; gap: var(--space-2); }
/* The website link: the theme toggle's round quiet button, so the two read as a pair. */
.header-icon {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.header-icon:hover { color: var(--brand-deep); border-color: var(--brand); background: var(--bg-soft); }
.header-icon .icon { width: 1.2rem; height: 1.2rem; }

/* The bar is fixed to the bottom of the screen, so the page is padded by its height and by the
   phone's safe area (the home indicator on an iPhone): nothing, the legal footer included, sits
   under it. `--bar-h` is the tallest an item gets, a 48 px target with room for its word. */
:root { --bar-h: 3.75rem; }
.layout-patient.has-bottom-bar { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); }
/* Whatever the browser scrolls into view (a focused field, a link to a section, an option in a sheet
   opened in place) stops above the bar, not under it. */
html:has(> body.has-bottom-bar) { scroll-padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + var(--space-3)); }
/* Toasts rise above the bar rather than covering it. */
.layout-patient.has-bottom-bar .toast-stack { bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + var(--space-3)); }

.bottom-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  /* A hairline drawn as a shadow, not a border, so the bar is exactly --bar-h tall. */
  box-shadow: 0 -1px 0 var(--line);
}
.bottom-bar-list { display: flex; width: min(100%, var(--layout-max)); margin-inline: auto; }
.bottom-bar-list > li { display: flex; flex: 1 1 0; min-width: 0; }
.bottom-bar .sheet { display: flex; flex: 1; min-width: 0; }

.bottom-bar-item {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  min-width: 3rem;
  min-height: var(--bar-h);
  padding: .4rem .125rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .75rem;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  list-style: none;
}
.bottom-bar-item::-webkit-details-marker { display: none; }
.bottom-bar-item:hover { color: var(--brand-deep); }
.bottom-bar-label { max-width: 100%; overflow-wrap: anywhere; }
/* The current item: heavier, in the brand's deep green, with an indicator bar along its top edge,
   so it is told apart by shape and weight as well as colour. */
.bottom-bar-item[aria-current],
.bottom-bar-item[aria-pressed="true"],
.sheet[open] > .bottom-bar-item { color: var(--brand-deep); font-weight: 700; }
.bottom-bar-item[aria-current]::before,
.bottom-bar-item[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 22%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--brand);
}
.bottom-bar-item:focus-visible { outline-offset: -3px; }

.bar-badge {
  position: absolute;
  top: .3rem;
  left: calc(50% + .35rem);
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 .3rem;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: var(--on-brand);
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1.15rem;
}

/* A sheet. Without JavaScript it is a <details> that opens in place; one in the bar rises above the
   bar instead of pushing it. sheet.js moves the panel into a modal <dialog> (below). */
.sheet-panel { color: var(--ink); }
.sheet-panel > * + * { margin-top: var(--space-3); }
.bottom-bar .sheet[open] > .sheet-panel {
  position: fixed;
  inset-inline: 0;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
  width: min(100%, var(--layout-max));
  max-height: 70vh;
  margin-inline: auto;
  padding: var(--space-4) var(--gutter);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.sheet-title { font-size: var(--step-1); }
.sheet-close {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.sheet-close[hidden] { display: none; }
.sheet-close:hover { color: var(--brand-deep); border-color: var(--brand); }

.sheet-list { display: grid; gap: var(--space-1); }
.sheet-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 3rem;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sheet-item:hover { background: var(--bg-soft); color: var(--brand-deep); }
.sheet-item[aria-current], .sheet-item[aria-pressed="true"] { color: var(--brand-deep); font-weight: 700; }
.sheet-item .bar-badge { position: static; margin-left: auto; order: 2; }

/* The enhanced sheet: a modal <dialog> along the bottom edge, the page dimmed behind it. The
   browser keeps focus inside it and makes the rest of the page inert while it is open. */
.sheet-dialog {
  width: min(100%, var(--layout-max));
  max-width: 100%;
  max-height: min(85vh, 40rem);
  margin: auto auto 0;
  padding: var(--space-4) var(--gutter) calc(var(--space-5) + env(safe-area-inset-bottom));
  border: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.sheet-dialog::backdrop { background: var(--scrim); }
.sheet-dialog[open] { animation: sheet-rise .2s ease-out; }
@keyframes sheet-rise { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .sheet-dialog[open] { animation: none; }
}

@media print {
  .bottom-bar, .sheet-dialog { display: none; }
  .layout-patient.has-bottom-bar { padding-bottom: 0; }
}

/* A short page centred in the screen above the bar: the app's home (Issue 256), a heading, one
   sentence and one button, which fits a 360 x 640 screen with nothing to scroll. */
.patient-main-centred { display: flex; flex-direction: column; justify-content: center; }
.app-home { --stack-gap: var(--space-4); }
