/*
 * Quiz "Dobierz pielęgnację": the [nz_skin_quiz] markup of the core plugin (templates/skin-quiz.php)
 * and the theme module <nz-skin-quiz> (assets/js/components/skin-quiz.js). Loaded only on pages
 * whose content has the shortcode (inc/assets.php), together with the module. Mobile first,
 * tokens only.
 *
 * Without JavaScript every question is visible and the form submits as GET. With html.js the
 * page paints the first question alone (Next instead of the submit button, the progress bar),
 * so nothing moves when the module starts; from then on the module drives the steps with the
 * hidden attribute (.is-enhanced). .is-static restores the plain form when the module never
 * starts.
 */

/* ---------- Page (template-parts/page/quiz.php): intro block and questions, 50% each from 1000px ---------- */
.nz-quiz-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 16px; }
.nz-quiz-main { min-width: 0; }
.nz-page--quiz .nz-quiz-main > :not(.nz-quiz) { max-width: 64ch; }

/* Intro block: the photo (setting quiz_image) behind an espresso overlay, or a plain brand block
   without it. The block has its own height, the image only fills it (object-fit), so the photo
   arriving moves nothing. Light text on the overlay: cream on 72% espresso over even a white
   photo stays above 5:1 (AA needs 4.5:1); the plain block is cream on dark terracotta, 7:1. */
.nz-quiz-hero { position: relative; isolation: isolate; display: flex; flex-direction: column; justify-content: flex-end; padding: 24px 20px; overflow: hidden; border-radius: var(--nz-radius); background: var(--nz-accent-dark); color: var(--nz-bg-light); }
.nz-quiz-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(46, 38, 34, 0.72); }
.nz-quiz-hero--plain { background: linear-gradient(160deg, var(--nz-accent-dark) 0%, var(--nz-text) 100%); }
.nz-quiz-hero--plain::before { content: none; }
.nz-quiz-hero__img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.nz-quiz-hero__text { display: grid; gap: 12px; max-width: 34rem; }
.nz-quiz-hero .nz-quiz-hero__title { margin: 0; color: inherit; }
.nz-quiz-hero .nz-lead { margin: 0; font-size: var(--wp--preset--font-size--lead); line-height: 1.5; color: inherit; }

/* Results replace the whole intro block (the results have their own heading and the answers): the
   block stays in the page for the h1, visually hidden, and the results take the full width. */
.nz-quiz-layout:has(.nz-quiz[data-state="results"]) { grid-template-columns: minmax(0, 1fr); min-height: 0; margin-top: 0; }
.nz-quiz-layout:has(.nz-quiz[data-state="results"]) .nz-quiz-hero { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nz-quiz-layout:has(.nz-quiz[data-state="results"]) .nz-quiz-main { padding-inline-start: 0; }

@media (min-width: 1000px) {
  /* The intro and the questions fill one screen: the block is as tall as the question column
     (which is centred in it), and the whole is at most what the viewport leaves under the header
     and the breadcrumb, so nothing needs scrolling on a laptop. */
  .nz-quiz-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: 8px; align-items: stretch; min-height: clamp(480px, calc(100svh - var(--nz-admin-bar, 0px) - 300px), 620px); }
  .nz-quiz-hero { padding: 40px 44px; }
  .nz-quiz-main { display: flex; flex-direction: column; justify-content: center; padding-inline-start: 56px; }
}

/* ---------- Component ---------- */
.nz-quiz { display: block; }
.nz-quiz [hidden] { display: none !important; }
.nz-quiz :is(.nz-quiz__form, .nz-quiz__results, .nz-quiz__results-title, .nz-quiz__question) { scroll-margin-top: 16px; }

/* Before the module runs (html.js): the first step alone, as the module will show it. When the
   module has not started after a few seconds (failed to load, very old browser), .is-static
   (inline script of templates/skin-quiz.php, or the module itself without fetch) brings back the
   plain form, so the quiz never ends in a dead end. */
.js .nz-quiz:not(.is-enhanced):not(.is-static) .nz-quiz__step ~ .nz-quiz__step,
.js .nz-quiz:not(.is-enhanced):not(.is-static) .nz-quiz__submit,
.js .nz-quiz:not(.is-enhanced):not(.is-static) .nz-quiz__form-intro,
.js .nz-quiz:not(.is-enhanced):not(.is-static) .nz-quiz__summary { display: none !important; }
.js .nz-quiz:not(.is-enhanced):not(.is-static) .nz-quiz__progress[hidden] { display: block !important; }
.js .nz-quiz:not(.is-enhanced):not(.is-static) .nz-quiz__next[hidden] { display: inline-flex !important; }
.js .nz-quiz[data-state="results"]:not(.is-enhanced):not(.is-static) .nz-quiz__form { display: none !important; }

/* ---------- Form and steps ---------- */
.nz-quiz__form { display: grid; gap: 20px; max-width: 760px; }
.nz-quiz .nz-quiz__form-intro { margin: 0; font-size: 1.0625rem; color: var(--nz-text-2); }

.nz-quiz__progress { height: 4px; background: var(--nz-line); border-radius: var(--nz-radius); overflow: hidden; }
.nz-quiz__progress-bar { display: block; width: 100%; height: 100%; background: var(--nz-accent); transform: scaleX(var(--nz-quiz-progress, 0)); transform-origin: left center; transition: transform 250ms ease; }

.nz-quiz__step { min-width: 0; margin: 0; padding: 0; border: 0; }
.nz-quiz.is-stepping .nz-quiz__step:not([hidden]) { animation: nz-quiz-step-in 220ms ease both; }
@keyframes nz-quiz-step-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.nz-quiz__legend { float: none; width: 100%; margin: 0 0 10px; padding: 0; }
.nz-quiz .nz-quiz__question { margin: 0; font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.25rem); line-height: 1.1; letter-spacing: -0.005em; }
.nz-quiz__question:focus { outline: none; }
.nz-quiz__question:focus-visible { outline: var(--nz-focus); outline-offset: 4px; }
.nz-quiz__count { display: block; margin: 0 0 8px; font-family: var(--nz-sans); font-size: 0.875rem; font-weight: 700; letter-spacing: 0.12em; line-height: 1.4; text-transform: uppercase; color: var(--nz-accent-dark); }
.nz-quiz__title { display: block; }
.nz-quiz .nz-quiz__hint { margin: 0 0 14px; font-size: 1rem; line-height: 1.5; color: var(--nz-text-2); }

/* Step error: text plus an icon, never colour alone. */
.nz-quiz .nz-quiz__error { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 14px; font-size: 1rem; font-weight: 700; line-height: 1.4; color: var(--nz-accent-dark); }
.nz-quiz__error::before { content: ""; flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 0a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15H9v-2h2v2Zm0-4H9V5h2v6Z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 0a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15H9v-2h2v2Zm0-4H9V5h2v6Z'/%3E%3C/svg%3E") center / contain no-repeat; }

/* ---------- Options: the whole box is the label (44px+ target) ---------- */
.nz-quiz__options { display: grid; gap: 8px; }
/* Two columns of answers where there is room: the phone/tablet width, and the wide right column
   (a 50% column is too narrow for them between 1000px and 1279px). */
@media (min-width: 700px) and (max-width: 999px), (min-width: 1280px) {
  .nz-quiz__options--many { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.nz-quiz__option { display: flex; align-items: flex-start; gap: 14px; min-height: 52px; padding: 12px 16px; background: var(--nz-bg-light); border: 1px solid var(--nz-line-linen); border-radius: var(--nz-radius); cursor: pointer; transition: border-color 150ms, background-color 150ms, box-shadow 150ms; }
.nz-quiz__option:hover { border-color: var(--nz-text); }
.nz-quiz__option:has(.nz-quiz__input:checked) { background: var(--wp--preset--color--peach-light); border-color: var(--nz-text); box-shadow: inset 0 0 0 1px var(--nz-text); }
.nz-quiz__input { flex: 0 0 auto; width: 24px; height: 24px; margin: 0; accent-color: var(--nz-text); cursor: pointer; }
.nz-quiz__input:focus-visible { outline: var(--nz-focus); outline-offset: 2px; }
@supports selector(:has(*)) {
  .nz-quiz__input:focus-visible { outline: none; }
  .nz-quiz__option:has(.nz-quiz__input:focus-visible) { outline: var(--nz-focus); outline-offset: 2px; }
}
.nz-quiz__option-text { display: grid; gap: 2px; min-width: 0; }
.nz-quiz__option-label { font-size: 1.0625rem; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.nz-quiz__option-hint { font-size: 0.9375rem; line-height: 1.45; color: var(--nz-text-2); }

/* ---------- Actions: Back, Next / submit ---------- */
.nz-quiz__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.nz-quiz__actions .nz-button { width: auto; min-height: 52px; }
.nz-quiz__next,
.nz-quiz__submit { flex: 1 1 auto; }
.nz-quiz__back { flex: 0 0 auto; padding-inline: 24px; }
@media (min-width: 700px) {
  .nz-quiz__next,
  .nz-quiz__submit { flex: 0 1 auto; min-width: 220px; }
}
.nz-quiz__submit[aria-disabled="true"] { cursor: progress; opacity: 0.7; }

/* Error summary of a submission without JavaScript (links to the questions). */
.nz-quiz__summary { padding: 16px 20px; background: var(--nz-bg-light); border: 1px solid var(--nz-line-linen); border-left: 3px solid var(--nz-accent-dark); border-radius: var(--nz-radius); }
.nz-quiz__summary:focus { outline: none; }
.nz-quiz .nz-quiz__summary-title { margin: 0; font-weight: 700; line-height: 1.4; color: var(--nz-accent-dark); }
.nz-quiz__summary-list { margin: 8px 0 0; padding: 0; list-style: none; }
.nz-quiz__summary-list a { display: inline-flex; align-items: center; min-height: 44px; font-size: 1rem; text-decoration: underline; text-underline-offset: 0.16em; }

/* ---------- Results ----------
   One column on every width, in reading order: a compact head (eyebrow, title, the count, the
   answers as small tags, two quiet text links), the recommended set as the hero panel, the other
   products under their heading, then the e-mail form as a slim band and the disclaimer. The set
   is always the first block, so on a phone it shows on the first screen. */
.nz-quiz__results { display: grid; gap: 40px; margin: 0 0 64px; }
.nz-quiz__results-head { display: grid; gap: 16px; }
.nz-quiz__results-intro { display: grid; gap: 8px; }
.nz-quiz .nz-quiz__eyebrow { margin: 0; font-family: var(--nz-sans); font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.14em; line-height: 1.4; text-transform: uppercase; color: var(--nz-accent-dark); }
.nz-quiz .nz-quiz__results-title { margin: 0; font-size: var(--wp--preset--font-size--heading-3); line-height: 1.05; }
.nz-quiz__results-title:focus { outline: none; }
.nz-quiz__results-title:focus-visible { outline: var(--nz-focus); outline-offset: 4px; }
.nz-quiz .nz-quiz__found { max-width: 52ch; margin: 0; font-size: 1.0625rem; line-height: 1.5; color: var(--nz-text-2); }
.nz-quiz__answers { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.nz-quiz__answer { margin: 0; padding: 4px 12px; background: transparent; border: 1px solid var(--nz-line); border-radius: 999px; font-size: 0.875rem; line-height: 1.4; color: var(--nz-text-2); }
.nz-quiz__answer-label { font-weight: 700; color: var(--nz-text); }
.nz-quiz__results-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 24px; }
/* Phone: the answers as one quiet line (Perimenopauza · Normalna · ...), their labels kept for
   screen readers only, so the set starts on the first screen. Tags from 700px. */
@media (max-width: 699px) {
  .nz-quiz__results { gap: 28px; }
  .nz-quiz__results-head { gap: 10px; }
  .nz-quiz .nz-quiz__results-title { font-size: 2rem; }
  .nz-quiz .nz-quiz__found { font-size: 1rem; }
  .nz-quiz__answers { display: block; font-size: 0.875rem; line-height: 1.5; color: var(--nz-text-2); }
  .nz-quiz__answer { display: inline; padding: 0; border: 0; font-size: inherit; }
  .nz-quiz__answer + .nz-quiz__answer::before { content: " · "; }
  .nz-quiz__answer-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.nz-quiz__results-actions .nz-link { display: inline-flex; align-items: center; min-height: 44px; padding-bottom: 0; border-bottom: 0; font-size: 1rem; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.25em; }

@media (min-width: 1000px) {
  /* Head in two columns: the intro and the tags on the left, the links bottom right. */
  .nz-quiz__results { gap: 56px; }
  .nz-quiz__results-head { grid-template-columns: minmax(0, 1fr) auto; column-gap: 48px; padding-bottom: 32px; border-bottom: 1px solid var(--nz-line); }
  .nz-quiz__results-intro,
  .nz-quiz__answers { grid-column: 1; }
  .nz-quiz__results-actions { grid-column: 2; grid-row: 1 / span 2; align-self: end; justify-content: flex-end; }
}

/* "Dlaczego" line of a card (also in server-rendered cards, inc/quiz.php of the core plugin). */
.nz-product-card .nz-product-card__reason { margin: 2px 0 0; font-size: 0.9375rem; line-height: 1.45; color: var(--nz-text-2); overflow-wrap: anywhere; }
.nz-product-card__reason-label { font-weight: 700; color: var(--nz-accent-dark); }

/* Recommended set: the hero panel. Phone: title, lead, note, then the card (photo on top). From
   700px the card puts the photo beside its text, from 1000px the photo takes half the panel. Its
   button is the filled primary one, the only filled button of the results. */
.nz-quiz__bundle { display: grid; gap: 12px; padding: 20px; background: var(--nz-bg-light); border: 1px solid var(--nz-line); border-radius: var(--nz-radius); }
.nz-quiz .nz-quiz__bundle-title { margin: 0; font-size: 1.75rem; line-height: 1.1; }
.nz-quiz .nz-quiz__bundle-lead,
.nz-quiz .nz-quiz__bundle-note { max-width: 60ch; margin: 0; font-size: 1rem; line-height: 1.5; color: var(--nz-text-2); }
.nz-quiz .nz-quiz__bundle-note:empty { display: none; }
.nz-quiz .nz-quiz__bundle-grid { grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
/* One card alone: no reserved height for a three-line name as in the grid. */
.nz-quiz__bundle-grid .nz-product-card__name { min-height: 0; font-size: 1.5rem; }
.nz-quiz__bundle-grid .nz-product-card .nz-product-card__button { background: var(--nz-text); color: var(--nz-bg-light); }
.nz-quiz__bundle-grid .nz-product-card .nz-product-card__button:hover { background: var(--nz-accent-dark); border-color: var(--nz-accent-dark); color: var(--nz-bg-light); }
@media (min-width: 700px) {
  .nz-quiz__bundle { padding: 32px; }
  .nz-quiz__bundle-grid .nz-product-card { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; gap: 10px 32px; align-items: start; }
  .nz-quiz__bundle-grid .nz-product-card__media { grid-row: 1 / span 5; }
  .nz-quiz__bundle-grid .nz-product-card__price { margin-top: 0; }
  .nz-quiz__bundle-grid .nz-product-card .nz-product-card__button { justify-self: start; width: auto; min-width: 260px; min-height: 54px; align-self: start; }
}
@media (min-width: 1000px) {
  .nz-quiz__bundle { row-gap: 10px; padding: 40px 48px; }
  .nz-quiz .nz-quiz__bundle-title { font-size: 2rem; }
  .nz-quiz .nz-quiz__bundle-grid { margin-top: 20px; }
  /* Photo up to 440px, the text centred beside it (empty rows above and below). */
  .nz-quiz__bundle-grid .nz-product-card { grid-template-columns: minmax(0, 440px) minmax(0, 1fr); grid-template-rows: 1fr auto auto auto 1fr; column-gap: 56px; row-gap: 14px; }
  .nz-quiz__bundle-grid .nz-product-card__media { grid-row: 1 / 6; }
  .nz-quiz__bundle-grid .nz-product-card > :not(.nz-product-card__media) { grid-column: 2; }
  .nz-quiz__bundle-grid .nz-product-card__body { grid-row: 2; }
  .nz-quiz__bundle-grid .nz-product-card__row { grid-row: 3; }
  .nz-quiz__bundle-grid .nz-product-card .nz-product-card__button { grid-row: 4; }
  .nz-quiz__bundle-grid .nz-product-card__name { font-size: 2rem; line-height: 1.15; }
  .nz-quiz__bundle-grid .nz-product-card__price { font-size: 1.5rem; }
}

/* Other products: two columns on a phone (shop grid), three from 700px. Their heading shows only
   under a set, and not over an empty list. */
@media (min-width: 700px) {
  .nz-quiz .nz-quiz__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .nz-quiz .nz-quiz__grid { gap: 44px 32px; }
}
.nz-quiz .nz-quiz__products-title { display: none; margin: 0 0 -16px; font-size: 1.75rem; line-height: 1.1; }
.nz-quiz__results:has(.nz-quiz__bundle:not([hidden])):not(:has(.nz-quiz__grid[hidden])) .nz-quiz__products-title { display: block; }
@media (min-width: 1000px) {
  .nz-quiz .nz-quiz__products-title { margin-bottom: -24px; font-size: 2rem; }
}

/* "Wyślij mi te propozycje": a slim band after the products, the text beside the form from 1000px. */
.nz-quiz__mail { display: grid; gap: 14px; padding: 24px 20px; background: var(--wp--preset--color--peach-light); border-radius: var(--nz-radius); }
.nz-quiz__mail-intro { display: grid; gap: 6px; }
.nz-quiz .nz-quiz__mail-title { margin: 0; font-size: 1.5rem; line-height: 1.2; }
.nz-quiz .nz-quiz__mail-text,
.nz-quiz .nz-quiz__mail-note { margin: 0; font-size: 0.9375rem; line-height: 1.5; color: var(--nz-text-2); }
.nz-quiz__mail-form { display: grid; gap: 12px; }
.nz-quiz__mail-row { display: flex; flex-wrap: wrap; gap: 8px; }
.nz-quiz__mail-input { flex: 1 1 200px; min-width: 0; min-height: 52px; padding: 0 14px; font: inherit; color: var(--nz-text); background: #fff; border: 1px solid var(--nz-line-linen); border-radius: var(--nz-radius); }
.nz-quiz__mail-input:hover { border-color: var(--nz-text); }
.nz-quiz__mail-input[aria-invalid="true"] { border-color: var(--nz-accent-dark); box-shadow: inset 0 0 0 1px var(--nz-accent-dark); }
.nz-quiz .nz-quiz__mail-submit { flex: 0 0 auto; width: auto; min-height: 52px; padding-inline: 28px; }
.nz-quiz__mail-submit[aria-disabled="true"] { cursor: progress; opacity: 0.7; }
.nz-quiz__mail-check { display: flex; align-items: flex-start; gap: 12px; font-size: 0.875rem; line-height: 1.45; color: var(--nz-text-2); cursor: pointer; }
.nz-quiz__mail-check .nz-quiz__input { margin-top: 1px; }
.nz-quiz__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.nz-quiz .nz-quiz__mail-status { margin: 0; font-size: 0.9375rem; font-weight: 700; line-height: 1.45; color: var(--nz-accent-dark); }
.nz-quiz .nz-quiz__mail-status:empty { display: none; }
.nz-quiz__mail.is-sent .nz-quiz__mail-form,
.nz-quiz__mail.is-sent .nz-quiz__mail-text { display: none; }
@media (min-width: 1000px) {
  .nz-quiz__mail { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: 56px; align-items: start; padding: 36px 48px; }
  .nz-quiz__mail-intro { grid-row: 1 / span 2; }
  .nz-quiz__mail-form,
  .nz-quiz__mail-status { grid-column: 2; }
}
.nz-quiz .nz-quiz__notice { margin: 0 0 20px; padding: 14px 18px; background: var(--nz-bg-light); border: 1px solid var(--nz-line-linen); border-left: 3px solid var(--nz-accent-dark); border-radius: var(--nz-radius); font-weight: 700; }

.nz-quiz .nz-quiz__more { margin: 0; }
.nz-quiz .nz-quiz__disclaimer { max-width: 64ch; margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--nz-text-2); }

@media (prefers-reduced-motion: reduce) {
  .nz-quiz__progress-bar,
  .nz-quiz__option { transition: none; }
  .nz-quiz.is-stepping .nz-quiz__step:not([hidden]) { animation: none; }
}
