/* Shared building blocks (#184 184-components, design C section 1). Every
   page builds from these; a page stylesheet only lays them out. Colours,
   type and space come from css/tokens.css, so light/dark, high contrast and
   the liveries carry every component with them. The handoff
   (docs/handoffs/web-shell.md) lists each class with one line of usage. */

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 100;
  padding: 10px 16px; border-radius: var(--r-1);
  background: var(--text); color: var(--bg); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }
/* The skip link's target takes focus without a ring around the whole page. */
#main:focus { outline: none; }

/* ---------- headings ---------- */
/* Design C sets headings in the display face. Sizes and margins stay with
   each page (the page topics); the public pages keep their own headings. */
:where(html.app-shell) :is(h1, h2, h3, h4) {
  font-family: var(--font-display); font-weight: 750; letter-spacing: -0.02em;
  line-height: var(--lh-tight); text-wrap: balance;
}
:where(html.app-shell) h1 { font-weight: 800; letter-spacing: -0.03em; }
:where(html.app-shell) h3 { letter-spacing: -0.01em; }

/* ---------- icons (the #appnav sprite, js/ui/icon.js) ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 28px; height: 28px; }

/* ---------- buttons ---------- */
/* .btn is the secondary button; -primary, -ghost, -danger restyle it.
   inline-flex so min-height also works on <a class="btn">. */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-pill);
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 650 var(--fs-14)/1.15 var(--font-display); text-decoration: none; text-align: center;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { border-color: var(--text-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger {
  background: transparent; color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: var(--fs-16); }
/* Compact on a mouse; a full tap target under a finger. */
.btn-sm { min-height: 36px; min-width: 36px; padding: 0 14px; font-size: var(--fs-13); }
@media (pointer: coarse), (max-width: 699px) { .btn-sm { min-height: var(--tap); min-width: var(--tap); } }
.icon-btn {
  appearance: none;
  width: var(--tap); height: var(--tap); flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text);
  text-decoration: none; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.bordered { border: 1.5px solid var(--line); background: var(--surface); }

/* ---------- segmented control ---------- */
/* <div class="seg"><button aria-pressed="true">..</button>..</div>; the
   older `.seg-btn.active` markup is the same control. */
.seg {
  display: flex; gap: 2px; padding: 3px; max-width: 100%;
  border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line);
}
.seg-inline { display: inline-flex; }
.seg > button, .seg > label {
  flex: 1 1 auto; min-height: 38px; min-width: var(--tap); padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-2);
  font: 650 var(--fs-13)/1.1 var(--font-display); text-align: center; cursor: pointer; margin: 0;
}
.seg > .active,
.seg > [aria-pressed='true'], .seg > [aria-checked='true'], .seg > [aria-selected='true'] {
  background: var(--text); color: var(--bg); box-shadow: 0 1px 2px var(--seg-shadow);
}
.seg > button:disabled { opacity: .45; cursor: not-allowed; }
@media (pointer: coarse), (max-width: 699px) { .seg > button, .seg > label { min-height: var(--tap); } }

/* ---------- chips + badges ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  appearance: none;
  min-height: 36px; padding: 0 14px; border-radius: var(--r-pill); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--text-2); font: 650 var(--fs-13)/1 var(--font-display);
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.chip[aria-pressed='true'], .chip[aria-current='true'], .chip[aria-current='page'] {
  background: var(--text); border-color: var(--text); color: var(--bg);
}
.chip .count { font-weight: 500; opacity: .7; }
@media (pointer: coarse), (max-width: 699px) { .chip { min-height: var(--tap); } }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-pill);
  font: 650 var(--fs-12)/1.4 var(--font-display); white-space: nowrap; vertical-align: 1px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.badge-neutral { background: var(--surface-2); color: var(--text-2); }
.badge-good { background: var(--good-soft); color: var(--good); }

/* ---------- cards + list rows ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-5); }
.card-tight { padding: var(--s-4); }
.card.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; }
.list-row > .grow { flex: 1 1 auto; min-width: 0; }
.list-row-title { font-weight: 600; }
.list-row-sub { font-size: var(--fs-14); color: var(--text-2); }

/* ---------- empty state ---------- */
/* <div class="empty"><svg class="empty-art">..</svg><h2>..</h2><p>..</p><a class="btn btn-primary">..</a></div> */
.empty {
  display: grid; justify-items: center; gap: var(--s-3); text-align: center;
  padding: var(--s-7) var(--s-5); border: 1.5px dashed var(--line-strong); border-radius: var(--r-3);
}
.empty-art { width: 120px; height: 72px; color: var(--text-3); }
.empty h2 { font-size: var(--fs-22); margin: 0; }
.empty p { color: var(--text-2); max-width: 44ch; margin: 0; }

/* ---------- dialogs + sheets (js/ui/sheet.js) ---------- */
/* Every native <dialog> keeps its pre-204 size (the page topics own theirs);
   .dlg is the header/body/actions layout openSheet() builds, a bottom sheet
   below 700 px. */
dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-2); box-shadow: var(--shadow-float);
  padding: 20px 22px; width: calc(100vw - 40px); max-width: 420px;
}
dialog::backdrop { background: var(--scrim); }
dialog h3 { margin-top: 0; }
.dialog-actions { justify-content: flex-end; margin-top: 14px; }
.dlg { padding: 0; width: calc(100vw - 32px); max-width: 480px; border-radius: var(--r-3); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: var(--s-4) var(--s-3) 0 var(--s-5); }
.dlg-title { flex: 1 1 auto; margin: 0; font: 750 var(--fs-22)/var(--lh-tight) var(--font-display); letter-spacing: -0.02em; }
/* German compounds are long: they wrap (hyphenated where the page's lang
   allows) rather than run past a 320 px sheet. */
.dlg-title, .dlg-body { overflow-wrap: anywhere; hyphens: auto; }
.dlg-body { display: grid; gap: var(--s-3); padding: var(--s-3) var(--s-5) var(--s-5); }
.dlg-body p { margin: 0; color: var(--text-2); max-width: 60ch; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 0 var(--s-5) var(--s-5); }
/* confirmSheet / promptSheet: the question is the heading, at reading size. */
.dlg-ask .dlg-head { padding: var(--s-5) var(--s-5) 0; }
.dlg-ask .dlg-title { font: 650 var(--fs-18)/1.35 var(--font-body); letter-spacing: 0; }
.dlg-ask .dlg-input { width: 100%; }
:root[data-theme='contrast'] dialog { border: 2px solid var(--text); }
@media (max-width: 699px) {
  .dlg-sheet {
    margin: auto 0 0; width: 100vw; max-width: 100vw; max-height: 85dvh;
    border-radius: var(--r-3) var(--r-3) 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---------- (i) button ---------- */
/* infoButton(key), or <button class="info-btn" data-info="<key>" aria-haspopup="dialog" aria-label="…">. */
.info-btn {
  appearance: none;
  width: var(--tap); height: var(--tap); flex: none; vertical-align: middle;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
}
.info-btn:hover { background: var(--surface-2); color: var(--text); }
h1 .info-btn, h2 .info-btn { margin-block: -10px; }

/* ---------- setting shortcut (js/ui/shortcut.js) ---------- */
.shortcut {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 12px;
  border-radius: var(--r-2); border: 1.5px dashed var(--line-strong);
  color: var(--text); text-decoration: none; background: transparent;
}
.shortcut:hover { border-style: solid; background: var(--surface-2); }
.shortcut > .grow { flex: 1 1 auto; min-width: 0; display: grid; }
.sc-label { font-size: var(--fs-12); color: var(--text-2); font-weight: 600; }
.sc-value { font: 650 var(--fs-14)/1.25 var(--font-display); }
.sc-go {
  flex: none; display: inline-flex; align-items: center; gap: 2px;
  font: 650 var(--fs-13)/1 var(--font-display); color: var(--accent-ink);
}
.sc-go .ic { width: 16px; height: 16px; }

/* the block a shortcut lands on (`[data-hl]`) */
.hl-flash { animation: hl-flash 2.4s var(--ease) 1; border-radius: var(--r-2); }
@keyframes hl-flash {
  0%, 60% { box-shadow: 0 0 0 3px var(--accent), 0 0 0 9px var(--accent-soft); background: var(--accent-soft); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .hl-flash { animation: none; box-shadow: 0 0 0 3px var(--accent); }
}

/* ---------- the public look ---------- */
/* Landing, the static pages and every signed-out view keep the pre-204
   button (round-204 brief); css/tokens.css keeps their palette. */
:where(html:not(.app-shell)) .btn {
  min-height: 40px; padding: 9px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: color-mix(in srgb, var(--text) 10%, var(--surface));
  font: inherit; font-weight: 500;
}
:where(html:not(.app-shell)) .btn:hover { background: color-mix(in srgb, var(--text) 17%, var(--surface)); border-color: var(--line); }
:where(html:not(.app-shell)) .btn:active { transform: none; }
:where(html:not(.app-shell)) .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
:where(html:not(.app-shell)) .btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, white); filter: none; }
:where(html:not(.app-shell)) .btn-ghost { background: transparent; }
:where(html:not(.app-shell)) .btn-danger {
  background: var(--danger-soft); border-color: var(--danger); color: color-mix(in srgb, var(--danger) 60%, white);
}
:where(html:not(.app-shell)) .btn-lg { padding: 13px 26px; font-size: 17px; }
:where(html:not(.app-shell)) .btn-sm { min-height: 34px; min-width: 0; padding: 6px 12px; font-size: 13px; }
@media (max-width: 720px) {
  :where(html:not(.app-shell)) .btn { min-height: 44px; }
  :where(html:not(.app-shell)) .btn-sm { min-height: 44px; min-width: 44px; }
}

/* ---------- staging label (js/config.js IS_STAGING) ---------- */
/* On staging.vamoto.app only: a small red tag on the logo, in the rail, the
   phone top bar and the public header; inert. */
html.is-staging .shell-brand { position: relative; }
html.is-staging :is(.shell-brand, .brand)::after {
  content: 'Staging';
  padding: 1px 5px; border-radius: 999px; pointer-events: none;
  font: 800 9px/1.4 var(--font-body); letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--danger); color: #fff;
}
html.is-staging .shell-brand::after { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); }
