/* ============================================================================
 * components.css — the shared shell vocabulary.
 *
 * These class names are the house standard: .topbar, .view/.active, .tabbar,
 * .overlay/.sheet, .btn, .chip, .card, .panel, .empty-state, .toast. Reuse
 * them rather than inventing new ones — every app in the set already reads
 * this way, so a component moved between apps mostly just works.
 *
 * Naming is flat kebab-case with a component prefix: `detail-sheet`,
 * `seed-toolbar`, `fav-item-title`. Prefix-noun-modifier. Not BEM, no CSS
 * modules, no utility framework.
 * ========================================================================= */

/* ---------- app shell ----------------------------------------------------
 * Fixed topbar, scrolling content between, fixed tabbar. The content column
 * pads itself clear of both so nothing hides under the chrome. */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

/* min-width:0 lets the brand name truncate instead of shoving the topbar
 * actions off the right edge on a narrow phone. A flex child's default
 * min-width is `auto`, which refuses to shrink below its content. */
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; min-width: 0;
}
.brand-icon { font-size: 1.25rem; line-height: 1; }
.brand-name {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* The install offer is a top-bar affordance, so it has to stay small enough
 * that it never competes with the brand. Compact by default; the label drops
 * away entirely on a narrow phone, leaving the glyph. */
.install-btn { padding: 8px 12px; font-size: 0.8rem; }
.install-btn-icon { font-size: 0.9rem; line-height: 1; }

@media (max-width: 380px) {
  .install-btn-label { display: none; }
  .install-btn { padding: 8px 10px; }
}

.container {
  max-width: 640px;          /* phone-first; a wide screen gets margins, not a redesign */
  margin: 0 auto;
  padding:
    calc(var(--topbar-h) + var(--safe-t) + 12px)
    14px
    calc(var(--tabbar-h) + var(--safe-b) + 24px);
}

/* Exactly one .view carries .active at a time. Switching is driven by the
 * `data-view` attribute on a .tab button, resolved to #view-<name> — see
 * js/ui.js. */
.view { display: none; }
.view.active { display: block; animation: view-in 180ms ease-out; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- bottom tab bar ---------------------------------------------- */

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
}

.tabbar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
}

.tab {
  flex: 1;
  min-height: 44px;              /* thumbs, not cursors */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  background: none;
  border: 0;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 150ms ease;
}

.tab.active { color: var(--accent); }
.tab-icon { font-size: 1.15rem; line-height: 1; }
.tab-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.01em; }

/* ---------- buttons ------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.925rem;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-contrast); }
.btn-ghost   { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-danger  { background: transparent; border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.btn-block   { display: flex; width: 100%; }

.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--ink-soft);
  cursor: pointer;
}

/* ---------- surfaces ----------------------------------------------------- */

.card, .panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card  { padding: 14px; }
.panel { padding: 16px; }
.panel-head { margin: 0 0 4px; font-size: 1rem; font-weight: 800; }
.panel-sub  { margin: 0 0 12px; color: var(--ink-soft); font-size: 0.85rem; }

/* ---------- chips -------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.chip.active { background: var(--accent); border-color: transparent; color: var(--accent-contrast); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- badges ------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--ink-soft);
  font-size: 0.7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.badge-good { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 30%, transparent); color: var(--good); }
.badge-bad  { background: var(--bad-bg);  border-color: color-mix(in srgb, var(--bad) 30%, transparent);  color: var(--bad); }

/* ---------- empty state -------------------------------------------------- */

.empty-state { padding: 40px 20px; text-align: center; color: var(--ink-soft); }
.empty-title { margin: 0 0 6px; font-size: 1rem; font-weight: 800; color: var(--ink); }
.empty-sub   { margin: 0; font-size: 0.875rem; }

/* ---------- overlay + bottom sheet --------------------------------------- */

.overlay {
  position: fixed; inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.overlay[hidden] { display: none; }

.overlay-backdrop {
  position: absolute; inset: 0;
  background: rgb(16 16 18 / 0.45);
  animation: fade-in 180ms ease-out;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lg);
  padding-bottom: var(--safe-b);
  animation: sheet-up 240ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 8px;
}

.sheet-title { margin: 0; font-size: 1.05rem; font-weight: 800; }
.sheet-body  { padding: 0 16px 20px; overflow-y: auto; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- toast -------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  transform: translateX(-50%) translateY(8px);
  z-index: 80;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- install sheet ------------------------------------------------ */

.install-steps { margin: 12px 0 0; padding-left: 20px; line-height: 1.7; }
.install-steps li { margin-bottom: 8px; }
.install-sub { margin: 0; color: var(--ink-soft); font-size: 0.875rem; }
.install-glyph { width: 1em; height: 1em; vertical-align: -0.15em; }

/* ---------- pointer-only affordances -------------------------------------
 * EVERY :hover rule in the app lives in this block, and that is deliberate.
 * On a touch screen Safari applies :hover to whatever sits under the last tap
 * and KEEPS it there — so the next element rendered into that same slot
 * inherits a highlight it never earned, which reads as a rendering bug.
 * Gating hover on an actual pointer makes the problem structurally
 * impossible rather than something to remember. */
@media (hover: hover) {
  .btn:hover        { border-color: var(--accent); color: var(--accent); }
  .btn-primary:hover{ background: var(--accent-soft); color: var(--accent-contrast); border-color: transparent; }
  .btn-ghost:hover  { background: var(--bg-sunken); color: var(--ink); }
  .btn-danger:hover { background: var(--bad-bg); }
  .icon-btn:hover   { border-color: var(--line-strong); color: var(--ink); }
  .chip:hover       { border-color: var(--line-strong); }
  .tab:hover        { color: var(--ink-soft); }
  .tab.active:hover { color: var(--accent); }
}
