/* Layout, controls and motion. Contains no hex codes — every colour is a token from
 * tokens.css, which is what makes the brand switch a one-attribute change on <html>. */

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

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

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font-family: inherit; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* One focus treatment for the whole page. :focus-visible so a mouse click on a face does not
   draw a ring the pointer user never asked for, while Tab always does. */
:focus-visible { outline: var(--focus) solid var(--accent); outline-offset: 3px; }
.opt:has(input:focus-visible) {
  outline: var(--focus) solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius-lg, 10px);
}

/* ------------------------------------------------------------------ frame */

/* A hairline the width of the window. Redundant with the bottle on a desktop, and the only
   progress signal that exists on a phone — so it stays at every size rather than appearing
   at the moment the layout is already changing under the reader. */
.bar {
  position: fixed; inset: 0 0 auto 0; height: 2px;
  background: var(--line); z-index: 30;
}
.bar::after {
  content: ''; display: block; height: 100%;
  width: calc(var(--p, 0) * 100%);
  background: var(--accent);
  transition: width var(--t-slow) var(--ease);
}

.shell { min-height: 100vh; }

.rail {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.rail-in {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--gap-3) var(--gap-3) var(--gap-2);
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-wordmark);
  letter-spacing: var(--track-wordmark);
  font-size: clamp(15px, 1.4vw, 19px);
  color: var(--ink);
  /* Keune tracks its wordmark wide, which pushes the optical centre right; the negative
     margin pulls the block back so it reads centred. Harmless at miiki's near-zero tracking. */
  margin-right: calc(var(--track-wordmark) * -1);
}

.vessel-wrap { display: none; }
.vessel { width: 100%; }

.main {
  display: grid; place-items: center;
  padding: var(--gap-5) var(--gap-3) var(--gap-6);
}
.stage { width: 100%; max-width: 620px; }

/* ------------------------------------------------------------------ card */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
[data-anim] { animation: rise 420ms var(--ease) both; }

.eyebrow {
  margin: 0 0 var(--gap-3);
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: var(--track-eyebrow);
  color: var(--ink-3);
}
.opt-tag {
  color: var(--ink-3);
  /* The bullet separates "section" from "optional" without a second element. */
  border-left: 1px solid var(--line); padding-left: 8px; margin-left: 4px;
}

.q {
  margin: 0 0 var(--gap-4);
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1.16;
  letter-spacing: -0.005em;
  max-width: var(--measure-q);
  color: var(--ink);
  text-wrap: balance;
}
.q--intro { max-width: 14ch; }

.lead { margin: 0 0 var(--gap-4); max-width: 46ch; color: var(--ink-2); }

.fineprint {
  margin: var(--gap-3) 0 0;
  font-size: 12px; line-height: 1.5; color: var(--ink-3); max-width: 46ch;
}

.counter {
  margin: var(--gap-3) 0 0;
  font-size: 12px; letter-spacing: .04em; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.err {
  margin: var(--gap-2) 0 0;
  font-size: 13px; color: var(--accent);
}

/* ------------------------------------------------------------------ text */

.field { display: block; }

.input {
  width: 100%;
  font-size: 17px; line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  resize: vertical;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input::placeholder { color: var(--ink-3); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

/* ------------------------------------------------------------------ scales */

.opt { position: relative; cursor: pointer; border-radius: var(--radius); }
.opt input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
  pointer-events: none;
}
.opt-num { font-variant-numeric: tabular-nums; }

.ends {
  display: flex; justify-content: space-between; gap: var(--gap-3);
  margin-top: var(--gap-2);
  font-size: 12px; color: var(--ink-3);
}
/* 🔴 Do NOT add `text-align: end` here — tried and reverted 2026-09-21. Below 560px the scale is
   six columns, so 11 cells leave an empty sixth in row two and this row runs ~48px past the 10.
   End-aligning the right label moves it AWAY from the 10 (measured at 320px: centres 275/255
   against the 10's 232, where start-aligned gives 213/233). The app carries the same note. */

/* --- faces (0–5 satisfaction) --- */

.scale--faces { display: flex; gap: clamp(4px, 1.2vw, 12px); }

.opt--face {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 8px 0;
  transition: transform var(--t-med) var(--ease-settle);
}
.opt--face:hover { transform: translateY(-3px); }
.opt--face.is-on { transform: translateY(-5px); }

.face { width: 100%; max-width: 58px; height: auto; display: block; }
.f-head {
  fill: none; stroke: var(--n-20); stroke-width: 2;
  transition: fill var(--t-med) var(--ease), stroke var(--t-med) var(--ease);
}
.f-eye { fill: var(--ink-3); transition: fill var(--t-med) var(--ease); }
.f-line {
  fill: none; stroke: var(--ink-3); stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: stroke var(--t-med) var(--ease);
}
.opt--face:hover .f-head { stroke: var(--ink-3); }

.opt--face.is-on .f-head { fill: var(--accent); stroke: var(--accent); }
.opt--face.is-on .f-eye  { fill: var(--accent-ink); }
.opt--face.is-on .f-line { stroke: var(--accent-ink); }
.opt--face.is-on .face   { animation: pick 520ms var(--ease-settle); }
.opt--face.is-on .opt-num { color: var(--ink); font-weight: var(--weight-strong); }

@keyframes pick {
  0%   { transform: scale(1); }
  38%  { transform: scale(1.14) rotate(-4deg); }
  100% { transform: scale(1); }
}

.opt--face .opt-num { font-size: 12px; color: var(--ink-3); }

/* --- NPS (0–10 likelihood to recommend) ---
   Eleven numbered cells, deliberately a different instrument from the faces above. The tint
   ramps with the value from --tint (set inline by the engine) and is NOT banded: colouring
   7–8 amber would tell the respondent how their answer is about to be classified, and a
   respondent who can see the bands answers differently. */

.scale--nps { display: grid; grid-template-columns: repeat(11, 1fr); gap: 5px; }

.opt--nps {
  aspect-ratio: 1 / 1;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) calc(var(--tint) * 18%), transparent);
  color: var(--ink-2);
  font-size: 15px;
  transition: transform var(--t-med) var(--ease-settle),
              background-color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}
.opt--nps:hover { border-color: var(--ink-3); transform: translateY(-2px); }
.opt--nps.is-on {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); font-weight: var(--weight-strong);
  transform: translateY(-4px);
}

/* --- choice --- */

.choices { display: grid; gap: 10px; }

.opt--choice {
  display: flex; align-items: center; gap: 14px;
  min-height: 54px; padding: 12px 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.opt--choice::before {
  content: ''; flex: none;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--n-20);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.opt--choice:hover { border-color: var(--ink-3); }
.opt--choice.is-on { border-color: var(--accent); background: var(--accent-wash); }
.opt--choice.is-on::before {
  border-color: var(--accent);
  /* Inset shadow instead of a nested element: one box draws the ring and the dot. */
  box-shadow: inset 0 0 0 4px var(--accent);
}
.opt-label { font-size: 16px; }

.other-wrap {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows var(--t-med) var(--ease), margin-top var(--t-med) var(--ease);
  margin-top: 0;
}
/* The padding-free inner box is what actually collapses; see the note in survey.js. */
.other-in { overflow: hidden; min-height: 0; }
.other-wrap.is-open { grid-template-rows: 1fr; margin-top: 10px; }

.input--other {
  padding: 12px 16px;
  /* A zero-height field is still in the tab order and still announced. Hide it outright while
     collapsed, and flip visibility only after the collapse has finished so the exit still
     animates. */
  visibility: hidden;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              visibility 0s linear var(--t-med);
}
.other-wrap.is-open .input--other { visibility: visible; transition-delay: 0s, 0s, 0s; }

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

.nav { display: flex; align-items: center; gap: 12px; margin-top: var(--gap-4); }
.nav--end { margin-top: var(--gap-5); }

.btn {
  font-size: var(--btn-size);
  font-weight: var(--weight-strong);
  text-transform: var(--btn-transform);
  letter-spacing: var(--btn-track);
  padding: 15px 30px;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease),
              background-color var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn--go { background: var(--accent-grad); color: var(--accent-ink); }
.btn--go:hover { opacity: .9; }

.btn--ghost {
  background: transparent; color: var(--ink-2); border-color: var(--line);
}
.btn--ghost:hover { border-color: var(--ink-3); color: var(--ink); }

/* ------------------------------------------------------------------ thanks */

.code { display: flex; flex-direction: column; gap: 10px; margin-top: var(--gap-4); }
.code-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: var(--track-eyebrow); color: var(--ink-3);
}
.code-chip {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 18px;
  padding: 14px 22px;
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-wash);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}
.code-chip.is-copied { border-style: solid; }
.code-value {
  font-size: 22px; font-weight: var(--weight-strong);
  letter-spacing: .14em; color: var(--ink);
}
.code-hint {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: var(--track-eyebrow); color: var(--accent);
}

.payload { margin-top: var(--gap-5); border-top: 1px solid var(--line); padding-top: var(--gap-3); }
.payload summary {
  cursor: pointer; list-style: none;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: var(--track-eyebrow); color: var(--ink-3);
}
.payload summary::-webkit-details-marker { display: none; }
.payload summary::before { content: '+ '; }
.payload[open] summary::before { content: '– '; }
.payload pre {
  margin: var(--gap-2) 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.6;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 340px; overflow: auto;
  color: var(--ink-2);
}

/* ------------------------------------------------------------------ bottle */

.bottle { width: 100%; height: auto; display: block; }

/* Keune's dropper cap is white and needs an outline to exist on a light page; miiki's pump is
   gloss black and sets --cap-line to its own fill so the same stroke disappears. One rule,
   both caps. */
.b-cap { fill: var(--cap); stroke: var(--cap-line); stroke-width: 1; }
.b-collar { fill: var(--cap-2); stroke: var(--cap-line); stroke-width: 1; }
.b-capgloss { fill: #fff; opacity: .11; }
.b-outline { fill: none; stroke: var(--glass); stroke-width: 2.5; }

/* Frosted glass genuinely obscures its contents, so miiki's fill reads through a white veil
   rather than as a clean coloured block. Keune's bottle is clear and gets no veil. */
.b-frost { fill: #fff; opacity: .44; }

/* The pipette inside Keune's bottle. Stroked in the glass grey, not white: white would be
   invisible against the empty bottle and only appear once liquid had risen behind it. */
.k-pipette { fill: #fff; fill-opacity: .28; stroke: var(--glass); stroke-width: 1.1; }

.liq-a { stop-color: var(--liquid-top); }
.liq-b { stop-color: var(--liquid-bottom); }

/* The one place the motion budget is spent: the liquid rises with a small overshoot, the way
   a poured liquid settles. No looping wave — a treatment serum is viscous and still, and a
   bobbing surface would be the one element on the page that looks generated. */
.b-liquid { transition: transform var(--t-slow) var(--ease-settle); }
.b-meniscus { fill: #fff; opacity: .30; }

.b-tick { stroke: var(--ink-3); stroke-width: 1.4; stroke-linecap: round; opacity: .5; }
.b-tick--full { stroke: var(--ink-2); opacity: .6; }

.b-shine rect { fill: #fff; opacity: 0; }
.b-shine.is-sweeping { animation: sweep 1200ms var(--ease) 220ms; }
@keyframes sweep {
  0%   { transform: translateX(0); opacity: 0; }
  18%  { opacity: .5; }
  100% { transform: translateX(250px); opacity: 0; }
}

/* ------------------------------------------------------------------ stamp */

/* Pressed across the full bottle when the questionnaire is submitted.
 *
 * Ink-coloured rather than accent-coloured on purpose: an accent stamp over the accent-filled
 * bottle would vanish into it, and both brands set their type in near-black anyway. multiply
 * is what makes it read as ink absorbed into the surface instead of a sticker sitting on top —
 * it darkens the coral and the frosted teal rather than covering them.
 *
 * Wider than the bottle, because a stamp that fits neatly inside the object looks placed;
 * one that overhangs looks pressed.
 */
.stamp {
  position: absolute;
  left: 50%; top: 63%;
  /* min-width, not width: the amount comes from surveys.js, so a longer offer than "10 CHF"
     has to widen the stamp rather than spill out of it. */
  min-width: 126%;
  width: max-content;
  max-width: 200%;
  display: none;
  flex-direction: column; align-items: center;
  gap: 0;
  padding: 8px 18px 9px;
  color: var(--ink);
  border: 3px solid currentColor;
  border-radius: calc(var(--radius) + 4px);
  font-family: var(--font-display);
  text-align: center;
  text-transform: uppercase;
  mix-blend-mode: multiply;
  opacity: .92;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-13deg);
}
/* The inner rule every rubber stamp has. A pseudo-element rather than a second box shadow so
   it can carry its own corner radius and lighter weight. */
.stamp::before {
  content: '';
  position: absolute; inset: 4px;
  border: 1.5px solid currentColor;
  border-radius: inherit;
  opacity: .6;
}
.stamp.is-on {
  display: flex;
  animation: stamp-press 520ms cubic-bezier(.2, .85, .3, 1.25) 620ms both;
}

.stamp-top, .stamp-label {
  font-size: clamp(9px, .95vw, 12.5px);
  font-weight: var(--weight-strong);
  letter-spacing: .22em;
  /* Tracking adds space after the last letter; pull it back so the words stay optically centred. */
  margin-right: -.22em;
  opacity: .85;
}
.stamp-value {
  font-size: clamp(22px, 2.4vw, 32px);
  font-weight: 700;
  letter-spacing: .005em;
  line-height: 1.12;
  white-space: nowrap;
}

/* Comes in large and out of focus, lands slightly small, settles — the way a stamp meets
   paper. The delay lets the liquid finish rising first, so it lands on a full bottle. */
@keyframes stamp-press {
  0%   { opacity: 0; filter: blur(4px);
         transform: translate(-50%, -50%) rotate(-13deg) scale(2.7); }
  60%  { opacity: .92; filter: blur(0);
         transform: translate(-50%, -50%) rotate(-13deg) scale(.93); }
  78%  { transform: translate(-50%, -50%) rotate(-13deg) scale(1.05); }
  100% { opacity: .92; filter: blur(0);
         transform: translate(-50%, -50%) rotate(-13deg) scale(1); }
}

/* ------------------------------------------------------------------ demo bar */

.demo {
  position: fixed; left: 16px; bottom: 16px; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 8px 8px 8px 14px;
  border-radius: 12px;
  background: #17171c; color: #e9e9ec;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  font-size: 11px;
  max-width: calc(100vw - 32px);
  flex-wrap: wrap;
}
.demo-tag {
  text-transform: uppercase; letter-spacing: .18em;
  color: #6e6e7a; font-weight: 600;
}
.seg { display: flex; align-items: center; gap: 8px; }
.seg-label { color: #85858f; }
.seg-btns { display: flex; gap: 2px; background: #232329; border-radius: 7px; padding: 2px; }
.seg-btn {
  border: 0; background: transparent; color: #9c9ca6;
  padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 11px;
}
.seg-btn:hover { color: #fff; }
.seg-btn.is-on { background: #3a3a44; color: #fff; }
.demo-x {
  border: 0; background: transparent; color: #6e6e7a;
  font-size: 18px; line-height: 1; padding: 4px 8px; cursor: pointer; border-radius: 6px;
}
.demo-x:hover { color: #fff; }

.demo-show {
  position: fixed; left: 16px; bottom: 16px; z-index: 40;
  display: none;
  border: 0; border-radius: 8px; cursor: pointer;
  background: #17171c; color: #9c9ca6;
  padding: 7px 12px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .18em;
}
/* The draft notice. Scaffolding greys like the rest of the demo bar, and deliberately NOT the
   brand — a notice that the questions were edited must not look like part of the questionnaire
   it is warning about. */
.demo-draft {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 4px 3px 10px; border-radius: 8px;
  border: 1px dashed #4a4a55; color: #c8c8d0;
}
.demo-reset {
  border: 0; border-radius: 6px; cursor: pointer;
  background: #2a2a33; color: #c8c8d0;
  padding: 4px 9px; font-size: 10px;
  text-transform: uppercase; letter-spacing: .14em;
}
.demo-reset:hover { background: #383843; }

body.demo-off .demo { display: none; }
body.demo-off .demo-show { display: block; }

/* ------------------------------------------------------------------ wide */

@media (min-width: 1024px) {
  .shell {
    display: grid;
    grid-template-columns: minmax(260px, 32%) 1fr;
    min-height: 100vh;
  }
  /* The column carries the background so it runs the full height of a long page; only the
     contents pin to the viewport. Making .rail itself 100vh left a white gap below the fold
     on the thank-you screen. */
  .rail { border-bottom: 0; border-right: 1px solid var(--line); }
  .rail-in {
    position: sticky; top: 0; height: 100vh;
    padding: var(--gap-5) var(--gap-4);
  }
  .vessel-wrap {
    display: block; position: relative;
    width: clamp(120px, 13vw, 178px);
    margin: auto 0;   /* centres the bottle in the leftover rail height */
  }
  .main { padding: var(--gap-6) var(--gap-5); }
  .stage { max-width: 640px; }
}

/* ------------------------------------------------------------------ narrow */

@media (max-width: 560px) {
  /* Eleven cells across a phone are ~28px wide, well under a comfortable tap target. Two
     rows of six give ~52px and cost nothing but a ragged last cell. */
  .scale--nps { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .opt--nps { font-size: 16px; }
  .scale--faces { gap: 2px; }
  .opt--face .opt-num { font-size: 11px; }
  .main { padding: var(--gap-4) var(--gap-3) var(--gap-6); }
  .nav { flex-wrap: wrap; }
  .btn { flex: 1 1 auto; }
  .demo { left: 8px; right: 8px; bottom: 8px; gap: 10px; }
}

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

/* Everything above degrades to instant. The liquid still moves to the right level, the
   selection still changes colour — only the travel is removed. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 1ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  .opt--face:hover, .opt--face.is-on, .opt--nps:hover, .opt--nps.is-on { transform: none; }
}
