/* Curio shared chrome for auth/account pages.
 *
 * Inherits the threads-meta-2023 palette (--ink / --bg / --link, etc).
 * Each page MUST include this file BEFORE its inline <style>, and MUST
 * also declare the standard :root variables (since CSS variables don't
 * cross stylesheet inclusions in a meaningful way for our use).
 *
 * We DO NOT redeclare the variables here — pages do that inline, matching
 * the existing chrome convention.  This file only carries auth/account-
 * specific styles that build on those variables.
 */

/* ─── Page reset (auth/account pages don't share index/gallery layout) ─── */
.curio-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ─── Auth chrome (header) ─── */
.auth-chrome {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  border-bottom: 1px solid var(--line-soft);
}
.auth-chrome a { display: inline-flex; align-items: center; gap: 6px; }
.auth-chrome .gem { height: 28px; }
.auth-chrome .wordmark { height: 18px; }

/* ─── Card (centered auth pages) ─── */
.auth-card-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 24px 80px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.auth-card h1 {
  font-size: 28px;
  letter-spacing: -0.02em;
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
}
.auth-card .sub {
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 0;
}
.auth-card .field { display: flex; flex-direction: column; gap: 6px; }
.auth-card label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 500;
}
.auth-card input[type="email"],
.auth-card input[type="text"] {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  transition: border-color 100ms;
  width: 100%;
}
.auth-card input[type="email"]:focus,
.auth-card input[type="text"]:focus {
  outline: none;
  border-color: var(--ink);
}
.auth-card .btn-primary {
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  border: 0;
  cursor: pointer;
  transition: background 100ms, opacity 100ms;
}
.auth-card .btn-primary:hover:not(:disabled) { background: #333; }
.auth-card .btn-primary:disabled {
  background: var(--ink-3);
  cursor: not-allowed;
  opacity: 0.7;
}
.auth-card .btn-secondary {
  height: 44px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.auth-card .btn-secondary:hover { background: var(--bg-sub); border-color: var(--ink-3); }
.auth-card .btn-secondary svg { width: 18px; height: 18px; }

/* OAuth provider buttons */
.oauth-row { display: flex; flex-direction: column; gap: 10px; }

/* Divider between OAuth and magic-link */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ToS checkbox */
.tos-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}
.tos-row input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--ink);
  flex-shrink: 0;
}
.tos-row a { color: var(--ink); border-bottom: 1px solid var(--line); }

/* Inline error / hint */
.auth-msg {
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 6px;
}
.auth-msg.error { background: #ffefef; color: #a32020; }
.auth-msg.info  { background: var(--bg-sub); color: var(--ink-2); }

.auth-footer-link {
  text-align: center;
  font-size: 14px;
  color: var(--ink-2);
}
.auth-footer-link a { color: var(--ink); font-weight: 500; border-bottom: 1px solid var(--line); }
.auth-footer-link a:hover { border-color: var(--ink); }

/* ─── Spinner ─── */
.curio-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--ink);
  animation: curio-spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes curio-spin { to { transform: rotate(360deg); } }

/* ─── Account layout (sidebar + main) ─── */
.account-shell {
  flex: 1;
  display: grid;
  /* sidebar + main as one centered unit. */
  grid-template-columns: 240px minmax(0, 680px);
  max-width: 1000px;   /* 240 sidebar + 48 gap + 680 main + 64 padding (32 each side) */
  width: 100%;
  margin: 0 auto;
  padding: 48px 32px 80px;
  gap: 48px;
}
.account-sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 24px;
  align-self: start;
}
.account-sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink-2);
  border-radius: 8px;
  font-weight: 500;
}
.account-sidebar a:hover { background: var(--bg-sub); color: var(--ink); }
.account-sidebar a.on { background: var(--bg-sub); color: var(--ink); font-weight: 600; }
.account-sidebar a[hidden] { display: none; }  /* override flex from .account-sidebar a */
.account-sidebar .divider { height: 1px; background: var(--line-soft); margin: 8px 0; }
.account-sidebar a.danger { color: #a32020; }

.account-main {
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-width: 0;
}
.account-main h1 {
  font-size: 28px;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.account-main h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 16px;
}

/* ─── Cards ─── */
.acc-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  background: var(--bg);
}
/* Dashboard subscription card — borderless, distinct elevation (per design call). */
.acc-card.acc-card--shadow,
#sub-card {
  border: 0;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 4px 10px rgba(0, 0, 0, 0.08),
    0 16px 40px -8px rgba(0, 0, 0, 0.12);
}

/* Secondary card style — gray fill, no border, no shadow.
   Used for list / log content (recent activity, invoice history).
   Uses a darker gray than --bg-sub (#FAFAFA) on purpose: with no border or
   shadow, --bg-sub reads as ~2% off white and the card doesn't frame
   visually. #F0F0F0 (≈6% darker than the page bg) gives an unambiguous
   card silhouette without re-introducing a border. */
.acc-card.acc-card--muted {
  border: 0;
  background: #F0F0F0;
  box-shadow: none;
}


.acc-card.featured { background: var(--ink); color: #fff; border-color: var(--ink); }
.acc-card.featured .muted { color: rgba(255, 255, 255, 0.7); }
.acc-card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.acc-card .muted { color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.acc-card .label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 500;
}
.acc-card.featured .label { color: rgba(255, 255, 255, 0.65); }

/* Tier tag (mirror of pricing page global) */
.tier-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}
.tier-tag.tier-free { background: var(--line); color: var(--ink-2); }
.tier-tag.tier-pro  { background: var(--ink); color: #fff; }
.tier-tag.tier-max  { background: var(--ink); color: #FFD700; }

/* Status pill (subscription state) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill.active   { background: #e8f7e8; color: #2c7a2c; }
.status-pill.pending  { background: #fff4d6; color: #8a6708; }
/* (past_due removed per §6.6 — renewal failure terminates immediately,
   no past_due intermediate state in V1.) */
.status-pill.canceled { background: #f3e6e6; color: #8c3232; }
.status-pill.none     { background: var(--bg-sub); color: var(--ink-2); }
.status-pill.incomplete { background: #f3e6e6; color: #8c3232; }
.status-pill.paused   { background: var(--bg-sub); color: var(--ink-2); }

/* ─── Quota progress bar ─── */
/* Track uses --line-soft (#ebebeb) rather than --bg-sub (#FAFAFA): the
   card it sits on is pure white, and a 5-RGB-channel difference made the
   track invisible against the card. --line-soft is the standard hairline
   gray used elsewhere in the design system. */
.quota-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
  margin-top: 4px;
}
.quota-bar > i {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
  transition: width 240ms ease;
}
.acc-card.featured .quota-bar { background: rgba(255, 255, 255, 0.18); }
.acc-card.featured .quota-bar > i { background: #fff; }

/* ─── Table (billing) ─── */
.acc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.acc-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 10px 12px;
}
.acc-table td { padding: 14px 12px; vertical-align: middle; }
.acc-table .empty { text-align: center; color: var(--ink-2); padding: 32px 0; }
/* Invoices table column alignment: only the invoice (last) column hugs
   the card's right edge; date / plan / amount / status all left-align. */
.acc-table th:last-child,
.acc-table td:last-child {
  text-align: right;
}

/* ─── Recent activity (compact list) ─── */
.act-list { display: flex; flex-direction: column; gap: 12px; }
.act-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.act-row .when { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.act-row .what { color: var(--ink); }

/* ─── Danger zone ─── */
.danger-zone {
  border: 1px solid #f0caca;
  background: #fff7f7;
  border-radius: 12px;
  padding: 20px 24px;
}
.danger-zone h3 { font-size: 15px; font-weight: 600; color: #a32020; margin: 0 0 4px; }
.danger-zone p { font-size: 13px; color: var(--ink-2); margin: 0 0 14px; line-height: 1.5; }
.btn-danger {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--bg-sub);
  color: #a32020;
  border: 0;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 100ms;
}
.btn-danger:hover { background: #fdf0f0; }

/* ─── Footer (shared chrome with index / pricing) ─────────────────────────
 * Full-width gray band, content centered as a fixed-width card. .ft is the
 * full-width band (just background + vertical padding); the card (.ft-inner)
 * is a max-width 1055px box centered via margin:0 auto. 5 cols are
 * max-content sized and distributed via justify-content: space-between, so
 * brand col hugs the card's left edge and legal col hugs the right edge
 * with equal gaps in between — no trailing white inside any cell,
 * regardless of viewport width. */
.ft { padding: 48px 56px 28px; background: var(--bg-sub); }
.ft-inner {
  max-width: 1055px; margin: 0 auto;
  display: grid;
  grid-template-columns: max-content max-content max-content max-content max-content;
  justify-content: space-between; row-gap: 32px;
}
.ft-brand { display: flex; flex-direction: column; gap: 14px; }
.ft-logo { display: flex; align-items: center; gap: 6px; }
.ft-logo .gem { height: 36px; width: auto; }
.ft-brand .ft-wordmark { height: 28px; width: auto; position: relative; top: 2px; }
.ft-brand p { font-size: 14px; color: var(--ink-2); line-height: 1.5; max-width: 280px; }
.ft-col h6 {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2); font-weight: 500; margin-bottom: 14px;
}
.ft-col a { display: block; padding: 5px 0; font-size: 14px; color: #000; transition: color 100ms; }
.ft-col a:hover { color: var(--ink-2); }
.ft-bar { padding: 18px 56px; background: var(--bg-sub); }
.ft-bar-inner {
  max-width: 1055px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
}
.ft-bar-inner .sp { flex: 1; }
/* Footer responsive — aligned with site-wide 767 / 1023 breakpoints. */
@media (max-width: 1023px) {
  .ft-inner { grid-template-columns: 1fr 1fr; gap: 24px; }
}
@media (max-width: 767px) {
  .ft { padding: 32px 20px 20px; }
  /* Footer stays 2-col on mobile; brand block hidden — see index.html. */
  .ft-brand { display: none; }
  .ft-bar { padding: 14px 20px; }
  .ft-bar-inner { flex-wrap: wrap; }
}


/* ─── Modal (used by delete account, cancel sub) ─── */
.curio-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.curio-modal-overlay.open { display: flex; }
.curio-modal {
  background: var(--bg);
  border-radius: 14px;
  max-width: 440px;
  width: 100%;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.curio-modal h2 { font-size: 18px; font-weight: 600; margin: 0; }
.curio-modal p { font-size: 14px; color: var(--ink-2); line-height: 1.5; margin: 0; }
.curio-modal .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ─── Avatar dropdown (nav, replaces signup/signin when logged in) ─── */
/* NOTE: explicitly NOT .lang-pop — avoid colliding with i18n styles */
.curio-user-wrap { position: relative; }
.curio-avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 0;
  font-family: inherit;
  transition: opacity 100ms;
}
.curio-avatar-btn:hover { opacity: 0.85; }
.curio-user-menu {
  position: absolute;
  top: 44px;
  right: 0;
  width: 240px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 120ms, transform 120ms;
  z-index: 100;
}
.curio-user-menu.open { opacity: 1; transform: none; pointer-events: auto; }
.curio-user-menu .info {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 6px;
}
.curio-user-menu .info .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  word-break: break-word;
}
.curio-user-menu .info .email {
  font-size: 12px;
  color: var(--ink-2);
  word-break: break-all;
  font-family: var(--mono);
}
.curio-user-menu a, .curio-user-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.curio-user-menu a:hover, .curio-user-menu button:hover { background: var(--bg-sub); }
.curio-user-menu .sep { height: 1px; background: var(--line-soft); margin: 4px 0; }
.curio-user-menu .signout { color: #a32020; }

/* ─── Dev panel (dashboard, hidden unless ?dev=1) ─── */
.dev-panel {
  margin-top: 12px;
  border: 1px dashed var(--ink-3);
  border-radius: 12px;
  padding: 16px 20px;
  background: repeating-linear-gradient(45deg, var(--bg) 0 12px, var(--bg-sub) 12px 24px);
}
.dev-panel summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
  list-style: none;
}
.dev-panel summary::-webkit-details-marker { display: none; }
.dev-panel summary::before { content: '🛠  '; }
.dev-panel .dev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.dev-panel button {
  height: 36px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
  transition: background 100ms, border-color 100ms;
}
.dev-panel button:hover { background: var(--bg-sub); border-color: var(--ink-3); }
.dev-panel .hint { font-size: 12px; color: var(--ink-2); margin-top: 10px; line-height: 1.5; }

/* ─── Loading screen (account pages while auth resolves) ─── */
.curio-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--ink-2);
  font-size: 13px;
}

/* ─── Mobile (≤640px) ─── */
/* Mobile — aligned with the 767 / 1023 breakpoint pair used across the site. */
@media (max-width: 767px) {
  .auth-card-wrap { padding: 32px 18px 56px; }
  .auth-card h1 { font-size: 24px; }
  .account-shell { grid-template-columns: 1fr; gap: 24px; padding: 28px 18px 56px; }
  .account-sidebar {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 4px;
    margin: 0 -18px;
    padding-left: 18px;
    padding-right: 18px;
  }
  .account-sidebar a { white-space: nowrap; }
  .account-sidebar .divider { display: none; }
  .acc-card { padding: 18px; }
  /* Keep .acc-card .row as horizontal flex on mobile too (no
     flex-direction:column override). For Subscription / Payment cards
     the action button should stay aligned next to the info instead of
     wrapping below it; force nowrap and allow the info column to
     shrink (min-width:0) so the button always fits on the same line. */
  .acc-card .row { flex-wrap: nowrap; gap: 12px; }
  .acc-card .row > * { min-width: 0; }
  /* Buttons should keep their natural width and one-line text — the
     info column is what shrinks (min-width:0 above). Without this,
     min-width:0 lets buttons compress to one character per line. */
  .acc-card .row > button { flex-shrink: 0; white-space: nowrap; }
  .account-main h1 { font-size: 22px; }
  .curio-user-menu { width: calc(100vw - 32px); right: 8px; }
}
