/* ==========================================================================
   What Aesthetic Are You?
   Cool paper light, soft-serif typography, quiet motion.

   The tone to hold: friendly, but not chatty. That mostly comes down to two
   habits — headings set in sentence case rather than tracked-out capitals, and
   one warm accent doing the work that hairline rules used to do. Small caps
   survive only on captions, and never above 0.11em of tracking.

   Written mobile first: the base rules are the phone layout, and the wider
   breakpoints add to them. Hover affordances are kept out of the base entirely
   so a tap on a touch screen never leaves a stuck hover state behind.
   ========================================================================== */

:root {
  --paper: linear-gradient(160deg, #fdf0e6 0%, #f6eaf6 48%, #e6f4f0 100%);
  --bg:          #fbf0ea;
  --bg-sunk:     #efe3dc;
  --surface:     #fffcfa;

  /* The greys carry a trace of the paper's blue. Warm browny greys on a cool
     ground look like a stain rather than a colour. */
  --ink:         #191c22;
  --ink-soft:    #454b56;
  --ink-faint:   #5f6673;
  --line:        rgba(25, 28, 34, 0.12);
  --line-strong: rgba(25, 28, 34, 0.22);

  /* A warm clay, and the only warm thing on the page — which is what keeps a
     cool paper from reading cold. Pitched so it clears 4.5:1 on the paper as
     well as on a card, because the small caption labels are set in it. */
  --accent:      #a34f2a;
  --accent-deep: #843d1e;
  --accent-soft: rgba(163, 79, 42, 0.1);

  --shadow-sm: 0 1px 2px rgba(28, 40, 62, 0.06);
  --shadow-md: 0 1px 2px rgba(28, 40, 62, 0.05), 0 10px 28px -16px rgba(28, 40, 62, 0.26);
  --shadow-lg: 0 2px 4px rgba(28, 40, 62, 0.06), 0 28px 60px -30px rgba(28, 40, 62, 0.36);

  /* Fraunces is the friendly half of the design — a soft, warm serif that still
     sets a serious headline. Inter keeps the interface plain underneath it. */
  --serif: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --shell: 66rem;
  --pad: 1.15rem;
  --gutter: max(var(--pad), env(safe-area-inset-left));
  --radius: 10px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --tap: 48px;

  /* The colour clouds behind everything. Each quiz theme sets its own. */
  --mood1: #e07a4f;
  --mood2: #8a6fd8;
  --mood3: #3fb5a8;

  --ease: cubic-bezier(0.32, 0.72, 0.24, 1);
  --fast: 180ms;
  --mid: 280ms;
  --slow: 520ms;
}

@media (min-width: 40rem) { :root { --pad: 2rem; } }
@media (min-width: 60rem) { :root { --pad: 3rem; } }

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.62;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@media (min-width: 40rem) {
  body { font-size: 1.0625rem; line-height: 1.68; }
}

/* Two fixed layers behind the page. Both are position: fixed rather than
   background-attachment: fixed, and neither blends with what is under it, so
   the browser paints them once and only moves them - scrolling never has to
   repaint the background (that is what made phones stutter). */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* The paper: a warm peach-to-lilac-to-mint wash, a fine dot grid and grain. */
body::before {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(circle at 1px 1px, rgba(60, 40, 70, 0.09) 1px, transparent 0) 0 0 / 22px 22px,
    var(--paper);
}

/* The colour clouds. Plain soft gradients - no blur filter, which on a layer
   this size cost frames on every screen - so drifting is only a transform. */
body::after {
  inset: -20%;
  background:
    radial-gradient(36rem 30rem at 12% 8%, var(--mood1), transparent 68%),
    radial-gradient(32rem 28rem at 90% 16%, var(--mood2), transparent 68%),
    radial-gradient(40rem 32rem at 30% 92%, var(--mood3), transparent 68%),
    radial-gradient(28rem 24rem at 86% 78%, var(--mood1), transparent 70%);
  opacity: 0.5;
  transition: opacity 1.2s var(--ease);
  animation: drift 26s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50%  { transform: translate3d(3%, -2%, 0) rotate(6deg) scale(1.06); }
  100% { transform: translate3d(-3%, 3%, 0) rotate(-4deg) scale(1.02); }
}

#app {
  position: relative;
  z-index: 1;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.75rem var(--gutter) 3rem;
  padding-right: max(var(--pad), env(safe-area-inset-right));
}

@media (min-width: 40rem) {
  #app { padding-top: clamp(2.5rem, 8vh, 5.5rem); padding-bottom: clamp(4rem, 12vh, 8rem); }
}

/* The Home button above every page. Fixed height so the one-screen phone quiz
   layout below can subtract it. */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  max-width: var(--shell);
  margin: 0 auto;
  padding: env(safe-area-inset-top) var(--gutter) 0;
}
:root { --topbar-h: calc(var(--tap) + 0.75rem); }
body:not(:has(.topbar)) { --topbar-h: 0px; } /* index.html has no Home button */

a.btn { text-decoration: none; }

/* Only on beta.estetikk.com, added by app.js. Doesn't block taps. */
.env-badge {
  position: fixed;
  z-index: 100;
  top: calc(0.5rem + env(safe-area-inset-top));
  right: calc(0.5rem + env(safe-area-inset-right));
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: #d62828;
  color: #fff;
  font: 700 0.7rem/1.4 var(--sans);
  letter-spacing: 0.08em;
  pointer-events: none;
}

/* Touch behaviour: no 300ms delay, no grey flash on tap. */
button, a, label, input { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* ---------- type ---------- */

/* Small labels stay uppercase, but at a fraction of the old tracking. Letters
   spaced out to 0.3em read as a plaque on a gallery wall; this reads as a
   caption. */
.eyebrow {
  margin: 0 0 0.9rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

@media (min-width: 40rem) {
  .eyebrow { font-size: 0.72rem; letter-spacing: 0.11em; margin-bottom: 1.1rem; }
}

/* Sentence case, and enough weight to look spoken rather than engraved. */
.display {
  margin: 0 0 1.3rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.6rem, 11vw, 5.6rem);
  line-height: 1;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

.lede {
  max-width: 46ch;
  margin: 0 0 1.1rem;
  font-size: clamp(1rem, 0.95rem + 0.35vw, 1.2rem);
  line-height: 1.66;
}

.lede--muted { color: var(--ink-soft); font-size: 0.96rem; }

.fineprint {
  margin: 1.3rem 0 0;
  max-width: 56ch;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--ink-faint);
}

.fineprint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.1em 0.45em;
  border-radius: 3px;
}

.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;
}

.loading {
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  font-size: 0.95rem;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0;
  padding: 0.8rem 1.6rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    background var(--mid) var(--ease),
    border-color var(--mid) var(--ease),
    color var(--mid) var(--ease),
    box-shadow var(--mid) var(--ease),
    transform var(--fast) var(--ease),
    opacity var(--mid) var(--ease);
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
  box-shadow: var(--shadow-sm);
  transition-duration: 60ms;
}

.btn:disabled { opacity: 0.38; cursor: default; box-shadow: none; }
.btn--primary:disabled { opacity: 0.55; filter: grayscale(0.5); }

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn--primary {
  border-color: transparent;
  color: #fdfcfb;
  background: linear-gradient(120deg, var(--accent), var(--accent-deep) 55%, #5e3aa0);
  box-shadow: 0 1px 2px rgba(28, 40, 62, 0.14), 0 10px 26px -10px rgba(132, 61, 30, 0.6);
}

.btn--ghost {
  box-shadow: none;
  color: var(--ink-soft);
  border-color: var(--line);
}

/* Still a full tap target on touch — only the padding and type come down. */
.btn--small {
  font-size: 0.85rem;
  padding: 0.55rem 1.1rem;
}

/* The gender-neutral / gender-specific name switch. */
.namemode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.namemode .fineprint { margin: 0; max-width: 46ch; }

@media (min-width: 40rem) {
  .namemode {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }
  .namemode .btn--small { flex: none; }
}

.btn--link {
  border: 0;
  background: none;
  box-shadow: none;
  min-height: 0;
  padding: 0.8rem 0;
  color: var(--ink-faint);
  letter-spacing: 0.01em;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

/* ---------- intro ---------- */

/* Hub layout from /redesing: glass cards and numbered steps, in the site's own
   type and colours. Scoped to the intro so no other screen changes. */
.screen--intro {
  --glass: color-mix(in srgb, var(--surface) 62%, transparent);
}

.intro__actions {
  display: grid;
  gap: 0.7rem;
  margin: 2rem 0 0;
}

.intro__section { margin-top: 3.2rem; }

.intro__head { margin-bottom: 1.1rem; }
.intro__head .eyebrow { margin-bottom: 0.3rem; }

.intro__h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.intro__grid {
  display: grid;
  gap: 0.9rem;
}

.intro__cardtitle {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
}

.intro__card .eyebrow { margin: 0 0 -0.6rem; }
.intro__card .btn { margin-top: auto; }
.intro__card .fineprint { margin: 0; }

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

.intro__card {
  align-content: start;
  display: grid;
  gap: 1rem;
  justify-items: start;
  padding: 1.3rem 1.4rem;
  border-radius: var(--radius-lg);
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.intro__card p { margin: 0; color: var(--ink-soft); }

.intro__steps {
  display: grid;
  gap: 0.9rem;
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.intro__steps li {
  counter-increment: step;
  padding: 1.2rem 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--glass);
  border: 1px solid var(--line);
}

.intro__steps li::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  margin-bottom: 0.3rem;
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1;
  color: var(--accent);
}

.intro__steps h3 { margin: 0 0 0.3rem; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.intro__steps p { margin: 0; font-size: 0.92rem; color: var(--ink-soft); }

.intro__facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem 1rem;
  list-style: none;
  margin: 3rem 0 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.intro__facts strong {
  display: block;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.15;
  color: var(--ink);
}

@media (min-width: 40rem) {
  .intro__actions { display: flex; flex-wrap: wrap; gap: 0.85rem; margin-top: 2.4rem; }
  .intro__steps { grid-template-columns: repeat(3, 1fr); }
  .intro__grid { grid-template-columns: repeat(2, 1fr); }
  .intro__card--main { grid-column: 1 / -1; }
  .intro__card--main .intro__cardtitle { font-size: 1.7rem; }
  .intro__facts { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; font-size: 0.8rem; padding-top: 1.8rem; }
}

/* ---------- preferences ---------- */

.display--sub { font-size: clamp(2.1rem, 8vw, 3.6rem); margin-bottom: 1rem; }

.chips {
  display: grid;
  gap: 0.6rem;
  margin: 1.8rem 0 0.4rem;
}

@media (min-width: 40rem) {
  .chips { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
}

.chip {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  min-height: var(--tap);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--mid) var(--ease), border-color var(--mid) var(--ease),
    box-shadow var(--mid) var(--ease), transform var(--fast) var(--ease);
}

.chip:active { transform: scale(0.985); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip__label {
  display: block;
  font-family: var(--serif);
  font-size: 1.08rem;
  color: var(--ink);
}

.chip__hint {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
  line-height: 1.4;
}

.chip--selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--accent);
}

.chip--selected .chip__label { color: var(--accent); }

.chips__note {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* ---------- quiz ---------- */

.screen--quiz {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 4.75rem);
}

.quiz__head { margin-bottom: 1.2rem; }

.progress {
  height: 3px;
  background: var(--line);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.progress__fill {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #b08f57, var(--accent));
  /* scaleX, not width: a width transition lays out the page every frame. */
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--slow) var(--ease);
}

/* The question counter sits under the progress bar. Answering a statement
   always advances on its own, so there is nothing else to put here. */
.quiz__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.quiz__counter {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.quiz__card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  /* extra room at the foot so the last option clears the sticky bar */
  padding: 1.35rem 1.1rem 1.6rem;
}

@media (min-width: 40rem) {
  .quiz__card { padding: clamp(1.5rem, 4.5vw, 3rem); }
  .quiz__head { margin-bottom: clamp(1.8rem, 5vh, 3rem); }
  .quiz__counter { font-size: 0.78rem; }
}

/* The whole block moves as one when the question changes. */
.quiz__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.quiz__body.is-out { opacity: 0; transform: translateY(-10px); }
.quiz__body.is-out-back { opacity: 0; transform: translateY(10px); }

/* Which theme you are in, beside the running count. Truncates rather than
   pushing the counter off a narrow screen. */
.quiz__theme {
  margin: 0;
  min-width: 0;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiz__theme:empty { display: none; }

.quiz__statement {
  margin: 0 0 1.4rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.4rem, 1.05rem + 2.1vw, 2.5rem);
  line-height: 1.24;
  letter-spacing: -0.005em;
  max-width: 26ch;
  text-wrap: balance;
}

@media (min-width: 40rem) {
  .quiz__statement { margin-bottom: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.26; }
}

.options { display: grid; gap: 6px; }

.option {
  --opt: var(--accent);
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: var(--tap);
  text-align: left;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  transition: background var(--mid) var(--ease), color var(--mid) var(--ease),
              border-color var(--mid) var(--ease), box-shadow var(--mid) var(--ease);
}

/* An accent bar that grows instead of a padding jump — no reflow, no judder. */
.option::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8%;
  bottom: 8%;
  width: 2px;
  border-radius: 2px;
  background: var(--opt);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform var(--mid) var(--ease);
}

.option:active { background: var(--accent-soft); }
.option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.option__dot {
  width: var(--dot, 12px);
  height: var(--dot, 12px);
  justify-self: center;
  border: 1.5px solid var(--opt);
  border-radius: 50%;
  transition: background var(--mid) var(--ease), border-color var(--mid) var(--ease),
              box-shadow var(--mid) var(--ease), transform var(--mid) var(--ease);
}

.option__label { transition: transform var(--mid) var(--ease); }

/* The scale reads at a glance: teal for agree, purple for disagree, and the
   dot grows towards either end. The chosen option lights up in its own colour. */
.option:nth-child(1) { --opt: #1f8a7c; --dot: 20px; }
.option:nth-child(2) { --opt: #2f9e8f; --dot: 17px; }
.option:nth-child(3) { --opt: #4fae9f; --dot: 14px; }
.option:nth-child(4) { --opt: #6b6f7a; --dot: 11px; }
.option:nth-child(5) { --opt: #9a78d0; --dot: 14px; }
.option:nth-child(6) { --opt: #8660c6; --dot: 17px; }
.option:nth-child(7) { --opt: #7048b5; --dot: 20px; }

/* The number shortcut is keyboard-only, so it stays out of the way on touch. */
.option__key {
  font-size: 0.68rem;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity var(--mid) var(--ease);
}

.option--selected {
  color: var(--ink);
  background: color-mix(in srgb, var(--opt) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--opt) 45%, transparent);
  box-shadow: 0 1px 2px rgba(28, 40, 62, 0.06);
  font-weight: 500;
}
.option--selected::before { transform: scaleY(1); }
.option--selected .option__label { transform: translateX(3px); }
.option--selected .option__dot {
  background: var(--opt);
  border-color: var(--opt);
  transform: scale(1.12);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--opt) 18%, transparent);
}

/* Back and Next ride along the bottom of the screen instead of sitting under
   the fold, so no question needs scrolling to answer. */
.quiz__nav {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 0.6rem;
  margin: 1.1rem calc(var(--gutter) * -1) 0;
  padding: 0.75rem var(--gutter) calc(0.75rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.quiz__nav .btn { width: 100%; }

@media (min-width: 40rem) {
  .quiz__nav {
    position: static;
    display: flex;
    justify-content: space-between;
    margin: 1.6rem 0 0;
    padding: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: 0;
  }
  .quiz__nav .btn { width: auto; min-width: 9rem; }
}

/* ---------- quiz: one-screen phone layout ---------- */
/* Below 40rem the quiz fills at least one viewport height so the card can sit
   centred, but it is never capped at it: on a short phone the page itself
   scrolls, rather than squeezing the options into a little scroll box of their
   own where the bottom answers hide. The page frame is trimmed to buy room. */
@media (max-width: 39.99rem) {
  #app:has(.screen--quiz) {
    padding-top: 0.85rem;
    padding-bottom: 0;
  }

  .screen--quiz {
    min-height: calc(100dvh - 0.85rem - var(--topbar-h) - env(safe-area-inset-top));
  }

  .quiz__head { margin-bottom: 0.8rem; }
  .quiz__head .eyebrow { display: none; } /* the page title says it already */
  .quiz__meta { margin-top: 0.5rem; }

  /* The card hugs its question and answers and sits centred in the space
     left over, rather than stretching and leaving a hole in the middle. */
  .quiz__card { padding: 0.95rem 0.85rem; flex: 0 1 auto; margin: auto 0; }

  .quiz__statement {
    margin-bottom: 0.9rem;
    font-size: clamp(1.25rem, 1rem + 1.8vw, 1.65rem);
    line-height: 1.2;
  }

  .options { gap: 5px; }

  .option {
    min-height: 44px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    font-size: 0.95rem;
  }

  .quiz__nav {
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom));
  }

  .quiz__nav .btn {
    min-height: 44px;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }
}

/* ---------- result: welcome + hero ---------- */

.result__welcome { margin-bottom: 1.4rem; }

.result__greeting {
  margin: 0;
  max-width: 34ch;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 1.1rem + 1.2vw, 1.95rem);
  font-weight: 400;
  line-height: 1.3;
  color: var(--ink-soft);
}

.hero {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
}

.hero__banner {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 13rem;
  padding: 1.2rem;
  isolation: isolate;
}

.hero__plate { position: absolute; inset: 0; z-index: -3; }
.hero__plate img { width: 100%; height: 100%; display: block; object-fit: cover; }

/* A real photograph, when Commons has one, fades in on top of the generated
   plate - the plate paints instantly and never leaves a blank hero waiting on
   the network. */
.hero__photo {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--slow) var(--ease);
}
.hero__photo.is-loaded { opacity: 1; }

.hero__credit {
  position: absolute;
  z-index: 1;
  top: 0.8rem;
  right: 0.8rem;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-pill);
  background: rgba(12, 11, 10, 0.38);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.62rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.hero__banner::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(0deg, rgba(12, 11, 10, 0.72) 0%, rgba(12, 11, 10, 0.28) 42%, rgba(12, 11, 10, 0.02) 78%),
    linear-gradient(90deg, rgba(12, 11, 10, 0.4) 0%, transparent 62%);
}

.hero__name {
  margin: 0;
  color: #fbfcff;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.2rem, 9.5vw, 5.5rem);
  line-height: 0.96;
  letter-spacing: -0.015em;
  text-wrap: balance;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.45);
}

.hero__foot {
  display: grid;
  gap: 0.9rem;
  padding: 1.2rem;
  border-top: 1px solid var(--line);
}

.hero__score { display: flex; align-items: baseline; gap: 0.3rem; }

.hero__percentnum {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 8vw, 3.8rem);
  line-height: 1;
  font-weight: 400;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.hero__percentsign { font-size: 1.3rem; color: var(--accent); }

.hero__scorelabel {
  margin-left: 0.6rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  align-self: center;
}

.hero__tagline {
  margin: 0 0 0.6rem;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1rem + 0.9vw, 1.5rem);
  font-style: italic;
  font-weight: 400;
}

.hero__meter { max-width: 26rem; }

@media (min-width: 44rem) {
  .result__welcome { margin-bottom: clamp(1.6rem, 5vh, 2.6rem); }
  .hero { margin-bottom: clamp(2rem, 6vh, 3.2rem); }
  .hero__banner { min-height: clamp(15rem, 40vh, 24rem); padding: clamp(1.4rem, 4vw, 2.6rem); }
  .hero__foot {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 2.4rem;
    padding: clamp(1.4rem, 4vw, 2.2rem);
  }
}

/* ---------- photo strip ---------- */

.photos { margin: 0 0 2.5rem; animation: fade var(--slow) var(--ease) both; }

/* On a phone three stacked photos push everything else off the screen, so they
   scroll sideways with snap points instead. */
.photos__grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 78%;
  gap: 0.7rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 var(--gutter) 0.4rem;
}

.photos__grid::-webkit-scrollbar { display: none; }
.photos__grid > * { scroll-snap-align: start; }

@media (min-width: 34rem) {
  .photos__grid {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-columns: auto;
    gap: 0.9rem;
    overflow: visible;
    margin: 0;
    padding: 0;
  }
}

@media (min-width: 40rem) {
  .photos { margin-bottom: clamp(2.5rem, 8vh, 4rem); }
}

.photo {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform var(--mid) var(--ease), box-shadow var(--mid) var(--ease);
}

.photo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--slow) var(--ease);
}
.photo img.is-loaded { opacity: 1; }

.photo__credit {
  display: block;
  padding: 0.5rem 0.65rem 0.6rem;
  font-size: 0.66rem;
  line-height: 1.4;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ---------- music ---------- */

.tracks { display: grid; gap: 0.7rem; margin: 0 0 1.1rem; }

@media (min-width: 46rem) {
  .tracks { grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 0.9rem; }
}

.track {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1.05rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: transform var(--mid) var(--ease), box-shadow var(--mid) var(--ease);
}

.track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.track__thumb {
  position: relative;
  flex: none;
  width: 6rem;
  aspect-ratio: 16 / 9;
  border-radius: calc(var(--radius) - 3px);
  overflow: hidden;
  background: var(--bg-sunk);
}

.track__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.track__thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(12, 11, 10, 0.45), rgba(12, 11, 10, 0) 60%);
}

.track__play {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: rgba(250, 251, 254, 0.94);
  color: var(--accent);
  font-size: 0.7rem;
  padding-left: 0.1rem;
  box-shadow: var(--shadow-sm);
}

.track__body { display: grid; gap: 0.25rem; min-width: 0; }

.track__title {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.track__mood { font-size: 0.86rem; color: var(--ink-soft); line-height: 1.5; }
.track__via { font-size: 0.78rem; font-style: italic; color: var(--accent); line-height: 1.4; }
.track__credit { font-size: 0.7rem; letter-spacing: 0.03em; color: var(--ink-faint); }

.music__search { margin-bottom: 0.9rem; }

/* ---------- shared blocks ---------- */

.block { margin: 0 0 2.6rem; }

@media (min-width: 40rem) { .block { margin-bottom: clamp(2.8rem, 8vh, 4.5rem); } }

.block__title {
  margin: 0 0 0.8rem;
  font-size: 0.75rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

@media (min-width: 40rem) {
  .block__title { font-size: 0.78rem; margin-bottom: 0.9rem; }
}

.block__lede {
  max-width: 50ch;
  margin: 0 0 1.4rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.prose { max-width: 58ch; }
.prose p { margin: 0 0 0.95rem; font-size: clamp(1rem, 0.96rem + 0.3vw, 1.1rem); line-height: 1.7; }
.prose p:last-child { margin-bottom: 0; }
.prose--muted { color: var(--ink-soft); font-size: 0.92rem; }

/* ---------- meters ---------- */

.bar {
  position: relative;
  height: 6px;
  background: var(--bg-sunk);
  border-radius: 4px;
  overflow: hidden;
}

.bar__fill {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 900ms var(--ease);
}

.bar__fill--subtle { background: linear-gradient(90deg, #cd8f6e, var(--accent)); }

/* ---------- facets ---------- */

/* Cells separated by 1px gaps showing the line colour behind them. */
.facets, .profile__grid {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.facets { box-shadow: var(--shadow-sm); }

@media (min-width: 42rem) { .facets { grid-template-columns: 1fr 1fr; } }

.facet {
  background: var(--surface);
  padding: 1.15rem 1.2rem;
  animation: rise var(--slow) var(--ease) both;
}

@media (min-width: 40rem) { .facet { padding: 1.5rem 1.6rem; } }

.facet__label {
  margin: 0 0 0.45rem;
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.facet__text { margin: 0; font-size: 0.95rem; line-height: 1.58; }

/* ---------- profile ---------- */

.profile__row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label value" "bar bar" "poles poles";
  align-items: center;
  gap: 0.35rem 0.8rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
}

.profile__label { grid-area: label; font-size: 0.85rem; font-weight: 450; }
.profile__row .bar { grid-area: bar; }
.profile__value {
  grid-area: value;
  text-align: right;
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.profile__poles {
  grid-area: poles;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

@media (min-width: 30rem) {
  .profile__row {
    grid-template-columns: 8.5rem 1fr 2.6rem;
    grid-template-areas: "label bar value" "poles poles poles";
    gap: 0.45rem 1rem;
  }
}

@media (min-width: 44rem) {
  .profile__row {
    grid-template-columns: 9rem 1fr 3rem 13rem;
    grid-template-areas: "label bar value poles";
    padding: 0.85rem 1.1rem;
  }
  .profile__poles { text-align: right; font-size: 0.64rem; }
}

/* ---------- footer ---------- */

.result__footer { border-top: 1px solid var(--line); padding-top: 1.8rem; }

.result__actions { display: grid; gap: 0.7rem; margin: 1.3rem 0 0.4rem; }

@media (min-width: 40rem) {
  .result__footer { padding-top: 2rem; }
  .result__actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.4rem; }
}

/* ---------- hover: pointing devices only ---------- */

@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--ink-faint);
  }
  .btn:active:not(:disabled) { transform: translateY(0); }
  .btn--primary:hover:not(:disabled) {
    background: linear-gradient(120deg, #b55a30, var(--accent-deep) 50%, #6c45b5);
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(28, 40, 62, 0.14), 0 16px 34px -12px rgba(132, 61, 30, 0.7);
  }
  .btn--ghost:hover:not(:disabled) { color: var(--ink); }
  .btn--link:hover { background: none; transform: none; box-shadow: none; color: var(--ink); }

  .option:hover { color: var(--ink); border-color: var(--line-strong); }
  .option:hover::before { transform: scaleY(0.55); }
  .option:hover .option__key { opacity: 0.55; }
  .option--selected:hover { background: color-mix(in srgb, var(--opt) 16%, var(--surface)); border-color: var(--opt); }
  .option--selected:hover::before { transform: scaleY(1); }

  .hero__credit:hover { color: #fff; }
  .photo:hover, .track:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

  .chip:hover { border-color: var(--ink-faint); }
  .chip--selected:hover { border-color: var(--accent); }
}

/* ---------- motion ---------- */

.fade-in { animation: fade var(--slow) var(--ease) both; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   Quiz themes. Each sub-quiz page sets a class on <html>; the main test keeps
   the default paper above. Only tokens change, so every component follows.
   ========================================================================== */

.theme-nature {
  --paper: linear-gradient(160deg, #eef5e4 0%, #e3efd9 48%, #d6e9d4 100%);
  --bg:          #eef4e6;
  --bg-sunk:     #dfe9d4;
  --surface:     #fbfdf7;
  --ink:         #1c261b;
  --ink-soft:    #3f4d3c;
  --ink-faint:   #586656;
  --accent:      #3f7a35;
  --accent-deep: #2c5a25;
  --accent-soft: rgba(63, 122, 53, 0.1);
  --mood1: #7fb069;
  --mood2: #c8b560;
  --mood3: #4f9a7a;
}

.theme-goth {
  --paper: linear-gradient(160deg, #1a1a1d 0%, #222226 48%, #17171a 100%);
  --bg:          #1b1b1e;
  --bg-sunk:     #141416;
  --surface:     #26262a;
  --ink:         #e6e4e8;
  --ink-soft:    #b4b1b8;
  --ink-faint:   #8f8c94;
  --line:        rgba(230, 228, 232, 0.14);
  --line-strong: rgba(230, 228, 232, 0.26);
  --accent:      #a9a3b3;
  --accent-deep: #4a4552;
  --accent-soft: rgba(169, 163, 179, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px -16px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.4), 0 28px 60px -30px rgba(0, 0, 0, 0.8);
  --mood1: #3a3a42;
  --mood2: #4b3f55;
  --mood3: #2c2c30;
  color-scheme: dark;
}

.theme-internet {
  --paper: linear-gradient(160deg, #ffe3f6 0%, #e4e0ff 45%, #d6fbff 100%);
  --bg:          #fbeaff;
  --bg-sunk:     #eedcf7;
  --surface:     #fffaff;
  --accent:      #c2188f;
  --accent-deep: #7a1fd1;
  --accent-soft: rgba(194, 24, 143, 0.1);
  --mood1: #ff4fd8;
  --mood2: #4fd6ff;
  --mood3: #b8ff4f;
}
.theme-internet body::after { opacity: 0.65; }

/* The primary button's gradient carries the default palette's purple, so each
   theme gives its own (hover included, hence the doubled selector). */
.theme-nature .btn--primary,
.theme-nature .btn--primary:hover:not(:disabled) { background: linear-gradient(120deg, #4d8a3f, #2c5a25 60%, #1f4a33); }
.theme-goth .btn--primary,
.theme-goth .btn--primary:hover:not(:disabled) { background: linear-gradient(120deg, #5a5560, #3a3640 60%, #2a2530); }
.theme-internet .btn--primary,
.theme-internet .btn--primary:hover:not(:disabled) { background: linear-gradient(120deg, #e0249f, #7a1fd1 55%, #1a8fd6); }
