/* =============================================================
   Calculadora de placas fotovoltaicas · estilos.css
   Sobrio, técnico. Tipografía del sistema. Sin dependencias.
   ============================================================= */

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg:        #ffffff;
  --surface:   #f5f6f7;
  --surface-2: #eceef0;
  --ink:       #1a1c1f;
  --muted:     #5b6169;
  --line:      #d7dbdf;
  --accent:    #b45f10;   /* ámbar técnico, uso mínimo */
  --accent-ink:#ffffff;
  --ok:        #1e7d43;
  --warn-bg:   #fbf0e8;
  --warn-ink:  #97400f;
  --warn-line: #e2b48f;
  --info-bg:   #eef3f7;
  --info-line: #b9cdda;

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

  --wrap: 900px;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14161a;
    --surface:   #1c1f24;
    --surface-2: #23272d;
    --ink:       #e7e9ec;
    --muted:     #9aa1a9;
    --line:      #333941;
    --accent:    #e0851f;
    --accent-ink:#1a1c1f;
    --ok:        #4caf72;
    --warn-bg:   #2b2019;
    --warn-ink:  #f0b481;
    --warn-line: #5a4130;
    --info-bg:   #1b232b;
    --info-line: #33424e;
  }
}

/* =============================================================
   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;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
p { text-wrap: pretty; }

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

/* =============================================================
   3. Utilidades
   ============================================================= */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 16px; }

.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: 16px; z-index: 999;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg);
  border-radius: 6px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* =============================================================
   4. Cabecera / pie
   ============================================================= */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.site-header__in {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-block: 12px;
}
.brand { font-weight: 700; letter-spacing: -0.01em; }
.site-header__link { font-size: .9rem; }

.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  padding-block: 24px;
  color: var(--muted);
  font-size: .88rem;
}
.site-footer__links { margin-top: 6px; display: flex; gap: 16px; flex-wrap: wrap; }

/* =============================================================
   5. Cabecera de página
   ============================================================= */
main { padding-top: 24px; }
h1 { font-size: 1.6rem; margin-bottom: 8px; }
.lede { color: var(--ink); margin-bottom: 14px; }
.disclaimer {
  font-size: .9rem; color: var(--warn-ink);
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 20px;
}

/* Hero: texto + ilustración */
.hero { display: grid; gap: 14px 28px; align-items: center; }
.hero__texto { min-width: 0; }
.hero__art { margin: 0; }
.hero__art svg { display: block; width: 100%; max-width: 300px; height: auto; margin-inline: auto; }
.hero-sol { stroke: var(--accent); }
.hero-suelo { stroke: var(--line); }
.hero-panel { stroke: var(--ink); }
.hero-panel-cara { fill: var(--surface-2); }
.hero-pata { stroke: var(--muted); }

@media (min-width: 720px) {
  h1 { font-size: 2rem; }
  main { padding-top: 32px; }
  .hero { grid-template-columns: 1fr minmax(210px, 280px); }
  .hero__art { order: 2; }
}

/* =============================================================
   6. Calculadora
   ============================================================= */
.calc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.campo { margin-bottom: 14px; }
.campo > label,
.campo--fieldset > legend {
  display: block; font-weight: 600; font-size: .92rem; margin-bottom: 5px;
}
.campo input[type="number"],
.campo select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}
.campo input[type="range"] { width: 100%; accent-color: var(--accent); }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }

.campo--fieldset { border: 0; padding: 0; }
.campo--inline { margin-top: 10px; margin-bottom: 0; }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.radio, .check {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 400; font-size: .9rem; cursor: pointer;
}
.radio input, .check input { accent-color: var(--accent); }

/* Ajustes avanzados */
.avanzado {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.avanzado > summary {
  cursor: pointer; font-weight: 600; font-size: .92rem;
  padding: 6px 0;
}
.avanzado__grid { margin-top: 10px; }
.avanzado__grid .campo { margin-bottom: 12px; }
.campo--check { display: flex; flex-direction: column; }

@media (min-width: 620px) {
  .calc { padding: 22px; }
  .avanzado__grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px;
  }
}

/* =============================================================
   7. Resultado
   ============================================================= */
.resultado { margin-top: 18px; }

.resultado__eyebrow {
  text-transform: uppercase; letter-spacing: .08em;
  font-size: .72rem; color: var(--muted); margin-bottom: 4px;
}
.resultado__titular {
  font-size: 1.45rem; font-weight: 700; line-height: 1.2;
  padding-bottom: 14px; border-bottom: 2px solid var(--ink);
}
.resultado__titular span { font-variant-numeric: tabular-nums; }
.resultado__sep { color: var(--muted); margin-inline: 4px; }

@media (min-width: 720px) {
  .resultado__titular { font-size: 1.8rem; }
}

.metricas {
  display: grid; grid-template-columns: 1fr; gap: 0;
  margin-top: 4px;
}
.metrica {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line);
}
.metrica dt { color: var(--muted); font-size: .9rem; }
.metrica dd {
  font-family: var(--mono); font-weight: 600; font-size: 1rem;
  text-align: right; font-variant-numeric: tabular-nums;
}

@media (min-width: 620px) {
  .metricas { grid-template-columns: 1fr 1fr; column-gap: 32px; }
}

.resultado__nota {
  font-size: .84rem; color: var(--muted);
  margin-top: 12px;
}
.resultado__nota--legal {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 10px 12px; color: var(--ink);
}

/* Avisos de incoherencia */
.avisos:empty { display: none; }
.avisos { margin-top: 12px; display: grid; gap: 8px; }
.aviso {
  font-size: .86rem; border-radius: 6px; padding: 9px 12px;
  border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-ink);
}
.aviso--info {
  border-color: var(--info-line); background: var(--info-bg); color: var(--ink);
}

/* =============================================================
   8. Gráfico
   ============================================================= */
.grafico { margin-top: 22px; }
.grafico figcaption, .grafico__leyenda {
  font-size: .85rem; color: var(--muted);
}
.grafico figcaption { margin-bottom: 8px; font-weight: 600; color: var(--ink); }
#grafico-canvas {
  width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
.grafico__leyenda { margin-top: 8px; display: flex; gap: 18px; }
.clave { display: inline-flex; align-items: center; gap: 6px; }
.clave::before {
  content: ""; width: 14px; height: 12px; border-radius: 2px; display: inline-block;
}
.clave--prod::before { background: var(--accent); }
.clave--cons::before { background: transparent; border: 2px solid var(--ink); height: 0; }

/* =============================================================
   9. Acciones / desglose
   ============================================================= */
.acciones {
  margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.acciones button {
  padding: 10px 16px; border-radius: 6px; font-weight: 600; font-size: .9rem;
  border: 1px solid var(--ink);
}
#btn-imprimir { background: var(--ink); color: var(--bg); }
#btn-compartir { background: var(--bg); color: var(--ink); }
.acciones__ok { font-size: .85rem; color: var(--ok); font-weight: 600; }

.desglose {
  margin-top: 20px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg);
}
.desglose > summary {
  cursor: pointer; font-weight: 600; font-size: .92rem; padding: 12px 14px;
}
.desglose__cuerpo { padding: 0 14px 14px; font-size: .88rem; overflow-x: auto; }
.desglose__cuerpo table { width: 100%; border-collapse: collapse; min-width: 320px; }
.desglose__cuerpo th, .desglose__cuerpo td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.desglose__cuerpo td:last-child {
  font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.desglose__cuerpo h4 { margin: 14px 0 4px; font-size: .9rem; }
.desglose__cuerpo .formula {
  font-family: var(--mono); font-size: .82rem; color: var(--muted);
  background: var(--surface); padding: 8px 10px; border-radius: 4px;
  margin-top: 8px; overflow-x: auto;
}

/* =============================================================
   10. Contenido SEO / FAQ
   ============================================================= */
.contenido, .faq, .mas-herramientas { margin-top: 40px; }
.contenido h2, .faq h2, .mas-herramientas h2 {
  font-size: 1.25rem; margin-bottom: 10px;
}
.contenido h2 { margin-top: 28px; }
.contenido h2:first-child { margin-top: 0; }
.contenido p { margin-bottom: 12px; }
.contenido ol, .contenido ul { margin: 0 0 14px 1.1rem; }
.contenido li { margin-bottom: 8px; }

/* Pasos con icono en lugar de número */
.pasos { list-style: none; margin-left: 0; padding-left: 0; }
.pasos li {
  display: grid; grid-template-columns: 26px 1fr; gap: 12px;
  align-items: start; margin-bottom: 12px;
}
.paso-ico { display: block; }
.paso-ico svg {
  width: 24px; height: 24px;
  stroke: var(--accent); fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.faq details {
  border-bottom: 1px solid var(--line); padding: 12px 0;
}
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin-top: 8px; color: var(--muted); }

.mas-herramientas__vacio { color: var(--muted); }

/* =============================================================
   11. Huecos de anuncio (placeholders vacíos)
   ============================================================= */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); border-radius: 6px;
  color: var(--muted); font-size: .75rem; letter-spacing: .12em;
  background: var(--surface);
}
.ad-slot--banner { min-height: 100px; margin-top: 24px; }
.ad-slot--contenido { min-height: 250px; margin: 24px 0; }

@media (min-width: 720px) {
  .ad-slot--banner { min-height: 120px; }
}

.ad-toast {
  position: fixed; right: 12px; bottom: 12px; z-index: 50;
  width: 320px; max-width: calc(100vw - 24px); min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); border-radius: 8px;
  background: var(--surface); color: var(--muted);
  font-size: .75rem; letter-spacing: .12em;
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
.ad-toast__x {
  position: absolute; top: 2px; right: 6px; font-size: 1.2rem;
  line-height: 1; color: var(--muted);
}

/* Rascacielos lateral: solo cuando sobra sitio a los lados del contenido */
.ad-rail { display: none; }
@media (min-width: 1300px) {
  .ad-rail {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 50%; transform: translateY(-50%);
    right: clamp(12px, calc((100vw - var(--wrap)) / 2 - 196px), 120px);
    width: 160px; height: 600px;
    border: 1px dashed var(--line); border-radius: 6px;
    background: var(--surface); color: var(--muted);
    font-size: .75rem; letter-spacing: .12em;
    z-index: 40;
  }
}

.ad-modal {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; max-width: 420px; width: calc(100vw - 32px);
  background: var(--bg); color: var(--ink);
}
.ad-modal::backdrop { background: rgba(0,0,0,.45); }
.ad-modal__x {
  position: absolute; top: 8px; right: 12px; font-size: 1.4rem; line-height: 1;
  color: var(--muted);
}
.ad-modal__slot {
  min-height: 250px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); border-radius: 6px;
  color: var(--muted); font-size: .75rem; letter-spacing: .12em;
  margin: 8px 0 16px;
}
.ad-modal__cerrar {
  display: block; width: 100%; padding: 10px 16px;
  border: 1px solid var(--ink); border-radius: 6px;
  background: var(--ink); color: var(--bg); font-weight: 600;
}

/* =============================================================
   12. Movimiento reducido
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* =============================================================
   13. Impresión
   ============================================================= */
@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff; --ink: #000;
    --muted: #333; --line: #999;
  }
  .site-header, .site-footer, .avanzado, .acciones,
  .ad-slot, .ad-toast, .ad-modal, .ad-rail, .skip-link, .hero__art,
  .contenido, .faq, .mas-herramientas, .disclaimer {
    display: none !important;
  }
  body { font-size: 12pt; color: #000; }
  main { padding-top: 0; }
  .calc { border: 0; padding: 0; background: #fff; }
  .calc__form { margin-bottom: 12pt; }
  .campo select, .campo input { border: 1px solid #999; }
  .resultado { margin-top: 0; }
  .resultado__titular { border-color: #000; }
  .desglose { border: 1px solid #999; }
  .desglose[open] > summary { font-weight: 700; }
  #grafico-canvas { border: 1px solid #999; page-break-inside: avoid; }
  a { text-decoration: none; color: #000; }
  h1 { font-size: 18pt; }
}
