/* Recypes — sistema visual alineado con el diseño de Claude Design
   ("Recypes leftovers app design"). Mobile-first; en pantallas anchas la app
   se centra en una columna. */

:root {
  --orange: #FF7A00;
  --orange-soft: #FF8A3D;
  --amber: #FFB000;
  --ink: #1F1F1F;
  --ink-soft: #6B6B6B;
  --ink-faint: #A3A3A3;
  --line: #F3EADC;
  --track: #E8E8E8;
  --cream: #FFF1DC;
  --card: #FFFFFF;
  --safety: #C25E00;
  --pill-used: #FFE794;
  --pill-left: #FFC4C4;

  --bg: linear-gradient(135deg, #FFF8ED, #FFEFD9);
  --g1: linear-gradient(135deg, #FFE794, #FFB000);
  --g2: linear-gradient(135deg, #FFD6A3, #FF8A3D);
  --g3: linear-gradient(135deg, #FFC4C4, #FF6B6B);

  --shadow-card: 0 8px 24px rgba(255, 122, 0, 0.08);
  --shadow-tile: 0 8px 24px rgba(255, 122, 0, 0.15);
  --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-cta: 0 8px 24px rgba(255, 122, 0, 0.35);

  --r-card: 20px;
  --r-btn: 16px;
  --gutter: 24px;
  --app-width: 480px;
  --tabbar-h: 76px;
  --font: "Outfit", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: #FFF8ED; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; color: inherit; }
button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

p, h1, h2, h3, h4 { margin: 0; }

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

[hidden] { display: none !important; }

/* Dentro de la vitrina (iframe) no se muestran barras de scroll, como en un teléfono. */
.embedded, .embedded * { scrollbar-width: none; }
.embedded ::-webkit-scrollbar { display: none; }

.app {
  max-width: var(--app-width);
  margin: 0 auto;
}

main {
  padding: 20px var(--gutter) calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
}

/* ── Header ─────────────────────────────── */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.logo { display: block; line-height: 0; color: inherit; }
.logo-word { height: 30px; width: auto; fill: var(--orange); }

.lang-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}

.lang-btn {
  border: 0;
  cursor: pointer;
  font: 500 12px/16px var(--font);
  padding: 6px 10px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
}

.lang-btn.active { background: var(--orange); color: #fff; }

/* ── Hero ───────────────────────────────── */
.hero-kicker {
  margin-top: 30px;
  font-size: 20px;
  line-height: 28px;
  color: var(--ink-soft);
}

.hero-title {
  margin-top: 4px;
  font-size: 32px;
  line-height: 40px;
  font-weight: 600;
}

/* ── Setup banner (sin API key) ─────────── */
.setup-banner {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--r-card);
  background: var(--cream);
}

.setup-banner h2 { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--safety); }
.setup-banner p { margin-top: 4px; font-size: 14px; line-height: 20px; }
.setup-banner code {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
}

/* ── Composer ───────────────────────────── */
/* Se ve como un campo de una línea (diseño "Original spacing"), pero es un
   textarea que crece al pegar una receta completa (ver autoGrow en app.js). */
.composer-box {
  margin-top: 20px;
  padding: 6px 6px 6px 18px;
  display: flex;
  align-items: center;
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

.composer-box:focus-within { box-shadow: var(--shadow-card), 0 0 0 2px var(--amber); }

#recipeInput {
  flex: 1;
  min-width: 0;
  height: 52px;
  max-height: 220px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 14px 0;
  background: transparent;
  font: 400 16px/24px var(--font);
  color: var(--ink);
}


.example-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.example-tile {
  border: 0;
  cursor: pointer;
  padding: 12px 4px 10px;
  border-radius: var(--r-btn);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font: 500 12px/16px var(--font);
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease;
}

.example-tile:hover { transform: translateY(-2px); }
.example-tile svg { width: 36px; height: 36px; }

.tile-lime   { background: linear-gradient(135deg, #F4FBB0, #B5D334); fill: #6B7F00; }
.tile-orange { background: linear-gradient(135deg, #FFE0B2, #FF9800); fill: #B85F00; }
.tile-green  { background: linear-gradient(135deg, #C8F5D1, #2E7D32); fill: #1B5E20; }
.tile-yellow { background: var(--g1); fill: #A66A00; }

/* ── Buttons ────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  border: 0;
  cursor: pointer;
  padding: 12px;
  border-radius: var(--r-btn);
  font: 500 16px/24px var(--font);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  margin-top: 24px;
  padding: 18px;
  font-weight: 600;
  color: #fff;
  background: var(--orange);
  box-shadow: var(--shadow-cta);
}

.btn-secondary {
  margin-top: 12px;
  padding: 18px;
  color: var(--ink);
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.btn-inline { width: auto; margin-top: 32px; padding: 18px 32px; }

.btn-link {
  margin-top: 12px;
  padding: 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: 500 16px/24px var(--font);
  color: var(--ink-soft);
}

.btn-link:hover { color: var(--orange); }

/* ── Rings (stats + impact) ─────────────── */
.ring { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring-track { stroke: rgba(255, 255, 255, 0.45); }
.ring-fill {
  stroke: #fff;
  stroke-linecap: round;
  stroke-dasharray: 314;
  transition: stroke-dashoffset 0.9s ease;
}

/* ── Stats ──────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  height: 176px;
  padding: 16px;
  border-radius: var(--r-card);
  box-shadow: var(--shadow-tile);
}

.stat-label { max-width: 110px; font-size: 14px; line-height: 20px; font-weight: 500; }
.stat-value { margin-top: 2px; font-size: 28px; line-height: 36px; font-weight: 600; }
.stat-ring { position: absolute; left: -20px; bottom: -24px; width: 112px; height: 112px; }
.stat-pct {
  position: absolute;
  left: 12px;
  bottom: 32px;
  width: 56px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

.grad-1 { background: var(--g1); }
.grad-2 { background: var(--g2); }
.grad-3 { background: var(--g3); }


/* ── Screen headings ────────────────────── */
.screen-title {
  margin-top: 8px;
  font-size: 32px;
  line-height: 40px;
  font-weight: 600;
}

.screen-lede { margin-top: 4px; font-size: 14px; line-height: 20px; color: var(--ink-soft); }

/* ── Recetario ──────────────────────────── */
.pill-row {
  display: flex;
  gap: 8px;
  margin: 20px calc(var(--gutter) * -1) 0;
  padding: 0 var(--gutter) 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.pill-row::-webkit-scrollbar { display: none; }

.pill {
  flex: none;
  border: 0;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 999px;
  font: 500 14px/20px var(--font);
  background: var(--card);
  color: var(--ink-soft);
  box-shadow: var(--shadow-soft);
}

.pill.active { background: var(--orange); color: #fff; }

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
  gap: 12px;
  margin-top: 12px;
}

.library-card {
  border: 0;
  cursor: pointer;
  text-align: left;
  min-height: 176px;
  padding: 16px;
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  color: var(--ink);
  box-shadow: var(--shadow-tile);
  transition: transform 0.15s ease;
}

.library-card:hover { transform: translateY(-2px); }
.library-card:nth-child(4n + 1) { background: var(--g1); }
.library-card:nth-child(4n + 2),
.library-card:nth-child(4n) { background: var(--g2); }
.library-card:nth-child(4n + 3) { background: var(--g3); }

.lib-cat { font-size: 12px; line-height: 16px; font-weight: 500; }
.library-card h3 { margin-top: 4px; font-size: 20px; line-height: 28px; font-weight: 600; }
.lib-label { font-size: 12px; line-height: 16px; }
.lib-label.first { margin-top: auto; padding-top: 12px; }
.lib-label + .lib-value + .lib-label { margin-top: 6px; }
.lib-value { font-size: 14px; line-height: 20px; font-weight: 500; }

/* ── Estados: carga / error ─────────────── */
.state-screen {
  min-height: calc(100vh - var(--tabbar-h) - 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 16px;
}

.big-spinner {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 12px solid var(--track);
  border-top-color: var(--amber);
  border-right-color: var(--amber);
  animation: spin 1.1s linear infinite;
}

.state-title { margin-top: 32px; font-size: 24px; line-height: 32px; font-weight: 600; overflow-wrap: anywhere; }
.state-body { margin-top: 8px; font-size: 16px; line-height: 24px; color: var(--ink-soft); }
.pulse { font-size: 14px; line-height: 20px; animation: pulse 1.6s infinite; }

.error-mark {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background: var(--g3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 600;
}

.error-mark + .state-title { margin-top: 24px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ── Resultados ─────────────────────────── */
.results-bar {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink-soft);
}

.back-btn {
  width: 44px;
  height: 44px;
  border: 0;
  cursor: pointer;
  border-radius: var(--r-btn);
  background: var(--card);
  font: 500 20px var(--font);
  box-shadow: var(--shadow-soft);
}

.results-head h2 { margin-top: 20px; font-size: 32px; line-height: 40px; font-weight: 600; }
.results-head p { margin-top: 4px; color: var(--ink-soft); }
.results-head .stale-note {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--cream);
  font-size: 14px;
  line-height: 20px;
  color: var(--ink);
}

.section-title { margin-top: 32px; font-size: 20px; line-height: 28px; font-weight: 600; }

.ingredients-card {
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

.ing-row { padding: 12px 0; }
.ing-row + .ing-row { border-top: 1px solid var(--line); }
.ing-name { font-weight: 500; }

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.tag {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 16px;
}

.tag-used { background: var(--pill-used); }
.tag-left { background: var(--pill-left); }
.tag-clean, .tag-life { background: var(--g1); }

.safety {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--cream);
  font-size: 14px;
  line-height: 20px;
}

.safety b { font-weight: 600; color: var(--safety); }

.leftover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
  gap: 12px;
  margin-top: 12px;
}

.leftover-card {
  padding: 16px;
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

.leftover-card h4 { font-size: 16px; line-height: 24px; font-weight: 600; }
.leftover-card .tag { display: inline-block; margin-top: 8px; }
.leftover-card p { margin-top: 8px; font-size: 14px; line-height: 20px; color: var(--ink-soft); }

/* ¿Te sobró algo más? — restos de envase para rehacer los platos */
.extras-card {
  margin-top: 32px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

.extras-title { font-size: 20px; line-height: 28px; font-weight: 600; }
.extras-lede { margin-top: 4px; font-size: 14px; line-height: 20px; color: var(--ink-soft); }

.extras-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.extras-chips:empty { display: none; }
.extra-chip { flex: 0 1 auto; max-width: 100%; text-align: left; background: var(--cream); box-shadow: none; }
.extra-chip.active { background: var(--orange); color: #fff; }

.extras-add {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 4px 4px 4px 16px;
  border-radius: var(--r-btn);
  background: var(--cream);
}

.extras-add:focus-within { box-shadow: 0 0 0 2px var(--amber); }

.extras-add input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 10px 0;
  background: transparent;
  font: 400 14px/20px var(--font);
  color: var(--ink);
}

.extras-add-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  background: var(--card);
  font: 500 20px/1 var(--font);
  box-shadow: var(--shadow-soft);
}

.extras-card .btn-primary { margin-top: 16px; }

.extras-status { margin-top: 8px; font-size: 14px; line-height: 20px; color: var(--ink-soft); }
.extras-status:empty { display: none; }
.extras-status.error { color: var(--safety); }

.dish-area { scroll-margin-top: 16px; transition: opacity 0.2s ease; }
.dish-area.is-loading { opacity: 0.4; pointer-events: none; }
.remix-tag { margin-left: 8px; vertical-align: middle; font-weight: 500; }

.dish-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

.dish-card {
  overflow: hidden;
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

.dish-toggle {
  width: 100%;
  border: 0;
  cursor: pointer;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  text-align: left;
}

.dish-num {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: var(--r-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
}

.dish-card:nth-child(3n + 1) .dish-num { background: var(--g1); }
.dish-card:nth-child(3n + 2) .dish-num { background: var(--g2); }
.dish-card:nth-child(3n) .dish-num { background: var(--g3); }

.dish-text { flex: 1; min-width: 0; }
.dish-text h4 { font-size: 16px; line-height: 24px; font-weight: 600; }
.dish-text h4::first-letter { text-transform: uppercase; }
.dish-meta { font-size: 14px; line-height: 20px; color: var(--ink-soft); }

.dish-chevron {
  flex: none;
  font-size: 20px;
  color: var(--ink-soft);
  transition: transform 0.2s ease;
}

.dish-card.open .dish-chevron { transform: rotate(180deg); }

.dish-body { padding: 0 16px 16px; font-size: 14px; line-height: 20px; }
.dish-card:not(.open) .dish-body { display: none; }
.dish-desc { margin-bottom: 8px; }
.dish-main { margin-bottom: 8px; color: var(--ink-soft); }

.dish-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }

.dish-steps li {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  counter-increment: step;
}

.dish-steps li::before {
  content: counter(step);
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cream);
  text-align: center;
  font-size: 12px;
  line-height: 24px;
  font-weight: 600;
}

.impact-card {
  margin-top: 32px;
  padding: 24px;
  border-radius: 24px;
  background: var(--g2);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.impact-copy { flex: 1 1 120px; min-width: 0; }

.impact-ring { position: relative; flex: none; width: 96px; height: 96px; }
.impact-ring .ring { width: 96px; height: 96px; }
.impact-ring .ring-track { stroke: rgba(255, 255, 255, 0.6); }

.impact-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.impact-ring-label strong { font-size: 20px; line-height: 24px; font-weight: 600; }
.impact-ring-label span { font-size: 12px; line-height: 14px; }

.impact-kicker { font-size: 12px; line-height: 16px; }
.impact-value { font-size: 28px; line-height: 36px; font-weight: 600; overflow-wrap: anywhere; }
.impact-unit { font-size: 14px; line-height: 20px; }

.impact-quote {
  margin: 16px 4px 0;
  font-style: italic;
  color: var(--ink-soft);
}

/* ── Tab bar ────────────────────────────── */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-width);
  display: flex;
  justify-content: space-around;
  padding: 12px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  background: var(--card);
  box-shadow: 0 -8px 24px rgba(255, 122, 0, 0.06);
  z-index: 10;
}

.tab {
  border: 0;
  cursor: pointer;
  background: transparent;
  min-width: 64px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font: 500 12px/16px var(--font);
  color: var(--ink-faint);
  fill: var(--ink-faint);
}

.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--orange-soft); fill: var(--orange-soft); }

/* En pantallas anchas la barra flota como una tarjeta */
@media (min-width: 560px) {
  main { padding-top: 32px; }
  .tabbar {
    bottom: 16px;
    width: calc(100% - 32px);
    max-width: calc(var(--app-width) - 32px);
    padding-bottom: 12px;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(255, 122, 0, 0.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
  .big-spinner { animation: spin 3s linear infinite !important; }
}
