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

:root {
  --bg: #fff9ee;
  --bg-input: #fdf2ed;
  --accent: #f59771;
  --accent-hover: #e8865f;
  --text: #2d2d2d;
  --text-muted: #8a8a8a;
  --border: #f0ddd4;
  --footer-bg: #1a1a1a;
  --radius: 4px;
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  --max-width: 640px;
  /* --app-height задаётся в viewport.js при загрузке (не меняется при скролле) */
  --page-min-height: var(--app-height, 100vh);
}

html {
  scroll-behavior: smooth;
  overflow-anchor: none;
}

@media (max-width: 768px) {
  html {
    scroll-behavior: auto;
  }
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow-anchor: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.req {
  color: var(--accent);
}

.app {
  display: block;
}

/* Screens */
.screen {
  display: none;
}

.screen--active {
  display: flex;
  flex-direction: column;
  min-height: var(--page-min-height);
}

/* Landing */
#screen-landing {
  background: var(--bg);
}

.hero {
  width: 100%;
  flex-shrink: 0;
  contain: layout style;
}

.hero__img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  object-position: center;
  aspect-ratio: 1 / 1;
}

.landing-content {
  flex-shrink: 0;
  padding: 32px 24px 48px;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

@media (orientation: portrait) {
  #screen-landing.screen--active {
    display: block;
  }
}

.landing-title {
  font-size: clamp(2rem, 6vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
  line-height: 1.15;
}

#btn-start {
  width: auto;
  max-width: fit-content;
  flex-shrink: 0;
}

@media (orientation: landscape) {
  #screen-landing.screen--active {
    flex-direction: row;
    align-items: stretch;
    min-height: var(--page-min-height);
  }

  .landing-content {
    order: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    max-width: none;
    margin: 0;
    padding: 32px 40px 32px 48px;
  }

  .hero {
    order: 2;
    flex: 0 0 48%;
    width: 48%;
    max-width: 52%;
    max-height: none;
    min-height: 0;
    align-self: stretch;
  }

  .hero__img {
    width: 100%;
    height: 100%;
    min-height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: center;
  }
}

/* Quiz */
#screen-quiz {
  flex-direction: column;
}

.quiz-progress {
  flex-shrink: 0;
  width: 100%;
}

.quiz-progress--hidden {
  display: none;
}

.quiz-progress__track {
  height: 4px;
  background: var(--border);
  overflow: hidden;
}

.quiz-progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.4s ease;
}

.quiz-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: var(--page-min-height);
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  padding: 40px 24px 24px;
}

.quiz-step {
  display: none;
  animation: fadeIn 0.35s ease;
}

.quiz-step--active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.quiz-heading {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  margin-bottom: 28px;
  line-height: 1.25;
}

.question-block {
  min-height: var(--question-block-height, auto);
  margin-bottom: 28px;
}

.question-block--measure {
  position: absolute;
  left: -9999px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
  height: auto;
}

#questions-container {
  position: relative;
}

.question-meta {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-align: center;
}

.question-text {
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 500;
  line-height: 1.45;
  margin-bottom: 0;
  text-align: center;
}

.question-block .question-text {
  margin-bottom: 0;
}

/* Fields */
.field {
  display: block;
  margin-bottom: 22px;
  border: none;
}

.field--group {
  margin-bottom: 22px;
}

.field__label,
.field legend {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text);
}

.field__input {
  width: 100%;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: box-shadow 0.2s;
}

.field__input:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.field__input.field--error {
  box-shadow: 0 0 0 2px #e74c3c;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: '▼';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--accent);
  pointer-events: none;
}

.field__select {
  appearance: none;
  cursor: pointer;
  padding-right: 40px;
}

/* Radio */
.radio-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.radio {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 1rem;
}

.radio input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio__box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s;
}

.radio input:checked + .radio__box::after {
  content: '';
  position: absolute;
  inset: 4px;
  background: var(--accent);
  border-radius: 50%;
}

/* Answer options (quiz) */
.answers {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 28px;
}

.answer {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 1.05rem;
  padding: 4px 0;
  white-space: nowrap;
}

.answer input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.answer__box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.answer input:checked + .answer__box::after {
  content: '';
  position: absolute;
  inset: 4px;
  background: var(--accent);
  border-radius: 50%;
}

/* Checkbox */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.45;
  position: relative;
}

.checkbox input {
  position: absolute;
  left: 0;
  top: 2px;
  width: 22px;
  height: 22px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.checkbox__box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  background: var(--bg);
  pointer-events: none;
}

.checkbox input:checked ~ .checkbox__box {
  background: var(--accent);
}

.checkbox input:checked ~ .checkbox__box::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.checkbox .field-error {
  flex-basis: 100%;
  margin-left: 34px;
}

.cookie-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 8px 0 20px;
}

.required-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.2s, opacity 0.2s;
}

.btn--primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn__arrow {
  font-size: 1.1em;
}

.btn--icon {
  width: 48px;
  height: 48px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn--icon:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Quiz navigation */
.quiz-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

/* .quiz-nav__step {
  font-size: 0.9rem;
  color: var(--text-muted);
} */

.quiz-nav__buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.quiz-nav--hidden {
  display: none;
}

/* Result panels */
.result-panel--hidden {
  display: none;
}

.result-error__message {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.btn--loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Thank you */
.thank-you {
  text-align: center;
  padding: 24px 0 16px;
}

.thank-you__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
}

.thank-you__text {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 32px;
  color: var(--text);
}

/* Footer */
.site-footer {
  background: var(--footer-bg);
  color: #fff;
  padding: 28px 24px;
  overflow-anchor: none;
}

.site-footer__inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.site-footer__info {
  font-size: 0.8rem;
  line-height: 1.7;
  opacity: 0.9;
}

.site-footer__info a {
  color: #fff;
  text-decoration: none;
}

.site-footer__info a:hover {
  text-decoration: underline;
}

.site-footer__contacts {
  display: flex;
  gap: 12px;
}

.footer-icon {
  width: 44px;
  height: 44px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  text-decoration: none;
  transition: transform 0.2s;
}

.footer-icon__svg {
  display: block;
  flex-shrink: 0;
}

.footer-icon:hover {
  transform: scale(1.05);
  text-decoration: none;
}

/* Error hint */
.field-error {
  font-size: 0.8rem;
  color: #e74c3c;
  margin-top: 6px;
  display: none;
}

.field-error--visible {
  display: block;
}

.quiz-step > .field-error {
  width: 100%;
  text-align: center;
}

@media (max-width: 480px) {
  .landing-content,
  .quiz-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }

  .quiz-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .quiz-nav__buttons {
    justify-content: flex-end;
  }
}
