/* ═══════════════════════════════════════════════════════════════
   mealPlanner — Production UI v1.0
   Aesthetic: Warm editorial food magazine — rich cream & terracotta
   Fonts: Playfair Display (headings) + DM Sans (body)
═══════════════════════════════════════════════════════════════ */

/* ── TOKENS ─────────────────────────────────────────────────── */
:root {
  --cream:       #faf7f2;
  --cream-dark:  #f0ebe0;
  --terracotta:  #c8541a;
  --terracotta-h:#a84214;
  --charcoal:    #1c1917;
  --stone:       #57534e;
  --pebble:      #a8a29e;
  --line:        #e7e2d8;
  --white:       #ffffff;
  --sage:        #5a6e55;
  --success-bg:  #f0f7ee;
  --success-fg:  #2d6a2d;
  --error-bg:    #fef2f0;
  --error-fg:    #b93b2a;
  --warn-bg:     #fffbeb;
  --warn-fg:     #92400e;

  --radius-sm:   10px;
  --radius:      18px;
  --radius-lg:   28px;
  --shadow-sm:   0 2px 8px rgba(28,25,23,.06);
  --shadow:      0 8px 32px rgba(28,25,23,.10);
  --shadow-lg:   0 20px 60px rgba(28,25,23,.14);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  --transition: 200ms cubic-bezier(.4,0,.2,1);
}

/* ── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--charcoal);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
a { color: var(--terracotta); }

/* ── PAGE FADE-IN ────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

body > * {
  animation: fadeUp .5s ease both;
}
.topbar       { animation-delay: .05s; }
.hero-band    { animation-delay: .12s; }
.feedback-banner { animation-delay: .18s; }
#stepProfile  { animation-delay: .22s; }
#stepResults  { animation-delay: .30s; }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 40px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--terracotta);
  color: var(--white);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 17px;
  letter-spacing: -.5px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(200,84,26,.35);
}

.brand-mark--sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 12px;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--charcoal);
}

.brand-text p {
  font-size: 12px;
  color: var(--stone);
  margin-top: 2px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  font-size: 13px;
  font-weight: 500;
  color: var(--stone);
  background: var(--cream-dark);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
}

.nav-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--terracotta);
  background: var(--terracotta);
  color: var(--white);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.nav-btn:hover { background: var(--terracotta-h); transform: translateY(-1px); }
.nav-btn--ghost { background: transparent; color: var(--terracotta); }
.nav-btn--ghost:hover { background: rgba(200,84,26,.07); }

/* ── LAYOUT ──────────────────────────────────────────────────── */
.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 28px 64px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ── HERO BAND ───────────────────────────────────────────────── */
.hero-band {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 48px;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 52px 56px;
  overflow: hidden;
  position: relative;
}

.hero-band::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 80% 50%, rgba(200,84,26,.06) 0%, transparent 70%);
  pointer-events: none;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--terracotta);
  background: rgba(200,84,26,.10);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 16px;
}

.hero-copy h2 {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 900;
  line-height: 1.1;
  color: var(--charcoal);
  margin-bottom: 16px;
}

.hero-copy p {
  font-size: 16px;
  line-height: 1.7;
  color: var(--stone);
  max-width: 520px;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* ── HERO IMAGE ──────────────────────────────────────────────── */
.hero-visual { position: relative; }

.hero-img-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, #e8d5c4 0%, #c9a882 100%);
  position: relative;
}

.hero-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s ease;
}

.hero-img-wrap:hover img { transform: scale(1.03); }

/* graceful fallback when image is missing */
.hero-img-wrap.img-fallback::after {
  content: '🍽️';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 80px;
  background: linear-gradient(135deg, #f5e6d3 0%, #e8c99a 100%);
}

.hero-badge {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(28,25,23,.78);
  backdrop-filter: blur(10px);
  color: var(--white);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-number {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  color: var(--terracotta);
}

.badge-label {
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255,255,255,.85);
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition);
}

.btn:hover::after { background: rgba(255,255,255,.12); }
.btn:active { transform: scale(.97); }

.btn-icon { font-size: 16px; }

.btn--lg { font-size: 16px; padding: 14px 30px; }

.btn--primary {
  background: var(--terracotta);
  color: var(--white);
  box-shadow: 0 4px 18px rgba(200,84,26,.38);
}
.btn--primary:hover {
  background: var(--terracotta-h);
  box-shadow: 0 6px 24px rgba(200,84,26,.48);
  transform: translateY(-2px);
}

.btn--secondary {
  background: var(--charcoal);
  color: var(--white);
  box-shadow: 0 4px 18px rgba(28,25,23,.22);
}
.btn--secondary:hover {
  background: #2c2825;
  transform: translateY(-2px);
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--stone);
}
.btn--ghost:hover { border-color: var(--pebble); background: var(--cream); }

.btn--hidden { display: none !important; }

/* loading state on buttons */
.btn.is-loading {
  pointer-events: none;
  opacity: .75;
}
.btn.is-loading .btn-icon::after {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}

/* ── FEEDBACK BANNER ─────────────────────────────────────────── */
.feedback-banner {
  border-radius: var(--radius);
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .4s ease, padding .3s ease, opacity .3s ease;
  opacity: 0;
  font-size: 15px;
  font-weight: 500;
}

.feedback-banner.visible {
  max-height: 100px;
  padding: 16px 24px;
  opacity: 1;
}

.feedback-banner.success {
  background: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid #b7e0b7;
}

.feedback-banner.error {
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid #f4c0b8;
}

.feedback-banner.info {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid #fcd9a0;
}

/* ── STEP SECTIONS ───────────────────────────────────────────── */
.step-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step-label {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.step-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--terracotta);
  color: var(--white);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(200,84,26,.3);
  margin-top: 2px;
}

.step-label h3 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 6px;
}

.step-label p {
  font-size: 15px;
  color: var(--stone);
  line-height: 1.6;
}

/* ── PROFILE FORM ────────────────────────────────────────────── */
.profile-card {
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 28px;
}

.form-full {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--charcoal);
  letter-spacing: .01em;
}

.field-hint {
  font-size: 12px;
  color: var(--pebble);
  margin-bottom: 2px;
}

input[type="text"],
input[type="number"],
select {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--charcoal);
  background: var(--cream);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

select {
  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='%23a8a29e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input:focus, select:focus {
  border-color: var(--terracotta);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(200,84,26,.13);
}

input::placeholder { color: var(--pebble); }

/* ── TOGGLES ─────────────────────────────────────────────────── */
.toggle-group {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--cream);
}

.toggle-group legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--charcoal);
  padding: 0 8px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--stone);
  user-select: none;
}

.toggle-item input[type="checkbox"] {
  display: none;
}

.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--line);
  border-radius: 999px;
  flex-shrink: 0;
  position: relative;
  transition: background var(--transition);
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: transform var(--transition);
}

.toggle-item input:checked + .toggle-track {
  background: var(--terracotta);
}

.toggle-item input:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* ── FORM ACTIONS ────────────────────────────────────────────── */
.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* ── RESULTS / TABS ──────────────────────────────────────────── */
.results-card {
  padding: 32px 36px;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1.5px solid var(--line);
}

.tab-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--cream);
  color: var(--stone);
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover {
  border-color: var(--terracotta);
  color: var(--terracotta);
  background: rgba(200,84,26,.06);
}

.tab-btn.active {
  background: var(--terracotta);
  color: var(--white);
  border-color: var(--terracotta);
  box-shadow: 0 3px 10px rgba(200,84,26,.3);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .3s ease both; }

/* ── OUTPUT PANELS ───────────────────────────────────────────── */
.output-panel { min-height: 220px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 40px 24px;
  background: var(--cream);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--stone);
  min-height: 220px;
}

.empty-icon { font-size: 40px; opacity: .6; }
.empty-state p { font-size: 15px; max-width: 360px; line-height: 1.6; }

/* meal plan output items */
.meal-day {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.meal-day:last-child { border-bottom: none; }

.meal-day h4 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 8px;
}

.meal-day ul, .meal-day ol {
  margin: 8px 0 0 20px;
  padding: 0;
  color: var(--stone);
  line-height: 1.7;
}

.meal-day h5 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--terracotta);
  margin: 14px 0 6px;
}

/* shopping list */
.shopping-category {
  margin-bottom: 24px;
}

.shopping-category h4 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--terracotta);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.shopping-category ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shopping-category li label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--stone);
  cursor: pointer;
  padding: 6px 0;
}

.shopping-category li input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--line);
  background: var(--white);
  accent-color: var(--terracotta);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── LOADING OVERLAY ─────────────────────────────────────────── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(28,25,23,.55);
  backdrop-filter: blur(6px);
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}

.loading-overlay.active {
  display: grid;
  opacity: 1;
  pointer-events: all;
}

.loading-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 48px 56px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
}

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

.spinner {
  width: 52px;
  height: 52px;
  border: 4px solid var(--line);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin .9s linear infinite;
  margin: 0 auto 20px;
}

.loading-card p {
  font-size: 17px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--stone) !important;
}

/* ── FOOTER ──────────────────────────────────────────────────── */
.site-footer {
  background: var(--charcoal);
  color: rgba(255,255,255,.55);
  padding: 28px 40px;
}

.footer-inner {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.8);
  font-weight: 600;
  font-size: 14px;
}

.footer-brand .brand-mark {
  background: var(--terracotta);
}

.footer-copy {
  font-size: 13px;
}

/* ── HIDDEN DEV ELEMENTS ─────────────────────────────────────── */
.message-box { display: none; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 960px) {
  .hero-band {
    grid-template-columns: 1fr;
    padding: 36px 32px;
  }
  .hero-visual { display: none; }
}

@media (max-width: 680px) {
  .topbar { padding: 14px 20px; }
  .layout { padding: 24px 16px 48px; }
  .profile-card { padding: 24px 20px; }
  .results-card { padding: 24px 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .hero-band { padding: 28px 24px; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .step-label { flex-direction: column; gap: 10px; }
  .tab-row { gap: 6px; }
  .tab-btn { font-size: 12px; padding: 8px 12px; }
  .footer-inner { flex-direction: column; text-align: center; }
}