/* Still Near — sender PWA component inventory.
 *
 * The concrete components every feature (402–408) reuses: app shell, buttons,
 * inputs, sheets, empty/waiting states, and the queued/sending/sent/failed send
 * states. Built from the teaser tokens in tokens.css — no new visual language.
 * (Feature 401, AC-8.)
 */

/* ---- App shell -------------------------------------------------------- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem var(--pad);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink-950) 88%, transparent);
}
.app-header .wordmark {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  font-size: 1.1rem;
  color: var(--text);
}

/* Signed-in nav: quiet text links, not buttons-as-chrome. Mobile-first. */
.app-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.app-nav[hidden] {
  display: none;
}
.nav-link {
  background: transparent;
  border: 0;
  padding: 0.25rem 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
}
.nav-link:hover {
  color: var(--text);
}
.nav-link:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Single-column, readable product surfaces. Shallow nav, mobile-first. */
.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--readw);
  margin: 0 auto;
  padding: 2rem var(--pad) 3rem;
}

.app-footer {
  padding: 1.5rem var(--pad);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Surface title — the room-aware "where am I". Keeps room identity visible
 * anywhere trust/billing/sending could be misread (spec constraint). */
.surface-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1.15;
  margin: 0 0 0.5rem;
}
.surface-sub { color: var(--linen-200); margin: 0 0 1.5rem; }

/* ---- Entry / hero (auth_entry welcome) -------------------------------- */

.entry { text-align: left; padding-top: 1rem; }
.entry .eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--fog-400);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  margin: 0 0 1.25rem;
}
.entry .display {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}
.entry .entry-sub {
  font-size: clamp(1.1rem, 4vw, 1.3rem);
  color: var(--linen-200);
  margin: 0 0 2rem;
}
.entry .reassure { color: var(--muted); font-size: 0.95rem; margin: 1rem 0 0; }

/* ---- Buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  /* 48px min touch target — old phones, tired thumbs. */
  min-height: 48px;
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  text-decoration: none;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: flex; width: 100%; }

.btn-primary { background: var(--rose); color: var(--ink-950); }
.btn-primary:hover:not(:disabled) { opacity: 0.92; }

.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--fog-400); }

/* Destructive (breakup / delete) — distinct from neutral leave (407). */
.btn-danger { background: transparent; color: var(--rose); border-color: var(--rose); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--rose) 14%, transparent); }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }

/* ---- Inputs ----------------------------------------------------------- */

.field { display: grid; gap: 0.4rem; margin-bottom: 1.1rem; }
.field > label { font-weight: 600; font-size: 0.95rem; }
.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0.8rem 0.9rem;
  font-size: 1rem; /* >=16px stops iOS Safari zoom-on-focus */
  font-family: var(--sans);
  background: var(--ink-950);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.field .helper { color: var(--muted); font-size: 0.9rem; }
.field .field-error { color: var(--rose); font-size: 0.9rem; margin: 0; }
.field input[aria-invalid="true"] { border-color: var(--rose); }

/* ---- Sheet (bottom sheet / modal flow on mobile) ---------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--ink-950) 70%, transparent);
  display: grid;
  align-items: end;
  z-index: 20;
}
.sheet {
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 1.5rem var(--pad) calc(1.5rem + env(safe-area-inset-bottom));
  max-width: var(--readw);
  margin: 0 auto;
  width: 100%;
}
.sheet h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 0.5rem; }
.sheet p { color: var(--linen-200); margin: 0 0 1rem; }
@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; }
}

/* ---- Empty / waiting state (first-class, AC-4) ------------------------ */

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.empty-state__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0 0 0.5rem;
}
.empty-state__body { color: var(--linen-200); margin: 0 auto 1.25rem; max-width: 24rem; }

/* Waiting variant — partner-not-joined, export-processing: a soft amber edge
 * signals "in progress", not "nothing here". */
.empty-state--waiting { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }

/* ---- Send-status pill (queued / sending / sent / failed) -------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}
.pill::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}
.pill--queued { color: var(--state-queued); }
.pill--sending { color: var(--state-sending); }
.pill--sent { color: var(--state-sent); }
.pill--failed { color: var(--state-failed); }

/* Gentle pulse while sending; suppressed for reduced-motion + on old hardware
 * it simply stays solid amber. */
@media (prefers-reduced-motion: no-preference) {
  .pill--sending::before { animation: pill-pulse 1.4s ease-in-out infinite; }
}
@keyframes pill-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ---- Stacked actions (onboarding / room home) ------------------------- */

/* Vertical CTA stack with the primary on top — one obvious next step, the rest
 * clearly secondary (no competing equal buttons). */
.btn-stack { display: grid; gap: 0.6rem; margin-top: 1.25rem; }

/* Invite code: large, tabular, selectable — easy to read aloud or type on an
 * old phone. */
.invite-code {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  padding: 0.9rem 1rem;
  margin: 0.5rem 0 1rem;
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: 10px;
  user-select: all;
  -webkit-user-select: all;
  word-break: break-all;
}

/* ---- Composer (photo send) -------------------------------------------- */

.composer-preview {
  margin: 1rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--ink-950);
}
.composer-preview img { width: 100%; height: auto; display: block; max-height: 60vh; object-fit: contain; }
.composer-status { margin: 1rem 0; display: flex; justify-content: center; }

/* ---- Pairing QR ------------------------------------------------------- */

.qr-wrap {
  margin: 1.25rem auto;
  width: max-content;
  max-width: 100%;
  padding: 0.75rem;
  background: var(--linen-100);
  border-radius: var(--radius);
}
.qr-wrap svg { display: block; width: 260px; max-width: 70vw; height: auto; }

/* ---- Billing plan comparison ------------------------------------------ */

.plan-compare {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0.5rem;
  display: grid;
  gap: 0.6rem;
}
.plan-compare li {
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 600;
}
.proof-note { color: var(--muted); font-size: 0.9rem; margin: 0.75rem 0 0; }

/* ---- Account settings list -------------------------------------------- */

.settings-list { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: 0.6rem; }
.settings-row {
  width: 100%;
  min-height: 48px;
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-family: var(--sans);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.settings-row:hover { border-color: var(--fog-400); }
/* Destructive rows read distinctly so leave/breakup/delete can't be mistapped. */
.settings-row.is-destructive { color: var(--rose); }

.safety {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

/* ---- Inline status note (offline, generic shell error) ---------------- */

.note {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--linen-200);
  font-size: 0.95rem;
}
.note--offline { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }

/* ---- Display management list (#70) ------------------------------------- */

.display-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.display-row-main { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.display-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.display-meta { font-size: 0.85rem; color: var(--linen-200); }
.display-row-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.display-row-actions .btn { width: auto; padding: 0.4rem 0.7rem; font-size: 0.85rem; }
