/* NUTRIA — base, layout y componentes */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 3px solid var(--apricot); outline-offset: 2px; border-radius: 8px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--forest); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 100; }
.skip:focus { top: 12px; }

/* ── Layout ── */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100dvh; padding: 28px 18px 20px; display: flex; flex-direction: column; gap: 28px;
  background: var(--paper); border-right: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 4px; }
.brand-mark { width: 44px; height: 44px; color: var(--forest); }
.brand-name { font-weight: 700; letter-spacing: .22em; font-size: 22px; color: var(--forest); padding-left: .22em; }
.brand-tag { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; font-size: 15px;
  transition: background-color var(--t-micro) ease, color var(--t-micro) ease;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a[aria-current="page"] { background: var(--forest); color: #fff; }
@media (hover: hover) and (pointer: fine) { .nav a:not([aria-current="page"]):hover { background: var(--paper-2); } }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.side-quote { background: var(--paper-2); border-radius: var(--r-md); padding: 18px 16px; text-align: center; color: var(--ink-2); font-size: 14px; }
.side-quote svg { width: 26px; height: 26px; margin: 0 auto 8px; color: var(--forest); }
.ai-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.ai-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 3px rgba(111, 160, 90, .2); }

.main { min-width: 0; padding: 28px 32px 120px; max-width: 1320px; width: 100%; margin: 0 auto; }
.view { animation: view-in var(--t-ui) var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.tabbar { display: none; }

/* ── Tipografía ── */
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--apricot-ink); }
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em; line-height: 1.02; }
.h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(36px, 4.4vw, 56px); line-height: 1.02; letter-spacing: -.01em; }
.h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: var(--r-pill);
  font-weight: 600; font-size: 15px; white-space: nowrap; user-select: none;
  transition: transform var(--t-micro) var(--ease-out), background-color var(--t-micro) ease, box-shadow var(--t-micro) ease, color var(--t-micro) ease;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--forest); color: #fff; box-shadow: 0 6px 18px rgba(31, 61, 43, .22); }
.btn-soft { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost { color: var(--forest); }
.btn-accent { background: var(--apricot); color: #1F1208; }
.btn-danger { background: #F6E1DF; color: #8A2A22; }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 16px; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--forest-2); }
  .btn-soft:hover { background: var(--paper-2); }
  .btn-ghost:hover { background: var(--mint); }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--paper); border: 1px solid var(--line); font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
  transition: background-color var(--t-micro) ease, color var(--t-micro) ease, border-color var(--t-micro) ease, transform var(--t-micro) var(--ease-out);
}
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"], .chip.on { background: var(--forest); color: #fff; border-color: var(--forest); }
.chip svg { width: 16px; height: 16px; }
.chip-x { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .08); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; background: var(--mint); color: var(--forest); }
.tag.warm { background: var(--apricot-soft); color: var(--apricot-ink); }
.tag.plain { background: var(--paper-2); color: var(--ink-2); }

/* ── Tarjetas ── */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.pad { padding: 22px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 24px; } .gap-6 { gap: 32px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.section { margin-top: 40px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }

/* Imagen de receta (foto o ilustración) */
.rimg { position: relative; overflow: hidden; background: var(--paper-2); }
.rimg > img, .rimg > svg { width: 100%; height: 100%; object-fit: cover; }
.rimg .art-note { position: absolute; left: 10px; bottom: 10px; font-size: 11px; background: rgba(251, 250, 246, .85); padding: 2px 8px; border-radius: 99px; color: var(--muted); backdrop-filter: blur(6px); }

/* RecipeCard */
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 18px; }
.rcard {
  position: relative; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; box-shadow: var(--shadow-1); transition: box-shadow var(--t-ui) var(--ease-out), transform var(--t-ui) var(--ease-out);
}
.rcard .rimg { aspect-ratio: 4 / 3; }
.rcard .rimg > * { transition: transform 700ms var(--ease-out); }
.rcard .over {
  position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: flex-end; padding: 12px;
  background: linear-gradient(to top, rgba(15, 30, 20, .45), rgba(15, 30, 20, 0) 55%); opacity: 0; transition: opacity var(--t-ui) ease;
}
.rcard .over span { background: #fff; color: var(--forest); font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 99px; transform: translateY(6px); transition: transform var(--t-ui) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .rcard:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
  .rcard:hover .rimg > img, .rcard:hover .rimg > svg { transform: scale(1.05); }
  .rcard:hover .over { opacity: 1; }
  .rcard:hover .over span { transform: none; }
}
.rcard .body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; flex: 1; }
.rcard .name { font-weight: 700; font-size: 16px; line-height: 1.25; }
.rcard .desc { font-size: 13px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard .meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: auto; padding-top: 6px; }
.meta-i { display: inline-flex; align-items: center; gap: 5px; }
.meta-i svg { width: 15px; height: 15px; }
.rcard .badge { position: absolute; left: 10px; top: 10px; z-index: 2; }
.rcard .why { font-size: 12px; color: var(--forest-3); font-weight: 600; }
.rcard-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.fav {
  position: absolute; right: 10px; top: 10px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(251, 250, 246, .92); color: var(--ink-2); backdrop-filter: blur(8px); transition: transform var(--t-micro) var(--ease-out), color var(--t-micro) ease;
}
.fav svg { width: 19px; height: 19px; }
.fav:active { transform: scale(.9); }
.fav[aria-pressed="true"] { color: var(--berry); }
.fav[aria-pressed="true"] svg { animation: pop 380ms var(--ease-out); fill: currentColor; }
@keyframes pop { 40% { transform: scale(1.25); } }

/* Carrusel */
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 280px); gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 12px; scrollbar-width: thin; }
.rail > * { scroll-snap-align: start; }

/* Nutrición */
.ncard { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.nbox { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 6px; text-align: center; }
.nbox b { display: block; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.nbox span { font-size: 11.5px; color: var(--muted); }
.nnote { font-size: 12px; color: var(--muted-2); margin-top: 8px; }

/* Reveal escalonado */
.reveal > * { animation: rise 520ms var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 8) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; align-items: center; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--forest); color: #fff; padding: 12px 18px; border-radius: 99px;
  box-shadow: var(--shadow-3); font-size: 14px; font-weight: 500; transition: opacity var(--t-ui) var(--ease-out), transform var(--t-ui) var(--ease-out);
}
.toast svg { width: 18px; height: 18px; color: #BFE3B0; }
.toast.enter { opacity: 0; transform: translateY(14px) scale(.97); }
.toast.leave { opacity: 0; transform: translateY(8px); }
.toast button { color: #FFD7BD; font-weight: 700; margin-left: 4px; }

/* Hoja inferior / modal */
.scrim { position: fixed; inset: 0; background: rgba(12, 22, 16, .38); z-index: 60; opacity: 0; transition: opacity var(--t-ui) ease; backdrop-filter: blur(2px); }
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 50%; bottom: 0; width: min(560px, 100%); max-height: 88dvh; overflow: auto; z-index: 61; background: var(--paper);
  border-radius: 28px 28px 0 0; padding: 10px 22px calc(24px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-3);
  transform: translate(-50%, 100%); transition: transform 420ms var(--ease-drawer);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 4px auto 14px; }
@media (min-width: 900px) {
  .sheet { bottom: auto; top: 50%; border-radius: 28px; transform: translate(-50%, -46%) scale(.97); opacity: 0; transition: transform var(--t-ui) var(--ease-out), opacity var(--t-ui) var(--ease-out); padding-bottom: 24px; }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { display: none; }
}
.opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--paper); transition: background-color var(--t-micro) ease; }
.opt + .opt { margin-top: 8px; }
@media (hover: hover) and (pointer: fine) { .opt:hover { background: var(--paper-2); } }
.opt svg { width: 20px; height: 20px; color: var(--forest); flex: none; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input {
  min-height: 48px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: #fff; outline: none;
  transition: border-color var(--t-micro) ease, box-shadow var(--t-micro) ease;
}
.input:focus { border-color: var(--forest-3); box-shadow: 0 0 0 4px rgba(59, 107, 76, .15); }
.search { position: relative; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--muted); }
.search .input { padding-left: 46px; width: 100%; border-radius: var(--r-pill); background: var(--paper); }
.seg { display: inline-flex; background: var(--paper-2); border-radius: 99px; padding: 4px; gap: 2px; }
.seg button { padding: 8px 14px; border-radius: 99px; font-size: 14px; font-weight: 600; color: var(--muted); transition: background-color var(--t-micro) ease, color var(--t-micro) ease; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-1); }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--paper-2); border-radius: 99px; padding: 4px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; background: var(--paper); font-weight: 700; }
.stepper output { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type=range] { accent-color: var(--forest); width: 100%; }
.switch { position: relative; width: 48px; height: 28px; border-radius: 99px; background: var(--line-2); transition: background-color var(--t-micro) ease; flex: none; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--t-ui) var(--ease-out); }
.switch[aria-checked="true"] { background: var(--forest); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Skeleton y estados de generación */
.skel { background: linear-gradient(90deg, var(--paper-2) 0%, #F7F4EC 50%, var(--paper-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.gen { display: flex; flex-direction: column; gap: 10px; }
.gen-step { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); opacity: .45; transition: opacity var(--t-ui) ease, color var(--t-ui) ease; }
.gen-step.on { opacity: 1; color: var(--ink); }
.gen-step.done { opacity: .8; }
.gen-step i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; display: grid; place-items: center; }
.gen-step.on i { border-color: var(--forest); border-top-color: transparent; animation: spin .8s linear infinite; }
.gen-step.done i { border-color: var(--ok); background: var(--ok); animation: none; }
.gen-step.done i::after { content: ''; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; margin: 0 auto 14px; color: var(--forest-3); }
.empty h3 { color: var(--ink); font-size: 18px; margin-bottom: 6px; }

.progress { height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--forest); border-radius: inherit; transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 700ms var(--ease-out); }
.progress.warm i { background: var(--apricot); }

/* ── Responsive ── */
@media (max-width: 1080px) { :root { --side-w: 212px; } .main { padding: 24px 22px 120px; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 18px 16px calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom); background: rgba(251, 250, 246, .94); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar [aria-current="page"] { color: var(--forest); }
  .tabbar .fab { position: relative; top: -16px; width: 60px; height: 60px; margin: 0 auto; border-radius: 50%; background: var(--forest); color: #fff; box-shadow: 0 10px 24px rgba(31, 61, 43, .35); }
  .tabbar .fab svg { width: 28px; height: 28px; }
  .toasts { bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); }
  .rgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .rcard .body { padding: 10px 12px 12px; }
  .rcard .name { font-size: 14.5px; }
  .rcard .desc { display: none; }
  .ncard { gap: 6px; }
  .nbox b { font-size: 16px; }
  .section { margin-top: 30px; }
}
@media (max-width: 380px) { .rgrid { grid-template-columns: 1fr; } }

/* Menos movimiento, no cero: se conservan los fundidos que ayudan a entender; se quita el desplazamiento. */
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .view, .reveal > *, .msg, .step-in { animation-name: fade !important; }
  .rcard, .btn, .chip, .fav, .toast, .rcard .rimg > * { transition-property: opacity, background-color, color, box-shadow !important; }
  .rcard:hover { transform: none !important; }
  .sheet { transition: opacity var(--t-ui) ease !important; }
  .skel { animation: none; }
  html { scroll-behavior: auto; }
}
