:root {
  color-scheme: light dark;
  --bg: #fbfaf8;
  --surface: #ffffff;
  --border: #e6e2db;
  --text: #1b1a17;
  --muted: #6b665d;
  --accent: #c8501e;
  --accent-soft: #fdf2ec;
  --radius: 12px;
  --measure: 48rem;   /* ancho del texto: ~80 caracteres por línea */
  --wide: 58rem;      /* imágenes, tablas y widgets se salen un poco */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --surface: #1d1c17;
    --border: #33302a;
    --text: #f0ede6;
    --muted: #a39d92;
    --accent: #ff7a45;
    --accent-soft: #2a1d15;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.page { max-width: 68rem; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }

.hero { text-align: center; padding: 2rem 0 3rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3rem); margin: 0 0 0.5rem; letter-spacing: -0.03em; }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1.5rem;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.card-text { padding: 1rem 1.1rem 1.25rem; }
.card-text time { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card-text h2 { font-size: 1.1rem; margin: 0.4rem 0 0.5rem; line-height: 1.35; letter-spacing: -0.01em; }
.card-text p { margin: 0; color: var(--muted); font-size: 0.93rem; }

article { max-width: var(--measure); margin: 0 auto; }
article h1 { font-size: clamp(1.75rem, 4.5vw, 2.5rem); line-height: 1.2; margin: 0.3rem 0 0.75rem; letter-spacing: -0.025em; }
.meta { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin: 0; }
.lede { font-size: 1.15rem; color: var(--muted); margin: 0 0 2rem; }

.video { margin: 0 0 2.5rem; }
.video-play {
  display: block; position: relative; width: 100%; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; background: #000; line-height: 0;
}
.video-play img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; opacity: 0.92; transition: opacity 0.2s; }
.video-play:hover img { opacity: 1; }
.video-icon {
  position: absolute; inset: 0; margin: auto; width: 68px; height: 48px;
  background: rgba(0,0,0,0.75); border-radius: 12px;
}
.video-icon::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0;
  border-style: solid; border-width: 11px 0 11px 19px; border-color: transparent transparent transparent #fff;
}
.video-play:hover .video-icon { background: var(--accent); }
.video iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius); display: block; }

.prose h2 { font-size: 1.45rem; margin: 2.25rem 0 0.75rem; letter-spacing: -0.015em; }
.prose h3 { font-size: 1.15rem; margin: 1.75rem 0 0.5rem; }
.prose p, .prose ul { margin: 0 0 1.15rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-bottom: 0.4rem; }
.prose code { background: var(--accent-soft); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.9em; }

.cta {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin: 2.5rem 0;
}
.cta-tag { margin: 0 0 0.4rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; }
.cta h2 { margin: 0 0 0.6rem; font-size: 1.3rem; letter-spacing: -0.015em; }
.cta p { margin: 0 0 1.25rem; color: var(--text); }
.cta-button {
  display: inline-block; background: var(--accent); color: #fff;
  padding: 0.8rem 1.6rem; border-radius: 8px; text-decoration: none; font-weight: 600;
}
.cta-button:hover { filter: brightness(1.08); }
.cta-note { margin: 1.1rem 0 0 !important; font-size: 0.8rem; color: var(--muted); line-height: 1.5; }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 2rem 0 0; }
.tags span { font-size: 0.78rem; color: var(--muted); border: 1px solid var(--border); padding: 0.2rem 0.6rem; border-radius: 999px; }

.empty { text-align: center; color: var(--muted); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem 3rem;
  max-width: var(--wide);
  margin: 0 auto;
}
.copy { max-width: var(--measure); margin: 0 auto; font-size: 0.82rem; color: var(--muted); }

/* ---------- Artículo: navegación y estructura ---------- */

.crumbs { max-width: var(--measure); margin: 0 0 1.25rem; font-size: 0.82rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs span { margin: 0 0.15rem; }

.meta { color: var(--muted); font-size: 0.86rem; margin: 0 0 1.75rem; }

.toc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem; margin: 0 0 2.5rem;
}
.toc-title { margin: 0 0 0.6rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.toc ol { margin: 0; padding-left: 1.1rem; }
.toc li { margin-bottom: 0.35rem; font-size: 0.93rem; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* ---------- Prosa enriquecida ---------- */
.prose h2 { scroll-margin-top: 1.5rem; }
.prose h3 { scroll-margin-top: 1.5rem; }
.prose figure { margin: 2rem 0; }
.prose figure img { width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); display: block; }
.prose figcaption { font-size: 0.82rem; color: var(--muted); margin-top: 0.6rem; text-align: center; line-height: 1.5; }
.prose ol { margin: 0 0 1.15rem; padding-left: 1.3rem; }
.prose ol li { margin-bottom: 0.5rem; }

.table-wrap { overflow-x: auto; margin: 0 0 1.75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.prose th, .prose td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.prose th { background: var(--accent-soft); font-weight: 700; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }

.callout {
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1.75rem;
}
.callout p { margin: 0; font-size: 0.94rem; }

.prose blockquote {
  margin: 0 0 1.75rem; padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent); color: var(--muted); font-style: italic;
}
.prose blockquote p { margin: 0; }

/* ---------- Llamada a la acción ---------- */
.cta-list { margin: 0 0 1.25rem; padding-left: 1.2rem; }
.cta-list li { margin-bottom: 0.4rem; font-size: 0.94rem; }
.cta-price { margin: 0.9rem 0 0 !important; font-size: 0.85rem; color: var(--muted); }

/* ---------- Preguntas frecuentes ---------- */
.faq { max-width: var(--measure); margin: 3rem auto 0; }
.faq h2 { font-size: 1.45rem; margin: 0 0 1rem; letter-spacing: -0.015em; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item summary {
  cursor: pointer; padding: 0.95rem 0; font-weight: 600; font-size: 1rem;
  list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--accent); font-size: 1.35rem; font-weight: 400; line-height: 1; }
.faq-item[open] summary::after { content: "−"; }
.faq-answer { padding: 0 0 1rem; }
.faq-answer p { margin: 0; color: var(--muted); font-size: 0.95rem; }


/* ---------- Imagen de cabecera ---------- */
.hero-img { margin: 0 0 2rem; }
.hero-img img {
  width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover;
  border-radius: var(--radius); display: block;
}

/* ---------- Resumen rápido ---------- */
.summary {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.25rem 1.5rem; margin: 0 0 2.5rem;
}
.summary-title {
  margin: 0 0 0.7rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--accent); font-weight: 700;
}
.summary ul { margin: 0; padding-left: 1.15rem; }
.summary li { margin-bottom: 0.45rem; font-size: 0.95rem; line-height: 1.55; }
.summary li:last-child { margin-bottom: 0; }

/* ---------- Calculadora ---------- */
.calc {
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius); padding: 1.5rem; margin: 0 0 2rem;
}
.calc-title {
  margin: 0 0 1.1rem; font-size: 1.1rem; font-weight: 700;
  letter-spacing: -0.015em; color: var(--text);
}
.calc-inputs { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.calc-inputs label {
  flex: 1 1 190px; display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.82rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.calc-unit { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 400; }
.calc input, .calc select {
  font: inherit; font-size: 1rem; font-weight: 600; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.7rem; width: 100%;
  text-transform: none; letter-spacing: 0;
}
.calc input { max-width: 6.5rem; }
.calc input:focus, .calc select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.calc-total {
  margin: 0 0 0.9rem; font-size: 1.05rem; padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.calc-total strong { color: var(--accent); font-size: 1.45rem; }
.calc-total span { display: block; font-size: 0.84rem; color: var(--muted); margin-top: 0.2rem; }

.calc-breakdown { list-style: none; margin: 0 0 0.9rem; padding: 0; }
.calc-breakdown li {
  display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 1rem;
  padding: 0.55rem 0; border-bottom: 1px dashed var(--border);
}
.calc-breakdown li:last-child { border-bottom: 0; }
.calc-part { font-weight: 600; font-size: 0.95rem; }
.calc-val { font-weight: 700; color: var(--accent); font-size: 1rem; text-align: right; }
.calc-note { grid-column: 1 / -1; font-size: 0.8rem; color: var(--muted); }
.calc-foot, .calc-empty { margin: 0; font-size: 0.8rem; color: var(--muted); line-height: 1.5; }

/* Las fotos del cuerpo reservan su espacio antes de cargar (evita saltos de
   diseño) y se recortan a formato apaisado para que una foto vertical no
   ocupe media pantalla. */
.prose figure img {
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface);
}
/* Los diagramas SVG conservan su proporción propia: no se recortan. */
.prose figure img[src$=".svg"] {
  aspect-ratio: auto;
  object-fit: contain;
  padding: 0.5rem;
}

/* ---------- Anchos: el texto se lee estrecho, lo visual respira ---------- */
/* La página de artículo debe medir --wide MÁS su propio padding lateral (1.5rem
   a cada lado); si no, los elementos anchos se salen y aparece scroll lateral. */
.page:has(article) { max-width: calc(var(--wide) + 3rem); }

/* Elementos que se salen del ancho del texto para ganar presencia. */
.hero-img,
.prose figure,
.prose .table-wrap,
.calc {
  /* width:auto + margen negativo ensancha de verdad; width:100% solo desplaza. */
  width: auto;
  max-width: none;
  margin-left: calc((var(--measure) - var(--wide)) / 2);
  margin-right: calc((var(--measure) - var(--wide)) / 2);
}

/* Por debajo del ancho combinado no hay sitio para salirse: todo a una columna. */
@media (max-width: 61rem) {
  .hero-img,
  .prose figure,
  .prose .table-wrap,
  .calc {
    width: auto;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
}
