/* Tablekeeper: warm, calm hospitality styling. System fonts only; nothing loads from outside the app. */

:root {
  --paper: #faf6ef;
  --surface: #fffdf9;
  --stone: #f1ebe2;
  --stone-deep: #e7dfd3;
  --line: #e2d7c8;
  --line-strong: #b9a892;
  --ink: #2a211c;
  --ink-soft: #54473e;
  --muted: #6e6056;
  --accent: #a8462a;
  --accent-strong: #8a3720;
  --accent-tint: #f6e5db;
  --success: #2c6339;
  --success-tint: #e2eee2;
  --danger: #9f2a21;
  --danger-tint: #f9e2df;
  --warn: #6f4b00;
  --warn-tint: #fbefcf;
  --warn-line: #d9b45a;
  --focus: #1d4f91;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --radius-small: 8px;
  --shadow: 0 1px 2px rgba(42, 33, 28, 0.06), 0 4px 16px rgba(42, 33, 28, 0.05);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; color: var(--ink); }
p { margin: 0; }
a { color: var(--accent-strong); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 10;
  background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: var(--radius-small);
}
.skip-link:focus { top: 12px; }

.icon { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- Header and navigation ---------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header__inner {
  max-width: 1160px; margin: 0 auto; padding: 12px 20px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; }
.brand__mark { width: 30px; height: 30px; }
.brand__name { font: 600 1.4rem/1 var(--serif); color: var(--ink); letter-spacing: 0.01em; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.site-nav__link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 10px;
  border-radius: var(--radius-small); color: var(--ink-soft); font-weight: 600; text-decoration: none;
}
.site-nav__link:hover { background: var(--stone); color: var(--ink); }
.site-nav__link[aria-current="page"] { color: var(--accent-strong); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.account { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.current-user { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.current-user__name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent-strong); font: 700 0.85rem/1 var(--sans);
}

@media (max-width: 639px) {
  .site-header__inner { padding: 10px 16px; gap: 4px 12px; }
  .brand { order: 1; }
  .account { order: 2; }
  .site-nav { order: 3; width: 100%; margin-left: -10px; }
  .brand__name { font-size: 1.25rem; }
}

/* ---------- Page scaffolding ---------- */

/* The page never scrolls sideways: anything wider is clipped here (clip, unlike
   hidden, is not a scroll container, so programmatic scrolling cannot shift it
   and sticky elements keep working). Wide content scrolls in its own container. */
.page {
  position: relative; overflow-x: clip;
  flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: 32px 20px 56px;
}
@media (max-width: 639px) { .page { padding: 20px 16px 40px; } }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; }
.site-footer p { max-width: 1160px; margin: 0 auto; padding: 18px 20px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.eyebrow {
  font: 700 0.78rem/1.4 var(--sans); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-strong); margin-bottom: 8px;
}
.intro { margin-bottom: 24px; max-width: 760px; }
.intro__title { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); }
.intro__lede { margin-top: 10px; color: var(--ink-soft); font-size: 1.05rem; max-width: 62ch; }
.intro--compact .intro__title { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }

.stack > * + * { margin-top: 16px; }

/* ---------- Form controls ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.field__hint { font-size: 0.85rem; color: var(--muted); }
.input {
  width: 100%; min-height: 46px; padding: 10px 12px;
  font: 400 1rem/1.3 var(--sans); color: var(--ink);
  background: #fff; border: 1.5px solid var(--line-strong); border-radius: var(--radius-small);
}
.input:hover { border-color: var(--ink-soft); }
.input:focus-visible { border-color: var(--focus); }
.input--reference { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: 0.08em; }
select.input { appearance: auto; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  font: 600 1rem/1.2 var(--sans); text-decoration: none; cursor: pointer;
  color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--ink); border-radius: var(--radius-small);
}
.button:hover { background: var(--stone); color: var(--ink); }
.button--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.button--danger { color: var(--danger); border-color: var(--danger); }
.button--danger:hover { background: var(--danger-tint); color: var(--danger); }
.button--ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.button--small { min-height: 38px; padding: 6px 12px; font-size: 0.92rem; }
.button--block { width: 100%; }
.button[disabled] { cursor: progress; opacity: 0.7; }

/* ---------- Search ---------- */

.search-bar, .lookup-bar {
  display: grid; gap: 16px; padding: 20px; align-items: end;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) minmax(0, 0.8fr) auto;
}
.lookup-bar { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 799px) {
  .search-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 16px; }
  .search-bar .field--grow, .search-bar .field--action { grid-column: 1 / -1; }
}
@media (max-width: 519px) {
  .lookup-bar { grid-template-columns: minmax(0, 1fr); padding: 16px; }
}

.workspace { display: grid; gap: 24px; margin-top: 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) {
  .workspace--booking { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .workspace--booking .booking-panel { position: sticky; top: 20px; }
}
.booking-panel:empty { display: none; }
.results { min-width: 0; }

.results__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px 24px; margin-bottom: 14px; }
.results__title { font-size: 1.45rem; }
.results__meta { color: var(--ink-soft); margin-top: 4px; }
.results__refresh { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; margin: 0; padding: 0; font-size: 0.85rem; color: var(--ink-soft); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend__swatch.cell { width: 24px; height: 20px; min-height: 0; padding: 0; border-radius: 5px; }
.legend__swatch .icon { width: 12px; height: 12px; }

/* position: relative makes the scroller the containing block of absolutely
   positioned descendants (visually-hidden labels), so they scroll inside it
   instead of widening the page. */
.grid-scroll {
  position: relative; max-width: 100%; overflow-x: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.grid-hint { margin: 0 0 8px; font-size: 0.85rem; color: var(--muted); }
.grid-hint[hidden] { display: none; }
@media (max-width: 639px) {
  .grid td { min-width: 88px; }
  .cell { font-size: 0.84rem; padding: 6px; }
}
.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
.grid th, .grid td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:last-child th, .grid tbody tr:last-child td { border-bottom: 0; }
.grid thead th {
  padding: 12px 6px 10px; text-align: left; font: 600 0.9rem/1.25 var(--sans); color: var(--ink);
  background: var(--stone); border-bottom: 1px solid var(--line);
}
.grid thead th:first-child { padding-left: 14px; }
.grid__table-name { display: block; }
.grid__table-seats { display: block; font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.grid tbody th {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  padding-left: 14px; padding-right: 10px; text-align: left; white-space: nowrap;
  font: 600 1rem/1 var(--sans); font-variant-numeric: tabular-nums;
}
.grid thead th:first-child { position: sticky; left: 0; z-index: 2; }
.grid td { min-width: 96px; }
.grid td.grid__combos { min-width: 168px; }

.cell {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 44px; padding: 6px 8px;
  border-radius: var(--radius-small); font: 600 0.9rem/1.15 var(--sans);
}
button.cell { cursor: pointer; }
.cell--available { background: #fff; color: var(--accent-strong); border: 1.5px solid var(--accent); }
.cell--available:hover { background: var(--accent-tint); }
.cell--available[aria-disabled="true"] { cursor: progress; }
.cell--selected, .cell--selected:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.cell--unavailable { background: var(--stone); color: var(--muted); border: 1.5px dashed var(--line-strong); font-weight: 500; }
.cell--mine { background: var(--success-tint); color: var(--success); border: 1.5px solid var(--success); }
.cell--combo { justify-content: flex-start; text-align: left; }
.cell__text { display: flex; flex-direction: column; }
.cell__sub { font-weight: 400; font-size: 0.78rem; }
.grid__combo-list { display: flex; flex-direction: column; gap: 6px; }
.grid__none { color: var(--muted); padding-left: 8px; }

/* ---------- States ---------- */

.state {
  padding: 36px 24px; text-align: center; border-radius: var(--radius);
  border: 1.5px dashed var(--line-strong); background: var(--surface); color: var(--ink-soft);
}
.state__icon { width: 36px; height: 36px; color: var(--accent); margin-bottom: 8px; }
.state__title { font-size: 1.3rem; margin-bottom: 6px; }
.state__text { max-width: 52ch; margin: 0 auto; }
.state .button { margin-top: 16px; }

.skeleton { display: grid; gap: 10px; padding: 16px; }
.skeleton__row { height: 44px; border-radius: var(--radius-small); background: var(--stone); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-weight: 600; padding: 4px 2px 12px; }

.spinner { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px;
  border-radius: var(--radius-small); border: 1.5px solid; font-size: 0.95rem;
}
.notice .icon { margin-top: 2px; }
.notice__title { font-weight: 700; display: block; }
.notice--error { background: var(--danger-tint); border-color: var(--danger); color: var(--danger); }
.notice--error .notice__body { color: var(--ink); }
.notice--uncertain { background: var(--warn-tint); border-color: var(--warn-line); color: var(--warn); }
.notice--uncertain .notice__body { color: var(--ink); }
.notice--info { background: var(--stone); border-color: var(--line-strong); color: var(--ink-soft); }
.notice--success { background: var(--success-tint); border-color: var(--success); color: var(--success); }
.notice a { color: inherit; font-weight: 600; }
.results > .notice, .auth__messages > .notice { margin-bottom: 16px; }

/* ---------- Booking panel ---------- */

.booking { padding: 20px; }
.booking__title { font-size: 1.3rem; margin-bottom: 14px; }
.booking-summary {
  padding: 14px 16px; border-radius: var(--radius-small);
  background: var(--stone); border-left: 4px solid var(--accent); margin-bottom: 16px;
}
.booking-summary__tables { font: 600 1.1rem/1.3 var(--serif); }
.booking-summary__when { margin-top: 4px; font-weight: 600; }
.booking-summary__where { margin-top: 2px; color: var(--ink-soft); font-size: 0.92rem; }
.booking__party { max-width: 160px; }
.booking__status:not(:empty) { margin-top: 16px; }
.booking__actions { margin-top: 18px; }

.confirmation { margin-top: 18px; padding: 20px; border-color: var(--success); }
.confirmation:focus { outline: none; }
.confirmation__badge { display: inline-flex; align-items: center; gap: 8px; color: var(--success); font-weight: 700; }
.confirmation__badge--cancelled { color: var(--ink-soft); }
.confirmation__label { margin-top: 12px; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.confirmation__reference {
  font: 700 1.8rem/1.2 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.12em; color: var(--ink); margin-top: 2px; word-break: break-all;
}
.confirmation__details { margin-top: 12px; display: grid; gap: 2px; }
.confirmation__restaurant { font: 600 1.1rem/1.3 var(--serif); }
.confirmation__note { margin-top: 12px; font-size: 0.9rem; color: var(--ink-soft); }

/* ---------- Auth ---------- */

.auth-layout { display: grid; place-items: start center; }
.auth { width: 100%; max-width: 440px; padding: 28px; }
.auth__title { font-size: 1.9rem; }
.auth__lede { margin: 8px 0 20px; color: var(--ink-soft); }
.auth__switch { margin-top: 20px; color: var(--ink-soft); }
@media (max-width: 519px) { .auth { padding: 20px; } }

/* ---------- Lookup ---------- */

.lookup-layout { display: grid; gap: 20px; max-width: 760px; }
.lookup-result:empty { display: none; }
.reservation { padding: 22px; }
.reservation__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.reservation__reference { font: 700 1.5rem/1.2 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: 0.1em; }
.reservation__facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 18px 0 0; }
.reservation__facts dt { color: var(--muted); font-weight: 600; }
.reservation__facts dd { margin: 0; }
.reservation__actions { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.reservation .notice { margin-top: 16px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border-radius: 6px; font-weight: 700; font-size: 0.92rem; border: 1.5px solid;
}
.status--confirmed { background: var(--success-tint); color: var(--success); border-color: var(--success); }
.status--cancelled { background: var(--stone); color: var(--ink-soft); border-color: var(--line-strong); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
