/* ============================================================
   GROUNDNUT PASTE SURVEY — style.css
   Mobile-first · Premium food brand aesthetic
   ============================================================ */

/* ── CSS Custom Properties ────────────────────────────────── */
:root {
  /* Colour palette */
  --cream:      #FEFCF7;
  --cream-100:  #FDF8EC;
  --sand-50:    #FAF6ED;
  --sand-100:   #F5EFE0;
  --sand-200:   #EDE3C9;
  --sand-300:   #E0D0AC;
  --gold:       #C4A35A;
  --gold-dark:  #A8893E;
  --walnut:     #3B2009;
  --walnut-mid: #5D3A1A;
  --walnut-lt:  #7A5A3A;
  --walnut-xs:  #9A7A5A;
  --walnut-fnt: #BEA07A;
  --green-wa:   #25D366;
  --green-wa-dk:#1EBF5A;
  --error:      #C0392B;
  --error-bg:   #FEF2F2;
  --error-bdr:  #FECACA;

  /* Spacing */
  --max-w:  520px;
  --pad-x:  20px;
  --pad-y:  32px;
  --gap:    12px;
  --radius: 16px;
  --radius-lg: 20px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;

  /* Shadows */
  --shadow-soft: 0 2px 14px rgba(59,32,9,.07);
  --shadow-card: 0 4px 24px rgba(59,32,9,.11);
  --shadow-btn:  0 2px 10px rgba(59,32,9,.22);

  /* Transitions */
  --trans-base: 0.18s ease;
  --trans-card: 0.27s cubic-bezier(.25,.46,.45,.94);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--cream);
  color: var(--walnut);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

a { -webkit-tap-highlight-color: transparent; }

img { max-width: 100%; display: block; }

/* ── App Shell ────────────────────────────────────────────── */
#app { min-height: 100dvh; min-height: 100vh; display: flex; flex-direction: column; }

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 100dvh;
  min-height: 100vh;
}

.screen.active { display: flex; }

/* ── Container ────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--pad-y) var(--pad-x);
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Typography ───────────────────────────────────────────── */
.serif { font-family: var(--font-serif); }

h1 {
  font-size: clamp(1.6rem, 5vw, 2rem);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--walnut);
}

h2 {
  font-size: clamp(1.25rem, 4.5vw, 1.6rem);
  line-height: 1.25;
  font-weight: 700;
  color: var(--walnut);
}

/* ── Landing Screen ───────────────────────────────────────── */
#screen-landing { justify-content: center; align-items: center; }

#screen-landing .container {
  justify-content: center;
  align-items: center;
}

.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.brand-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  animation: float 5s ease-in-out infinite;
  /* fallback: if logo fails to load, show emoji at this size */
  font-size: 64px;
  line-height: 1;
}

.brand-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 140px;
  max-height: 140px;
  object-fit: contain;        /* never stretch */
  image-rendering: -webkit-optimize-contrast; /* crisp on retina */
  image-rendering: crisp-edges;
  -webkit-user-drag: none;
  /* transparent PNGs work with no background needed */
}

@media (max-width: 380px) {
  .brand-logo { max-width: 110px; max-height: 110px; }
}

@keyframes float {
  0%, 100% { transform: translateY(0);    }
  50%       { transform: translateY(-9px); }
}

.landing-text { display: flex; flex-direction: column; gap: 10px; }

#survey-desc {
  color: var(--walnut-lt);
  font-size: 1rem;
  line-height: 1.6;
}

.time-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--sand-100);
  color: var(--walnut-xs);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
}

.privacy-note {
  font-size: 0.75rem;
  color: var(--gold);
  letter-spacing: 0.01em;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--walnut);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  padding: 15px 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-btn);
  transition: background var(--trans-base), transform var(--trans-base),
              box-shadow var(--trans-base), opacity var(--trans-base);
  letter-spacing: 0.01em;
}

.btn-primary:hover:not(:disabled) { background: var(--walnut-mid); }
.btn-primary:active:not(:disabled) { transform: scale(0.975); box-shadow: none; }

.btn-primary:disabled,
.btn-primary[aria-disabled="true"] {
  background: var(--sand-300);
  color: var(--gold);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}

.btn-full { width: 100%; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--walnut-lt);
  font-size: 1rem;
  font-weight: 600;
  padding: 15px 20px;
  border-radius: var(--radius);
  border: 2px solid var(--sand-300);
  transition: border-color var(--trans-base), color var(--trans-base), transform var(--trans-base);
}

.btn-secondary:hover { border-color: var(--walnut); color: var(--walnut); }
.btn-secondary:active { transform: scale(0.975); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; border-radius: 10px; }

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--green-wa);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  padding: 15px 28px;
  border-radius: var(--radius);
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(37,211,102,.3);
  transition: background var(--trans-base), transform var(--trans-base);
}

.btn-whatsapp:hover { background: var(--green-wa-dk); }
.btn-whatsapp:active { transform: scale(0.975); }

/* ── Progress Bar ─────────────────────────────────────────── */
#progress-container {
  width: 100%;
  padding: 16px var(--pad-x) 12px;
  background: var(--cream);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--sand-200);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-w);
  margin: 0 auto 8px;
}

.progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--walnut-xs);
  letter-spacing: 0.04em;
}

.progress-track {
  height: 5px;
  background: var(--sand-300);
  border-radius: 999px;
  overflow: hidden;
  max-width: var(--max-w);
  margin: 0 auto;
}

#progress-fill {
  height: 100%;
  width: 0;
  background: var(--walnut);
  border-radius: 999px;
  transition: width 0.45s cubic-bezier(.25,.46,.45,.94);
}

/* ── Survey Screen ────────────────────────────────────────── */
#screen-survey {
  justify-content: flex-start;
  min-height: 100dvh;
  min-height: 100vh;
}

#screen-survey .container {
  justify-content: space-between;
  padding-top: 28px;
  padding-bottom: 28px;
  gap: 28px;
}

/* ── Question Card Transition ─────────────────────────────── */
#question-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  transition: opacity var(--trans-card), transform var(--trans-card);
}

#question-wrap.exit-fwd {
  opacity: 0;
  transform: translateX(-38px);
  pointer-events: none;
}

#question-wrap.exit-back {
  opacity: 0;
  transform: translateX(38px);
  pointer-events: none;
}

#question-wrap.enter-fwd {
  opacity: 0;
  transform: translateX(38px);
  transition: none;
  pointer-events: none;
}

#question-wrap.enter-back {
  opacity: 0;
  transform: translateX(-38px);
  transition: none;
  pointer-events: none;
}

/* ── Step label ───────────────────────────────────────────── */
.step-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--walnut-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ── Navigation Buttons ───────────────────────────────────── */
#nav-buttons {
  display: flex;
  gap: 10px;
}

#btn-back { flex: 1; }
#btn-next { flex: 2; }

/* ── Multiple Choice Options ──────────────────────────────── */
.options-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 15px 18px;
  border-radius: var(--radius);
  border: 2px solid var(--sand-300);
  background: #fff;
  color: var(--walnut);
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--trans-base), background var(--trans-base),
              color var(--trans-base), box-shadow var(--trans-base), transform var(--trans-base);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.option-btn:hover {
  border-color: var(--gold);
}

.option-btn:active { transform: scale(0.985); }

.option-btn.selected {
  border-color: var(--walnut);
  background: var(--walnut);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

/* Radio dot */
.option-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--trans-base);
}

.option-btn.selected .option-radio {
  border-color: rgba(255,255,255,.65);
}

.option-radio-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  display: none;
}

.option-btn.selected .option-radio-dot { display: block; }

/* ── Image Choice ─────────────────────────────────────────── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}

.image-option {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 2px solid var(--sand-300);
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  transition: border-color var(--trans-base), box-shadow var(--trans-base),
              transform var(--trans-base);
  box-shadow: var(--shadow-soft);
  -webkit-tap-highlight-color: transparent;
}

.image-option:hover  { border-color: var(--gold); }
.image-option:active { transform: scale(0.97); }

.image-option.selected {
  border-color: var(--walnut);
  box-shadow: 0 0 0 3px rgba(59,32,9,.14), var(--shadow-card);
}

.image-option-img {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--sand-100);
  overflow: hidden;
}

.image-option-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Checkmark badge */
.image-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: var(--walnut);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(59,32,9,.35);
  animation: pop-in .2s cubic-bezier(.17,.67,.53,1.4) forwards;
}

.image-option.selected .image-check { display: flex; }

@keyframes pop-in {
  0%   { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.image-option-label {
  padding: 10px 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  color: var(--walnut);
  background: #fff;
  transition: background var(--trans-base), color var(--trans-base);
}

.image-option.selected .image-option-label {
  background: var(--walnut);
  color: #fff;
}

/* ── Textarea ─────────────────────────────────────────────── */
.survey-textarea {
  width: 100%;
  min-height: 140px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--sand-300);
  background: #fff;
  color: var(--walnut);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  box-shadow: var(--shadow-soft);
  transition: border-color var(--trans-base), box-shadow var(--trans-base);
  outline: none;
}

.survey-textarea::placeholder { color: var(--gold); }

.survey-textarea:focus {
  border-color: var(--walnut);
  box-shadow: 0 0 0 3px rgba(59,32,9,.08), var(--shadow-soft);
}

/* ── Complete Screen ──────────────────────────────────────── */
#screen-complete { justify-content: center; align-items: center; }

#screen-complete .container { justify-content: center; align-items: center; }

.complete-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  animation: fade-up .45s ease both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.check-circle {
  width: 80px;
  height: 80px;
  background: var(--walnut);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: var(--shadow-card);
  animation: pop-in .4s cubic-bezier(.17,.67,.53,1.4) .15s both;
}

.complete-heading {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
}

.complete-message {
  color: var(--walnut-lt);
  font-size: 1rem;
  line-height: 1.7;
}

/* ── Error Overlay ────────────────────────────────────────── */
.error-overlay {
  position: fixed;
  inset: 0;
  background: rgba(59,32,9,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade-in .2s ease;
}

.error-overlay[hidden] { display: none; }

.error-box {
  background: var(--error-bg);
  border: 1px solid var(--error-bdr);
  color: var(--error);
  border-radius: var(--radius);
  padding: 18px 20px;
  width: 100%;
  max-width: var(--max-w);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-card);
}

@keyframes fade-in {
  from { opacity: 0; } to { opacity: 1; }
}

/* ── Toast Notifications ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  max-width: calc(var(--max-w) - 40px);
  width: calc(100% - 40px);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: var(--shadow-card);
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast--success {
  background: var(--walnut);
  color: #fff;
}

.toast--error {
  background: var(--error-bg);
  border: 1px solid var(--error-bdr);
  color: var(--error);
}

.toast--info {
  background: var(--sand-100);
  border: 1px solid var(--sand-200);
  color: var(--walnut);
}

/* ── Loading Spinner (inside Submit button) ───────────────── */
.btn-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── Mobile Safari / Android Chrome fixes ─────────────────── */
/* Prevent double-tap zoom on buttons on iOS */
button, a, [role="button"] {
  touch-action: manipulation;
}

/* iOS safe-area padding for bottom navigation on notched devices */
#nav-buttons {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Prevent textarea font-size zoom on iOS (must be >= 16px) */
.survey-textarea {
  font-size: max(16px, 1rem);
}

/* Ensure minimum tap target size per WCAG (44×44px) */
.option-btn, .btn-primary, .btn-secondary, .btn-whatsapp {
  min-height: 44px;
}

.image-option {
  min-height: 44px;
}

/* Fix 100vh bug on mobile browsers where the address bar overlaps content */
#app, .screen {
  min-height: 100dvh;
}

/* ── Custom Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--sand-100); }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 999px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (min-width: 480px) {
  #screen-survey .container { padding-top: 36px; padding-bottom: 36px; }
  .image-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 600px) {
  .landing-content { gap: 28px; }
}
