/* Cold Side colour survey
   Ground: ink #111111. Text: chalk #EDE8DF. Buttons: indigo #24304A.
   Motion: one easing for everything. Timings live in the variables below
   and app.js reads them, so the JS timeouts always match the CSS. */

:root {
  --ink: #111111;
  --chalk: #EDE8DF;
  --indigo: #24304A;

  --font-display: "Syne", "Helvetica Neue", Arial, sans-serif;
  --font-text: "Satoshi", "Helvetica Neue", Arial, sans-serif;

  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  /* A question step chains the expand and the wipe, so those two must total
     under 1s: 360 + 560 = 920ms, measured at about 950ms end to end. */
  --t-wipe: 560ms;    /* colour halves wiping in */
  --t-expand: 360ms;  /* chosen half filling the screen */
  --t-out: 450ms;     /* start screen leaving */
  --t-fade: 560ms;    /* colours to black, form in, form to thank-you */
  --t-lead: 200ms;    /* head start the wordmark gets before the colours arrive */
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;   /* no pull-to-refresh mid-survey on Android */
  background: var(--ink);
  color: var(--chalk);
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--ink);
}

.screen {
  position: absolute;
  inset: 0;
}

/* ---------- Shared pieces ---------- */

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.9;
  text-transform: lowercase;
}

.btn {
  font: 500 16px/1 var(--font-text);
  color: var(--chalk);
  background: var(--indigo);
  border: 0;
  border-radius: 999px;
  padding: 17px 30px;
  cursor: pointer;
  touch-action: manipulation;
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: #2c3a5a; }
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--chalk); outline-offset: 3px; }

/* ---------- 1. Start ---------- */

.screen-start {
  z-index: 1;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  text-align: center;
}

.start-inner {
  display: grid;
  justify-items: center;
  transition: opacity var(--t-out) var(--ease), transform var(--t-out) var(--ease);
}
.start-inner.leave {
  opacity: 0;
  transform: translateY(-48px);
}
.start-inner.anim { will-change: transform, opacity; }

/* Syne Extra Bold is a very wide face: "coldside" runs about 6.4em, so 13.5vw fills ~86% of any width. */
.screen-start .wordmark { font-size: clamp(40px, 13.5vw, 200px); }

.tagline {
  margin: 14px 0 44px;
  font-size: 15px;
  opacity: 0.72;
}

/* ---------- 2. Questions ---------- */

.screen-question { z-index: 2; }

.panes {
  position: absolute;
  inset: 0;
}

.layer {
  position: absolute;
  inset: 0;
  isolation: isolate;
  transition: opacity var(--t-fade) var(--ease);
}
.layer.fade {
  opacity: 0;
  pointer-events: none;   /* a fading layer must not swallow taps meant for the form */
  will-change: opacity;
}

.half {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-wipe) var(--ease), opacity var(--t-wipe) var(--ease);
}
.half-first  { left: 0;   top: 0; width: 50%; height: 100%; transform-origin: left center; }
.half-second { left: 50%; top: 0; width: 50%; height: 100%; transform-origin: right center; }

.layer.enter .half-first  { transform: translateX(-100%); }
.layer.enter .half-second { transform: translateX(100%); }
.layer.anim .half { will-change: transform; }

.half.chosen {
  z-index: 1;
  transition-duration: var(--t-expand);
}
.half-first.chosen,
.half-second.chosen { transform: scaleX(2); }

/* Hover / focus hint: a thin inner line, tinted to suit light or dark halves.
   Only its opacity moves, so the colour itself never changes. */
.half::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(237, 232, 223, 0.6);
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
}
.half.is-light::after { border-color: rgba(17, 17, 17, 0.35); }
@media (hover: hover) and (pointer: fine) {
  .half:hover::after { opacity: 1; }
}
.half:focus-visible::after { opacity: 1; }
.half.chosen::after,
.layer.enter .half::after { opacity: 0 !important; }

/* Question capsule, sitting on the seam between the two colours */
.capsule-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 24px;
  pointer-events: none;
  transition: opacity var(--t-fade) var(--ease);
}
.capsule-wrap.fade { opacity: 0; }

/* One capsule that fades out, swaps its text, then fades back in. Two stacked
   capsules would ghost the two progress numbers over each other mid-fade. */
.capsule {
  width: min(340px, 80vw);
  padding: 14px 18px 10px;
  border-radius: 18px;
  background: rgba(17, 17, 17, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--chalk);
  text-align: center;
  opacity: 1;
  transition: opacity calc(var(--t-wipe) / 2) var(--ease);
}
.capsule.off { opacity: 0; }

.capsule p { margin: 0; }
.capsule .question { font-size: 15px; line-height: 1.35; }
.capsule .note { margin-top: 4px; font-size: 12.5px; line-height: 1.35; opacity: 0.8; }
.capsule .progress {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  opacity: 0.55;
}

/* ---------- 3. Form ---------- */

/* Top-aligned rather than centred, so an open phone keyboard never covers Submit
   and the top of the form stays reachable when the box is short. */
.screen-form {
  z-index: 1;
  display: grid;
  justify-items: center;
  align-items: start;
  padding: max(12vh, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  overflow-y: auto;
  transition: opacity var(--t-fade) var(--ease);
}
.screen-form.fade { opacity: 0; }

.form-inner {
  width: min(360px, 100%);
  transition: opacity var(--t-fade) var(--ease), transform var(--t-fade) var(--ease);
}
.form-inner.enter {
  opacity: 0;
  transform: translateY(32px);
}
.form-inner.anim { will-change: transform, opacity; }

.form-title:focus-visible,
.thanks-title:focus-visible { outline: 2px solid var(--chalk); outline-offset: 4px; }

.form-title {
  margin: 0 0 30px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1;
}

.field {
  display: block;
  margin-bottom: 24px;
}
.field > label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  opacity: 0.72;
}
.field input {
  display: block;
  width: 100%;
  padding: 8px 0 10px;
  font: 500 18px/1.3 var(--font-text);
  color: var(--chalk);
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(237, 232, 223, 0.35);
  border-radius: 0;
  outline: none;
}
.field input:focus,
.field.invalid input { border-bottom-color: var(--chalk); }

/* Stays in the flow while empty, so screen readers announce it when it fills. */
.error {
  margin: 8px 0 0;
  font-size: 13px;
}
.error:empty { margin: 0; }

.form-status {
  margin: 16px 0 0;
  font-size: 14px;
}
.form-status:empty { display: none; }

/* ---------- 4. Thank you ---------- */

.screen-thanks {
  z-index: 3;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: max(32px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  text-align: center;
  opacity: 0;
  transition: opacity var(--t-fade) var(--ease);
}
.screen-thanks.is-on { opacity: 1; }

.thanks-inner { max-width: 540px; }
.thanks-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(24px, 4.2vw, 32px);
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}
.thanks-inner p {
  max-width: 40ch;
  margin: 0 auto;
  opacity: 0.85;
}
.wordmark-small { font-size: 18px; opacity: 0.7; }

/* ---------- Phone: halves stack top / bottom ---------- */

@media (max-width: 767px) {
  .half-first  { left: 0; top: 0;   width: 100%; height: 50%; transform-origin: center top; }
  .half-second { left: 0; top: 50%; width: 100%; height: 50%; transform-origin: center bottom; }

  .layer.enter .half-first  { transform: translateY(-100%); }
  .layer.enter .half-second { transform: translateY(100%); }

  .half-first.chosen,
  .half-second.chosen { transform: scaleY(2); }
}

/* ---------- Reduced motion: everything becomes a 0.3s fade ---------- */

@media (prefers-reduced-motion: reduce) {
  :root {
    --t-wipe: 300ms;
    --t-expand: 300ms;
    --t-out: 300ms;
    --t-fade: 300ms;
    --t-lead: 0ms;
  }
  .layer.enter .half-first,
  .layer.enter .half-second { transform: none; opacity: 0; }
  .half-first.chosen,
  .half-second.chosen { transform: none; }
  .layer.picked .half:not(.chosen) { opacity: 0; }
  .start-inner.leave { transform: none; }
  .form-inner.enter { transform: none; }
}
