/* CalculaFácil - estilos base (mobile-first) */

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-text: #0f172a;
  --color-muted: #475569;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-soft: #eff6ff;
  --color-error-bg: #fef2f2;
  --color-error: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
}

[hidden] { display: none !important; }

img, svg { max-width: 100%; }

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

:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.4rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

.container {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: 16px;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  background: var(--color-text);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus { top: 8px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

section[id] { scroll-margin-top: 72px; }

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding-block: 10px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--color-text);
  text-decoration: none;
}

.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.1rem;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list a {
  display: inline-block;
  padding: 10px 8px;
  border-radius: 8px;
  color: var(--color-muted);
  font-weight: 600;
  text-decoration: none;
}
.nav-list a:hover { background: var(--color-soft); color: var(--color-primary-dark); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 22px;
  border: 2px solid var(--color-primary);
  border-radius: 10px;
  background: var(--color-primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }

.btn-secondary {
  background: transparent;
  color: var(--color-primary-dark);
}
.btn-secondary:hover { background: var(--color-soft); color: var(--color-primary-dark); }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(180deg, var(--color-soft), var(--color-bg));
  padding-block: 44px 36px;
  text-align: center;
}
.hero h1 { font-size: 2.1rem; }
.hero p {
  max-width: 560px;
  margin-inline: auto;
  margin-bottom: 1.5em;
  color: var(--color-muted);
  font-size: 1.1rem;
}

/* ---------- Secciones ---------- */
.section { padding-block: 36px; }
.section > .container > h2:first-child { margin-top: 0; }
.section-intro { color: var(--color-muted); max-width: 640px; }

/* ---------- Tarjetas de calculadoras ---------- */
.card-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tool-card h3 { margin: 0; font-size: 1.15rem; }
.tool-card p { margin: 0 0 auto; color: var(--color-muted); }
.tool-card .btn { margin-top: 12px; }

.tool-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--color-soft);
  color: var(--color-primary);
}
.tool-icon svg { width: 28px; height: 28px; }

/* ---------- Bloques de contenido ---------- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.info-grid { display: grid; gap: 16px; }

/* ---------- FAQ ---------- */
.faq details {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 10px;
}
.faq summary {
  cursor: pointer;
  padding: 14px 16px;
  min-height: 48px;
  font-weight: 700;
}
.faq details p { margin: 0; padding: 0 16px 16px; color: var(--color-muted); }

/* ---------- Página de herramienta ---------- */
.tool-main {
  max-width: 760px;
  margin-inline: auto;
  padding: 20px 16px 40px;
}

.breadcrumb { font-size: 0.9rem; color: var(--color-muted); margin-bottom: 12px; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: #94a3b8; }

.lead { font-size: 1.1rem; color: var(--color-muted); }

.calc {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.calc h2, .calc h3 { margin-top: 0; }
.calc + .calc { margin-top: 20px; }

.field { margin-bottom: 16px; }
.field label, .field legend {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  padding: 0;
}
.field .hint { display: block; font-size: 0.875rem; color: var(--color-muted); font-weight: 400; }

fieldset.field { border: 0; margin-inline: 0; padding: 0; min-width: 0; }

input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--color-text);
  font: inherit;
  font-size: 1rem; /* 16px evita el zoom automático en iOS */
}
input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus { border-color: var(--color-primary); }

textarea { min-height: 120px; resize: vertical; line-height: 1.5; }

input:disabled { background: #f1f5f9; color: var(--color-muted); }

.form-note { margin: 12px 0; font-size: 0.875rem; color: var(--color-muted); }

.radio-row { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 14px;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.radio-row input { width: 20px; height: 20px; accent-color: var(--color-primary); }

.form-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.form-error {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--color-error-bg);
  color: var(--color-error);
  font-weight: 600;
}

.result {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--color-soft);
  border: 2px solid #bfdbfe;
  text-align: center;
}
.result-label { margin: 0; color: var(--color-muted); font-weight: 600; }
.result-value { margin: 4px 0 0; font-size: clamp(1.5rem, 7vw, 2.1rem); font-weight: 800; color: var(--color-primary-dark); line-height: 1.2; overflow-wrap: anywhere; }
.result-details { margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid #bfdbfe; text-align: left; }
.result-details div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.result-details dt { color: var(--color-muted); }
.result-details dd { margin: 0; font-weight: 700; text-align: right; }

/* Resultados con varias tarjetas, notas y tabla */
.result-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-top: 4px; }
.result-tile { padding: 12px 10px; background: var(--color-surface); border: 1px solid #bfdbfe; border-radius: 10px; }
.result-tile .result-label { font-size: 0.875rem; }
.result-tile-value { margin: 4px 0 0; font-size: 1.4rem; font-weight: 800; color: var(--color-primary-dark); line-height: 1.25; overflow-wrap: anywhere; }
.result-note { margin: 12px 0 0; text-align: left; font-size: 0.95rem; color: var(--color-muted); overflow-wrap: anywhere; }
.table-wrap { margin-top: 14px; overflow-x: auto; text-align: left; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table-wrap caption { margin-bottom: 6px; font-weight: 700; text-align: left; }
.table-wrap th, .table-wrap td { padding: 8px 10px; border-bottom: 1px solid #bfdbfe; text-align: right; white-space: nowrap; }
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; }

/* Índice de calculadoras y llamada a ver todas */
.hub-main { padding-block: 20px 40px; }
.hub-group { margin-top: 28px; }
.hub-group h2 { margin-top: 0; }
.section-cta { margin: 20px 0 0; }

/* Filas de notas y filas dinámicas */
.grade-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; }
.grade-row .field { flex: 1; min-width: 0; margin: 0; }
.btn-icon { min-width: 48px; padding: 10px; flex: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.row-title { margin: 0 0 4px; font-weight: 700; }
.source { font-size: 0.9rem; color: var(--color-muted); }

/* Regla de tres */
.rule3 { display: grid; gap: 10px; align-items: center; }
.rule3 .arrow { display: none; text-align: center; color: var(--color-muted); font-weight: 700; }

/* Contenido explicativo */
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: 0.4em; }

.formula {
  padding: 14px 16px;
  border-left: 4px solid var(--color-primary);
  background: var(--color-surface);
  border-radius: 0 10px 10px 0;
  font-weight: 700;
  overflow-x: auto;
}

.example {
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 12px;
}
.example p { margin: 0; }

.related { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.related a {
  display: block;
  padding: 14px 16px;
  min-height: 48px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
}
.related a:hover { border-color: var(--color-primary); background: var(--color-soft); }

/* ---------- Espacios para anuncios (AdSense) ----------
   Reservan altura para evitar saltos de diseño (CLS). Cuando insertes
   los anuncios, borra el borde/texto placeholder y deja solo el contenedor. */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  margin: 24px auto;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  color: #64748b;
  font-size: 0.8rem;
  text-align: center;
  overflow: hidden;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 40px;
  padding: 32px 0 24px;
  background: #0f172a;
  color: #cbd5e1;
}
.site-footer a { color: #e2e8f0; }
.footer-grid { display: grid; gap: 20px; }
.footer-brand { font-size: 1.2rem; font-weight: 800; color: #fff; margin-bottom: 6px; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.footer-links a { display: inline-block; padding: 11px 0; }
.copyright { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid #334155; font-size: 0.875rem; }

.placeholder-note {
  padding: 10px 14px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  color: #78350f;
}

/* ---------- Pantallas medianas y grandes ---------- */
@media (min-width: 600px) {
  .site-header { position: sticky; top: 0; z-index: 50; }
  .nav-list a { padding: 10px 12px; }
  h1 { font-size: 2.2rem; }
  .hero h1 { font-size: 2.8rem; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .form-actions { flex-direction: row; }
  .form-actions .btn { flex: 1; }
  .rule3 { grid-template-columns: 1fr auto 1fr; }
  .rule3 .arrow { display: block; }
  .related { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr auto; align-items: start; }
  .calc { padding: 28px; }
}

@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}

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