/* ============================================================
   Calculadoras — hoja de estilos compartida
   Diseño: "clinical editorial" — papel cálido, serif Fraunces
   para títulos, Public Sans para UI, acento verde-teal.
   Compacto, sobrio, reutilizable en todas las herramientas.
   ============================================================ */

:root {
  --bg:        #F6F4EE;
  --surface:   #FFFFFF;
  --surface-2: #FBFAF6;
  --ink:       #15211C;
  --muted:     #5B6A62;
  --faint:     #8A968F;
  --line:      #E6E1D5;
  --line-soft: #EFEBE1;
  --primary:   #0F7A60;
  --primary-d: #0B5C48;
  --primary-l: #E4F1EC;
  --accent:    #D9633A;
  --ok:        #2F9E68;
  --ok-bg:     #E4F3EA;
  --warn:      #C9942B;
  --warn-bg:   #F7EFD8;
  --bad:       #C2492F;
  --bad-bg:    #F7E3DC;
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(21,33,28,.04), 0 8px 24px -12px rgba(21,33,28,.12);
  --shadow-sm: 0 1px 2px rgba(21,33,28,.05);
  --maxw:      760px;
  --font-d: "Fraunces", Georgia, serif;
  --font-b: "Public Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

/* subtle paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: -1;
  background-image: radial-gradient(rgba(21,33,28,.018) 1px, transparent 1px);
  background-size: 4px 4px;
}

a { color: var(--primary-d); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(246,244,238,.85);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; max-width: var(--maxw); margin: 0 auto;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-d); font-weight: 600; font-size: 1.18rem;
  color: var(--ink); letter-spacing: -.01em; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  display: grid; place-items: center; color: #fff; font-weight: 700;
  font-family: var(--font-b); font-size: .95rem;
}
.brand .mark::after { content: "÷"; font-size: 1.05rem; line-height: 1; }
.brand b { color: var(--primary-d); font-weight: 600; }

/* nav: scroll horizontal en móvil, sin JS */
.site-nav {
  margin-left: auto; min-width: 0;
  display: flex; gap: 4px; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  white-space: nowrap; color: var(--muted); font-size: .9rem;
  font-weight: 500; padding: 7px 11px; border-radius: 8px;
}
.site-nav a:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.site-nav a.active { background: var(--primary-l); color: var(--primary-d); }

/* ---------- Breadcrumb ---------- */
.crumbs { font-size: .82rem; color: var(--faint); padding: 16px 0 0; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 6px; }

/* ---------- Hero / page head ---------- */
.page-head { padding: 22px 0 8px; }
.eyebrow {
  display: inline-block; font-size: .72rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--primary);
  background: var(--primary-l); padding: 4px 9px; border-radius: 6px; margin-bottom: 12px;
}
h1 {
  font-family: var(--font-d); font-weight: 600; letter-spacing: -.02em;
  font-size: clamp(1.7rem, 5vw, 2.5rem); line-height: 1.12; color: var(--ink);
}
.lede { color: var(--muted); font-size: 1.04rem; margin-top: 10px; max-width: 60ch; }

/* ---------- Tool card (calculadora) ---------- */
.tool {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin: 22px 0;
}
.tool h2 { font-family: var(--font-d); font-weight: 600; font-size: 1.15rem; margin-bottom: 4px; }
.tool .hint { color: var(--faint); font-size: .86rem; margin-bottom: 18px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .85rem; font-weight: 600; color: var(--ink); }
.field .sub { font-weight: 400; color: var(--faint); font-size: .78rem; }

input[type="number"], select {
  font-family: var(--font-b); font-size: 1rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
input[type="number"]:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-l); background: #fff;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235B6A62' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}
.input-affix { position: relative; }
.input-affix .unit {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--faint); font-size: .85rem; pointer-events: none;
}
.input-affix input { padding-right: 42px; }

/* segmented control (sexo) */
.segment { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment label {
  flex: 1; text-align: center; font-size: .9rem; font-weight: 600; color: var(--muted);
  padding: 8px 6px; border-radius: 7px; cursor: pointer; transition: all .15s;
}
.segment input:checked + label { background: #fff; color: var(--primary-d); box-shadow: var(--shadow-sm); }

.btn {
  font-family: var(--font-b); font-weight: 600; font-size: 1rem; color: #fff;
  background: var(--primary); border: none; border-radius: var(--radius-sm);
  padding: 13px 20px; width: 100%; cursor: pointer; margin-top: 16px;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-d); }
.btn:active { transform: translateY(1px); }

/* ---------- Resultado ---------- */
.result { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); display: none; }
.result.show { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.result-main {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.result-main .num { font-family: var(--font-d); font-weight: 600; font-size: 2.6rem; line-height: 1; color: var(--primary-d); }
.result-main .num small { font-size: 1rem; color: var(--faint); font-family: var(--font-b); font-weight: 500; }
.tag { display: inline-block; font-size: .8rem; font-weight: 700; padding: 5px 10px; border-radius: 999px; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.result-note { color: var(--muted); font-size: .92rem; margin-top: 10px; }
.result-note b { color: var(--ink); }

/* gauge IMC */
.gauge { margin-top: 16px; }
.gauge-bar { height: 10px; border-radius: 999px; position: relative;
  background: linear-gradient(90deg, #6FAEE0 0 18%, var(--ok) 18% 45%, var(--warn) 45% 64%, var(--bad) 64% 100%); }
.gauge-pin { position: absolute; top: -5px; width: 4px; height: 20px; border-radius: 3px;
  background: var(--ink); transform: translateX(-50%); transition: left .4s ease; box-shadow: 0 0 0 2px #fff; }
.gauge-scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--faint); margin-top: 7px; }

/* mini cards (objetivos calóricos) */
.cards3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 16px; }
.minicard { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; text-align: center; }
.minicard .lbl { font-size: .78rem; color: var(--muted); font-weight: 600; }
.minicard .val { font-family: var(--font-d); font-weight: 600; font-size: 1.45rem; color: var(--ink); margin-top: 3px; }
.minicard .val small { font-family: var(--font-b); font-weight: 500; font-size: .72rem; color: var(--faint); display: block; }
.minicard.featured { background: var(--primary-l); border-color: #BFE0D4; }
.minicard.featured .val { color: var(--primary-d); }

/* ---------- Contenido / prosa ---------- */
.prose { margin: 28px 0; }
.prose h2 { font-family: var(--font-d); font-weight: 600; font-size: 1.45rem; letter-spacing: -.01em; margin: 28px 0 12px; }
.prose h3 { font-size: 1.1rem; font-weight: 700; margin: 22px 0 8px; }
.prose p { color: #2b3631; margin-bottom: 14px; }
.prose ul, .prose ol { margin: 0 0 14px 20px; color: #2b3631; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--ink); }

table.data { width: 100%; border-collapse: collapse; margin: 8px 0 18px; font-size: .92rem; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
table.data thead th { background: var(--surface-2); color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tbody tr:last-child td { border-bottom: none; }

.formula {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 6px 0 18px;
  font-family: var(--font-b); color: var(--ink); font-size: .95rem;
}
.formula code { background: var(--primary-l); padding: 2px 6px; border-radius: 5px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9em; }

/* FAQ (sin JS, <details>) */
.faq details { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.faq summary { cursor: pointer; padding: 15px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--primary); font-weight: 700; font-size: 1.2rem; }
.faq details[open] summary::after { content: "–"; }
.faq details[open] summary { border-bottom: 1px solid var(--line-soft); }
.faq .a { padding: 14px 16px; color: #2b3631; }

/* related / más herramientas */
.related { margin: 30px 0; }
.related h2 { font-family: var(--font-d); font-weight: 600; font-size: 1.3rem; margin-bottom: 14px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; }
.tool-link {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px; transition: border-color .15s, transform .1s, box-shadow .15s;
}
.tool-link:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.tool-link .ic { font-size: 1.3rem; }
.tool-link .t { font-weight: 700; color: var(--ink); margin-top: 8px; }
.tool-link .d { font-size: .85rem; color: var(--muted); margin-top: 3px; }
.tool-link.soon { opacity: .6; pointer-events: none; }
.tool-link .badge { font-size: .68rem; font-weight: 700; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; float: right; }

/* anuncios (placeholder) */
.ad-slot {
  margin: 22px 0; min-height: 90px; display: grid; place-items: center;
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  color: var(--faint); font-size: .78rem; background: var(--surface-2);
}

/* aviso */
.disclaimer { font-size: .82rem; color: var(--faint); background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 12px 14px; margin: 24px 0; }

/* ---------- Hub específico ---------- */
.hub-hero { text-align: center; padding: 40px 0 24px; }
.hub-hero h1 { font-size: clamp(2rem, 6vw, 3rem); }
.hub-hero .lede { margin: 14px auto 0; }
.cat { margin: 8px 0 26px; }
.cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cat-head h2 { font-family: var(--font-d); font-weight: 600; font-size: 1.35rem; }
.cat-head .count { font-size: .78rem; color: var(--faint); background: var(--line-soft); padding: 2px 9px; border-radius: 999px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; background: var(--surface-2); }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px; display: flex; flex-wrap: wrap; gap: 18px 40px; justify-content: space-between; }
.footer-inner .col h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 9px; }
.footer-inner .col a { display: block; color: var(--muted); font-size: .9rem; padding: 3px 0; }
.footer-inner .col a:hover { color: var(--primary-d); }
.footer-bottom { border-top: 1px solid var(--line); text-align: center; padding: 16px; font-size: .82rem; color: var(--faint); }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .cards3 { grid-template-columns: 1fr; }
  .brand span.full { display: none; }
  .result-main .num { font-size: 2.2rem; }
}
