/* ===========================================================
   Cocina Resuelta — sistema de diseño
   Paleta: beige cálido + verde oliva, tonos pastel
   Tipografía: Fraunces (display) + Work Sans (texto/UI)
=========================================================== */

:root {
  --beige-50: #FAF7EF;
  --beige-100: #F3EEE3;
  --beige-200: #EAE2D1;
  --beige-300: #DCD2B9;
  --line: #DDD3BC;

  --olive-900: #333B22;
  --olive-700: #4A5334;
  --olive-600: #56623D;
  --olive-500: #6E7B4C;
  --olive-400: #8B9968;
  --olive-100: #E3E8D5;
  --olive-050: #EEF1E4;

  --clay-500: #B0603A;
  --clay-100: #F2DFCF;

  --ink: #2C2A20;
  --ink-soft: #5B5748;
  --paper: #FFFFFF;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(44,42,32,0.06), 0 8px 24px -12px rgba(44,42,32,0.18);
  --shadow-pop: 0 12px 32px -8px rgba(44,42,32,0.28);

  --font-display: "Fraunces", "Iowan Old Style", serif;
  --font-body: "Work Sans", -apple-system, BlinkMacSystemFont, sans-serif;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--beige-100);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: inherit; }

/* ---------- App shell ---------- */
#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--beige-100);
  position: relative;
  padding-bottom: 84px; /* tab bar */
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--beige-100);
  padding: 18px 20px 12px;
  border-bottom: 1px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.topbar.is-stuck {
  border-bottom-color: var(--line);
  box-shadow: 0 6px 16px -12px rgba(44,42,32,0.3);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--olive-700);
  letter-spacing: -0.01em;
}
.brand-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--olive-500);
}
.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--olive-700);
}
.icon-btn:active { transform: scale(0.94); }

.search-row {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}
.search-input-wrap {
  flex: 1;
  position: relative;
}
.search-input-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--olive-500);
}
input[type="search"], input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-pill);
  padding: 12px 16px 12px 40px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}
input[type="search"]:focus, input[type="text"]:focus {
  border-color: var(--olive-500);
  box-shadow: 0 0 0 3px var(--olive-100);
}

/* ---------- Main scroll area ---------- */
main { padding: 4px 20px 24px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Hero / pantry selector (signature element) ---------- */
.pantry-hero {
  margin: 14px 0 20px;
  background: linear-gradient(155deg, var(--olive-600), var(--olive-700));
  border-radius: var(--radius-lg);
  padding: 22px 20px 20px;
  color: var(--beige-50);
  position: relative;
  overflow: hidden;
}
.pantry-hero::after {
  content: "";
  position: absolute; right: -40px; top: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(255,255,255,0.14), transparent 70%);
}
.pantry-hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.25;
  margin: 0 0 4px;
}
.pantry-hero p {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--olive-100);
  max-width: 46ch;
}
.pantry-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: var(--radius-pill);
  padding: 6px 14px 6px 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.pantry-count .dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--beige-50); color: var(--olive-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.pantry-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  background: var(--beige-50);
  color: var(--olive-700);
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px 18px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
}
.pantry-cta:active { transform: scale(0.98); }

/* ---------- Section headers ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 26px 0 12px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--olive-700);
  margin: 0;
}
.section-head .see-all {
  font-size: 12.5px;
  color: var(--olive-500);
  cursor: pointer;
  font-weight: 600;
}

/* ---------- Category chips ---------- */
.chip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: none;
}
.chip-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: var(--radius-pill);
  padding: 8px 15px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip.active {
  background: var(--olive-600);
  border-color: var(--olive-600);
  color: var(--beige-50);
}
.chip .n {
  opacity: .65;
  font-size: 11.5px;
  margin-left: 3px;
}

/* ---------- Ingredient chip grid (pantry picker) ---------- */
.ing-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.ing-chip {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-pill);
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.ing-chip.selected {
  background: var(--olive-100);
  border-color: var(--olive-400);
  color: var(--olive-700);
  font-weight: 600;
}
.ing-chip .check {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--olive-400);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.ing-chip.selected .check { background: var(--olive-500); border-color: var(--olive-500); }
.ing-chip.selected .check svg { display: block; }
.ing-chip .check svg { display: none; width: 9px; height: 9px; color: white; }

.ing-search {
  margin-bottom: 14px;
}

/* ---------- Recipe cards ---------- */
.recipe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.recipe-list { display: flex; flex-direction: column; gap: 10px; }

.recipe-card {
  background: var(--paper);
  border-radius: var(--radius-md);
  border: 1px solid var(--beige-200);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.recipe-card:active { transform: scale(0.98); }
.recipe-card .thumb {
  height: 96px;
  background: var(--olive-100);
  display: flex; align-items: center; justify-content: center;
  color: var(--olive-400);
  position: relative;
}
.recipe-card .thumb .cat-tag {
  position: absolute; top: 8px; left: 8px;
  background: rgba(255,255,255,0.85);
  color: var(--olive-700);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}
.recipe-card .match-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--olive-600);
  color: var(--beige-50);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}
.recipe-card .body { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; }
.recipe-card h3 {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 6px;
  color: var(--ink);
}
.recipe-card .macros {
  margin-top: auto;
  display: flex; gap: 8px;
  font-size: 11px;
  color: var(--ink-soft);
}

/* horizontal row card (used in lists) */
.recipe-row {
  display: flex;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--beige-200);
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  align-items: center;
}
.recipe-row:active { transform: scale(0.99); }
.recipe-row .thumb {
  width: 64px; height: 64px; flex: none;
  border-radius: var(--radius-sm);
  background: var(--olive-100);
  display: flex; align-items: center; justify-content: center;
  color: var(--olive-400);
}
.recipe-row .info { flex: 1; min-width: 0; }
.recipe-row h3 {
  font-family: var(--font-display);
  font-size: 14.5px; font-weight: 600; margin: 0 0 3px;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recipe-row .macros { font-size: 11.5px; color: var(--ink-soft); }
.recipe-row .match-badge {
  flex: none;
  background: var(--olive-100);
  color: var(--olive-700);
  font-size: 11px; font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}
.empty-state .emoji { font-size: 34px; margin-bottom: 10px; }
.empty-state h3 { font-family: var(--font-display); color: var(--olive-700); margin: 0 0 6px; }
.empty-state p { font-size: 13.5px; margin: 0; }

/* ---------- Recipe detail ---------- */
.detail-header {
  position: relative;
  background: var(--olive-600);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 54px 20px 20px;
  color: var(--beige-50);
  margin: -1px -20px 0;
}
.detail-header .cat-tag {
  display: inline-block;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  padding: 4px 10px; border-radius: var(--radius-pill);
  margin-bottom: 10px;
}
.detail-header h1 {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 600; line-height: 1.2;
  margin: 0 0 8px;
}
.detail-header .servings { font-size: 12.5px; color: var(--olive-100); }
.detail-back, .detail-fav {
  position: absolute; top: 14px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  color: var(--beige-50);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.detail-back { left: 20px; }
.detail-fav { right: 20px; }
.detail-fav.active { background: var(--beige-50); color: var(--clay-500); }

.macro-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0 4px;
}
.macro-pill {
  background: var(--paper);
  border: 1px solid var(--beige-200);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
}
.macro-pill .val { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--olive-700); }
.macro-pill .lab { font-size: 10px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }

.detail-desc {
  margin: 18px 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.pill-tag {
  font-size: 11.5px; font-weight: 600;
  background: var(--olive-100); color: var(--olive-700);
  padding: 4px 10px; border-radius: var(--radius-pill);
}
.pill-tag.freezer { background: var(--clay-100); color: var(--clay-500); }

.detail-block { margin-top: 24px; }
.detail-block h2 {
  font-family: var(--font-display);
  font-size: 16.5px; font-weight: 600;
  color: var(--olive-700);
  margin: 0 0 12px;
}
.ing-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.ing-list li {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--ink);
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--beige-300);
}
.ing-list li:last-child { border-bottom: none; }
.ing-list li .have-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--beige-300); flex: none;
}
.ing-list li.have .have-dot { background: var(--olive-500); }

.step-list { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step-list li {
  counter-increment: step;
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--beige-200);
  font-size: 14px; line-height: 1.5; color: var(--ink);
}
.step-list li:last-child { border-bottom: none; }
.step-list li::before {
  content: counter(step);
  flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--olive-100); color: var(--olive-700);
  font-weight: 700; font-size: 12.5px;
  display: flex; align-items: center; justify-content: center;
}
.freezer-note {
  background: var(--clay-100);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13.5px;
  color: #7A3F24;
  line-height: 1.5;
  display: flex; gap: 10px;
}

/* ---------- Bonus content list ---------- */
.bonus-card {
  background: var(--paper);
  border: 1px solid var(--beige-200);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.bonus-card .eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--clay-500); font-weight: 700; margin-bottom: 6px;
}
.bonus-card h3 { font-family: var(--font-display); font-size: 16px; margin: 0 0 6px; color: var(--olive-700); }
.bonus-card p { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 10px; line-height: 1.5; }
.bonus-card .link-btn {
  font-size: 13px; font-weight: 600; color: var(--olive-600);
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px;
  background: var(--beige-50);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0;
  background: none; border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 600;
}
.tab-btn.active { color: var(--olive-600); }
.tab-btn svg { width: 22px; height: 22px; }

/* ---------- Install banner ---------- */
.install-banner {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 88px;
  width: calc(100% - 32px); max-width: 528px;
  background: var(--olive-700);
  color: var(--beige-50);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-pop);
  z-index: 40;
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.install-banner p { flex: 1; margin: 0; font-size: 12.5px; line-height: 1.4; }
.install-banner button.primary {
  background: var(--beige-50); color: var(--olive-700);
  border: none; border-radius: var(--radius-pill);
  padding: 8px 14px; font-weight: 700; font-size: 12.5px; cursor: pointer;
}
.install-banner button.dismiss {
  background: none; border: none; color: var(--olive-100);
  font-size: 18px; cursor: pointer; padding: 4px;
}

/* ---------- Misc ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--olive-900); color: var(--beige-50);
  padding: 10px 18px; border-radius: var(--radius-pill);
  font-size: 13px; z-index: 50;
  box-shadow: var(--shadow-pop);
  animation: fadeIn .2s ease;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

@media (min-width: 561px) {
  #app { border-left: 1px solid var(--beige-200); border-right: 1px solid var(--beige-200); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
