/* Last One — base layer.
   This is an app, not a page: one viewport, no scrolling, everything either
   fits or lives in a panel that scrolls inside itself. */
@import url('/css/tokens.css');

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

/* The page itself never scrolls. Anything taller than the screen scrolls in
   its own pane, so the map can be pinned and a rubber-band drag on the map
   cannot drag the document out from under it. */
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* A screen that genuinely needs to scroll (forms, the lobby) says so. */
.scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; margin: 0; line-height: 1.15; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p  { margin: 0 0 0.7em; }
p:last-child { margin-bottom: 0; }
a { color: var(--gold); text-underline-offset: 3px; }

.icon { display: block; flex: none; }
/* Directional glyphs follow the reading direction: "next" points left in Hebrew. */
[dir="rtl"] .icon-dir { transform: scaleX(-1); }

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.tiny  { font-size: var(--step--1); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.wrap-narrow { width: min(560px, 100%); margin-inline: auto; padding: var(--pad); }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- buttons -- */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  transition: transform .12s ease, background .16s ease, border-color .16s ease;
}
.btn:hover:not(:disabled) { background: var(--bg-raised); border-color: var(--gold); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: var(--gold-ink); border-color: transparent;
  box-shadow: 0 8px 24px rgba(240,185,60,.22);
}
.btn-danger { border-color: var(--danger); color: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-block { width: 100%; }
.btn-lg { font-size: var(--step-1); padding: 17px 26px; min-height: 58px; border-radius: var(--radius-lg); }
.btn-icon { padding: 10px; min-height: 44px; min-width: 44px; border-radius: 12px; }

.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--pad); }
.card-tight { padding: 13px 15px; border-radius: var(--radius); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--bg-raised); border: 1px solid var(--line);
  font-size: var(--step--1); font-weight: 700; color: var(--ink-soft);
}
.chip-gold { color: var(--gold); border-color: rgba(240,185,60,.4); }
.chip-danger { color: var(--danger-soft); border-color: rgba(224,82,60,.45); }

/* ----------------------------------------------------------------- fields -- */
label.field { display: flex; flex-direction: column; gap: 7px; font-weight: 700; font-size: var(--step--1); color: var(--ink-soft); }
.input, textarea.input {
  width: 100%; background: var(--bg-sunken);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  color: var(--ink); font: inherit; font-weight: 400; padding: 13px 15px; min-height: 50px;
}
.input:focus { border-color: var(--gold); outline: none; }
textarea.input { resize: vertical; min-height: 80px; }
.check { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; font-size: var(--step--1); color: var(--ink-soft); }
.check input { width: 22px; height: 22px; accent-color: var(--gold); flex: none; margin-top: 2px; }

/* A row of mutually exclusive choices — used for every table setting. */
.seg { display: flex; gap: 6px; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px; }
.seg button {
  flex: 1; min-height: 42px; border: none; border-radius: 11px; cursor: pointer;
  background: transparent; color: var(--ink-soft); font: inherit; font-weight: 700; font-size: var(--step--1);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px;
}
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.seg button .sub { font-size: .68rem; font-weight: 400; opacity: .75; }

/* ------------------------------------------------------------------ sheet -- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(6,9,4,.74); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease;
}
.sheet {
  width: min(560px, 100%); max-height: min(86dvh, 760px);
  background: var(--bg-raised); border: 1px solid var(--line-strong); border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: rise .24s cubic-bezier(.2,.9,.3,1.1);
  padding-bottom: var(--safe-b);
}
@media (min-width: 720px) {
  .sheet-scrim { align-items: center; }
  .sheet { border-radius: var(--radius-xl); border-bottom: 1px solid var(--line-strong); }
}
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 17px 19px 11px; border-bottom: 1px solid var(--line); }
.sheet-body { padding: 17px 19px 22px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-title { font-family: var(--font-display); font-size: var(--step-1); }

.toast-rail { position: fixed; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--bg-card); border: 1px solid var(--line-strong); padding: 11px 17px; border-radius: 999px; box-shadow: var(--shadow); font-size: var(--step--1); font-weight: 700; max-width: min(90vw, 460px); animation: rise .2s ease; }
.toast-error { border-color: var(--danger); color: var(--danger-soft); }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(16px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
@keyframes pop { 0% { transform: scale(.92); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }
@keyframes spin { to { transform: rotate(360deg) } }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--line-strong); border-top-color: var(--gold); animation: spin .9s linear infinite; margin-inline: auto; }

/* ENFORCEMENT RULE 4. The text is fixed; only this styling is ours. */
.cerevision-footer { padding: 16px 16px calc(16px + var(--safe-b)); text-align: center; font-size: var(--step--1); color: var(--ink-faint); letter-spacing: .04em; }
.cerevision-footer__text { opacity: .85; }

.skip-link { position: absolute; inset-inline-start: -9999px; top: 0; z-index: 200; background: var(--gold); color: var(--gold-ink); padding: 12px 18px; border-radius: 0 0 12px 0; font-weight: 700; }
.skip-link:focus { inset-inline-start: 0; }
