/* ==========================================================================
   The Attraction Study — styles
   Perf tiers: html.perf-high | html.perf-mid | html.perf-low
   The low tier strips blur + heavy animation for weak GPUs.
   ========================================================================== */

:root {
  --hue-a: 258;
  --hue-b: 190;
  --hue-c: 320;
  --scroll-shift: 0;         /* set by JS: parallax offset in px            */
  --card-w: min(92vw, 34rem);
  --glass-bg: rgba(16, 20, 38, 0.55);
  --glass-border: rgba(255, 255, 255, 0.14);
  --text: #f4f6ff;
  --text-dim: #aab2d0;
  --accent: hsl(var(--hue-a) 90% 70%);
  --accent-soft: hsl(var(--hue-a) 90% 70% / 0.25);
  --danger: #ff7a90;
  --ok: #5df0b8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;                /* the wheel owns all vertical motion */
  overscroll-behavior: none;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: #0b0f1e;
  color: var(--text);
  touch-action: none;              /* custom gesture handling */
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Background: moving gradient blobs (parallax) ---------------- */

#bg {
  position: fixed;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(120% 120% at 20% 10%, hsl(var(--hue-a) 60% 14%) 0%, transparent 60%),
    radial-gradient(120% 120% at 85% 90%, hsl(var(--hue-b) 55% 12%) 0%, transparent 55%),
    #0b0f1e;
  transform: translate3d(0, calc(var(--scroll-shift) * -0.25px), 0);
  will-change: transform;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}
.blob-a {
  width: 55vmax; height: 55vmax; left: -10vmax; top: 0;
  background: hsl(var(--hue-a) 85% 55%);
  transform: translate3d(0, calc(var(--scroll-shift) * -0.55px), 0);
}
.blob-b {
  width: 45vmax; height: 45vmax; right: -12vmax; top: 30%;
  background: hsl(var(--hue-b) 85% 50%);
  transform: translate3d(0, calc(var(--scroll-shift) * -0.85px), 0);
}
.blob-c {
  width: 40vmax; height: 40vmax; left: 25%; bottom: -15vmax;
  background: hsl(var(--hue-c) 80% 55%);
  transform: translate3d(0, calc(var(--scroll-shift) * -1.2px), 0);
}

.grain {
  position: absolute; inset: 0; opacity: 0.05; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* Reduced-fidelity background for weak hardware */
html.perf-low .blob { filter: none; opacity: 0.14; border-radius: 45%; }
html.perf-low .grain { display: none; }
html.perf-mid .blob { filter: blur(50px); opacity: 0.4; }

/* ---------- Chrome ------------------------------------------------------- */

#chrome {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: calc(0.9rem + var(--safe-top)) 1.2rem 0.9rem;
  pointer-events: none;
}

.brand {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.brand span { color: var(--accent); font-weight: 300; }


/* ---------- Stage & wheel ------------------------------------------------ */

#stage {
  position: fixed;
  inset: 0;
  z-index: 10;
}

/* Perspective sits on the wheel itself so every card is projected
   individually — no preserve-3d context needed. Cards with 2D transforms
   (the settled front card) rasterize as normal crisp DOM content, while
   tilted neighbors still get true perspective projection. */
#wheel {
  position: absolute;
  inset: 0;
  perspective: 1100px;
  perspective-origin: 50% 50%;
}

.card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--card-w);
  max-height: min(76dvh, 46rem);
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  border: 1px solid var(--glass-border);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

/* The glass lives on a pseudo-element BEHIND the content. backdrop-filter
   forces whatever element carries it onto a composited GPU surface, and on
   mobile that surface (text and all) gets rasterized soft. Keeping the blur
   on a text-free layer lets card content render in the normal DOM raster. */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

/* Weak GPUs: solid card instead of live blur — readability without the cost */
html.perf-low .card::before,
html.perf-mid .card::before {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(15, 19, 36, 0.92);
}

.card.is-off { visibility: hidden; }
.card:not(.is-active) { pointer-events: none; }

/* Dark scrim behind text keeps glass readable over bright blobs */
.card-inner {
  position: relative;      /* stack above the ::before glass layer */
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.6rem 1.5rem calc(1.4rem);
  background: linear-gradient(180deg, rgba(10, 13, 26, 0.25), rgba(10, 13, 26, 0.05));
}

.card-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.55rem;
}

.card-title {
  font-size: clamp(1.2rem, 2.2vh + 0.8rem, 1.6rem);
  line-height: 1.3;
  font-weight: 650;
  margin-bottom: 0.4rem;
  text-wrap: balance;
}

.card-sub {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 1rem;
}

.policy-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 5px 3px;          /* clearance so rings/borders never hit the clip edge */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding-top: 1.1rem;
}

.hint {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ---------- Buttons & inputs -------------------------------------------- */

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

.btn {
  position: relative;
  overflow: hidden;
  padding: 0.7rem 1.5rem;
  border-radius: 12px;
  font-weight: 650;
  font-size: 0.95rem;
  /* Flat: single muted fill, no glow, no gradient shout */
  background: hsl(var(--hue-a) 45% 58%);
  color: #0b0f1e;
  transition: transform 0.15s ease, opacity 0.2s ease, filter 0.2s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.96); }
.btn[disabled] { opacity: 0.35; filter: saturate(0.3); cursor: not-allowed; }

/* Hover: subtle sheen sweeps across once, plus a gentle brightness lift */
.btn::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: -45%;
  width: 45%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg) translateX(-120%);
  pointer-events: none;
}
@media (hover: hover) {
  .btn:hover:not([disabled]) { filter: brightness(1.1); }
  .btn:hover:not([disabled])::after { animation: btnSheen 0.55s ease; }
}
@keyframes btnSheen {
  to { transform: skewX(-20deg) translateX(430%); }
}
html.perf-low .btn::after { display: none; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--glass-border);
}

/* Choice list */
.choices { display: flex; flex-direction: column; gap: 0.6rem; }

.choice {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.95rem;
  line-height: 1.35;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.choice:active { transform: scale(0.985); }
.choice .dot {
  flex: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.choice.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.choice.selected .dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-soft);
}
.choice.multi .dot { border-radius: 6px; }

/* Scale (1..N tap track) */
.scale-track {
  display: flex;
  gap: 0.35rem;
  margin: 0.5rem 0 0.4rem;
}
.scale-cell {
  flex: 1;
  height: 3.1rem;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-dim);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.scale-cell:active { transform: scale(0.94); }
.scale-cell.lit {
  background: linear-gradient(180deg, hsl(var(--hue-b) 65% 46%), hsl(var(--hue-a) 65% 52%));
  border-color: transparent;
  color: #fff;
}
/* Picked marker stays INSIDE the shape (inset ring) — outer glows get
   clipped by the card body's overflow edge and look like artifacts. */
.scale-cell.picked {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
  color: #fff;
  font-weight: 800;
}
.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Bipolar variant: unnumbered circles between two anchored poles.
   space-between (not flex-grow) spreads fixed-size circles evenly across
   the full track, aligned with the pole labels at the edges. */
.scale-track.bipolar {
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}
.scale-cell.circle {
  position: relative;
  flex: 0 0 auto;
  width: clamp(2.1rem, 8.5vw, 2.9rem);
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  /* Gradient edge: dark fill clipped to padding-box, gradient ring on the
     border-box behind it. Opaque layers — no translucent stacking. */
  border: 2px solid transparent;
  background:
    linear-gradient(rgb(24, 28, 48), rgb(24, 28, 48)) padding-box,
    linear-gradient(135deg,
      hsl(var(--hue-b) 75% 58% / 0.6),
      hsl(var(--hue-a) 75% 62% / 0.6),
      hsl(var(--hue-c) 75% 62% / 0.6)) border-box;
  transition: transform 0.12s ease;
}
.scale-cell.circle.lit {
  /* Selected: opaque gradient fill with a white core dot, radio-style.
     Everything paints inside the circle — no scale, no shadows, no halo:
     anything outside the shape gets clipped by the card body and looks
     like a glitch on edge rows. */
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 24%, transparent 28%),
    linear-gradient(135deg,
      hsl(var(--hue-b) 85% 58%),
      hsl(var(--hue-a) 85% 62%),
      hsl(var(--hue-c) 85% 60%));
  border-color: transparent;
  box-shadow: none;
}
/* Likert variant: circles grow with distance from the neutral center.
   Extra block padding tallens the card so the base sizes can breathe. */
.scale-track.likert {
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 1.1rem 0 0.9rem;
}
.scale-track.likert .circle.d0 { width: clamp(1.9rem, 7vw, 2.4rem); }
.scale-track.likert .circle.d1 { width: clamp(2.5rem, 9.5vw, 3.1rem); }
.scale-track.likert .circle.d2 { width: clamp(3rem, 11.5vw, 3.8rem); }
.scale-track.likert + .scale-labels {
  font-size: 0.8rem;
  color: var(--text);
}

/* Give the bipolar anchors a little more presence than tick labels */
.scale-track.bipolar + .scale-labels {
  font-size: 0.8rem;
  color: var(--text);
  gap: 1rem;
}
.scale-track.bipolar + .scale-labels span { max-width: 45%; }

/* ---------- Diagram cards ------------------------------------------------ */

.diagram-wrap {
  display: grid;
  grid-template-columns: minmax(90px, 130px) 1fr;
  gap: 0.9rem;
  align-items: start;
}
.diagram-wrap.no-figure { grid-template-columns: 1fr; }

.figure-box { position: sticky; top: 0; }
.figure-box svg { width: 100%; height: auto; display: block; }

/* Cohesive human body: opaque children unioned, then one group opacity so the
   overlapping shapes composite seamlessly (no internal seams). */
.silhouette-body { opacity: 0.28; }
.silhouette-body > * { fill: #d6def5; stroke: none; }

/* Answerable zones (clipped to the body outline in markup): invisible when
   idle so the crisp anatomical figure reads first, a soft contained glow when
   rated. Light blur softens section edges without turning the body to mush;
   dropped on low tier for performance. */
.region {
  fill: transparent;
  stroke: none;
  transition: fill 0.25s ease;
  filter: blur(1.4px);
}
html.perf-low .region { filter: none; }
.region.filled { fill: hsl(var(--hue-a) 82% 62% / 0.44); }
.region.breathing { animation: regionBreathe 1.8s ease-in-out infinite; }

@keyframes regionBreathe {
  0%, 100% { fill: rgba(255, 200, 120, 0.10); }
  50%      { fill: rgba(255, 200, 120, 0.32); }
}

.parts { display: flex; flex-direction: column; gap: 0.55rem; }

.part-row {
  padding: 0.55rem 0.7rem;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.part-row .part-name {
  font-size: 0.85rem;
  font-weight: 650;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.part-row .part-val { font-size: 0.75rem; color: var(--accent); font-weight: 700; }

/* Breathing = not yet answered. Steady = done. */
.part-row.breathing {
  animation: rowBreathe 1.8s ease-in-out infinite;
}
.part-row.filled {
  border-color: hsl(var(--hue-a) 80% 65% / 0.5);
  background: hsl(var(--hue-a) 80% 65% / 0.08);
}

@keyframes rowBreathe {
  0%, 100% { border-color: rgba(255, 200, 120, 0.25); background: rgba(255, 200, 120, 0.03); }
  50%      { border-color: rgba(255, 200, 120, 0.75); background: rgba(255, 200, 120, 0.10); }
}

/* Low tier: static highlight instead of animation (still clearly "unfilled") */
html.perf-low .part-row.breathing { animation: none; border-color: rgba(255, 200, 120, 0.6); background: rgba(255, 200, 120, 0.07); }
html.perf-low .region.breathing { animation: none; fill: rgba(255, 200, 120, 0.25); stroke: rgba(255, 200, 120, 0.7); }

.pips { display: flex; gap: 0.3rem; }
.pip {
  flex: 1;
  height: 2rem;
  border-radius: 9px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  transition: background 0.12s ease, color 0.12s ease, transform 0.1s ease;
}
.pip:active { transform: scale(0.9); }
.pip.lit { background: hsl(var(--hue-a) 80% 62% / 0.55); border-color: transparent; color: #fff; }

/* ---------- Anatomy-textbook diagram (body map) ------------------------- */
.diagram-wrap.textbook {
  display: grid;
  grid-template-columns: 1fr minmax(94px, 128px) 1fr;
  gap: 0.35rem;
  align-items: stretch;
  margin-top: 0.35rem;
}
.diagram-wrap.textbook .figure-box { position: relative; top: auto; }
.figure-svg { overflow: visible; }        /* let leader lines run into the flanks */

.tag-rail { position: relative; }

.part-tag {
  position: absolute;
  transform: translateY(-50%);
  width: 100%;
  max-width: 190px;
}
.part-tag.side-left  { right: 6px; text-align: right; }
.part-tag.side-right { left: 6px;  text-align: left; }

.tag-name {
  display: flex;
  align-items: baseline;
  gap: 0.28rem;
  font-size: 0.74rem;
  font-weight: 650;
  line-height: 1.12;
  margin-bottom: 0.28rem;
  color: var(--text);
  transition: color 0.2s ease;
  white-space: nowrap;   /* single line -> predictable height, never overlaps neighbor */
}
.part-tag.side-left .tag-name { justify-content: flex-end; }
.tag-val { color: var(--accent); font-weight: 800; font-size: 0.72rem; min-width: 0.6em; }
.part-tag.filled .tag-name { color: #fff; }

.diagram-wrap.textbook .pips { display: flex; gap: 0.22rem; }
.part-tag.side-left .pips { justify-content: flex-end; }
.diagram-wrap.textbook .pip {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 2.15rem;
  font-size: 1.05rem;
  border-radius: 11px;
}

/* Leader lines + endpoint dots (drawn in the figure's SVG space) */
.leader { stroke: rgba(255, 255, 255, 0.22); stroke-width: 0.8; transition: stroke 0.25s ease; }
.leader.filled { stroke: var(--accent); }
.leader-dot { fill: rgba(255, 255, 255, 0.30); transition: fill 0.25s ease; }
.leader-dot.filled { fill: var(--accent); }

/* Breathing = still unanswered */
.part-tag.breathing .tag-name { animation: tagBreathe 1.8s ease-in-out infinite; }
.leader.breathing { animation: leaderBreathe 1.8s ease-in-out infinite; }
.leader-dot.breathing { animation: dotBreathe 1.8s ease-in-out infinite; }
@keyframes tagBreathe    { 0%,100% { color: rgba(255,200,120,0.55); } 50% { color: rgba(255,214,150,1); } }
@keyframes leaderBreathe { 0%,100% { stroke: rgba(255,200,120,0.35); } 50% { stroke: rgba(255,214,150,0.9); } }
@keyframes dotBreathe    { 0%,100% { fill: rgba(255,200,120,0.5); }  50% { fill: rgba(255,214,150,1); } }

/* Low tier / no animation: static amber highlight for unanswered */
html.perf-low .part-tag.breathing .tag-name,
html.perf-low .leader.breathing,
html.perf-low .leader-dot.breathing { animation: none; }
html.perf-low .part-tag.breathing .tag-name { color: rgba(255, 214, 150, 0.95); }
html.perf-low .leader.breathing { stroke: rgba(255, 214, 150, 0.7); }
html.perf-low .leader-dot.breathing { fill: rgba(255, 214, 150, 0.95); }

/* Shake feedback when user tries to advance past an incomplete card */
.card.shake { animation: cardShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes cardShake {
  10%, 90% { transform: translate(-50%, -50%) translateX(-2px); }
  20%, 80% { transform: translate(-50%, -50%) translateX(4px); }
  30%, 50%, 70% { transform: translate(-50%, -50%) translateX(-7px); }
  40%, 60% { transform: translate(-50%, -50%) translateX(7px); }
}

/* ---------- Nav arrows --------------------------------------------------- */

#navdots {
  position: fixed;
  right: max(0.9rem, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.nav-arrow {
  width: 2.7rem; height: 2.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  transition: opacity 0.2s ease, transform 0.15s ease, background 0.15s ease;
}
html.perf-low .nav-arrow { backdrop-filter: none; background: rgba(30, 36, 60, 0.9); }
.nav-arrow:active { transform: scale(0.9); }
.nav-arrow.dim { opacity: 0.25; pointer-events: none; }
.nav-arrow.pulse { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Update pill -------------------------------------------------- */

.update-pill {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 35;
  padding: 0.65rem 1.4rem;
  border-radius: 99px;
  font-weight: 650;
  font-size: 0.88rem;
  color: #0b0f1e;
  background: linear-gradient(135deg, hsl(var(--hue-b) 80% 58%), hsl(var(--hue-a) 80% 62%));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: pillIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.update-pill[hidden] { display: none; }
.update-pill:active { transform: translateX(-50%) scale(0.95); }
.update-pill[disabled] { opacity: 0.6; }
@keyframes pillIn {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}
html.perf-low .update-pill { animation: none; }

/* ---------- Toast -------------------------------------------------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.4rem + var(--safe-bottom));
  transform: translate(-50%, 20px);
  z-index: 40;
  padding: 0.65rem 1.2rem;
  border-radius: 99px;
  background: rgba(20, 24, 44, 0.92);
  border: 1px solid rgba(255, 200, 120, 0.4);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 86vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Special cards ------------------------------------------------ */

.emoji-hero { font-size: 3rem; margin-bottom: 0.6rem; }

.review-list { display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.85rem; }
.review-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}
.review-item .q { color: var(--text-dim); flex: 1; }
.review-item .a { font-weight: 650; text-align: right; }

.spinner {
  width: 1.2rem; height: 1.2rem;
  border: 2.5px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: -0.3em;
  margin-right: 0.5em;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results cards */
.stat-big {
  font-size: clamp(2.6rem, 8vh, 3.6rem);
  font-weight: 800;
  line-height: 1.05;
  margin-bottom: 0.5rem;
  background: linear-gradient(120deg, hsl(var(--hue-b) 90% 62%), hsl(var(--hue-a) 90% 68%), hsl(var(--hue-c) 90% 66%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-text { font-size: 1.02rem; line-height: 1.5; }

.scatter-wrap svg { width: 100%; height: auto; display: block; }
.scatter-wrap .ax { stroke: rgba(255, 255, 255, 0.25); stroke-width: 1; }
.scatter-wrap .axlbl { fill: #aab2d0; font-size: 10px; }
.scatter-wrap .pt { fill: hsl(var(--hue-b) 80% 65% / 0.5); }
.scatter-wrap .trend { stroke: hsl(var(--hue-a) 90% 70%); stroke-width: 2; stroke-linecap: round; }
.scatter-wrap .you-dot { fill: #fff; stroke: hsl(var(--hue-c) 90% 65%); stroke-width: 3; }
.scatter-wrap .you-lbl { fill: #fff; font-weight: 700; font-size: 11px; }

/* Free-text card */
.text-input {
  width: 100%;
  resize: none;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  line-height: 1.5;
  user-select: text;
  -webkit-user-select: text;
}
.text-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.text-input::placeholder { color: rgba(170, 178, 208, 0.55); }

.pub-check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
/* Native input stays for semantics/keyboard; visuals live on .pub-box */
.pub-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.pub-box {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  /* Same gradient-ring language as the answer circles */
  border: 2px solid transparent;
  background:
    linear-gradient(rgb(24, 28, 48), rgb(24, 28, 48)) padding-box,
    linear-gradient(135deg,
      hsl(var(--hue-b) 75% 58% / 0.7),
      hsl(var(--hue-a) 75% 62% / 0.7),
      hsl(var(--hue-c) 75% 62% / 0.7)) border-box;
  transition: transform 0.15s ease;
}
.pub-box svg {
  opacity: 0;
  transform: scale(0.4) rotate(-12deg);
  transition: opacity 0.12s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pub-check input:checked + .pub-box {
  background: linear-gradient(135deg,
    hsl(var(--hue-b) 85% 58%),
    hsl(var(--hue-a) 85% 62%),
    hsl(var(--hue-c) 85% 60%));
}
.pub-check input:checked + .pub-box svg {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}
.pub-check:active .pub-box { transform: scale(0.88); }
.pub-check input:focus-visible + .pub-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pub-label { line-height: 1.3; transition: color 0.15s ease; }
.pub-check input:checked ~ .pub-label { color: var(--text); }

/* Fantasy quotes on the compare card */
.fantasy-list { margin-bottom: 1rem; }
.fantasy-head {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.fantasy-quote {
  margin: 0 0 0.5rem;
  padding: 0.6rem 0.9rem;
  border-left: 3px solid hsl(var(--hue-c) 70% 60% / 0.6);
  border-radius: 0 12px 12px 0;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  line-height: 1.45;
  font-style: italic;
  color: var(--text);
}

/* Share card */
.share-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.6rem 0.7rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 0.9rem;
}
.share-link {
  flex: 1;
  font-weight: 650;
  letter-spacing: 0.02em;
  user-select: all;               /* long-press selects the whole link */
  -webkit-user-select: all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-btn {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text);
  transition: transform 0.12s ease, background 0.15s ease;
}
.copy-btn:active { transform: scale(0.9); }
.share-cta { width: 100%; }

.err-text { color: var(--danger); font-size: 0.85rem; margin-top: 0.6rem; }
.ok-text { color: var(--ok); }

/* ---------- Responsive tuning ------------------------------------------- */

/* Short/landscape phones: tighten paddings, shrink diagram figure */
@media (max-height: 620px) {
  .card-inner { padding: 1.1rem 1.2rem 1rem; }
  .card-title { margin-bottom: 0.25rem; }
  .card-sub { margin-bottom: 0.6rem; }
  .card { max-height: 88dvh; }
  .diagram-wrap { grid-template-columns: minmax(70px, 90px) 1fr; }
}

/* Phones: shrink the center figure so the enlarged pips keep their size.
   Numbers stay big and readable even if labels run near the card edge. */
@media (max-width: 480px) {
  .diagram-wrap.textbook { grid-template-columns: 1fr minmax(72px, 82px) 1fr; gap: 0.1rem; }
  .diagram-wrap.textbook .pips { gap: 0.14rem; }
  .diagram-wrap.textbook .pip { width: 1.2rem; height: 1.7rem; font-size: 0.88rem; }
  .diagram-wrap.textbook .tag-name { font-size: 0.66rem; }
}

/* Very narrow screens */
@media (max-width: 380px) {
  .diagram-wrap:not(.textbook) { grid-template-columns: 1fr; }
  .diagram-wrap:not(.textbook) .figure-box { display: none; } /* rows carry breathing */
  .scale-cell { font-size: 0.72rem; }
  #navdots { right: 0.4rem; }
  .nav-arrow { width: 2.3rem; height: 2.3rem; }
}

/* Big desktop: cap card, enlarge type slightly */
@media (min-width: 1400px) {
  :root { --card-w: 38rem; }
}

/* Accessibility: honor reduced motion regardless of perf tier */
@media (prefers-reduced-motion: reduce) {
  .part-row.breathing, .region.breathing, .blob,
  .part-tag.breathing .tag-name, .leader.breathing, .leader-dot.breathing { animation: none !important; }
  .part-row.breathing { border-color: rgba(255, 200, 120, 0.6); }
  .part-tag.breathing .tag-name { color: rgba(255, 214, 150, 0.95); }
  .leader.breathing { stroke: rgba(255, 214, 150, 0.7); }
  .leader-dot.breathing { fill: rgba(255, 214, 150, 0.95); }
}

/* Keyboard focus */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
