/* CuántosMateriales — hoja de estilos principal
   Paleta: ámbar de obra + gris piedra. Sin dependencias externas. */

:root {
  --brand: #b45309;
  --brand-dark: #92400e;
  --brand-mid: #d97706;
  --brand-light: #fffbeb;
  --brand-border: #fde68a;

  --ink: #1c1917;
  --ink-2: #57534e;
  --ink-3: #78716c;

  --bg: #ffffff;
  --bg-2: #fafaf9;
  --bg-3: #f5f5f4;
  --line: #e7e5e4;
  --line-2: #d6d3d1;

  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;

  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;

  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-ink: #92400e;

  --r: 10px;
  --r-lg: 14px;
  --maxw: 1080px;
  --read: 74ch;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

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

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; margin-top: 2em; }
h3 { font-size: 1.1rem; margin-top: 1.6em; }
p { margin: 0 0 1em; }

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

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--brand); color: #fff;
  padding: 10px 16px; z-index: 100; border-radius: 0 0 var(--r) 0;
}
.skip:focus { left: 0; }

/* ---------- Cabecera ----------
   Escritorio: marca + fila horizontal de secciones.
   Móvil con JS: botón hamburguesa + panel desplegable a pantalla completa.
   Móvil sin JS: la fila se envuelve (nunca queda inaccesible). */
.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 60;
}
.topbar > .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; position: relative; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.06rem; color: var(--ink); letter-spacing: -.02em; flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px; background: var(--brand);
  display: grid; place-items: center; flex: none;
}
.brand-mark span { width: 12px; height: 12px; border: 2px solid #fff; border-radius: 2px; display: block; }
.brand b { color: var(--brand-dark); }

/* --- Botón hamburguesa: solo existe si hay JS y la pantalla es angosta --- */
.nav-toggle {
  display: none; margin-left: auto; padding: 0; flex: none;
  width: 42px; height: 42px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--bg); color: var(--ink); cursor: pointer;
}
.nav-toggle:hover { background: var(--bg-3); }
.nav-toggle:focus-visible { outline: 2px solid var(--brand-mid); outline-offset: 2px; }
.nav-toggle-icon { display: block; position: relative; width: 20px; height: 14px; }
.nav-toggle-icon i {
  position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px;
  background: currentColor; transition: transform .18s ease, opacity .18s ease;
}
.nav-toggle-icon i:nth-child(1) { top: 0; }
.nav-toggle-icon i:nth-child(2) { top: 6px; }
.nav-toggle-icon i:nth-child(3) { top: 12px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon i:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Velo que cubre la página mientras el panel está abierto */
.nav-backdrop {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  height: 100vh; height: 100dvh;
  background: rgba(28, 25, 23, .42); z-index: 1;
}

.nav { margin-left: auto; }
.nav-list { list-style: none; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 0; padding: 0; }
.nav-list a {
  display: block; color: var(--ink-2); font-size: .9rem;
  padding: 7px 11px; border-radius: 7px; white-space: nowrap;
}
.nav-list a:hover { background: var(--bg-3); color: var(--ink); text-decoration: none; }
.nav-list a[aria-current] { color: var(--brand-dark); background: var(--brand-light); font-weight: 600; }

@media (max-width: 899px) {
  .js .nav-toggle { display: inline-flex; }

  /* El panel se ancla al borde inferior de la cabecera y ocupa todo el ancho */
  .js .nav {
    display: none; position: absolute; top: 100%; left: -20px; right: -20px;
    z-index: 2; margin-left: 0;
    padding: 8px 12px 14px;
    background: var(--bg);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 20px 34px -20px rgba(28, 25, 23, .5), 0 1px 3px rgba(28, 25, 23, .1);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .js .nav.is-open { display: block; }
  .js.nav-open .nav-backdrop { display: block; }
  .js.nav-open body { overflow: hidden; }

  .js .nav-list { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 0; }
  .js .nav-list li:not(:last-child) { border-bottom: 1px solid var(--line); }
  .js .nav-list a {
    display: flex; align-items: center; min-height: 48px;
    padding: 11px 14px; font-size: .98rem; border-radius: 8px;
    white-space: normal;
  }
  .js .nav-list a[aria-current] { background: var(--brand-light); box-shadow: inset 3px 0 0 var(--brand); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .nav-toggle-icon i { transition: none; }
}

/* Los enlaces a anclas no deben quedar tapados por la cabecera fija */
[id] { scroll-margin-top: 74px; }

/* ---------- Miga de pan ---------- */
.crumbs { font-size: .82rem; color: var(--ink-3); padding: 14px 0 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.crumbs li::after { content: "/"; margin-left: 6px; color: var(--line-2); }
.crumbs li:last-child::after { content: ""; }
.crumbs a { color: var(--ink-3); }

/* ---------- Hero ---------- */
.hero { padding: 42px 0 30px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--brand-light), var(--bg)); }
.hero h1 { font-size: 2.15rem; max-width: 22ch; }
.hero .lead { font-size: 1.08rem; color: var(--ink-2); max-width: 62ch; margin-bottom: 0; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tag {
  font-size: .8rem; color: var(--brand-dark); background: var(--bg);
  border: 1px solid var(--brand-border); padding: 4px 11px; border-radius: 999px; font-weight: 500;
}

/* ---------- Secciones ---------- */
.section { padding: 40px 0; }
.section > .wrap > h2:first-child { margin-top: 0; }
.sec-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.sec-head h2 { margin: 0; }
.sec-head p { margin: 0; color: var(--ink-2); font-size: .92rem; }

/* ---------- Rejilla de herramientas ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 940px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: block; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; background: var(--bg); color: inherit; transition: border-color .15s, transform .15s;
}
.card:hover { text-decoration: none; border-color: var(--brand-border); transform: translateY(-2px); }
.card h3 { margin: 0 0 6px; font-size: 1.02rem; color: var(--brand-dark); }
.card p { margin: 0; font-size: .89rem; color: var(--ink-2); line-height: 1.55; }
.card .meta { margin-top: 10px; font-size: .77rem; color: var(--ink-3); font-family: var(--mono); }

/* ---------- Panel calculadora ---------- */
.calc {
  border: 1px solid var(--line-2); border-radius: var(--r-lg); overflow: hidden;
  background: var(--bg); margin: 26px 0 8px;
}
.calc-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  background: var(--bg-3); border-bottom: 1px solid var(--line);
  font-size: .88rem; font-weight: 600; color: var(--ink-2);
}
.calc-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-mid); flex: none; }
.calc-body { display: grid; grid-template-columns: 1fr; }
@media (min-width: 840px) { .calc-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.calc-inputs { padding: 20px 18px; border-bottom: 1px solid var(--line); }
@media (min-width: 840px) { .calc-inputs { border-bottom: 0; border-right: 1px solid var(--line); } }

.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: .76rem; color: var(--ink-3); font-weight: 400; display: block; margin-top: 5px; }

.field-group { border: 0; padding: 0; margin: 0 0 15px; }
.field-group legend { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; padding: 0; }
.field-group .hint { font-size: .76rem; color: var(--ink-3); display: block; margin-top: 5px; }

.input, .select {
  width: 100%; padding: 9px 11px; font-family: inherit; font-size: .95rem;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); color: var(--ink);
}
.input:focus, .select:focus { outline: 2px solid var(--brand-mid); outline-offset: -1px; border-color: var(--brand-mid); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: .87rem; color: var(--ink-2); margin-bottom: 11px; }
.check:last-child { margin-bottom: 0; }
.check input { margin: 3px 0 0; width: 16px; height: 16px; flex: none; accent-color: var(--brand); }

.calc-results { padding: 20px 18px; background: var(--bg-2); }
.res-hero {
  background: var(--bg); border: 1px solid var(--ok-border); border-radius: var(--r);
  padding: 15px 16px; margin-bottom: 16px;
}
.res-hero .lbl { font-size: .77rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
.res-hero .val { font-size: 1.85rem; font-weight: 700; color: var(--ok); line-height: 1.15; margin-top: 3px; }
.res-hero .sub { font-size: .84rem; color: var(--ink-2); margin-top: 3px; }

.mat-table { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--bg); }
.mat-table caption { text-align: left; font-size: .77rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding-bottom: 7px; }
.mat-table th, .mat-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.mat-table th { font-size: .78rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.mat-table td:last-child, .mat-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.mat-table tbody tr:last-child td { border-bottom: 0; }
.mat-table .item { font-weight: 600; color: var(--ink); }
.mat-table .note { display: block; font-size: .76rem; color: var(--ink-3); font-weight: 400; }

.calc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn {
  font: inherit; font-size: .87rem; font-weight: 600; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-2); cursor: pointer;
}
.btn:hover { background: var(--bg-3); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

/* ---------- Prosa ---------- */
.prose { max-width: var(--read); }
.prose h2 + p, .prose h3 + p { margin-top: .2em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose strong { font-weight: 650; }

.formula {
  font-family: var(--mono); font-size: .86rem; background: var(--bg-3);
  border-left: 3px solid var(--brand-mid); border-radius: 0 8px 8px 0;
  padding: 12px 15px; margin: 0 0 1.2em; overflow-x: auto; line-height: 1.7;
}

/* ---------- Tablas de datos ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin: 0 0 1.4em; }
.data-table caption { text-align: left; font-size: .82rem; color: var(--ink-3); padding-bottom: 8px; }
.data-table th, .data-table td { padding: 9px 11px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table thead th { background: var(--bg-3); font-size: .8rem; color: var(--ink-2); font-weight: 650; }
.data-table tbody tr:nth-child(even) { background: var(--bg-2); }
.data-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { overflow-x: auto; margin-bottom: 1.4em; }
.table-scroll .data-table { margin-bottom: 0; min-width: 520px; }

/* ---------- Avisos ---------- */
.callout {
  border: 1px solid var(--info-border); background: var(--info-bg);
  border-radius: var(--r); padding: 14px 16px; margin: 0 0 1.4em; font-size: .91rem; color: #1e3a8a;
}
.callout p:last-child { margin-bottom: 0; }
.callout strong { font-weight: 650; }
.callout.warn { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn-ink); }
.callout.ok { border-color: var(--ok-border); background: var(--ok-bg); color: #14532d; }

/* ---------- FAQ ---------- */
.faq { max-width: var(--read); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  cursor: pointer; padding: 14px 30px 14px 0; font-weight: 600; font-size: .97rem;
  list-style: none; position: relative; color: var(--ink);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 4px; top: 12px; font-size: 1.25rem;
  font-weight: 400; color: var(--brand-mid); line-height: 1;
}
.faq details[open] summary::after { content: "\2212"; }
.faq .ans { padding: 0 0 16px; font-size: .93rem; color: var(--ink-2); max-width: 68ch; }
.faq .ans p:last-child { margin-bottom: 0; }

/* ---------- Enlaces relacionados ---------- */
.related { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .related { grid-template-columns: repeat(2, 1fr); } }
.rel {
  display: block; border: 1px solid var(--line); border-left: 3px solid var(--brand-mid);
  border-radius: 8px; padding: 13px 15px; color: inherit; background: var(--bg-2);
}
.rel:hover { text-decoration: none; background: var(--brand-light); border-color: var(--brand-border); border-left-color: var(--brand); }
.rel b { display: block; font-size: .93rem; color: var(--brand-dark); }
.rel span { font-size: .82rem; color: var(--ink-3); }

/* ---------- Espacios publicitarios (marcadores) ---------- */
.slot {
  border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--bg-2);
  padding: 18px; text-align: center; color: var(--ink-3); font-size: .8rem; margin: 28px 0;
}
.slot b { display: block; font-size: .85rem; color: var(--ink-2); font-weight: 600; margin-bottom: 3px; }

/* ---------- Pie ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); margin-top: 50px; padding: 40px 0 26px; font-size: .87rem; }
.foot-grid { display: grid; gap: 26px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .foot-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.site-footer h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--ink-2); }
.foot-note { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 18px; color: var(--ink-3); font-size: .8rem; }
.foot-note p { margin-bottom: .6em; }

/* ---------- Utilidades ---------- */
.updated { font-size: .82rem; color: var(--ink-3); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 34px; }
.updated b { color: var(--ink-2); font-weight: 600; }
.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;
}
main { display: block; }
