/* Dark is the default theme (no attribute needed) — light is opt-in via
   [data-theme="light"] on <html>, toggled by #theme-toggle in app.js and
   persisted to localStorage. Every color that differs between themes lives
   here as a variable; nothing else in this file should hardcode a color that
   needs to flip between light/dark. */
:root {
  --bg: hsl(0, 0%, 6%);      /* 6% lightness black page background */
  --ink: #ffffff;
  --ink-light: #b3b3b3;
  --ink-soft: #b3b3b3;
  --pill-bg: #1a1a1a;
  --pill-bg-hover: #262626;
  --modal-bg: var(--bg);       /* same as page background */
  --modal-border: rgba(255, 255, 255, 0.04);
  --pill-translucent: rgba(255, 255, 255, 0.08);
  --pill-translucent-hover: rgba(255, 255, 255, 0.14);
  --separator: rgba(255, 255, 255, 0.18);
  --sticky-shadow: rgba(255, 255, 255, 0.08);
  --check-ring: #333333;
  --check-mark: #ffffff;
  --accent: #cdf45f;        /* lime badge — same in both themes */
  /* High-contrast surface for CTAs / active pills. In light mode this is a
     dark pill on a white page; in dark mode the equivalent strong-contrast
     surface is a light pill, so these are split from --ink/--bg rather than
     reusing them. */
  --surface-strong: #ffffff;
  --surface-strong-ink: #0f0f0f;
  --card-radius: 32px;
  --max-grid: 1456px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --ink: #0f0f0f;
  --ink-light: #555555;
  --ink-soft: #555555;
  --pill-bg: #f1f1f2;
  --pill-bg-hover: #e7e7e9;
  --modal-bg: #ffffff;
  --modal-border: rgba(15, 15, 15, 0.08);
  --pill-translucent: rgba(241, 241, 242, 0.75);
  --pill-translucent-hover: rgba(231, 231, 233, 0.85);
  --separator: rgba(15, 15, 15, 0.15);
  --sticky-shadow: rgba(26, 26, 26, 0.08);
  --check-ring: #e5e5e5;
  --check-mark: #1a1a1a;
  --surface-strong: #0f0f0f;
  --surface-strong-ink: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 80px 16px 80px;
  max-width: 720px;
  margin: 0 auto;
}

.hero h1,
#apple-thanks h2 {   /* post-purchase heading: h2 for SEO, but visually identical to the hero h1 */
  font-weight: 700;
  font-size: clamp(40px, 8vw, 64px);     /* 64 on desktop, scales down on mobile */
  line-height: 1.1;                      /* 110% */
  letter-spacing: -0.05em;               /* -5% */
  margin: 0;
  text-wrap: balance;
}



.subtitle {
  color: var(--ink-light);
  font-size: 18px;
  line-height: 1.5;
  letter-spacing: -0.015em;              /* -1.5% */
  max-width: 680px;
  margin: 16px auto 0;
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 16px;
}

body.is-pro .filters {
  position: sticky;
  top: 16px;
  z-index: 50;
}

.filters-pills {
  display: inline-flex;
  gap: 8px;
}

.filter-separator {
  width: 2px;
  height: 20px;
  background: var(--separator);
  border-radius: 999px;
  flex-shrink: 0;
}

.pill {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;  /* -2% */
  color: var(--ink);
  background: var(--pill-translucent);
  backdrop-filter: blur(12px);
  padding: 11px 22px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.pill:hover { background: var(--pill-translucent-hover); }

.pill.is-active {
  background: var(--surface-strong);
  color: var(--surface-strong-ink);
  backdrop-filter: none;
}

/* ---------- Grid ---------- */
main {
  max-width: none;
  margin: 0;
  padding: 16px;          /* 16px from every edge */
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;              /* 12px between avatars */
}

.card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: var(--pill-bg);
  transform: translateZ(0); /* Fix Safari border-radius bleed */
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--card-radius);
}

.card-actions {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  opacity: 0;
  background: rgba(26, 26, 26, 0.15);
}

.card:hover .card-actions,
.card:focus-within .card-actions {
  opacity: 1;
  transition: opacity 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}

.action {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 15px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #14141a; /* fixed, not var(--ink) — this pill stays white-on-photo in any theme */
  box-shadow: none;
  backdrop-filter: blur(4px);
  transform: translateY(16px);
  transition: background 0.12s ease;
}

.card:hover .action,
.card:focus-within .action {
  transform: translateY(0);
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1), background 0.12s ease;
}

.action:hover { background: #f0f0f0; transition: background 0.12s ease; }
.action.icon-only { flex: 0 0 auto; padding: 15px; }
.action svg { width: 20px; height: 20px; display: block; }
.action.is-secondary {
  background: #444444;
  color: #fff;
  border: none;
}
.action.is-secondary:hover {
  background: #555555;
}

/* ---------- Auth & Modal ---------- */
.auth-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 16px;
  gap: 16px;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
}
.auth-bar * {
  pointer-events: auto;
}

.theme-toggle {
  position: relative;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--pill-bg);
  padding: 0;
}
.theme-toggle-track {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}
.theme-toggle-icon {
  width: 14px;
  height: 14px;
  display: block;
  color: var(--ink-soft);
}
.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-strong);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Thumb rests at the moon (dark) side by default, slides to the sun (light)
   side once [data-theme="light"] is set. */
[data-theme="light"] .theme-toggle-thumb {
  transform: translateX(24px);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.modal[hidden] {
  display: none;
  opacity: 0;
}
.modal-content {
  background: var(--modal-bg); /* a little lighter than the page background */
  border: 1px solid var(--modal-border);
  padding: 64px 80px;
  border-radius: 24px;
  width: 100%;
  max-width: 560px;
  position: relative;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(0);
  transition: transform 0.2s ease;
}

/* Expand modal width for #view-buy so features fit on one line */
.modal-content:has(#view-buy:not([hidden])) {
  max-width: 680px;
}

#view-buy .paywall-features {
  flex-wrap: nowrap;
}

.modal[hidden] .modal-content {
  transform: translateY(10px);
}
.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--pill-bg);
  border: none;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.modal-close:hover {
  background: var(--pill-bg-hover);
  color: var(--ink);
}
.modal h2 {
  margin: 0 0 16px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.modal-sub {
  margin: 0 auto 32px;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--ink-light);
  max-width: 360px;
}
.highlight-email {
  color: var(--ink);
  font-weight: 700;
}
.modal-view[hidden] { display: none; }
.modal .cta-button {
  display: flex;
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.modal-foot {
  margin: 16px 0 0;
  font-size: 14px;
  text-align: center;
  color: var(--ink-soft);
}
.modal-foot a {
  color: var(--ink);
  font-weight: 700;
}
.modal input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  margin-bottom: 12px;
  background: var(--pill-bg);
  border: 1.5px solid transparent;
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  box-sizing: border-box;
}
.modal input:focus {
  outline: none;
  border-color: var(--ink);
}
.modal input:-webkit-autofill,
.modal input:-webkit-autofill:hover, 
.modal input:-webkit-autofill:focus, 
.modal input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--pill-bg) inset !important;
  -webkit-text-fill-color: var(--ink) !important;
  transition: background-color 5000s ease-in-out 0s;
}
.error-msg {
  color: #e11d48;
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

/* ---------- Paywall ---------- */
/* the banner that splits free avatars from the locked preview wall */
.paywall { margin-top: 0; }

.paywall-sentinel { height: 1px; }

.paywall-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  text-align: center;
  padding: 64px 16px 64px;
  transition: box-shadow 0.2s ease;
}

/* subtle drop shadow only while pinned to the top (toggled from JS).
   On a pure-black page a dark shadow is invisible, so this uses a soft light
   glow instead — the equivalent depth cue against --bg: #000. */
.paywall-banner.is-stuck {
  box-shadow: 0 6px 22px var(--sticky-shadow);
}

.paywall-title {
  font-weight: 700;
  font-size: clamp(30px, 4.5vw, 42px);
  letter-spacing: -0.04em;
  line-height: 1.1;
  max-width: 800px;
  margin: 0 auto;
  text-wrap: balance;
}

.paywall-features {
  list-style: none;
  padding: 0;
  margin: 32px auto 0;
  max-width: 600px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  text-align: left;
}

.paywall-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  white-space: nowrap;
}

.paywall-features .feature-check {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
}
.feature-check-ring { stroke: var(--check-ring); }
.feature-check-mark { stroke: var(--check-mark); }

.cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--surface-strong-ink);
  background: var(--surface-strong);
  height: 52px;
  padding: 0 32px;
  border-radius: 999px;
  transition: background 0.15s ease, opacity 0.15s ease;
  box-sizing: border-box;
}
.cta-button:hover { background: #e6e6e6; }

.paywall-banner .cta-button {
  margin-top: 32px;
}

/* locked preview cards: the blur is now baked into thumbs-locked/ itself
   (permanent, server-side) — no CSS filter needed on top of it anymore. */

.lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.32);
}

.lock-ico {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  border: none;
  padding: 0;
}
.lock-ico svg { width: 20px; height: 20px; display: block; overflow: visible; }
.lock-ico .shackle {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 17px 11px;
}

.card.is-locked:hover .lock-ico {
  background: #fff;
  color: #0f0f0f;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.card.is-locked:hover .lock-ico .shackle {
  transform: translateY(-2px) rotate(25deg);
}

.lock-name {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 20px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.lock-name b { font-weight: 700; }
.lock-count {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 2px;
}
.card.is-locked:hover .lock-name {
  opacity: 1;
  transform: translateY(0);
}

/* keyboard focus visibility */
.action:focus-visible,
.pill:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 16px;
  padding: 40px 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 16px);
  /* Fixed dark surface regardless of theme — a toast reading the page's
     light-mode pill color would turn light-gray-on-white and lose contrast. */
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  padding: 12px 32px 12px 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  box-shadow: 0 8px 32px rgba(26, 26, 26, 0.35);
  white-space: nowrap;
}

.toast lottie-player {
  display: block;
  flex: 0 0 auto;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 520px) {
  main { padding: 10px; }
  .hero { padding-top: 96px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .filters { gap: 8px; }
  .paywall-banner { margin-left: -10px; margin-right: -10px; padding-left: 20px; padding-right: 20px; }
  .modal { padding: 10px; box-sizing: border-box; background: rgba(0, 0, 0, 0.8); }
  .modal-content { padding: 48px 24px; }
  #view-buy .paywall-features { flex-wrap: wrap; }
}

/* Transitions.dev — Success check */
:root {
  --check-opacity-dur: 500ms;
  --check-rotate-dur: 500ms;
  --check-rotate-from: 80deg;
  --check-bob-dur: 500ms;
  --check-y-amount: 40px;
  --check-blur-dur: 500ms;
  --check-blur-from: 10px;
  --check-path-dur: 500ms;
  --check-path-delay: 80ms;
  --check-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --check-ease-opacity: cubic-bezier(0.22, 1, 0.36, 1);
  --check-ease-rotate: cubic-bezier(0.22, 1, 0.36, 1);
  --check-ease-bob: cubic-bezier(0.34, 1.35, 0.64, 1);
  --check-ease-path: cubic-bezier(0.22, 1, 0.36, 1);
}

.t-success-check {
  display: inline-block;
  transform-origin: center;
  opacity: 0;
  will-change: transform, opacity, filter;
}
.t-success-check svg { display: block; overflow: visible; }
.t-success-check svg path {
  stroke-dasharray: 35;
  stroke-dashoffset: 35;
}

.t-success-check[data-state="in"] {
  animation:
    t-check-fade   var(--check-opacity-dur) var(--check-ease-opacity) forwards,
    t-check-rotate var(--check-rotate-dur)  var(--check-ease-rotate)  forwards,
    t-check-blur   var(--check-blur-dur)    var(--check-ease-out)     forwards,
    t-check-bob    var(--check-bob-dur)     var(--check-ease-bob)     forwards;
}
.t-success-check[data-state="in"] svg path {
  animation: t-check-draw var(--check-path-dur) var(--check-ease-path) var(--check-path-delay, 0ms) forwards;
}

@keyframes t-check-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes t-check-rotate {
  from { transform: rotate(var(--check-rotate-from)); }
  to   { transform: rotate(0deg); }
}
@keyframes t-check-blur {
  from { filter: blur(var(--check-blur-from)); }
  to   { filter: blur(0); }
}
@keyframes t-check-bob {
  from { translate: 0 var(--check-y-amount); }
  to   { translate: 0 0; }
}
@keyframes t-check-draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .t-success-check { animation: none !important; opacity: 1; }
  .t-success-check svg path { animation: none !important; stroke-dashoffset: 0 !important; }
}
