/* /personalisierig — Tee-Abo step 1: one question per screen on every viewport
   (php/personalisierig2.php, js/personalisierig.js). Base, header, buttons and footer come
   from tz-funnel.css (its global prefers-reduced-motion rule stays in charge there).

   Stepper mode (html.pz-js, set by the page's head script before the first paint): the six
   questions and the completion step share one grid cell (.pz-stage), so the stage is as tall
   as its tallest step, the tiles sit at the same y on every question and nothing around the
   stage moves when the step changes. Inactive steps are visibility:hidden (+ inert from the
   script), never display:none. Every text slot that changes has its space reserved.
   Without JS (no html.pz-js) the steps stack as a plain form that posts natively.

   Calm layout: three groups per question (progress row, picture with question, answers), a
   640px column centred in the first screen from 768px, the answers as a list below 480px. */

/* the header lines up with the /kasse-abo/ shell (tz-funnel.css --tz-shell) */
.tz-header > .tz-container {
  max-width: var(--tz-shell);
}

.pz-main {
  /* the legal footer stays below the first screen; 118px = the header with its stepper row */
  min-height: calc(100vh - 118px);
  min-height: calc(100svh - 118px);
}

/* the form (the flex item) is centred in the first screen; .pz-col keeps margin: 0 auto */
@media (min-width: 768px) {
  .pz-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

.pz-col {
  max-width: 672px;
  margin: 0 auto;
  padding: 32px 16px clamp(32px, 10vh, 96px);
}

.pz-kicker {
  margin: 0;
  overflow: hidden;
  color: var(--tz-muted);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.6;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

/* ---------- Progress row: Zrugg | pips | counter, fixed slots ---------- */

/* 1fr auto 1fr: the pips stay centred whatever the side slots hold */
.pz-meta {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 44px;
  margin-top: 4px;
}

.pz-back {
  justify-self: start;
  min-height: 44px;
  margin: 0;
  padding: 0 16px 0 0;
  border: 0;
  background: none;
  color: var(--tz-primary-accent);
  font: inherit;
  font-size: 14.4px;
  font-weight: 700;
  cursor: pointer;
}

.pz-back:hover {
  color: #111;
}

.pz-back:focus-visible {
  outline: 3px solid var(--tz-primary);
  outline-offset: 2px;
}

.pz-back.is-off {
  visibility: hidden; /* keeps its space on the first question: the pips stay centred */
}

.pz-count {
  justify-self: end;
  color: var(--tz-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.pz-alert {
  margin: 16px 0 0; /* shown without JS only */
}

/* ---------- Steps ---------- */

.pz-stage {
  margin-top: 32px;
}

.pz-step {
  min-width: 0;
  margin: 0 0 48px;
  padding: 0;
  border: 0;
  text-align: center;
}

.pz-step__legend {
  float: left; /* the legend sits inside the fieldset box */
  width: 100%;
  margin: 0 0 4px; /* the gap to the hint: its clearance would swallow a margin-top of its own */
  padding: 0;
}

.pz-step__legend + * {
  clear: both;
}

.pz-step__media {
  display: block;
}

.pz-step__media img {
  display: block;
  width: 150px;
  height: 150px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--tz-primary-tint); /* until the photo is decoded */
  object-fit: cover;
}

.pz-step__q {
  display: block;
  margin: 24px 0 0;
  color: var(--tz-heading);
  font-size: clamp(21px, 1.2vw + 16px, 28px);
  font-weight: 700;
  line-height: 1.25;
}

.pz-step__q:focus {
  outline: none; /* focus only marks the new question for screen readers */
}

.pz-step__hint {
  margin: 0; /* 4px below the question: the legend's margin-bottom */
  overflow: hidden;
  color: var(--tz-muted);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Answer tiles ---------- */

.pz-scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 32px;
}

.pz-tile {
  position: relative;
  display: block;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pz-tile input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.pz-tile__face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 88px;
  padding: 8px 4px;
  border: 2px solid var(--tz-border);
  border-radius: var(--tz-radius);
  background: var(--tz-surface);
  color: var(--tz-heading);
  font-size: 15px;
  font-weight: 700; /* the same weight checked or not: choosing never re-wraps a label */
  line-height: 1.2;
  transition: background-color .12s, border-color .12s, color .12s;
}

.pz-tile__key {
  position: absolute;
  top: 3px;
  left: 7px;
  display: none;
  color: #999;
  font-size: 11px;
  font-weight: 400;
}

/* only where a pointer hovers: on touch :hover sticks to the tile under the last tap, on the next question too */
@media (hover: hover) {
  .pz-tile:hover .pz-tile__face {
    border-color: var(--tz-primary);
  }
}

.pz-tile input:focus-visible + .pz-tile__face {
  outline: 3px solid var(--tz-primary);
  outline-offset: 2px;
}

.pz-tile input:checked + .pz-tile__face {
  border-color: var(--tz-primary);
  background: var(--tz-primary);
  color: #fff;
}

.pz-tile input:checked + .pz-tile__face .pz-tile__key {
  color: rgba(255, 255, 255, .75);
}

/* Reserved slot under the tiles: "Letschti Frag", the keyboard hint, the count of open questions
   after a bounce. One line on wide screens, two on phones. */
.pz-step__note {
  min-height: 1.6em;
  margin: 16px 0 0;
  color: var(--tz-muted);
  font-size: 14px;
  line-height: 1.6;
}

.pz-step__note.is-alert {
  color: var(--tz-alert);
  font-weight: 700;
}

/* Mouse and keyboard: the digit on each tile (keys 1–5). */
@media (hover: hover) and (pointer: fine) {
  .pz-tile__key {
    display: block;
  }
}

/* ---------- Completion step ("Merci") ---------- */

.pz-done .pz-step__q {
  margin-top: 0;
}

.pz-fav {
  min-height: 1.6em; /* filled by the script */
  margin: 8px 0 0;
  color: var(--tz-text);
}

.pz-fav strong {
  color: var(--tz-heading);
}

.pz-done__why {
  margin: 4px 0 0;
  color: var(--tz-text);
}

.pz-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

/* photo left, tea and answer right: the same six photos as the questions (no extra request) */
.pz-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 60px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--tz-border);
  border-radius: var(--tz-radius);
  background: var(--tz-surface);
  font: inherit;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s;
}

.pz-chip__img {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--tz-primary-tint); /* until the photo is decoded */
  object-fit: cover;
}

.pz-chip__text {
  display: flex;
  flex-direction: column;
  min-width: 0; /* lets the ellipsis below work inside the flex row */
}

@media (hover: hover) {
  .pz-chip:hover {
    border-color: var(--tz-primary);
  }
}

.pz-chip:focus-visible {
  outline: 3px solid var(--tz-primary);
  outline-offset: 2px;
}

.pz-chip__tea,
.pz-chip__val {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pz-chip__tea {
  color: var(--tz-muted);
  font-size: 13px;
}

.pz-chip__val {
  color: var(--tz-heading);
  font-size: 15px;
  font-weight: 700;
}

.pz-done__note {
  margin: 12px 0 0;
  color: var(--tz-muted);
  font-size: 13px;
}

.pz-cta {
  width: min(100%, 400px); /* inline-flex: centred by the step's text-align */
  min-height: 52px;
  margin-top: 32px;
}

.pz-trust {
  margin: 24px 0 0;
  color: var(--tz-muted);
  font-size: 13px;
  line-height: 1.5;
}

.pz-trust a {
  color: inherit;
  text-decoration: none;
}

.pz-trust a:hover {
  color: #111;
  text-decoration: underline;
}

.pz-trust__stars {
  color: var(--tz-star);
  letter-spacing: 1px;
}

.pz-quote {
  margin: 4px 0 0;
  color: var(--tz-muted);
  font-size: 13px;
  font-style: italic;
  line-height: 1.5;
}

.pz-quote__by {
  font-style: normal;
  white-space: nowrap;
}

/* ---------- Progress segments in the progress row (fill by transform/opacity only) ---------- */

.pz-pips {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 0;
}

.pz-pips span {
  position: relative;
  width: 24px;
  height: 4px;
  border-radius: 2px;
  background: var(--tz-border);
}

.pz-pips span::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: var(--tz-primary);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.pz-pips span.is-on::after {
  opacity: 1;
  transform: none;
}

.pz-pips span.is-current {
  transform: none;
  background: #999;
}

.pz-ready .pz-pips span,
.pz-ready .pz-pips span::after {
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), opacity .2s;
}

/* ---------- Without JS: the plain stacked form ---------- */

html:not(.pz-js) .pz-meta,
html:not(.pz-js) .pz-pips,
html:not(.pz-js) .pz-chips,
html:not(.pz-js) .pz-fav,
html:not(.pz-js) .pz-done__why,
html:not(.pz-js) .pz-done .pz-step__q,
html:not(.pz-js) .pz-done__note {
  display: none;
}

html:not(.pz-js) .pz-step__note:empty {
  min-height: 0;
}

/* ---------- Stepper mode ---------- */

html.pz-js .pz-alert {
  display: none; /* the note slot of the open question says what is missing */
}

html.pz-js .pz-stage {
  display: grid;
}

html.pz-js .pz-step {
  grid-area: 1 / 1;
  align-self: start;
  margin: 0;
  visibility: hidden;
}

/* the current step; before the script ran, the one the head script chose from the cookies */
html.pz-js .pz-step.is-current,
html.pz-js[data-pz-start="0"] .pz-step[data-step="0"],
html.pz-js[data-pz-start="1"] .pz-step[data-step="1"],
html.pz-js[data-pz-start="2"] .pz-step[data-step="2"],
html.pz-js[data-pz-start="3"] .pz-step[data-step="3"],
html.pz-js[data-pz-start="4"] .pz-step[data-step="4"],
html.pz-js[data-pz-start="5"] .pz-step[data-step="5"],
html.pz-js[data-pz-start="6"] .pz-step[data-step="6"] {
  visibility: visible;
}

html.pz-js[data-pz-start]:not([data-pz-start="0"]) .pz-back.is-off,
html.pz-js[data-pz-edit] .pz-back.is-off {
  visibility: visible;
}

/* ---------- Neighbouring teas beside the question (from 1024px, stepper mode only) ----------
   #pz-reel (php/personalisierig2.php): the six tea photos again, decorative. js/personalisierig.js
   (placeReel) gives each a data-pos: the previous tea left, the current one in the place of the step's
   own photo, the next one right, the rest parked outside. A move to the neighbouring question slides
   the strip (transform/opacity only); the reel is absolutely positioned, so nothing else moves.
   Below 1024px, without JS and after the script's fallback the reel is not shown. */

.pz-reel {
  display: none;
}

@media (min-width: 1024px) {
  .pz-main {
    overflow-x: hidden;
    overflow-x: clip; /* parked photos sit outside the window */
  }

  html.pz-js .pz-stage {
    position: relative;
  }

  html.pz-js .pz-reel {
    --pz-reel-gap: min(calc(160px + 25vw), 520px); /* centre to centre */
    display: block;
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 150px;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .1s ease-in;
  }

  html.pz-js .pz-reel.is-on {
    visibility: visible;
  }

  html.pz-js .pz-reel.is-done {
    opacity: 0; /* Merci: no photo */
  }

  .pz-reel img {
    position: absolute;
    top: 0;
    left: -75px;
    width: 150px;
    max-width: none;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    opacity: 0;
    transform: translateX(0) scale(.8);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .28s cubic-bezier(.2, .8, .2, 1);
  }

  .pz-reel img[data-pos="out-left"] {
    transform: translateX(calc(-2 * var(--pz-reel-gap))) scale(.8);
  }

  .pz-reel img[data-pos="prev"] {
    transform: translateX(calc(-1 * var(--pz-reel-gap))) scale(.8);
    opacity: .45;
  }

  .pz-reel img[data-pos="cur"] {
    transform: translateX(0) scale(1);
    opacity: 1;
  }

  .pz-reel img[data-pos="next"] {
    transform: translateX(var(--pz-reel-gap)) scale(.8);
    opacity: .45;
  }

  .pz-reel img[data-pos="out-right"] {
    transform: translateX(calc(2 * var(--pz-reel-gap))) scale(.8);
  }

  .pz-reel.is-jump img {
    transition: none;
  }

  /* the strip's centre photo stands in for the step's own, at the same place */
  html.pz-js .pz-reel.is-on ~ .pz-step .pz-step__media img {
    visibility: hidden;
  }
}

/* ---------- Tablets and phones ---------- */

@media (min-width: 550px) and (max-width: 767px) {
  .pz-step__media img {
    width: 120px;
    height: 120px;
  }
}

@media (max-width: 549px) {
  .pz-main {
    min-height: calc(100vh - 102px);
    min-height: calc(100svh - 102px);
  }

  .pz-col {
    padding: 12px 16px 32px;
  }

  .pz-pips span {
    width: 16px;
  }

  .pz-stage {
    margin-top: 16px;
  }

  .pz-step__media img {
    width: 112px;
    height: 112px;
  }

  .pz-step__q {
    margin-top: 14px;
  }

  /* 480-549: five across, each label on one line (no min-content width any more) */
  .pz-scale {
    gap: 6px;
    margin-top: 16px;
  }

  .pz-tile__face {
    min-height: 64px;
    padding: 6px 2px;
    font-size: 14px;
  }

  .pz-step__note {
    min-height: 3.2em; /* two lines */
    margin-top: 12px;
    font-size: 14px;
  }

  /* two lines each, also in the fallback font before Lato has loaded */
  .pz-fav {
    min-height: 3.2em;
  }

  .pz-trust {
    min-height: 3em;
    margin-top: 16px;
  }

  .pz-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
  }

  .pz-chip {
    height: 56px;
    gap: 8px;
    padding: 0 8px;
  }

  .pz-chip__img {
    width: 36px;
    height: 36px;
  }

  .pz-cta {
    width: 100%;
    min-height: 48px;
    margin-top: 20px;
  }
}

/* Below 480px the answers are a list: one full-width row each, label on one line, "Sehr gern" on top
   ("up is good"; wider screens read "Gar ned" .. "Sehr gern" left to right). Only the order on screen is
   reversed: the DOM, the values and the keys 1–5 stay 1..5. */
@media (max-width: 479px) {
  .pz-step__media img {
    width: 88px;
    height: 88px;
  }

  .pz-step__q {
    margin-top: 12px;
  }

  .pz-scale {
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    max-width: 400px;
    margin: 16px auto 0;
  }

  .pz-tile__face {
    min-height: 48px;
    padding: 0 16px;
    font-size: 16px;
  }

  .pz-tile__key {
    top: 50%;
    left: 16px;
    transform: translateY(-50%); /* mouse and keyboard only, as above */
  }

  .pz-step__note {
    margin-top: 12px;
  }
}

/* Short phones (iPhone SE, 360x640): the five rows stay in the first screen. */
@media (max-width: 479px) and (max-height: 740px) {
  .pz-col {
    padding-top: 8px;
  }

  .pz-step__media img {
    width: 64px;
    height: 64px;
  }

  .pz-step__q {
    margin-top: 8px;
  }

  .pz-scale {
    gap: 6px;
    margin-top: 12px;
  }

  .pz-tile__face {
    min-height: 44px;
  }
}

@media (max-width: 359px) {
  /* "Gsundheitstee" stays on one line beside its photo at 320px */
  .pz-chip {
    gap: 6px;
    padding: 0 6px;
  }

  .pz-chip__img {
    width: 30px;
    height: 30px;
  }

  .pz-step__q {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5em; /* two lines: the longest question wraps here */
  }

  .pz-step__note {
    font-size: 13px;
  }

  .pz-quote {
    min-height: 3em; /* two lines */
  }
}
