/* ── Variables ─────────────────────────────── */
:root {
  --color-teal:     #3C5A6E;
  --color-teal-dk:  #2A3F4E;
  --color-teal-lt:  #EEF3F6;
  --color-gold:     #F9B340;
  --color-gold-dk:  #E09C20;
  --color-white:    #FFFFFF;
  --color-bg:       #F7F9FB;
  --color-text:     #1A2E3B;
  --color-text-2:   #4A6070;
  --color-border:   #D8E2E9;
  --color-error:    #D94040;
  --color-success:  #2A9E6A;
  --color-hot:      #E8603A;
  --color-warm:     #F9B340;
  --color-nurture:  #3C8FD4;
  --color-cool:     #7A9BAD;
  --color-special:  #7C5CBF;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-card: 0 2px 20px rgba(60,90,110,0.10);
  --shadow-btn:  0 2px 8px  rgba(60,90,110,0.15);

  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --transition: 200ms cubic-bezier(0.4,0,0.2,1);
  --slide-duration: 320ms;
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
a { color: inherit; }
/* Suppress focus ring on headings focused programmatically (tabindex="-1").
   Screen readers still receive focus; sighted users don't see the rectangle. */
h1[tabindex="-1"]:focus,
h2[tabindex="-1"]:focus,
h3[tabindex="-1"]:focus { outline: none; }

/* ── Skip link ─────────────────────────────── */
.skip-link {
  position: absolute; top: -100%; left: 1rem;
  background: var(--color-teal); color: #fff;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  font-weight: 600; text-decoration: none; z-index: 200;
}
.skip-link:focus { top: 1rem; }

/* ── Quiz header ───────────────────────────── */
.quiz-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1.5rem;
  transition: opacity var(--transition), transform var(--transition);
}
.quiz-header[aria-hidden="true"] { opacity: 0; pointer-events: none; transform: translateY(-100%); }
.quiz-header__inner {
  max-width: 680px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.25rem;
}
.quiz-header__logo { flex-shrink: 0; height: 36px; width: auto; }
.quiz-header__progress { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.quiz-header__label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-teal); }
.quiz-header__counter { font-size: 0.7rem; color: var(--color-text-2); text-align: right; }

/* ── Progress bar ──────────────────────────── */
.progress-bar {
  height: 5px; background: var(--color-teal-lt);
  border-radius: 99px; overflow: hidden;
}
.progress-bar__fill {
  height: 100%; background: var(--color-gold);
  border-radius: 99px; width: 0%;
  transition: width 400ms cubic-bezier(0.4,0,0.2,1);
}

/* ── Main + Steps ──────────────────────────── */
main {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 2rem 1rem;
}
.step {
  display: none; width: 100%; max-width: 680px;
  animation: slideIn var(--slide-duration) cubic-bezier(0.4,0,0.2,1);
}
.step.is-active { display: flex; flex-direction: column; align-items: center; }
.step.is-exiting { animation: slideOut var(--slide-duration) cubic-bezier(0.4,0,0.2,1) forwards; }

@keyframes slideIn     { from { opacity: 0; transform: translateX(40px); }  to { opacity: 1; transform: none; } }
@keyframes slideOut    { from { opacity: 1; transform: none; }              to { opacity: 0; transform: translateX(-40px); } }
@keyframes slideInBack { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }

/* ── Cards ─────────────────────────────────── */
.card {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 2.5rem 2rem;
  width: 100%;
}
.card--wide { max-width: 580px; }
.card--centered {
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 1rem; max-width: 480px;
}
.card--question { padding: 2.5rem 2rem 1.5rem; }
.card--module { background: var(--color-teal); color: var(--color-white); overscroll-behavior: contain; }
.card--module .card__section-label { color: rgba(255,255,255,0.7); }
.card--module .card__title { color: var(--color-white); }
.card--module .card__body { color: rgba(255,255,255,0.85); }

.card__badge {
  display: inline-block;
  background: var(--color-gold); color: var(--color-teal-dk);
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0.3rem 0.85rem; border-radius: 99px; margin-bottom: 1rem;
}
.card__section-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--color-teal); margin-bottom: 0.5rem;
}
.card__title {
  font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; line-height: 1.2;
  color: var(--color-teal-dk); margin-bottom: 0.75rem; text-wrap: balance;
}
.card__title--large { font-size: clamp(1.75rem, 5vw, 2.5rem); }
.card__body { font-size: 1rem; line-height: 1.65; color: var(--color-text-2); }
.card__icon { font-size: 2.5rem; }
.card__icon--error { color: var(--color-error); }

.feature-list { list-style: none; margin: 1rem 0 1.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.feature-list li { font-size: 0.9rem; color: var(--color-text-2); }

/* ── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--font); font-weight: 700; font-size: 0.95rem;
  border: 2px solid transparent; border-radius: var(--radius-md);
  padding: 0.85rem 1.75rem; cursor: pointer; text-decoration: none;
  transition: background var(--transition), color var(--transition),
    border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn:focus-visible { outline: 3px solid var(--color-gold); outline-offset: 3px; }
.btn:active { transform: scale(0.97); }

.btn--primary { background: var(--color-teal); color: #fff; box-shadow: var(--shadow-btn); }
.btn--primary:hover { background: var(--color-teal-dk); }

.btn--ghost { background: transparent; color: var(--color-teal); border-color: var(--color-border); }
.btn--ghost:hover { background: var(--color-teal-lt); border-color: var(--color-teal); }

.btn--large { font-size: 1.05rem; padding: 1rem 2.25rem; }
.btn--full  { width: 100%; margin-top: 1rem; }
.btn--sm    { font-size: 0.825rem; padding: 0.5rem 1rem; }

.btn--back {
  background: none; border: none; color: var(--color-text-2);
  font-size: 0.875rem; font-weight: 600; padding: 0.5rem 0; margin-top: 1.5rem; opacity: 0.7;
}
.btn--back:hover { opacity: 1; color: var(--color-teal); }

.btn-row { display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center; margin-top: 0.5rem; }

/* ── Yes / No buttons ──────────────────────── */
.yn-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2rem; }
.btn--yn {
  flex-direction: column; gap: 0.4rem;
  padding: 1.5rem 1rem; border-radius: var(--radius-lg);
  border: 2px solid var(--color-border); background: var(--color-white);
  color: var(--color-text); font-weight: 700;
  box-shadow: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn--yn:hover { border-color: var(--color-teal); background: var(--color-teal-lt); transform: translateY(-2px); box-shadow: var(--shadow-btn); }
.btn--yn.is-selected.btn--yes { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.btn--yn.is-selected.btn--no  { background: var(--color-error);   border-color: var(--color-error);   color: #fff; }
.yn-key   { font-size: 1.5rem; font-weight: 800; }
.yn-label { font-size: 1rem; }

/* ── Forms ─────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.25rem; }
.field__label { font-size: 0.875rem; font-weight: 700; color: var(--color-teal-dk); }
.field__input {
  font-family: var(--font); font-size: 1rem; color: var(--color-text);
  border: 2px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem; background: var(--color-white); width: 100%;
  transition: border-color var(--transition);
}
.field__input:focus { border-color: var(--color-teal); }
.field__input:focus-visible { outline: 3px solid var(--color-gold); outline-offset: 2px; }
@supports not selector(:focus-visible) {
  .field__input:focus { outline: 3px solid var(--color-gold); outline-offset: 2px; }
}
.field__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233C5A6E' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.5rem;
}
.field__hint  { font-size: 0.775rem; color: var(--color-text-2); }
.field__error { font-size: 0.8rem; color: var(--color-error); font-weight: 600; min-height: 1.2em; }
.field--checkbox .field__checkbox-label {
  display: flex; align-items: flex-start; gap: 0.75rem;
  cursor: pointer; font-size: 0.875rem; color: var(--color-text-2);
}
.field--checkbox input[type="checkbox"] {
  flex-shrink: 0; width: 18px; height: 18px; accent-color: var(--color-teal); margin-top: 2px;
}

/* ── Question card ─────────────────────────── */
.question-meta {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;
}
.question-module-tag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-teal); background: var(--color-teal-lt); padding: 0.25rem 0.65rem; border-radius: 99px;
}
.question-hint { font-size: 0.7rem; color: var(--color-text-2); }
.question-text {
  font-size: clamp(1.1rem, 3.5vw, 1.4rem); font-weight: 700; line-height: 1.4;
  color: var(--color-teal-dk); text-wrap: balance;
}

/* ── Module transition ─────────────────────── */
.module-badge { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* ── Spinner ───────────────────────────────── */
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--color-teal-lt); border-top-color: var(--color-teal);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result page ───────────────────────────── */
#step-result { flex-direction: column; gap: 0; }
.result-hero {
  background: var(--color-teal); color: #fff;
  width: 100%; max-width: 580px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 2.5rem 2rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.25rem;
}
.result-logo { filter: brightness(0) invert(1); opacity: 0.85; }
.result-score-ring { position: relative; width: 140px; height: 140px; }
.score-ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring-bg   { fill: none; stroke: rgba(255,255,255,0.15); stroke-width: 10; }
.score-ring-fill {
  fill: none; stroke: var(--color-gold); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327;
  transition: stroke-dashoffset 1.4s cubic-bezier(0.4,0,0.2,1);
}
.score-ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-number { font-size: 2.5rem; font-weight: 800; color: #fff; }
.score-label  { font-size: 0.75rem; color: rgba(255,255,255,0.6); }

.result-temp-badge {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.35rem 1rem; border-radius: 99px;
}
.result-temp-badge.hot          { background: var(--color-hot);     color: #fff; }
.result-temp-badge.warm         { background: var(--color-warm);    color: var(--color-teal-dk); }
.result-temp-badge.nurture      { background: var(--color-nurture); color: #fff; }
.result-temp-badge.cool         { background: var(--color-cool);    color: #fff; }
.result-temp-badge.special_route { background: var(--color-special); color: #fff; }

.result-body { border-radius: 0 0 var(--radius-xl) var(--radius-xl); box-shadow: var(--shadow-card); max-width: 580px; }
.result-heading {
  font-size: clamp(1.25rem, 3.5vw, 1.75rem); font-weight: 800;
  color: var(--color-teal-dk); margin-bottom: 0.75rem; text-wrap: balance;
}
.result-copy { font-size: 0.975rem; line-height: 1.7; color: var(--color-text-2); margin-bottom: 2rem; }

.result-breakdown { margin-bottom: 2rem; }
.breakdown-title {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--color-teal); margin-bottom: 1rem;
}
.breakdown-bar { margin-bottom: 0.75rem; }
.breakdown-bar__label {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; font-weight: 600; color: var(--color-text-2); margin-bottom: 0.3rem;
}
.breakdown-bar__track { height: 8px; background: var(--color-teal-lt); border-radius: 99px; overflow: hidden; }
.breakdown-bar__fill {
  height: 100%; background: var(--color-teal); border-radius: 99px;
  width: 0%; transition: width 800ms cubic-bezier(0.4,0,0.2,1);
}

.result-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.25rem; flex-wrap: wrap; }

/* ── Reduced motion ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .step, .step.is-exiting,
  .progress-bar__fill,
  .score-ring-fill,
  .breakdown-bar__fill,
  .spinner { animation: none; transition: none; }
  .score-ring-fill { transition: stroke-dashoffset 0ms; }
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 480px) {
  .card { padding: 1.75rem 1.25rem; }
  .result-hero { padding: 2rem 1.25rem; }
  .quiz-header { padding: 0.6rem 1rem; }
  .yn-buttons { gap: 0.75rem; }
}

/* ── Print ─────────────────────────────────── */
@media print {
  .quiz-header, .result-actions, .btn--back, #btn-back { display: none; }
  .step { display: flex !important; animation: none; }
  #step-result { display: flex; flex-direction: column; }
}
