/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #faf9f6;
  --bg-muted: #f1efe9;
  --surface: #ffffff;
  --ink: #16201d;
  --ink-soft: #4b564f;
  --ink-faint: #7c887f;
  --border: #e4e1d8;
  --border-strong: #d3cfc2;

  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ef;
  --accent-strong: #0b5951;

  --deficit: #2563a8;
  --deficit-soft: #e8f0fb;
  --surplus: #c2670f;
  --surplus-soft: #fbf0e2;

  --error: #c23b3b;

  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Sora", var(--sans);
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

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

  --shadow-sm: 0 1px 2px rgba(22, 32, 29, 0.06), 0 1px 1px rgba(22, 32, 29, 0.04);
  --shadow-md: 0 8px 24px -8px rgba(22, 32, 29, 0.16);
  --shadow-lg: 0 24px 60px -20px rgba(22, 32, 29, 0.28);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --container: 1120px;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.1; font-family: var(--display); letter-spacing: -0.01em; }
ul { padding-left: 1.2em; }
::selection { background: var(--accent-soft); color: var(--accent-strong); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* =============================================================
   3. Utilities
   ============================================================= */
.container { max-width: var(--container); margin-inline: auto; padding-inline: 1.25rem; }

.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;
}

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg);
  z-index: 9999; border-radius: 8px; font-weight: 600;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); }
[data-reveal].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* =============================================================
   4. Buttons
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem; padding: .9rem 1.4rem; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 1rem; transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
}
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--bg-muted); color: var(--ink);
}
.btn-secondary:hover { background: var(--border); }

/* =============================================================
   5. Header / footer
   ============================================================= */
.site-header { padding-block: 1.1rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); flex-shrink: 0; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.site-header-tag { font-size: .85rem; color: var(--ink-faint); display: none; margin-right: auto; margin-left: 1.5rem; }
@media (min-width: 540px) { .site-header-tag { display: block; } }

.lang-switcher-wrap { display: block; }
.lang-switcher {
  padding: .45rem .6rem; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg); font-family: var(--sans); font-weight: 700; font-size: .82rem;
  color: var(--ink); letter-spacing: .02em;
}
.lang-switcher:focus { outline: none; border-color: var(--accent); }

.site-footer { border-top: 1px solid var(--border); background: var(--bg-muted); padding-block: 2.5rem 1.5rem; margin-top: 4rem; }
.site-footer-inner { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; justify-content: space-between; }
.site-footer-tagline { max-width: 46ch; color: var(--ink-soft); font-size: .92rem; margin-top: .4rem; }
.site-footer-links { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.site-footer-links a { color: var(--ink-soft); font-weight: 600; font-size: .92rem; }
.site-footer-links a:hover { color: var(--accent); }
.site-footer-copy { margin-top: 2rem; font-size: .8rem; color: var(--ink-faint); }

/* =============================================================
   6. Hero + tool card
   ============================================================= */
.hero { padding-block: 2.5rem 1.5rem; }
.hero-title { font-size: clamp(1.9rem, 4.4vw, 2.75rem); max-width: 20ch; }
.hero-subtitle { margin-top: .9rem; max-width: 62ch; color: var(--ink-soft); font-size: 1.05rem; }

.tool-card {
  margin-top: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: var(--shadow-md);
}

.field-group { border: 0; padding: 0; margin-bottom: 1.1rem; }
.field-group legend { font-weight: 700; font-size: .9rem; margin-bottom: .5rem; padding: 0; }

.sex-toggle { display: flex; gap: .6rem; }
.sex-option {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: .75rem 1rem; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer; transition: all .15s var(--ease-out);
}
.sex-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sex-option.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.sex-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.field-grid { display: grid; grid-template-columns: 1fr; gap: 1.1rem; }
@media (min-width: 540px) { .field-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 720px) { .field-grid { grid-template-columns: 1fr 1fr 1fr; } }
.field--wide { grid-column: 1 / -1; }

.field label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .4rem; }
.field-optional { font-weight: 500; color: var(--ink-faint); }

.field-input {
  display: flex; align-items: center;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color .15s var(--ease-out);
}
.field-input:focus-within { border-color: var(--accent); }
.field-input input {
  flex: 1; min-width: 0; border: 0; background: none; padding: .8rem .9rem;
  font-size: 1rem; font-family: var(--mono); color: var(--ink);
}
.field-input input:focus { outline: none; }
.field-unit { padding-inline: .9rem; color: var(--ink-faint); font-size: .88rem; font-weight: 600; }

.field-unit-select {
  flex-shrink: 0; align-self: stretch; display: flex; align-items: center;
  border: 0; border-left: 1px solid var(--border-strong);
  background: transparent; color: var(--ink-faint); font-family: var(--sans);
  font-weight: 600; font-size: .85rem; letter-spacing: .01em;
  padding: 0 1.7rem 0 .85rem; margin: 0;
  cursor: pointer; appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%237c887f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center; background-size: 12px;
  transition: color .15s var(--ease-out), background-color .15s var(--ease-out);
}
.field-unit-select:hover { color: var(--accent-strong); background-color: var(--accent-soft); }
.field-unit-select:focus { outline: none; color: var(--accent-strong); background-color: var(--accent-soft); }

.field-input--height { flex-wrap: nowrap; }
.field-height-part {
  flex: 0 1 2.6rem; min-width: 0; width: 2.6rem; text-align: center;
  border: 0; background: none; padding: .8rem 0; font-size: 1rem;
  font-family: var(--mono); color: var(--ink);
}
.field-height-part:focus { outline: none; }
.field-height-sep { color: var(--ink-faint); font-weight: 600; font-size: .95rem; }

select#activity {
  width: 100%; padding: .8rem .9rem; border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg); font-size: .96rem; color: var(--ink);
  font-family: var(--sans); font-weight: 500;
}
select#activity:focus { outline: none; border-color: var(--accent); }

.field-hint { margin-top: .45rem; font-size: .83rem; color: var(--ink-faint); }

input[aria-invalid="true"], .field-input:has(input[aria-invalid="true"]) { border-color: var(--error); }

#calc-btn { margin-top: 1.6rem; font-size: 1.05rem; padding-block: 1.05rem; }

.privacy-badge { margin-top: 1rem; font-size: .82rem; color: var(--ink-faint); text-align: center; }

/* =============================================================
   7. Resultado
   ============================================================= */
.result { margin-top: 2rem; opacity: 0; transform: translateY(14px); transition: opacity .5s var(--ease-out), transform .5s var(--ease-out); }
.result.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .result { transition: none; } }

.formula-badge {
  display: flex; gap: .85rem; align-items: flex-start;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius-md); padding: 1.1rem 1.25rem;
}
.formula-badge-icon { width: 22px; height: 22px; color: var(--accent-strong); flex-shrink: 0; margin-top: .15rem; }
.formula-badge-title { font-weight: 700; color: var(--accent-strong); }
.formula-badge-reason { margin-top: .3rem; color: var(--ink-soft); font-size: .92rem; }

.stat-row { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1.25rem; }
@media (min-width: 640px) { .stat-row { grid-template-columns: 1fr 1fr; } }

.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 1.4rem 1.5rem;
}
.stat-card--accent { background: var(--ink); border-color: var(--ink); color: #fff; }
.stat-label { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-faint); }
.stat-card--accent .stat-label { color: rgba(255,255,255,.65); }
.stat-value { margin-top: .35rem; font-family: var(--mono); font-weight: 700; font-size: clamp(2.1rem, 5vw, 2.7rem); display: flex; align-items: baseline; gap: .4rem; }
.stat-unit { font-size: .95rem; font-weight: 600; color: var(--ink-faint); }
.stat-card--accent .stat-unit { color: rgba(255,255,255,.7); }
.stat-note { margin-top: .5rem; font-size: .85rem; color: var(--ink-soft); }
.stat-card--accent .stat-note { color: rgba(255,255,255,.75); }

.formula-chips { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.1rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--border-strong);
  font-size: .82rem; font-weight: 600; color: var(--ink-soft); background: var(--surface);
}
.chip--primary { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.chip-check { width: 14px; height: 14px; }
.chip-val { font-family: var(--mono); }

/* Ad slots */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: repeating-linear-gradient(135deg, var(--bg-muted), var(--bg-muted) 10px, var(--bg) 10px, var(--bg) 20px);
  color: var(--ink-faint); font-weight: 700; letter-spacing: .08em; font-size: .8rem;
}
.ad-slot-label::before { content: "📢 "; }
.ad-slot--banner { min-height: 90px; margin-top: 1.5rem; }
.ad-slot--incontent { min-height: 250px; margin-block: 1rem; }
.ad-slot--popup { min-height: 200px; margin-block: 1rem; }
.ad-slot--corner { min-height: 100px; }

.goals-title { margin-top: 2.5rem; font-size: clamp(1.4rem, 3vw, 1.8rem); }
.goals-subtitle { margin-top: .4rem; color: var(--ink-soft); }

.goals-grid { margin-top: 1.25rem; display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .goals-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .goals-grid { grid-template-columns: repeat(3, 1fr); } }

.goal-card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem; display: flex; flex-direction: column; gap: .6rem;
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.goal-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.goal-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.goal-label { font-size: 1rem; }
.goal-badge { font-family: var(--mono); font-weight: 700; font-size: .8rem; padding: .25rem .55rem; border-radius: 999px; background: var(--bg-muted); }

.goal-card--deficit { border-color: var(--deficit); background: var(--deficit-soft); }
.goal-card--deficit .goal-badge { background: rgba(37,99,168,.12); color: var(--deficit); }
.goal-card--surplus { border-color: var(--surplus); background: var(--surplus-soft); }
.goal-card--surplus .goal-badge { background: rgba(194,103,15,.14); color: var(--surplus); }
.goal-card--maintenance {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: var(--shadow-md);
}
.goal-card--maintenance .goal-badge { background: rgba(15,118,110,.14); color: var(--accent-strong); }
@media (min-width: 1024px) { .goal-card--maintenance { order: 0; } }

.goal-kcal { display: flex; align-items: baseline; gap: .35rem; }
.goal-kcal-num { font-family: var(--mono); font-weight: 800; font-size: 1.7rem; }
.goal-kcal-unit { font-size: .82rem; color: var(--ink-faint); font-weight: 600; }

.goal-stats { display: flex; gap: 1.2rem; padding-block: .5rem; border-top: 1px dashed var(--border-strong); border-bottom: 1px dashed var(--border-strong); }
.goal-stats > div { display: flex; flex-direction: column; gap: .1rem; }
.goal-stat-label { font-size: .74rem; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.goal-stat-val { font-family: var(--mono); font-weight: 700; font-size: .95rem; }

.goal-desc { font-size: .85rem; color: var(--ink-soft); }

.goals-disclaimer { margin-top: 1.4rem; font-size: .78rem; color: var(--ink-faint); max-width: 76ch; }

/* =============================================================
   8. Secciones de contenido
   ============================================================= */
.section { padding-block: 3rem; }
.section--muted { background: var(--bg-muted); border-radius: var(--radius-lg); }
.section-title { font-size: clamp(1.5rem, 3.2vw, 2rem); text-align: center; margin-bottom: 2rem; }

.steps-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; position: relative; }
.step-number {
  position: absolute; top: -12px; left: 1.4rem; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800; font-family: var(--display);
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.step-icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: .8rem; margin-top: .6rem; }
.step-card h3 { font-size: 1.1rem; margin-bottom: .4rem; }
.step-card p { color: var(--ink-soft); font-size: .92rem; }

.audience-grid { display: grid; grid-template-columns: 1fr; gap: 1.1rem; }
@media (min-width: 640px) { .audience-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .audience-grid { grid-template-columns: repeat(4, 1fr); } }
.audience-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.4rem; }
.audience-icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: .8rem; }
.audience-card h3 { font-size: 1.02rem; margin-bottom: .4rem; }
.audience-card p { color: var(--ink-soft); font-size: .88rem; }

.prose { max-width: 74ch; margin-inline: auto; }
.prose p { margin-bottom: 1rem; color: var(--ink-soft); }
.prose ul { margin-bottom: 1rem; }
.prose li { margin-bottom: .55rem; color: var(--ink-soft); }
.prose strong { color: var(--ink); }

.faq-list { max-width: 74ch; margin-inline: auto; display: flex; flex-direction: column; gap: .7rem; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .3rem 1.1rem; }
.faq-item summary {
  padding-block: .95rem; font-weight: 700; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; font-size: 1.3rem; color: var(--accent); flex-shrink: 0; font-weight: 400;
  transition: transform .2s var(--ease-out);
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding-bottom: 1rem; color: var(--ink-soft); font-size: .93rem; }

/* =============================================================
   9. Anuncios: popup y esquina
   ============================================================= */
.ad-popup {
  border: 0; border-radius: var(--radius-lg); padding: 1.5rem;
  max-width: 380px; width: calc(100% - 2.5rem); box-shadow: var(--shadow-lg);
  background: var(--surface);
}
.ad-popup::backdrop { background: rgba(22, 32, 29, 0.55); backdrop-filter: blur(2px); }
.ad-popup-close {
  position: absolute; top: .7rem; right: .7rem; width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-muted); font-size: 1.3rem; display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
}
.ad-popup-close:hover { background: var(--border); }
.ad-popup .btn { margin-top: .8rem; }

.ad-corner {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 40;
  width: min(260px, calc(100vw - 2rem));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: .9rem;
  opacity: 0; transform: translateY(16px); transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.ad-corner.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .ad-corner { transition: none; } }
.ad-corner-close {
  position: absolute; top: .45rem; right: .45rem; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-muted); font-size: 1rem; display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
}
.ad-corner-close:hover { background: var(--border); }

/* =============================================================
   10. Aviso de cookies
   ============================================================= */
.cookie-banner {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 60;
  max-width: 760px; margin-inline: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 1.1rem 1.25rem;
  display: flex; flex-direction: column; gap: 1rem;
  opacity: 0; transform: translateY(16px); transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.cookie-banner[hidden] { display: none; }
.cookie-banner.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .cookie-banner { transition: none; } }
.cookie-banner-text { font-size: .88rem; color: var(--ink-soft); }
.cookie-banner-text a { color: var(--accent); font-weight: 600; text-decoration: underline; }
.cookie-banner-actions { display: flex; gap: .7rem; flex-wrap: wrap; }
.cookie-banner-actions .btn { flex: 1 1 auto; white-space: nowrap; padding-block: .7rem; font-size: .9rem; }
@media (min-width: 540px) { .cookie-banner { flex-direction: row; align-items: center; } .cookie-banner-actions { flex-shrink: 0; } }

/* =============================================================
   11. Responsive misc
   ============================================================= */
@media (max-width: 539px) {
  .site-footer-inner { flex-direction: column; }
}
