:root {
  --bg: #f7f7f5;
  --bg-card: #ffffff;
  --text: #1c1c1e;
  --text-muted: #5a5a60;
  --border: #e3e2de;
  --accent: #1a56db;
  --accent-dark: #123f9e;
  --warn-bg: #fff4e5;
  --warn-border: #f0b429;
  --warn-text: #7a4d00;
  --ad-bg: #ececea;
  --ad-border: #c9c8c3;
  --ad-text: #8a8a86;
  --radius: 10px;
  --max-width: 760px;
}

/* ---------- Tema oscuro ---------- */
:root[data-theme="dark"] {
  --bg: #121214;
  --bg-card: #1b1b1f;
  --text: #f0f0f0;
  --text-muted: #a8a8ae;
  --border: #2d2d32;
  --accent: #6d9bff;
  --accent-dark: #9dbcff;
  --warn-bg: #3a2e10;
  --warn-border: #caa23a;
  --warn-text: #f0c674;
  --ad-bg: #1f1f23;
  --ad-border: #3a3a40;
  --ad-text: #86868c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --bg-card: #1b1b1f;
    --text: #f0f0f0;
    --text-muted: #a8a8ae;
    --border: #2d2d32;
    --accent: #6d9bff;
    --accent-dark: #9dbcff;
    --warn-bg: #3a2e10;
    --warn-border: #caa23a;
    --warn-text: #f0c674;
    --ad-bg: #1f1f23;
    --ad-border: #3a3a40;
    --ad-text: #86868c;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color .2s ease, color .2s ease;
}

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

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

/* Foco visible global — accesibilidad de navegación por teclado (WCAG 2.4.7) */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Oculto visualmente pero accesible para lectores de pantalla */
.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;
}

/* Enlace "saltar al contenido" — visible solo con foco de teclado */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 18px;
  font-weight: 700;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header__inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}
.logo span { color: var(--accent); }
.site-header__right { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.main-nav { display: flex; gap: 20px; flex-wrap: wrap; }
.main-nav a {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}
.main-nav a:hover { color: var(--accent); text-decoration: none; }

/* ---------- Botón de modo oscuro/claro ---------- */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
  transition: border-color .2s ease, transform .15s ease;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Migas de pan (breadcrumbs) ---------- */
.breadcrumb {
  max-width: 1000px;
  margin: 14px auto 0;
  padding: 0 20px;
}
.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.breadcrumb li { display: flex; align-items: center; gap: 4px; }
.breadcrumb li:not(:last-child)::after {
  content: "/";
  margin-left: 4px;
  color: var(--border);
}
.breadcrumb a { color: var(--text-muted); font-weight: 600; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; }

/* ---------- Preguntas frecuentes (FAQ) ---------- */
.faq { max-width: 1000px; margin: 40px auto 0; padding: 0 20px; }
.faq h2 { font-size: 1.5rem; margin: 0 0 6px; }
.faq > p { color: var(--text-muted); margin: 0 0 18px; }
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1;
}
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p { margin: 10px 0 0; color: var(--text-muted); }

/* ---------- Bloque de confianza / método editorial (E-E-A-T) ---------- */
.trust-block { max-width: 1000px; margin: 40px auto 0; padding: 0 20px; }
.trust-block__inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 18px 24px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.trust-block h2 { grid-column: 1 / -1; font-size: 1.3rem; margin: 0; }
.trust-item strong { display: block; margin-bottom: 4px; font-size: 0.95rem; }
.trust-item p { margin: 0; font-size: 0.88rem; color: var(--text-muted); }

/* ---------- Layout ---------- */
main { max-width: var(--max-width); margin: 0 auto; padding: 32px 20px 64px; }

.hero {
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 20px 8px;
  text-align: left;
}
.hero h1 { font-size: 2.1rem; line-height: 1.25; margin: 0 0 12px; letter-spacing: -0.01em; }
.hero p.lead { font-size: 1.1rem; color: var(--text-muted); max-width: 640px; margin: 0 0 8px; }

/* ---------- Ad slots (reservan espacio para no romper el layout cuando se active AdSense) ---------- */
.ad-slot {
  width: 100%;
  min-height: 100px;
  margin: 28px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ad-bg);
  border: 1px dashed var(--ad-border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.ad-slot::before {
  content: "Publicidad";
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ad-text);
}
.ad-slot--header { min-height: 90px; }
.ad-slot--in-article { min-height: 250px; }
.ad-slot--sidebar { min-height: 600px; }
.ad-slot--footer { min-height: 90px; }

/* ---------- Post list (index) ---------- */
.post-grid {
  max-width: 1000px;
  margin: 8px auto 0;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.post-card__tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.post-card h2 { font-size: 1.15rem; margin: 0; line-height: 1.35; }
.post-card p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.post-card__link { font-weight: 700; font-size: 0.9rem; margin-top: auto; }

/* ---------- Article ---------- */
.article-header { max-width: var(--max-width); margin: 0 auto; padding: 40px 20px 0; }
.article-header__tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 10px;
}
.article-header h1 { font-size: 1.9rem; line-height: 1.3; margin: 0 0 10px; }
.article-meta { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; }

article.post-body h2 { font-size: 1.4rem; margin: 36px 0 12px; }
article.post-body h3 { font-size: 1.15rem; margin: 24px 0 10px; }
article.post-body p { margin: 0 0 16px; }
article.post-body ul, article.post-body ol { margin: 0 0 16px; padding-left: 22px; }
article.post-body li { margin-bottom: 8px; }
article.post-body blockquote {
  margin: 20px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.callout-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 20px 0;
  font-size: 0.95rem;
}
.callout-warn strong { display: block; margin-bottom: 4px; }

.related {
  max-width: var(--max-width);
  margin: 40px auto 0;
  padding: 24px 20px 0;
  border-top: 1px solid var(--border);
}
.related h3 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.related ul { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.related a { font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.site-footer__inner { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.site-footer__disclaimer { max-width: 700px; }
.footer-legal-links { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 4px; }
.footer-legal-links a,
.footer-legal-links button {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
}
.footer-legal-links button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-legal-links a:hover,
.footer-legal-links button:hover { color: var(--accent); }

/* ---------- Botones genéricos ---------- */
.btn {
  border-radius: 8px;
  padding: 12px 18px;
  min-height: 44px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
}
.btn--primary { background: var(--accent); color: #ffffff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn[hidden] { display: none; }

/* ---------- Banner de consentimiento de cookies ---------- */
.cookie-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 640px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 20px;
  z-index: 200;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner__content p {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.cookie-banner__content a { font-weight: 700; }
.cookie-banner__prefs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.88rem;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cookie-banner__prefs[hidden] { display: none; }
.cookie-banner__prefs label { display: flex; align-items: center; gap: 8px; }
.cookie-banner__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Páginas legales ---------- */
.legal-body { max-width: var(--max-width); margin: 0 auto; padding: 8px 20px 48px; }
.legal-body h2 { font-size: 1.2rem; margin: 32px 0 10px; }
.legal-body h3 { font-size: 1.02rem; margin: 22px 0 8px; }
.legal-body p, .legal-body li { margin: 0 0 12px; }
.legal-body ul, .legal-body ol { padding-left: 22px; }
/* Envoltorio con scroll horizontal — evita que las tablas rompan el layout en móvil */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 14px 0 20px;
  border-radius: var(--radius);
}
.legal-body table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.85rem;
}
.legal-body th, .legal-body td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.legal-body th { background: var(--bg-card); }
.legal-updated { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 24px; }
.legal-placeholder {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.88rem;
  margin: 0 0 28px;
}

@media (max-width: 640px) {
  .hero h1 { font-size: 1.6rem; }
  .hero p.lead { font-size: 1rem; }
  .article-header h1 { font-size: 1.5rem; }

  /* Cabecera en móvil: logo + toggle en la fila superior, nav en tira
     deslizable horizontal debajo. Con 4 enlaces, el texto no cabe en
     una sola línea en pantallas de ~375px o menos — en vez de que se
     rompa a mitad de palabra, se convierte en scroll horizontal. */
  .site-header__inner { padding: 12px 16px; }
  .site-header__right {
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
    gap: 10px;
  }
  .main-nav {
    order: 2;
    flex: 1 1 100%;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    gap: 18px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .theme-toggle { order: 1; }

  /* Post-grid y secciones: menos aire lateral en pantallas estrechas */
  .post-card { padding: 18px; }
  .faq h2, .trust-block h2 { font-size: 1.2rem; }
  .cookie-banner { padding: 16px; bottom: 8px; width: calc(100% - 16px); }
}
