/* ==========================================================
   A Healthy Trend — Kids Wellness Survey
   Design system: warm, modern, child-friendly, premium.
   Color tokens + base reset live in tokens.css (shared with the
   admin dashboard) — everything below is survey-page-specific.
   ========================================================== */

@import url("tokens.css");

/* ==========================================================
   App shell / layout
   ========================================================== */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

.app-bg-deco {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.app-bg-deco svg {
  position: absolute;
  opacity: 0.5;
}

.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 40px 0 140px;
  animation: fadeSlideIn var(--t-slow) var(--ease);
}

.screen[hidden] {
  display: none;
}

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

@keyframes fadeSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.screen.leaving {
  animation: fadeSlideOut var(--t-fast) var(--ease) forwards;
}

/* ==========================================================
   Brand header (small, persistent)
   ========================================================== */

.brand-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px;
  position: relative;
  z-index: 2;
}

/* Official A Healthy Trend logo. Height-constrained with width:auto
   so the browser scales it proportionally from its native size —
   never stretched, always sharp. */
.brand-logo-img {
  height: 36px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .brand-logo-img {
    height: 26px;
  }
}

/* ==========================================================
   Landing page
   ========================================================== */

.landing {
  text-align: center;
  align-items: center;
  padding-top: 12px;
  gap: 0;
}

.landing-illustration {
  width: 220px;
  height: 220px;
  margin: 8px auto 20px;
}

.landing h1 {
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.25;
  max-width: 480px;
  margin: 0 auto 14px;
}

.landing .subhead {
  color: var(--text-soft);
  font-size: 17px;
  max-width: 420px;
  margin: 0 auto 32px;
}

.landing .hint {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.trust-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 28px;
}

.trust-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-soft);
  box-shadow: var(--shadow-card);
}

/* ==========================================================
   Progress indicator
   ========================================================== */

.progress-wrap {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
  padding: 14px 0 10px;
}

.progress-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
}

.progress-caption {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-track {
  position: relative;
  height: 10px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-radius: 999px;
  transition: width var(--t-slow) var(--ease);
}

.progress-stages {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-faint);
}

.progress-stages span {
  transition: transform var(--t-med) var(--ease), filter var(--t-med) var(--ease);
  filter: grayscale(1) opacity(0.5);
}

.progress-stages span.reached {
  filter: grayscale(0) opacity(1);
  transform: scale(1.15);
}

/* ==========================================================
   Section header
   ========================================================== */

.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 76px 0 28px;
}

.section-emoji {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--brand-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.section-header h2 {
  font-size: 22px;
}

.section-header .section-intro {
  color: var(--text-soft);
  font-size: 14px;
  margin-top: 2px;
}

/* ==========================================================
   Question cards
   ========================================================== */

.question-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.question-label {
  font-family: "Baloo 2", sans-serif;
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 4px;
}

.question-required {
  color: var(--coral);
  margin-left: 3px;
}

.question-description {
  color: var(--text-soft);
  font-size: 14px;
  margin: 6px 0 18px;
  line-height: 1.5;
}

.question-label + .question-description {
  margin-top: 6px;
}

.question-label:last-child {
  margin-bottom: 18px;
}

/* --- Number / text / tel / email inputs --- */

.number-input-wrap {
  margin-top: 18px;
}

.number-input,
.text-field-input {
  width: 100%;
  font-size: 18px;
  font-family: inherit;
  padding: 16px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.number-input {
  font-size: 20px;
}

.number-input::placeholder,
.text-field-input::placeholder {
  color: var(--text-faint);
}

.number-input:focus,
.text-field-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-tint);
  outline: none;
}

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

.consent-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 18px 20px;
  border: 2px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.consent-card:hover {
  border-color: var(--brand);
}

.consent-card.checked {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.consent-checkbox-input {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--brand);
  cursor: pointer;
}

.consent-label-text {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--text);
}

.privacy-notice {
  font-size: 13.5px;
  color: var(--text-soft);
  margin-top: 16px;
  line-height: 1.55;
}

.privacy-link-placeholder {
  color: var(--text-soft);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: default;
}

/* --- Textarea --- */

.textarea-input {
  width: 100%;
  min-height: 120px;
  font-size: 16px;
  font-family: inherit;
  padding: 16px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  resize: vertical;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.textarea-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-tint);
  outline: none;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.example-chip {
  font-size: 12.5px;
  color: var(--brand);
  background: var(--brand-tint);
  border-radius: 999px;
  padding: 6px 12px;
}

/* --- Option cards (single-select & yes/no) --- */

.options-grid {
  display: grid;
  gap: 12px;
}

.options-grid.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.option-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border: 2px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  transition: border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.option-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.option-card:active {
  transform: translateY(0) scale(0.99);
}

.option-card .option-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.option-card .option-dot svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.option-card[aria-checked="true"] {
  border-color: var(--brand);
  background: var(--brand-tint);
  box-shadow: 0 0 0 1px var(--brand);
}

.option-card[aria-checked="true"] .option-dot {
  border-color: var(--brand);
  background: var(--brand);
}

.option-card[aria-checked="true"] .option-dot svg {
  opacity: 1;
  transform: scale(1);
}

/* Yes/No pair sits side by side */
.yes-no-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.yes-no-grid .option-card {
  justify-content: center;
  text-align: center;
}

/* ==========================================================
   Buttons
   ========================================================== */

.btn {
  font-family: "Baloo 2", sans-serif;
  font-weight: 600;
  font-size: 16px;
  border-radius: 999px;
  padding: 16px 30px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    opacity var(--t-fast) var(--ease);
}

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

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px rgba(123, 34, 48, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(123, 34, 48, 0.34);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: var(--text-soft);
  border: 2px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.btn-large {
  padding: 18px 40px;
  font-size: 17px;
}

/* ==========================================================
   Nav bar (Back / Next) — sticky, thumb-friendly on mobile
   ========================================================== */

.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 18px 0 22px;
}

.nav-bar-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  padding: 10px 10px 10px 8px;
}

.nav-bar .btn {
  flex: 1;
}

.nav-bar .btn-secondary {
  border: none;
  flex: 0 0 auto;
}

.field-error {
  color: var(--coral);
  font-size: 13.5px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-error[hidden] {
  display: none;
}

/* ==========================================================
   Completion page
   ========================================================== */

.complete {
  text-align: center;
  align-items: center;
  padding-top: 40px;
}

.complete-illustration {
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
  animation: popIn var(--t-slow) var(--ease);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.complete h1 {
  font-size: clamp(26px, 5vw, 34px);
  margin-bottom: 12px;
}

.complete p {
  color: var(--text-soft);
  max-width: 420px;
  margin: 0 auto;
}

.report-placeholder {
  margin-top: 30px;
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.report-placeholder .icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--butter-tint);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.report-placeholder .copy {
  font-size: 14px;
  color: var(--text-soft);
}

.report-placeholder .copy strong {
  display: block;
  color: var(--text);
  font-family: "Baloo 2", sans-serif;
  font-size: 15px;
  margin-bottom: 2px;
}

/* Submit error banner */
.submit-error {
  margin-top: 18px;
  background: var(--coral-tint);
  border: 1px solid rgba(156, 74, 52, 0.35);
  color: var(--coral);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
}

.submit-error[hidden] {
  display: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================
   Responsive
   ========================================================== */

@media (max-width: 600px) {
  .container {
    padding: 0 18px;
  }

  .screen {
    padding: 24px 0 150px;
  }

  .section-header {
    margin-top: 84px;
  }

  .yes-no-grid,
  .options-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }

  .question-card {
    padding: 22px 18px;
  }

  .landing-illustration {
    width: 180px;
    height: 180px;
  }
}

@media (min-width: 601px) {
  .app-shell {
    padding-bottom: 0;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
