/* ==========================================================================
   Two Hearts, One Name — baby-name swiping app
   Mobile-first, warm/calm palette, light + dark via prefers-color-scheme.
   ========================================================================== */

:root {
  --bg: #faf5ee;
  --bg-elevated: #ffffff;
  --bg-sunken: #f1e9dd;
  --text: #2c241d;
  --text-muted: #7a6f61;
  --border: #e5d9c8;
  --accent: #c96a5b;
  --accent-hover: #b45747;
  --accent-contrast: #fff8f2;
  --accent-soft: #f6dfd8;
  --like: #4f8a6a;
  --like-soft: #e1efe6;
  --pass: #c05a4c;
  --pass-soft: #f7e2de;
  --shadow-color: 30 20% 20%;
  --shadow-sm: 0 1px 3px hsl(var(--shadow-color) / 0.12);
  --shadow-md: 0 8px 24px hsl(var(--shadow-color) / 0.16);
  --shadow-lg: 0 20px 48px hsl(var(--shadow-color) / 0.22);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1815;
    --bg-elevated: #262019;
    --bg-sunken: #171310;
    --text: #f3ece2;
    --text-muted: #a89c8b;
    --border: #3a3128;
    --accent: #e08a76;
    --accent-hover: #e89f8e;
    --accent-contrast: #241611;
    --accent-soft: #3d2822;
    --like: #7cbb9a;
    --like-soft: #1e3129;
    --pass: #e08a76;
    --pass-soft: #3a2621;
    --shadow-color: 0 0% 0%;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visibility everywhere. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------
   Shell / header / nav
   -------------------------------------------------------------------- */

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(env(safe-area-inset-top) + 0.85rem) 1.25rem 0.85rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.app-brand-mark {
  color: var(--accent);
  font-size: 2rem;
}

.app-nav {
  display: flex;
  gap: 0.25rem;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 0.4rem max(0.5rem, env(safe-area-inset-left)) calc(env(safe-area-inset-bottom) + 0.4rem) max(0.5rem, env(safe-area-inset-right));
  justify-content: space-around;
}

.app-nav-link {
  flex: 1;
  text-align: center;
  padding: 0.55rem 0.25rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.app-main {
  flex: 1;
  padding: 1rem 1rem calc(6rem + env(safe-area-inset-bottom));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .app-nav {
    position: static;
    border-top: none;
    background: transparent;
    padding: 0;
    justify-content: flex-end;
    gap: 0.5rem;
    width: auto;
  }

  .app-nav-link {
    flex: none;
    min-height: auto;
    padding: 0.5rem 0.9rem;
  }

  .app-main {
    padding: 2rem 1.5rem 3rem;
  }
}

/* --------------------------------------------------------------------
   Buttons, forms, generic bits (also used by auth pages)
   -------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.7rem 1.3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-flip {
  font-size: 0.85rem;
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  white-space: nowrap;
}

.btn-flip--like { color: var(--like); }
.btn-flip--pass { color: var(--pass); }

.field {
  margin-bottom: 1.25rem;
}

.field label,
.field legend {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.auth-field input {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
}

.field-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.radio-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.radio-option {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
}

.radio-option input[type="radio"] {
  margin: 0;
}

.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.group-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0.9rem 0 0.35rem;
}

.checkbox-list {
  display: grid;
  gap: 0.15rem;
}

.checkbox-list--tall {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem;
  background: var(--bg-elevated);
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.92rem;
}

.checkbox-option:hover {
  background: var(--accent-soft);
}

.checkbox-option:has(input:checked) {
  background: var(--accent-soft);
}

.checkbox-option input[type="checkbox"],
.checkbox-option input[type="radio"] {
  margin: 0;
}

.checkbox-option small {
  color: var(--text-muted);
  font-weight: 400;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-success {
  background: var(--like-soft);
  color: var(--like);
  border: 1px solid var(--like);
}

/* --------------------------------------------------------------------
   Auth pages (register / login) — class hooks for the auth agent's HTML
   -------------------------------------------------------------------- */

.auth-card {
  max-width: 380px;
  margin: 3rem auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
  text-align: center;
}

.auth-field {
  margin-bottom: 1rem;
}

.auth-error {
  color: var(--pass);
  background: var(--pass-soft);
  border: 1px solid var(--pass);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* --------------------------------------------------------------------
   Deck / swipe cards
   -------------------------------------------------------------------- */

.page-deck {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.deck-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.deck-progress {
  width: 100%;
  max-width: 420px;
}

.deck-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-sunken);
  overflow: hidden;
}

.deck-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.deck-progress-label {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.deck-cards {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: min(62dvh, 560px);
}

.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  touch-action: none;
  will-change: transform;
  user-select: none;
}

.card--next {
  transform: scale(0.94) translateY(14px);
  opacity: 0.85;
  z-index: 1;
  pointer-events: none;
}

.card--top {
  z-index: 2;
  cursor: grab;
}

.card--top:active { cursor: grabbing; }

.card--top.is-returning {
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card--top.is-leaving {
  transition: transform 0.4s ease, opacity 0.4s ease;
}

@media (prefers-reduced-motion: reduce) {
  .card--top.is-returning,
  .card--top.is-leaving {
    transition: none;
  }
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.75rem;
  text-align: center;
  overflow: hidden;
}

.card-name {
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  line-height: 1.05;
}

.card-fullname {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.card-native {
  font-size: 1.3rem;
  margin: 0 0 1.25rem;
  color: var(--accent);
}

.card-meta {
  margin: 1.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.card-meta-row {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.card-meta-row dt {
  color: var(--text-muted);
  font-weight: 600;
}

.card-meta-row dd {
  margin: 0;
}

.card-namecensus-link {
  display: inline-block;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.card-badge {
  position: absolute;
  top: 1.5rem;
  z-index: 3;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 3px solid currentColor;
  opacity: 0;
  pointer-events: none;
}

.card-badge--like {
  left: 1.5rem;
  color: var(--like);
  transform: rotate(-12deg);
}

.card-badge--pass {
  right: 1.5rem;
  color: var(--pass);
  transform: rotate(12deg);
}

.deck-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  padding: 2rem;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.deck-empty-mark {
  font-size: 2.5rem;
  margin: 0;
}

.deck-empty h2 {
  margin: 0;
  font-size: 1.3rem;
}

.deck-empty p {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
}

.deck-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.action-btn:hover { box-shadow: var(--shadow-md); }
.action-btn:active { transform: scale(0.93); }

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.action-icon {
  width: 24px;
  height: 24px;
}

.action-btn--pass {
  color: var(--pass);
  width: 68px;
  height: 68px;
}

.action-btn--like {
  color: var(--like);
  width: 68px;
  height: 68px;
}

.action-btn--undo {
  width: 48px;
  height: 48px;
}

/* --------------------------------------------------------------------
   Review / matches
   -------------------------------------------------------------------- */

.segmented {
  display: flex;
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.segmented-option {
  flex: 1;
  text-align: center;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.segmented-option.is-active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.review-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.review-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.review-row-main { min-width: 0; }

.review-row-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.review-row-fullname {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.review-row-meta {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-row-revised {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.review-row-flip { flex-shrink: 0; }

.review-sentinel {
  height: 1px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state-mark {
  font-size: 2.5rem;
  margin: 0;
}

.empty-state h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.2rem;
}

/* --------------------------------------------------------------------
   Settings
   -------------------------------------------------------------------- */

.settings-form {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.settings-stats,
.settings-partners,
.settings-security {
  margin-bottom: 1.75rem;
}

.settings-stats h2,
.settings-partners h2,
.settings-security h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 0;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.4rem;
  text-align: center;
}

.stat dt {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat dd {
  margin: 0.2rem 0 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.partner-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.partner-row {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
}
