/* ============================================================================
 * Shared component library (plan §5). Every component reads ONLY tokens, so it
 * re-skins per room for free — set data-theme on a container and the same markup
 * becomes light/host/product. This is what makes pages uniform by construction:
 * nobody hand-rolls a one-off button.
 *
 * Requires tokens.css. The existing PWA keeps its bespoke in-event styles; this
 * library serves the Host Shell, the TapSnap Light room, and the bridge prototype.
 * ========================================================================== */

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

.ts-surface { background: var(--bg); color: var(--text); }

/* ---- wordmark / brand lockup (the persistent element across every room) ---- */
.ts-wordmark {
  display: inline-flex; align-items: baseline; gap: .34em;
  font-weight: 800; letter-spacing: -.01em; text-decoration: none; color: var(--text);
  font-family: -apple-system, "SF Pro Display", system-ui, sans-serif;
}
.ts-wordmark .ts-tap { color: var(--text); }
.ts-wordmark .ts-sub { font-weight: 650; color: var(--muted); font-size: .62em; letter-spacing: .04em; }

/* ---- top bar ---- */
.ts-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
}

/* ---- buttons ---- */
.ts-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border-radius: var(--r-card); border: none; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 650; letter-spacing: -.01em;
  transition: transform var(--t-fast) var(--ease-standard), opacity var(--t-fast), box-shadow var(--t-fast);
}
.ts-btn:active { transform: scale(.97); }
.ts-btn:disabled { opacity: .55; cursor: default; box-shadow: none; }
.ts-btn--primary { background: var(--accent-grad); color: #fff; box-shadow: var(--accent-glow), var(--ring-top); }
.ts-btn--primary:hover { filter: brightness(1.07); }
.ts-btn--ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--ring-top); }
.ts-btn--ghost:hover { border-color: var(--border-2); background: var(--surface-2); }
.ts-btn--pill { border-radius: var(--r-pill); }

/* Social sign-in (login/signup). Brand-correct marks so they read as "official"; compound
   selectors (.ts-btn.ts-btn--x) beat the host-theme .ts-btn background so the brand colors win. */
.ts-btn.ts-btn--social { width: 100%; gap: 10px; font-size: 14.5px; font-weight: 600; text-decoration: none; }
.ts-btn.ts-btn--social svg { width: 18px; height: 18px; flex: none; }
.ts-btn.ts-btn--google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; box-shadow: none; }
.ts-btn.ts-btn--google:hover { background: #f6f7f9; border-color: #c9ccd1; filter: none; }
.ts-btn.ts-btn--apple { background: #000; color: #fff; border: 1px solid #000; box-shadow: none; }
.ts-btn.ts-btn--apple:hover { background: #161616; filter: none; }
/* "or" divider between social + email sign-in. */
.auth-or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .09em; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Shared auth-page chrome (login / signup / reset). */
.auth-back { position: fixed; top: 18px; left: 20px; z-index: 5; color: var(--muted); text-decoration: none;
  font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.auth-back:hover { color: var(--text); }
.auth-brand-lockup { display: flex; width: max-content; margin: 0 auto 22px; }
.auth-field-head { display: flex; justify-content: space-between; align-items: baseline; }
.auth-field-head .ts-label { margin-bottom: 0; }
.auth-link { background: none; border: none; padding: 0; font: inherit; font-size: 13px; color: var(--accent);
  cursor: pointer; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-link--block { display: block; width: 100%; text-align: center; margin-top: 14px; }
.auth-note { margin-top: 12px; font-size: 13px; text-align: center; color: var(--muted); min-height: 1em; }
.auth-note--err { color: #ff8a8a; }
.auth-note--ok { color: #5fd08a; }

/* Button loading state: a spinner before the (updated) label, e.g. "Logging in…". */
@keyframes ts-spin { to { transform: rotate(360deg); } }
.ts-btn.is-loading { pointer-events: none; }
.ts-btn.is-loading::before { content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: ts-spin .6s linear infinite; }

/* ---- form fields ---- */
.ts-field {
  width: 100%; min-height: 46px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px; outline: none;
  transition: border-color var(--t-fast);
}
.ts-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent); }
.ts-label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; }

/* ---- cards (tactile: elev-card gradient over surface + top-highlight ring) ---- */
.ts-card {
  background: var(--elev-card), var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-sm), var(--ring-top); padding: 18px;
}

/* ---- numerals for timers/counts/prices (plan §4.2) ---- */
.ts-nums { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---- inline line icons (see /js/host/icons.js) — size to the surrounding text, inherit color.
 * Replaced the decorative emoji the console/marketing used to sprinkle around. ---- */
.ic { width: 1em; height: 1em; display: inline-block; vertical-align: -.14em; flex: none; }
svg.ic { stroke: currentColor; }
[data-icon] { display: inline-flex; }

/* ---- bottom sheet ---- */
.ts-sheet-scrim {
  position: fixed; inset: 0; z-index: 58; display: flex; align-items: flex-end;
  background: rgba(0, 0, 0, .5); animation: ts-fade var(--t-base) var(--ease-standard) both;
}
.ts-sheet {
  width: 100%; max-height: 72vh; overflow-y: auto;
  background: var(--bg-elev); border-top: 1px solid var(--border-2);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 10px 18px calc(24px + var(--safe-b));
  box-shadow: var(--ring-top); animation: ts-sheet-up var(--t-room) var(--ease-standard) both;
}
.ts-sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 6px auto 14px; }
@keyframes ts-sheet-up { from { transform: translateY(100%) } to { transform: none } }

/* ---- toast ---- */
.ts-toast {
  position: fixed; left: 0; right: 0; width: fit-content; margin: 0 auto;
  bottom: calc(26px + var(--safe-b)); z-index: 40; max-width: 88vw;
  padding: 12px 18px; border-radius: 14px; border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, #000); color: var(--text);
  font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transform: translateY(12px);
  transition: opacity var(--t-base), transform var(--t-base);
}
.ts-toast.show { opacity: 1; transform: none; }
.ts-toast--ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.ts-toast--err { border-color: color-mix(in srgb, var(--err) 50%, transparent); }

/* ---- account chip (the "you're in TapSnap" signal, constant across rooms) ---- */
.ts-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; flex: none;
}

@keyframes ts-fade { from { opacity: 0 } to { opacity: 1 } }

@media (prefers-reduced-motion: reduce) {
  .ts-btn, .ts-sheet, .ts-sheet-scrim, .ts-toast { animation: none !important; transition: opacity var(--t-base) !important; }
}

/* Skip-to-content link (a11y, V1): off-screen until keyboard-focused, then anchors to the
 * page's <main>. Reads tokens so it matches whichever room it sits in. */
.skip-link {
  position: absolute; left: 8px; top: -56px; z-index: 200;
  background: var(--brand); color: #fff; text-decoration: none;
  padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
  transition: top var(--t-base);
}
.skip-link:focus { top: 8px; outline: 2px solid #fff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .skip-link { transition: none; } }
