/* ==========================================================================
   Dating Card Game — core design system
   Shared by every page: fonts, tokens, base elements, ambient background,
   and reusable components (buttons, chips, segmented controls, sheets,
   toasts, meters, footer). Page-specific styles live next to each page.
   ========================================================================== */

/* ---------- Fonts (self-hosted, OFL licensed — see assets/fonts) ---------- */
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* Smooth cross-page transitions where supported (progressive enhancement). */
@view-transition { navigation: auto; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  --ink-0: #0c0910;
  --ink-1: #15101b;
  --ink-2: #1e1727;
  --ink-3: #2a2134;
  --line: rgb(255 238 244 / 0.09);
  --line-strong: rgb(255 238 244 / 0.17);

  --text: #f8f0ea;
  --text-2: #cfc1cb;
  --text-3: #9d8e9b;

  --paper: #fbf4ea;
  --paper-2: #f2e6d8;
  --paper-ink: #2b1c25;
  --paper-ink-2: #806a76;

  --rose: #ff6b8e;
  --ember: #ff8a4c;
  --gold: #f4c96b;
  --lilac: #b8a0ff;
  --mint: #7fe0c2;
  --sky: #86c8ff;
  --good: #5fd49a;
  --bad: #ff6b6b;

  --accent: var(--rose);
  --accent-2: var(--ember);
  --on-accent: #1d0b13;

  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-s: 12px;
  --r-m: 18px;
  --r-l: 26px;
  --r-xl: 34px;
  --gutter: clamp(16px, 4.6vw, 40px);
  --maxw: 1180px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  /* Damped spring (≈8% overshoot), generated from a stiffness 170 / damping 16 simulation. */
  --spring: linear(0, 0.033, 0.115, 0.228, 0.356, 0.488, 0.613, 0.727, 0.826, 0.907, 0.971, 1.019, 1.053,
    1.073, 1.084, 1.086, 1.083, 1.075, 1.065, 1.054, 1.043, 1.032, 1.022, 1.014, 1.007, 1.002, 0.998,
    0.995, 0.994, 0.993, 0.994, 0.995, 0.997, 0.999, 1);

  --shadow-1: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 10px 30px -14px rgb(0 0 0 / 0.7);
  --shadow-2: 0 30px 80px -24px rgb(0 0 0 / 0.8), 0 12px 24px -12px rgb(0 0 0 / 0.55);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--ink-0);
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

main { flex: 1; overflow-x: clip; }
img,
svg { display: block; max-width: 100%; }
button,
input,
select,
textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
h1, h2, h3, h4, p, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
::selection { background: color-mix(in oklab, var(--accent) 45%, transparent); color: var(--text); }

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

.icon { width: 1.25em; height: 1.25em; flex: none; }
[data-icon] { display: inline-grid; place-items: center; }

/* ---------- Ambient background: drifting light + film grain ---------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -12%, rgb(120 30 72 / 0.55), transparent 62%),
    radial-gradient(90% 60% at 50% 115%, rgb(60 30 110 / 0.45), transparent 70%),
    var(--ink-0);
}
.ambient::before,
.ambient::after,
.ambient > i {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow), transparent);
  will-change: transform;
}
.ambient::before {
  --glow: rgb(255 92 140 / 0.3);
  width: 80vmax;
  height: 80vmax;
  top: -38vmax;
  left: -30vmax;
  animation: drift-a 28s var(--ease-in-out) infinite alternate;
}
.ambient::after {
  --glow: rgb(150 110 255 / 0.24);
  width: 75vmax;
  height: 75vmax;
  bottom: -42vmax;
  right: -32vmax;
  animation: drift-b 34s var(--ease-in-out) infinite alternate;
}
.ambient > i {
  --glow: rgb(255 150 80 / 0.14);
  width: 55vmax;
  height: 55vmax;
  top: 28%;
  left: 36%;
  animation: drift-c 40s var(--ease-in-out) infinite alternate;
}
.ambient > b {
  position: absolute;
  inset: -50%;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
@keyframes drift-a { to { transform: translate3d(22vmax, 14vmax, 0) scale(1.15); } }
@keyframes drift-b { to { transform: translate3d(-18vmax, -16vmax, 0) scale(0.9); } }
@keyframes drift-c { to { transform: translate3d(-24vmax, 10vmax, 0) scale(1.2); } }

/* ---------- Typography ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}
.display,
.h2,
.h3 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.display {
  font-size: clamp(40px, 9vw, 92px);
  line-height: 1;
}
.h2 {
  font-size: clamp(32px, 6.4vw, 60px);
  line-height: 1.04;
}
.h3 {
  font-size: clamp(22px, 3.6vw, 30px);
  line-height: 1.12;
  letter-spacing: -0.01em;
}
.display em,
.h2 em,
.h3 em {
  font-style: italic;
  font-weight: 400;
  padding-right: 0.06em;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede {
  color: var(--text-2);
  font-size: clamp(16px, 2.1vw, 19px);
  line-height: 1.6;
  max-width: 58ch;
  text-wrap: pretty;
}
.muted { color: var(--text-3); }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: rgb(255 255 255 / 0.04);
  font: 700 11px/1 var(--font-ui);
  color: var(--text-2);
}

/* ---------- Layout ---------- */
.wrap {
  width: min(var(--maxw), 100% - 2 * var(--gutter));
  margin-inline: auto;
}
.section { padding-block: clamp(64px, 11vw, 128px); }
.section-head {
  display: grid;
  gap: 14px;
  margin-bottom: clamp(28px, 5vw, 48px);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(7px + var(--safe-top)) var(--gutter) 7px;
  background: rgb(12 9 16 / 0.55);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, background-color 0.3s;
}
.topbar.is-scrolled {
  border-bottom-color: var(--line);
  background: rgb(12 9 16 / 0.78);
}
.topbar__spacer { flex: 1; }
.topbar__title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 560;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 560;
  letter-spacing: -0.015em;
  white-space: nowrap;
  view-transition-name: brand;
}
.brand__mark { width: 32px; height: 32px; flex: none; }

/* ---------- Buttons ---------- */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.05);
  border: 1px solid var(--line);
  color: var(--text-2);
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s, transform 0.3s var(--spring), border-color 0.2s;
}
.icon-btn:hover { background: rgb(255 255 255 / 0.1); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn[aria-pressed="false"] { color: var(--text-3); }
.icon-btn__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.icon-btn__badge:empty { display: none; }

.btn {
  --btn-bg: rgb(255 255 255 / 0.06);
  --btn-fg: var(--text);
  --btn-bd: var(--line-strong);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 24px;
  border-radius: 999px;
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0.005em;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.3s var(--spring), background-color 0.2s, box-shadow 0.3s, border-color 0.2s, filter 0.2s;
}
.btn:hover { background: rgb(255 255 255 / 0.1); }
.btn:active { transform: scale(0.97); }
.btn .icon { width: 20px; height: 20px; }
.btn--primary {
  --btn-bg: linear-gradient(135deg, var(--accent), var(--accent-2));
  --btn-fg: var(--on-accent);
  --btn-bd: transparent;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.35),
    0 14px 34px -12px color-mix(in oklab, var(--accent) 75%, transparent);
}
.btn--primary:hover { background: var(--btn-bg); filter: brightness(1.07) saturate(1.05); }
.btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.8s var(--ease-out);
}
.btn--primary:hover::after { transform: translateX(120%); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--text-2); }
.btn--ghost:hover { color: var(--text); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 16px; font-size: 14px; }
.btn:disabled { opacity: 0.45; filter: saturate(0.6); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 0.035);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 700;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.3s var(--spring);
}
.chip:hover { color: var(--text); border-color: rgb(255 255 255 / 0.28); }
.chip:active { transform: scale(0.95); }
.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  border-color: color-mix(in oklab, var(--accent) 70%, transparent);
  color: var(--text);
}
.chip .icon { width: 16px; height: 16px; }

/* ---------- Segmented control (radiogroup with a sliding thumb) ---------- */
.seg {
  --n: 3;
  --i: 0;
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.045);
  border: 1px solid var(--line);
  isolation: isolate;
}
.seg::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--n));
  border-radius: 999px;
  background: var(--seg-thumb, linear-gradient(135deg, var(--accent), var(--accent-2)));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.3), 0 8px 22px -8px var(--seg-glow, var(--accent));
  transform: translateX(calc(100% * var(--i)));
  transition: transform 0.55s var(--spring), background 0.4s, box-shadow 0.4s;
}
.seg > [role="radio"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 15px;
  font-weight: 750;
  white-space: nowrap;
  transition: color 0.3s;
}
.seg > [role="radio"]:hover { color: var(--text); }
.seg > [aria-checked="true"],
.seg > [aria-checked="true"]:hover { color: var(--on-accent); }
.seg > [role="radio"] .icon { width: 17px; height: 17px; }
.seg--sm > [role="radio"] { min-height: 38px; font-size: 14px; }

/* ---------- Text field ---------- */
.field {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 0.05);
  color: var(--text);
  font-size: 16px; /* ≥16px stops iOS from zooming on focus */
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.field::placeholder { color: var(--text-3); }
.field:focus {
  border-color: var(--accent);
  background: rgb(255 255 255 / 0.07);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 22%, transparent);
}

/* ---------- Single-page views (quiz pages swap between these) ---------- */
.view { display: grid; gap: 22px; }
.view[hidden] { display: none; }
.view.is-entering { animation: view-in 0.6s var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(18px); } }
.view-head { display: grid; gap: 10px; }

.resume {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 16px 8px 8px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 0.04);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 650;
  transition: background-color 0.2s, color 0.2s;
}
.resume[hidden] { display: none; }
.resume:hover { background: rgb(255 255 255 / 0.08); color: var(--text); }
.resume b { color: var(--text); }

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}
@media (min-width: 860px) {
  .result-actions { display: flex; flex-wrap: wrap; }
}

/* ---------- Surfaces ---------- */
.surface {
  background: linear-gradient(180deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0.025));
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
}

/* ---------- Meter / progress ---------- */
.meter {
  --v: 0;
  height: 6px;
  border-radius: 99px;
  background: rgb(255 255 255 / 0.08);
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  width: calc(var(--v) * 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s var(--ease-out);
}

/* ---------- Bottom sheet (native <dialog>) ---------- */
dialog.sheet {
  position: fixed;
  top: auto;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: min(100%, 540px);
  max-width: 100%;
  max-height: min(88svh, 760px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: linear-gradient(180deg, #241b2e, #17111f 60%);
  color: var(--text);
  box-shadow: var(--shadow-2);
  overflow: auto;
  overscroll-behavior: contain;
}
dialog.sheet::backdrop {
  background: rgb(6 4 9 / 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
dialog.sheet[open] { animation: sheet-in 0.55s var(--spring); }
dialog.sheet[open]::backdrop { animation: fade-in 0.3s ease; }
dialog.sheet.is-closing { animation: sheet-out 0.28s var(--ease-in-out) forwards; }
dialog.sheet.is-closing::backdrop { animation: fade-out 0.28s ease forwards; }
.sheet__body {
  display: grid;
  gap: 18px;
  padding: 14px var(--gutter) calc(26px + var(--safe-bottom));
}
.sheet__grip {
  justify-self: center;
  width: 40px;
  height: 5px;
  border-radius: 9px;
  background: rgb(255 255 255 / 0.18);
}
.sheet__title {
  font-family: var(--font-display);
  font-size: clamp(26px, 6vw, 32px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.sheet__text { color: var(--text-2); }
.sheet__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
@media (min-width: 640px) {
  dialog.sheet {
    top: 0;
    margin: auto;
    height: fit-content;
    border-bottom: 1px solid var(--line-strong);
    border-radius: var(--r-xl);
  }
  dialog.sheet[open] { animation: pop-in 0.45s var(--spring); }
  dialog.sheet.is-closing { animation: pop-out 0.22s ease forwards; }
  .sheet__grip { display: none; }
  .sheet__body { padding: 30px 32px 30px; }
}
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 200;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgb(38 29 48 / 0.96);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  box-shadow: var(--shadow-2);
  animation: toast-in 0.5s var(--spring), toast-out 0.35s ease 2.5s forwards;
}
.toast .icon { width: 18px; height: 18px; color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: clamp(48px, 10vw, 110px);
  padding: 36px var(--gutter) calc(30px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}
.site-footer .brand { font-size: 17px; color: var(--text); }
.site-footer .brand__mark { width: 28px; height: 28px; }
.site-footer__love .icon { display: inline; width: 14px; height: 14px; vertical-align: -2px; color: var(--rose); }
.socials { display: flex; gap: 10px; }

/* ---------- Scroll reveal (scroll-driven, with graceful fallback) ---------- */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal {
      animation: reveal-up linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }
  }
}
@keyframes reveal-up { from { opacity: 0; transform: translateY(46px) scale(0.98); } }

/* ---------- Page transitions ---------- */
::view-transition-old(root) { animation: 0.22s ease both vt-out; }
::view-transition-new(root) { animation: 0.5s var(--ease-out) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: scale(0.985); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(14px); } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
