/* ==========================================================================
   Questionnaire
   Premium diagnostic instrument, not a form. One question per screen,
   section-based progress, generous whitespace.
   ========================================================================== */

.audit-body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Progress rail
   -------------------------------------------------------------------------- */

.progress {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(248, 245, 239, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.progress[hidden] { display: none; }

.progress__inner {
  max-width: var(--w-audit);
  margin-inline: auto;
  padding: var(--s-5) clamp(14px, 4vw, 40px) var(--s-4);
}

/* Six numbered nodes joined by a rule. In RTL, node 1 sits at the right. */
.progress__rail {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}

/* The joining rule runs behind the nodes, from the first centre to the last. */
.progress__rail::before {
  content: "";
  position: absolute;
  top: 19px;
  inset-inline: calc(100% / 12);
  height: 1.5px;
  background: var(--line-strong);
}

.progress__seg {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  min-width: 0;
  text-align: center;
}

.progress__node {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--line-strong);
  color: var(--ink-faint);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.progress__node svg { width: 15px; height: 15px; }

.progress__seg.is-done .progress__node {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
}
.progress__seg.is-current .progress__node {
  background: var(--accent);
  border-color: var(--accent);
  color: #FBF7F1;
}

.progress__name {
  display: block;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--ink-faint);
  letter-spacing: 0.005em;
  transition: color var(--dur) var(--ease);
  padding-inline: 2px;
}
.progress__seg.is-current .progress__name { color: var(--accent); font-weight: 700; }
.progress__seg.is-done .progress__name { color: var(--ink-soft); }

@media (max-width: 620px) {
  .progress__node { width: 32px; height: 32px; font-size: 0.875rem; }
  .progress__rail::before { top: 16px; }
  .progress__inner { padding-block: var(--s-4) var(--s-3); }
  .progress__seg { gap: 7px; }
  .progress__name {
    font-size: 0.625rem;
    line-height: 1.3;
    padding-inline: 1px;
    /* Six labels in a phone width: allow two lines, then clamp. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}
@media (max-width: 330px) {
  .progress__name { display: none; }
}

/* --------------------------------------------------------------------------
   Stage: the scrollable screen area
   -------------------------------------------------------------------------- */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-block: clamp(32px, 5vw, 72px) clamp(48px, 6vw, 96px);
}
.stage__inner {
  width: 100%;
  max-width: var(--w-audit);
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 40px);
}

/* Screen transition */
.screen { animation: screen-in var(--dur-slow) var(--ease) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}

/* --------------------------------------------------------------------------
   Panel — the ivory card that holds a question or a message
   -------------------------------------------------------------------------- */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow);
  padding: clamp(28px, 4.5vw, 64px);
}
.panel--plain {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding-inline: 0;
}

/* --------------------------------------------------------------------------
   Intro / message screens
   -------------------------------------------------------------------------- */

.intro { text-align: center; }

.intro__mark {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: 0 auto var(--s-6);
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
}
.intro__mark svg { width: 32px; height: 32px; }

.intro__title {
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.025em;
  color: var(--accent);
  text-wrap: balance;
}
.intro__text {
  font-size: var(--fs-body);
  line-height: 1.85;
  color: var(--ink-soft);
  max-width: 44ch;
  margin-inline: auto;
}

.intro__highlight {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-6);
  padding: 11px 22px;
  background: var(--bg-alt);
  border-radius: 100px;
  font-family: var(--font-display);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--accent);
}
.intro__highlight svg { width: 17px; height: 17px; flex: none; }

.intro__notes {
  margin-top: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.intro__note {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--bg);
  border-radius: var(--r);
  font-size: var(--fs-small);
  line-height: 1.7;
  color: var(--ink-soft);
  text-align: start;
}
.intro__noteIcon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-soft);
  color: var(--gold);
}
.intro__noteIcon svg { width: 19px; height: 19px; }

.intro__actions { margin-top: var(--s-6); }
.intro__actions .btn { width: 100%; }

@media (max-width: 520px) {
  .intro__mark { width: 62px; height: 62px; }
  .intro__mark svg { width: 27px; height: 27px; }
  .intro__note { padding: var(--s-3) var(--s-4); gap: var(--s-3); }
  .intro__noteIcon { width: 36px; height: 36px; }
}

/* --------------------------------------------------------------------------
   Divider: hairline · gold star · hairline
   -------------------------------------------------------------------------- */

.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  margin: var(--s-5) auto;
  max-width: 300px;
}
.divider span { flex: 1; height: 1px; }
.divider span:first-child { background: linear-gradient(to right, transparent, var(--line-strong)); }
.divider span:last-child { background: linear-gradient(to left, transparent, var(--line-strong)); }
.divider svg { width: 13px; height: 13px; flex: none; color: var(--gold); }

/* --------------------------------------------------------------------------
   Question
   -------------------------------------------------------------------------- */

.q__eyebrow {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-display);
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: var(--ls-eyebrow);
  color: var(--ink-faint);
  margin-bottom: var(--s-5);
}
.q__eyebrow span { color: var(--gold); font-variant-numeric: tabular-nums; }

.q__title {
  font-family: var(--font-display);
  font-size: var(--fs-question);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}
.q__help {
  margin-top: var(--s-4);
  font-size: var(--fs-small);
  line-height: 1.7;
  color: var(--ink-faint);
  max-width: 52ch;
}
.q__optional {
  display: inline-block;
  margin-inline-start: var(--s-3);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0;
  vertical-align: middle;
}

.q__field { margin-top: var(--s-6); }

/* --------------------------------------------------------------------------
   Options — whole card is the control
   -------------------------------------------------------------------------- */

.opts {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}
.opts--two {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 560px) {
  .opts--two { grid-template-columns: 1fr; }
}

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-height: 60px;
  padding: 14px 20px;
  background: var(--card-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.opt:hover { border-color: var(--ink-faint); background: #FFFFFF; }

/* The real input stays in the accessibility tree, visually hidden */
.opt__input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  margin: 0;
  pointer-events: none;
}

/* Focus ring is driven by the input, painted on the card */
.opt__input:focus-visible + .opt__mark {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.opt:has(.opt__input:focus-visible) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.opt__mark {
  flex: none;
  width: 22px; height: 22px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg);
  display: grid;
  place-items: center;
  transition:
    border-color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}
.opt__mark--radio { border-radius: 50%; }
.opt__mark--check { border-radius: var(--r-xs); }

.opt__mark svg {
  width: 12px; height: 12px;
  opacity: 0;
  transform: scale(0.6);
  color: #FBF7F1;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.opt__label {
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink);
  transition: font-weight var(--dur-fast) var(--ease);
}

/* Selected: border + tint + filled mark + weight change.
   Four cues, only one of which is colour. */
.opt.is-selected {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.opt.is-selected .opt__mark {
  border-color: var(--accent);
  background: var(--accent);
}
.opt.is-selected .opt__mark svg { opacity: 1; transform: none; }
.opt.is-selected .opt__label { font-weight: 700; color: var(--accent); }

@media (max-width: 560px) {
  .opt { min-height: 58px; padding: 13px 16px; gap: var(--s-3); }
  .opt__label { font-size: 1rem; }
}

/* --------------------------------------------------------------------------
   Rating — 1..5
   -------------------------------------------------------------------------- */

.rating {
  border: 0; margin: 0; padding: 0;
  min-inline-size: 0;
}
.rating__scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--s-3);
}
.rating__item {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 76px;
  background: var(--card-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition:
    border-color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.rating__item:hover { border-color: var(--ink-faint); }
.rating__item:has(input:focus-visible) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.rating__item input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  margin: 0;
  pointer-events: none;
}
.rating__item.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #FBF7F1;
  box-shadow: inset 0 0 0 1px var(--accent);
}
.rating__ends {
  display: flex;
  justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-3);
  font-size: var(--fs-micro);
  color: var(--ink-faint);
}

@media (max-width: 480px) {
  .rating__scale { gap: 6px; }
  .rating__item { min-height: 62px; font-size: 1.15rem; }
}

/* --------------------------------------------------------------------------
   Text inputs
   -------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field + .field { margin-top: var(--s-5); }

.field__label {
  font-family: var(--font-display);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink);
}
.field__hint {
  font-size: var(--fs-micro);
  color: var(--ink-faint);
}

.input,
.textarea {
  width: 100%;
  background: var(--card-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 15px 18px;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder,
.textarea::placeholder { color: #B3AAA0; }
.input:hover, .textarea:hover { border-color: var(--ink-faint); }
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.textarea {
  min-height: 132px;
  resize: vertical;
  font-family: var(--font-body);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] { border-color: var(--warn); }

/* Latin-only inputs read correctly when typed into an RTL page */
.input--ltr {
  direction: ltr;
  text-align: left;
}

/* --------------------------------------------------------------------------
   Consent
   -------------------------------------------------------------------------- */

.consent {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  margin-top: var(--s-6);
  padding: var(--s-5);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
}
.consent:has(input:focus-visible) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.consent.is-selected { border-color: var(--accent); background: var(--accent-tint); }
.consent input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  margin: 0;
  pointer-events: none;
}
.consent__mark {
  flex: none;
  margin-top: 2px;
  width: 22px; height: 22px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-xs);
  background: var(--card-raised);
  display: grid;
  place-items: center;
}
.consent__mark svg {
  width: 12px; height: 12px;
  opacity: 0;
  color: #FBF7F1;
  transition: opacity var(--dur-fast) var(--ease);
}
.consent.is-selected .consent__mark { background: var(--accent); border-color: var(--accent); }
.consent.is-selected .consent__mark svg { opacity: 1; }
.consent__text {
  font-size: var(--fs-small);
  line-height: 1.65;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   Validation — calm, never an alarm
   -------------------------------------------------------------------------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  margin-top: var(--s-5);
  padding: 13px 17px;
  background: var(--warn-tint);
  border: 1px solid #E8D9C0;
  border-inline-start: 3px solid var(--warn);
  border-radius: var(--r-sm);
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--warn);
}
.notice[hidden] { display: none; }
.notice svg { flex: none; width: 16px; height: 16px; margin-top: 3px; }

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-7);
  padding-top: var(--s-6);
  border-top: 1px solid var(--line);
}
.nav__spacer { flex: 1; }

@media (max-width: 560px) {
  .nav {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: var(--s-3);
  }
  .nav .btn { width: 100%; }
  .nav__spacer { display: none; }
}

/* --------------------------------------------------------------------------
   Terminal screens (exit / success)
   -------------------------------------------------------------------------- */

.outcome__mark {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-tint);
  color: var(--accent);
  margin-bottom: var(--s-5);
}
.outcome__mark svg { width: 20px; height: 20px; }

.outcome__title {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.outcome__body {
  margin-top: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  color: var(--ink-soft);
  font-size: var(--fs-lead);
  line-height: var(--lh-loose);
  max-width: 52ch;
}
.outcome__form { margin-top: var(--s-7); }
.outcome__actions {
  margin-top: var(--s-7);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
}
@media (max-width: 560px) {
  .outcome__actions { flex-direction: column; }
  .outcome__actions .btn { width: 100%; }
}

/* --------------------------------------------------------------------------
   Thank-you pop-up

   A native <dialog>, so focus trapping and Escape-to-close come from the
   platform rather than hand-rolled JavaScript.
   -------------------------------------------------------------------------- */

.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal::backdrop {
  background: rgba(36, 25, 22, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal__inner {
  padding: clamp(28px, 5vw, 40px) clamp(22px, 5vw, 36px);
  text-align: center;
}

.modal__mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto var(--s-5);
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
}
.modal__mark [data-icon] { width: 22px; height: 22px; }

.modal__title {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--accent);
}
.modal__text {
  margin-top: var(--s-4);
  font-size: var(--fs-small);
  line-height: 1.8;
  color: var(--ink-soft);
}

.modal__actions {
  margin-top: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.modal__whatsapp { width: 100%; }
.modal__whatsapp [data-icon] { width: 19px; height: 19px; }
.modal__close { width: 100%; }

/* Entrance. Skipped entirely under reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
  .modal[open] { animation: modal-in var(--dur-slow) var(--ease) both; }
  .modal[open]::backdrop { animation: backdrop-in var(--dur) var(--ease) both; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --------------------------------------------------------------------------
   Submitting state
   -------------------------------------------------------------------------- */

.spinner {
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2400ms; }
}

/* --------------------------------------------------------------------------
   Exit link back to the landing page
   -------------------------------------------------------------------------- */

.audit-top {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.audit-top__inner {
  max-width: var(--w-audit);
  margin-inline: auto;
  padding: var(--s-3) clamp(16px, 4vw, 40px);
  display: flex;
  align-items: center;
  /* Privacy note at the inline-start (right); back arrow at the end (left). */
  flex-direction: row-reverse;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 58px;
}

.audit-top__privacy {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-micro);
  color: var(--ink-soft);
}
.audit-top__privacy svg { width: 16px; height: 16px; flex: none; color: var(--ink-faint); }

.audit-top__back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-inline-end: -8px;
  border-radius: var(--r-sm);
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--dur) var(--ease);
}
.audit-top__back:hover { background: var(--bg-alt); }
.audit-top__back svg { width: 21px; height: 21px; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.audit-foot {
  padding: var(--s-5) clamp(16px, 4vw, 40px) var(--s-6);
  border-top: 1px solid var(--line);
}
.audit-foot__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  max-width: var(--w-audit);
  margin-inline: auto;
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  text-align: center;
  line-height: 1.6;
}
.audit-foot__inner svg { width: 15px; height: 15px; flex: none; color: var(--gold); }

/* --------------------------------------------------------------------------
   Setup warning — localhost only, never shown to a visitor in production
   -------------------------------------------------------------------------- */

.setup-warning {
  background: #2C2622;
  color: #F0E7D8;
  font-size: var(--fs-micro);
  line-height: 1.6;
  padding: 10px clamp(20px, 5vw, 40px);
  text-align: center;
}
.setup-warning code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 6px;
  border-radius: 3px;
  direction: ltr;
  display: inline-block;
}
