/* ==========================================================================
   Design identity: safari daylight — warm sand, cream and olive, the palette
   of a canvas tent at midday. One accent (olive green), one rare second
   voice (camel), no cold neutrals anywhere. A single deliberate world: this
   is about warmth and openness, not a UI light/dark preference.
   Frank Ruhl Libre (literary Hebrew serif) carries the voice of the
   questions; Assistant carries the answers.
   ========================================================================== */

:root {
  --ink:          #3d3626;
  --ink-dim:      #6d6248;
  --ink-faint:    #9c9070;
  --paper:        #f6efdc;
  --surface:      #ece0c2;
  --surface-2:    #e2d3aa;
  --hairline:     rgba(61, 54, 38, 0.16);
  --hairline-2:   rgba(61, 54, 38, 0.09);
  --accent:       #6f7d47;
  --accent-soft:  #8b9760;
  --accent-deep:  #4f5a32;
  --accent-glow:  rgba(111, 125, 71, 0.22);
  --camel:        #b9884f;
  --on-accent:    #f8f3e4;
  --danger:       #a6543f;
  --shadow-lg:    0 30px 70px rgba(61, 54, 38, 0.20);
  --shadow-md:    0 10px 24px rgba(61, 54, 38, 0.16);
  --radius-xl:    30px;
  --radius-lg:    22px;
  --radius-md:    16px;
  --radius-sm:    10px;
  --font-display: 'Assistant', 'Arial Hebrew', 'Noto Sans Hebrew', Arial, sans-serif;
  --font-body:    'Assistant', 'Arial Hebrew', 'Noto Sans Hebrew', Arial, sans-serif;
  --ease-out:     cubic-bezier(.22, .61, .36, 1);
  --ease-in-out:  cubic-bezier(.65, 0, .35, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; text-wrap: balance; margin: 0; }

button { font-family: inherit; }

::selection { background: var(--accent-glow); color: var(--ink); }

/* ---------- ambient background ---------- */

.app {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--paper);
}

.ember-glow {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  will-change: transform;
}

.ember-glow--a {
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  top: -20vmax;
  right: -18vmax;
  animation: drift-a 26s var(--ease-in-out) infinite alternate;
}

.ember-glow--b {
  background: radial-gradient(circle, var(--camel) 0%, transparent 70%);
  bottom: -24vmax;
  left: -20vmax;
  opacity: 0.14;
  animation: drift-b 32s var(--ease-in-out) infinite alternate;
}

@keyframes drift-a {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-6vmax, 5vmax) scale(1.12); }
}
@keyframes drift-b {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(5vmax, -4vmax) scale(1.08); }
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce) {
  .ember-glow { animation: none; }
}

/* ---------- topbar / progress ---------- */

.topbar[hidden] { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 20px 14px;
  background: linear-gradient(to bottom, var(--paper) 60%, transparent);
}

.back-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color .2s var(--ease-out), border-color .2s var(--ease-out), transform .2s var(--ease-out);
}
.back-btn svg { transform: scaleX(-1); } /* RTL: point right-to-left visually as "back" */
.back-btn:hover { color: var(--ink); border-color: var(--accent-soft); }
.back-btn:active { transform: scale(0.92); }
.back-btn:disabled { opacity: 0; pointer-events: none; }
.back-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.progress-wrap { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.progress-track {
  height: 3px;
  border-radius: 3px;
  background: var(--hairline);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  border-radius: 3px;
  transition: width .5s var(--ease-out);
  box-shadow: 0 0 12px var(--accent-glow);
}

.step-counter {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- stage / screens ---------- */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 20px max(28px, env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px 0 10px;
  animation: enter .5s var(--ease-out);
}

.screen.leaving { animation: leave .28s var(--ease-in-out) forwards; }

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

@media (prefers-reduced-motion: reduce) {
  .screen, .screen.leaving { animation: none; }
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* intro screen */

.intro h1 {
  font-size: clamp(30px, 7.5vw, 42px);
  line-height: 1.2;
  color: var(--ink);
}

.intro p {
  margin-top: 18px;
  font-size: 17px;
  color: var(--ink-dim);
  max-width: 48ch;
  line-height: 1.7;
}

.intro p.lede {
  color: var(--accent-deep);
  font-weight: 700;
  font-size: 18px;
}

.intro p.closing {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 19px;
}

.intro p.fine {
  font-size: 14px;
  color: var(--ink-faint);
}

/* question header */

.q-head { margin-bottom: 28px; }

.q-title {
  font-size: clamp(22px, 6vw, 29px);
  line-height: 1.35;
  color: var(--ink);
}

.q-sub {
  margin-top: 10px;
  font-size: 14.5px;
  color: var(--ink-faint);
}

/* text inputs */

.field-text input,
.field-text textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--hairline);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  padding: 10px 2px 14px;
  transition: border-color .25s var(--ease-out);
  resize: none;
}

.field-text textarea {
  min-height: 130px;
  line-height: 1.6;
  font-size: 17px;
  border-bottom: none;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.field-text input::placeholder,
.field-text textarea::placeholder { color: var(--ink-faint); opacity: 0.8; }

.field-text input:focus,
.field-text textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field-text textarea:focus { box-shadow: 0 0 0 3px var(--accent-glow) inset, 0 0 0 1px var(--accent) inset; }

.char-count {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-faint);
  text-align: left;
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

.field-error {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--danger);
  min-height: 18px;
}

/* single choice */

.choice-list { display: flex; flex-direction: column; gap: 10px; }

.choice-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--surface);
  cursor: pointer;
  text-align: right;
  color: var(--ink-dim);
  font-size: 16.5px;
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out), color .2s var(--ease-out), transform .15s var(--ease-out);
}
.choice-card:hover { border-color: var(--accent-soft); color: var(--ink); }
.choice-card:active { transform: scale(0.985); }

.choice-radio {
  flex: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
  display: flex; align-items: center; justify-content: center;
  transition: border-color .2s var(--ease-out);
}
.choice-radio::after {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform .18s var(--ease-out);
}

.choice-card.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.choice-card.selected .choice-radio { border-color: var(--accent); }
.choice-card.selected .choice-radio::after { transform: scale(1); }

/* multi choice chips */

.chip-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-dim);
  font-size: 15px;
  cursor: pointer;
  transition: all .2s var(--ease-out);
}
.chip:hover { border-color: var(--accent-soft); color: var(--ink); }
.chip.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.chip.disabled { opacity: 0.4; pointer-events: none; }

.chip-check {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.chip.selected .chip-check { background: var(--on-accent); border-color: var(--on-accent); }
.chip.selected .chip-check::after { content: '✓'; font-size: 10px; color: var(--accent); line-height: 1; }

.chip-counter {
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.chip-counter strong { color: var(--accent-deep); font-weight: 700; }

/* rating scale */

.rating-value {
  font-family: var(--font-display);
  font-size: 64px;
  line-height: 1;
  color: var(--accent-deep);
  text-align: center;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.rating-value.empty { color: var(--ink-faint); font-size: 40px; }

.rating-row {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  margin-top: 22px;
}

.rating-dot {
  flex: 1;
  aspect-ratio: 1;
  max-width: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .18s var(--ease-out);
}
.rating-dot:hover { border-color: var(--accent-soft); }
.rating-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  transform: scale(1.08);
  box-shadow: 0 0 16px var(--accent-glow);
}
.rating-dot.in-range {
  border-color: var(--accent-soft);
  background: var(--surface-2);
}

.rating-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-faint);
}
.rating-labels span:last-child { text-align: left; }

/* nav / cta */

.nav-row {
  margin-top: 34px;
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  appearance: none;
  border: none;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: var(--on-accent);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  padding: 15px 30px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), opacity .2s;
}
.btn-primary svg { transform: scaleX(-1); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 16px 30px rgba(61, 54, 38, 0.22); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-primary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.btn-primary.loading .btn-label { visibility: hidden; }
.btn-primary .spinner {
  display: none;
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(248, 243, 228, 0.35);
  border-top-color: var(--on-accent);
  animation: spin .7s linear infinite;
}
.btn-primary.loading { position: relative; }
.btn-primary.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* thank you */

.thankyou { text-align: center; align-items: center; }
.thankyou-icon {
  width: 74px; height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  border: 1px solid var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 26px;
}
.thankyou h1 {
  font-size: clamp(28px, 7vw, 38px);
  color: var(--ink);
}
.thankyou p {
  margin-top: 16px;
  font-size: 16.5px;
  color: var(--ink-dim);
  max-width: 42ch;
  margin-inline: auto;
  line-height: 1.7;
}
.thankyou .eyebrow { display: flex; justify-content: center; }

.error-banner {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(166, 84, 63, 0.10);
  border: 1px solid rgba(166, 84, 63, 0.32);
  color: var(--danger);
  font-size: 13.5px;
}

@media (min-width: 720px) {
  .stage { padding-top: 24px; }
  .rating-dot { font-size: 14px; }
}
