/* ============================================================
   Stockmeta customer portal — built on the shared design system.
   design-system/styles.css (tokens + components) loads FIRST; this
   file adds only the portal-specific centered-card layout, the
   account/billing surface, and the plan picker. Dark-first (DS
   default). `sm-*` = portal-local classes; DS classes (.btn, .badge,
   .banner, .card, .input …) are consumed directly from the DS.
   ============================================================ */

/* ── Page + card ─────────────────────────────────────────────── */
.sm-portal {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
}
.sm-portal-card {
  width: 100%;
  max-width: 27rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
  box-shadow: var(--shadow);
}
.sm-portal-card.wide { max-width: 34rem; }
.sm-portal-card.center { text-align: center; }

/* ── Brand lockup ────────────────────────────────────────────── */
.sm-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}
/* Flat terracotta mark, no tile — the "App title bar" application in
   design-system/brand/index.html. The old gradient tile was doubly wrong: the
   gradient colourway is display-only and needs a mark of 48px or more, and this
   was an ad-hoc two-stop ramp rather than the brand's 5-stop one.
   24px is the top of the band the small-size drawing (stroke 5) is drawn for.
   `color` drives the inlined `currentColor` SVG, so the mark follows --accent:
   #d97757 on dark, the #c8643f light-surface substitute on light. */
.sm-brand-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--accent);
}
.sm-brand-mark svg { width: 24px; height: 24px; display: block; }
.sm-brand-name {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
}

/* ── Headings / text ─────────────────────────────────────────── */
.sm-title {
  margin: 0 0 5px;
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}
.sm-sub {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}
.sm-fine {
  margin-top: 18px;
  color: var(--text-faint);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}
.sm-fine a { color: var(--accent); }

/* ── Auth extras ─────────────────────────────────────────────── */
.sm-google { display: flex; justify-content: center; min-height: 44px; }
.sm-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-faint);
  font-size: var(--fs-sm);
  margin: 18px 0;
}
.sm-or::before, .sm-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Give the DS field a touch more breathing room in the card. */
.sm-portal .field + .btn, .sm-portal .field + .btn-primary { margin-top: 14px; }
.sm-gap-top { margin-top: 12px; }

/* Clearly-INACTIVE submit button. The DS default (opacity:0.5) on a terracotta
   primary still reads as an active button, so give the disabled state a plainly
   muted, non-accent look — the affordance for "pick a different plan first". */
.sm-portal .btn:disabled,
.sm-portal .btn[disabled] {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-faint);
  opacity: 1;
  cursor: not-allowed;
}

/* ── Status / message line ───────────────────────────────────── */
.sm-msg {
  min-height: 1.1rem;
  margin: 10px 0 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.sm-msg--error { color: var(--danger); }
.sm-msg--ok { color: var(--ok); }

/* ── Banner body (stacked title / text / action) ─────────────── */
/* The shared DS `.banner` provides the box; this stacks its contents + the
   Resume/Refresh action button vertically (BUG-004 convergence, BUG-005 cancel). */
.sm-banner-body { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
/* The DS `.banner { display:flex }` outranks the UA `[hidden]` rule, so the empty
   cancel/converge banners would render as bare boxes. Keep `hidden` authoritative. */
.banner[hidden] { display: none; }
/* Same for DS buttons (`.btn { display:inline-flex }`) — the Change-plan button hides
   while its confirmation step is open. */
.btn[hidden] { display: none; }
/* Private-beta "payments are simulated" note: the DS neutral banner; only its
   support link needs the accent (the DS has no banner link style). */
.sm-test-note a { color: var(--accent); }

/* ── Key/value rows ──────────────────────────────────────────── */
.sm-kv { margin: 0 0 18px; }
.sm-kv > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-faint);
}
.sm-kv > div:last-child { border-bottom: 0; }
.sm-kv dt { color: var(--text-muted); font-size: var(--fs-base); }
.sm-kv dd {
  margin: 0;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Balance meter ───────────────────────────────────────────── */
.sm-meter {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
  margin-top: 9px;
}
.sm-meter > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.35s ease;
}
.sm-balance-num { font-family: var(--font-mono); }

/* ── Section eyebrow ─────────────────────────────────────────── */
.sm-eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 22px 0 10px;
}

/* ── Plan picker (radio cards) ───────────────────────────────── */
.sm-plans { display: grid; gap: 8px; }
.sm-plan {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  padding: 12px 13px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.sm-plan:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.sm-plan.sel { border-color: var(--accent-line); background: var(--accent-soft); }
.sm-plan input { accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }
.sm-plan-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sm-plan-name { font-weight: var(--fw-semibold); font-size: var(--fs-base); }
.sm-plan-cap { color: var(--text-muted); font-size: var(--fs-sm); font-family: var(--font-mono); }

/* Plan card tag ("Upgrade · starts today" / "Downgrade · at renewal") */
.sm-plan-tag {
  color: var(--text-faint);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  white-space: nowrap;
}
.sm-plans.sm-busy { opacity: 0.55; pointer-events: none; }

/* ── Change-plan confirmation (BUG-009) ──────────────────────── */
.sm-confirm {
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
}
.sm-confirm-title {
  margin: 0 0 6px;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
}
.sm-confirm-text {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}
.sm-confirm-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Carried-over photos after an upgrade ("112 — 100 + 12 carried over") */
.sm-carry { color: var(--text-muted); font-family: var(--font-ui); font-weight: var(--fw-regular); font-size: var(--fs-sm); }

/* ── Overage control (subscriber-only) ───────────────────────── */
.sm-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
}
.sm-toggle input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}
.sm-ceiling { margin-top: 10px; }
.sm-ceiling-opts { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.sm-ceiling-opt {
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 7px 15px;
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.sm-ceiling-opt:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.sm-ceiling-opt.sel { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.sm-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.sm-custom-in {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
  font-family: var(--font-mono);
}
.sm-custom-in input {
  width: 4.5rem;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.sm-custom-in:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Account header row ──────────────────────────────────────── */
.sm-acct-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.sm-acct-head .sm-brand { margin: 0; }
.sm-acct-head .spacer { flex: 1; }

/* ── Spinner ─────────────────────────────────────────────────── */
.sm-spinner {
  width: 34px;
  height: 34px;
  margin: 6px auto 18px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sm-spin 0.8s linear infinite;
}
@keyframes sm-spin { to { transform: rotate(360deg); } }
/* Inline variant (plan-change progress) */
.sm-spinner--sm {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  border-width: 2px;
  flex: none;
}
@media (prefers-reduced-motion: reduce) {
  .sm-spinner { animation-duration: 2.4s; }
}

/* ── Plan-change progress (shown in place while Stripe is updated) ── */
.sm-progress {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
}
.sm-progress[hidden] { display: none; }
.sm-progress-title {
  margin: 0 0 4px;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
}
.sm-progress-text {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}

/* ── Toast ───────────────────────────────────────────────────── */
.sm-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 15px;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.sm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sm-toast--ok { border-color: rgba(56, 178, 112, 0.4); }
.sm-toast--error { border-color: rgba(224, 90, 78, 0.45); }

/* ── Monospace activation code block ─────────────────────────── */
.sm-code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  word-break: break-all;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  margin: 8px 0 0;
  text-align: left;
}

/* Private-beta "by invitation" note on the code page (invite-only
   sign-up): the same banner as the payments note, spaced from the form below. */
.sm-invite-note { margin-bottom: 16px; }
