/**
 * AmigoCare quiz wizard — modal version. 5 steps with реальні дієтологічні питання.
 * Tokens-only (amg-tokens.css). Mobile-first, BEM.
 * CSS isolation reset захищає від XTS theme/WC plugin global rules.
 */

/* CSS isolation: force inheritance тільки в межах модалки */
.amg-quiz-modal, .amg-quiz-modal * {
  font-family: var(--font-sans) !important;
}
.amg-quiz-modal h1, .amg-quiz-modal h2, .amg-quiz-modal h3, .amg-quiz-modal h4, .amg-quiz-modal p {
  margin: 0;
  letter-spacing: -0.01em;
}
.amg-quiz-modal ul, .amg-quiz-modal ol { list-style: none; padding: 0; margin: 0; }
.amg-quiz-modal button {
  font: inherit !important;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  text-transform: none !important;
  letter-spacing: 0 !important;
}
.amg-quiz-modal input, .amg-quiz-modal textarea {
  font-family: var(--font-sans) !important;
  letter-spacing: 0 !important;
}

/* ============ Modal shell ============ */
.amg-quiz-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 12px;
}
.amg-quiz-modal[hidden] { display: none; }

.amg-quiz-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(25, 10, 3, 0.72);
  backdrop-filter: blur(2px);
}

.amg-quiz-modal__panel {
  position: relative;
  width: 100%; max-width: 720px;
  max-height: calc(100dvh - 48px);
  background: var(--white);
  border-radius: var(--r-lg, 20px);
  box-shadow: 0 30px 80px rgba(25, 10, 3, 0.4);
  overflow-y: auto;
  padding: 28px 28px 32px;
}
@media (max-width: 600px) {
  .amg-quiz-modal { padding: 0; align-items: stretch; }
  .amg-quiz-modal__panel {
    max-width: 100%; max-height: 100dvh;
    border-radius: 0; padding: 24px 18px 32px;
  }
}

.amg-quiz-modal__close {
  position: absolute; top: 14px; right: 16px;
  background: var(--gray-50); border: none;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 24px; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  z-index: 2;
}
.amg-quiz-modal__close:hover { background: var(--gray-100); }

/* ============ Header ============ */
.amg-quiz-modal__head {
  margin-bottom: 24px; padding-right: 40px;
}
.amg-quiz-modal__brand {
  display: inline-block;
  font-weight: 800; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink); padding: 5px 11px;
  background: var(--amber-soft); border-radius: 99px;
  margin-bottom: 10px;
}
.amg-quiz-modal__title {
  font-size: 24px; font-weight: 800; color: var(--ink);
  letter-spacing: -0.02em; line-height: 1.15;
  margin: 0 0 16px;
}
@media (max-width: 600px) { .amg-quiz-modal__title { font-size: 22px; } }

.amg-quiz-modal__progress {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.amg-quiz-modal__progress-bar {
  flex: 1; min-width: 160px;
  height: 5px; background: var(--gray-100);
  border-radius: 99px; overflow: hidden;
}
.amg-quiz-modal__progress-fill {
  height: 100%; background: var(--amber);
  border-radius: 99px; transition: width 0.35s ease;
}
.amg-quiz-modal__step-meta {
  font-size: 13px; font-weight: 600; color: var(--gray-700);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ============ Step content ============ */
.amg-quiz-step__title {
  font-size: 24px; font-weight: 800; color: var(--ink);
  margin: 0 0 8px; line-height: 1.2; letter-spacing: -0.015em;
}
.amg-quiz-step__sub {
  font-size: 15px; color: var(--gray-700);
  margin: 0 0 28px;
}

.amg-quiz-q {
  margin-bottom: 16px;
  padding: 20px 20px 22px;
  background: var(--off-white, #fafafa);
  border: 1px solid var(--line, #e5e5e5);
  border-radius: 16px;
}
.amg-quiz-q:last-child { margin-bottom: 0; }
.amg-quiz-q__label {
  display: block;
  font-weight: 800; font-size: 16px; color: var(--ink);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
/* Choices живуть у білих картках всередині сірого блоку — посилює контраст */
.amg-quiz-q .amg-quiz-choice { background: var(--white); }
.amg-quiz-q__hint {
  font-size: 13px; color: var(--gray-500);
  margin: 8px 0 0;
}

.amg-quiz-choices { display: grid; gap: 10px; }

.amg-quiz-choice {
  position: relative;
  display: flex; align-items: center;
  padding: 18px 56px 18px 20px;
  min-height: 60px;
  width: 100%;
  border: 2px solid var(--line, #e5e5e5);
  border-radius: 14px;
  background: var(--white);
  text-align: left;
  font-size: 16px; line-height: 1.35; color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .18s ease, background .18s ease, transform .12s ease, box-shadow .18s ease;
}

/* Right-side circle indicator (empty / filled) */
.amg-quiz-choice::after {
  content: "";
  position: absolute;
  right: 18px; top: 50%;
  width: 24px; height: 24px;
  margin-top: -12px;
  border: 2px solid var(--line-strong, #d4d4d4);
  border-radius: 50%;
  background: var(--white);
  transition: border-color .18s ease, background .18s ease;
}

/* Checkmark glyph inside selected indicator */
.amg-quiz-choice::before {
  content: "";
  position: absolute;
  right: 24px; top: 50%;
  width: 12px; height: 7px;
  margin-top: -6px;
  border-left: 2.5px solid var(--ink);
  border-bottom: 2.5px solid var(--ink);
  transform: rotate(-45deg) scale(0);
  transition: transform .18s ease;
  z-index: 1;
}

.amg-quiz-choice:hover {
  border-color: var(--amber);
  background: #fffdf6;
  box-shadow: 0 4px 14px rgba(255, 186, 0, .12);
}
.amg-quiz-choice:active { transform: scale(.985); }

.amg-quiz-choice.is-selected {
  border-color: var(--amber);
  background: var(--amber-soft);
  font-weight: 700;
}
.amg-quiz-choice.is-selected::after {
  border-color: var(--amber);
  background: var(--amber);
}
.amg-quiz-choice.is-selected::before { transform: rotate(-45deg) scale(1); }

/* 2-column compact для коротких списків (2 вибори) на ширших екранах */
@media (min-width: 600px) {
  .amg-quiz-choices[data-cols="2"] { grid-template-columns: 1fr 1fr; }
}

/* ============ Toggle pills (None / Describe) — step 3 health ============ */
.amg-quiz-toggle {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 0 0 10px;
}
.amg-quiz-toggle__btn {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: var(--white);
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.amg-quiz-toggle__btn:hover { border-color: var(--amber); }
.amg-quiz-toggle__btn.is-selected {
  border-color: var(--amber);
  background: var(--amber-soft);
}

/* ============ Required asterisk ============ */
.amg-quiz-q__req { color: var(--orange); margin-left: 2px; font-weight: 800; }

.amg-quiz-input {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--line, #e5e5e5);
  border-radius: 14px;
  background: var(--white); font: inherit; color: var(--ink);
  font-size: 16px;
  transition: border-color .18s ease, box-shadow .18s ease;
  -webkit-appearance: none;
}
.amg-quiz-input::placeholder { color: var(--gray-500); }
.amg-quiz-input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 4px rgba(255, 186, 0, .18);
}
.amg-quiz-input--area { resize: vertical; min-height: 80px; line-height: 1.4; }

/* ============ Pet picker (re-use) ============ */
.amg-care-pet-list { display: grid; gap: 10px; margin: 16px 0 12px; }
.amg-care-pet-card {
  display: grid; grid-template-columns: 56px 1fr 32px;
  align-items: center; gap: 14px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--r-md, 12px);
  background: var(--white);
  text-align: left;
  cursor: pointer;
  transition: border 0.15s, background 0.15s, transform 0.15s;
}
.amg-care-pet-card:hover { border-color: var(--amber); transform: translateY(-1px); }
.amg-care-pet-card.is-selected { border-color: var(--amber); background: var(--amber-soft); }
.amg-care-pet-card__avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--gray-50);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; color: var(--ink);
}
.amg-care-pet-card__avatar img { width: 100%; height: 100%; object-fit: cover; }
.amg-care-pet-card__avatar svg { width: 32px; height: 32px; }
.amg-care-pet-card__name { font-weight: 700; font-size: 15px; color: var(--ink); }
.amg-care-pet-card__meta { font-size: 12px; color: var(--gray-700); margin-top: 2px; }
.amg-care-pet-card__check {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: transparent;
}
.amg-care-pet-card.is-selected .amg-care-pet-card__check {
  background: var(--amber); border-color: var(--amber); color: var(--ink);
}
.amg-care-pet-add {
  width: 100%; padding: 11px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md, 12px);
  background: transparent;
  color: var(--gray-700);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.amg-care-pet-add:hover { border-color: var(--amber); color: var(--ink); }

.amg-care-pet-empty {
  text-align: center;
  padding: 28px 18px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-md, 12px);
  background: var(--off-white);
  margin: 12px 0 0;
}
.amg-care-pet-empty__icon {
  display: flex; gap: 8px; justify-content: center; margin-bottom: 12px;
  color: var(--gray-500);
}
.amg-care-pet-empty__icon svg { width: 32px; height: 32px; }
.amg-care-pet-empty__text { color: var(--gray-700); margin-bottom: 16px; font-size: 14px; }

/* ============ Auth gate (anonymous) ============ */
.amg-quiz-auth {
  text-align: center; padding: 16px 0 8px;
}
.amg-quiz-auth__lede {
  font-size: 14px; color: var(--gray-700); margin: 0 0 18px;
}

/* Quiz-scoped CTA — модалка живе поза <main.amg-care>, тому root .amg-care .amg-care-btn rule не покриває */
.amg-quiz-modal .amg-care-btn,
.amg-quiz-modal a.amg-care-btn,
.amg-quiz-modal button.amg-care-btn {
  background-color: var(--amber);
  color: var(--ink);
  border: none;
  padding: 14px 26px;
  border-radius: var(--r-pill, 99px);
  font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.amg-quiz-modal .amg-care-btn:hover,
.amg-quiz-modal a.amg-care-btn:hover { background-color: var(--amber-deep); transform: translateY(-1px); }
.amg-quiz-modal .amg-care-btn--ghost {
  background-color: transparent !important;
  color: var(--ink);
  border: 2px solid var(--gray-300);
  padding: 12px 24px;
}
.amg-quiz-modal .amg-care-btn--ghost:hover {
  background-color: var(--ink) !important;
  color: var(--white);
  border-color: var(--ink);
}

/* ============ Nav footer (sticky на mobile щоб не падати під клавіатуру) ============ */
.amg-quiz-modal__nav {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 28px; padding-top: 20px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .amg-quiz-modal__nav {
    position: sticky; bottom: 0;
    background: var(--white);
    padding: 16px 0 calc(16px + env(safe-area-inset-bottom, 0px));
    margin-top: 20px;
    z-index: 3;
  }
  .amg-quiz-modal__panel { padding-bottom: env(safe-area-inset-bottom, 18px); }
}
.amg-quiz-modal__nav [hidden],
.amg-quiz-modal [data-quiz-step][hidden] { display: none !important; }
.amg-quiz-modal__back {
  background: none; border: none;
  color: var(--gray-700); font-size: 14px; font-weight: 600;
  cursor: pointer; padding: 8px 0;
}
.amg-quiz-modal__back:hover { color: var(--ink); }
.amg-quiz-modal__next, .amg-quiz-modal__submit {
  margin-left: auto;
}
.amg-quiz-modal__next:disabled, .amg-quiz-modal__submit:disabled {
  opacity: 0.6; cursor: wait;
}

.amg-quiz-modal__error {
  background: #fef2f2; color: #b91c1c;
  border: 1px solid #fca5a5; border-radius: 12px;
  padding: 12px 16px; margin-top: 16px;
  font-size: 14px; line-height: 1.5;
}
.amg-quiz-modal__error:empty { display: none; }

/* ============ Success ============ */
.amg-quiz-success {
  text-align: center; padding: 16px 8px 8px;
}
.amg-quiz-success__icon {
  width: 64px; height: 64px;
  color: var(--amber);
  margin: 0 auto 14px;
  display: block;
}
.amg-quiz-success__title {
  font-size: 22px; font-weight: 800; color: var(--ink);
  margin: 0 0 18px;
}
.amg-quiz-success__note {
  font-family: var(--font-hand);
  font-size: 19px; line-height: 1.55; color: var(--ink);
  background: var(--amber-soft);
  border-left: 4px solid var(--amber);
  padding: 18px 22px;
  border-radius: 8px;
  text-align: left;
  max-width: 540px; margin: 0 auto 20px;
}
.amg-quiz-success__sig {
  display: block;
  font-size: 13px; font-weight: 800; letter-spacing: 0.06em;
  color: var(--orange); text-transform: uppercase;
  margin-bottom: 8px;
}
