/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: #fafafa;
  color: #1a1a1a;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: #2563eb;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===== Layout ===== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ===== Nav ===== */
.nav {
  border-bottom: 1px solid #e5e5e5;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-logo {
  font-weight: 700;
  color: #1a1a2e;
  font-size: 1.05rem;
  white-space: nowrap;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}

.nav-logo:hover {
  text-decoration: none;
  color: #2563eb;
}

.nav-logo img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.nav-links {
  display: flex;
  gap: 0.15rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  font-weight: 500;
  padding: 0.3rem 0.55rem;
  font-size: 0.82rem;
  font-family: inherit;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}

.nav-link:hover {
  color: #2563eb;
  background: #f0f4ff;
  text-decoration: none;
}

.nav-link.active {
  color: #2563eb;
  font-weight: 600;
  background: #eff3ff;
}

/* Hamburger button - hidden on desktop */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  color: #444;
  font-size: 1.5rem;
  line-height: 1;
  transition: background 0.15s;
}

.nav-toggle:hover {
  background: #f0f0f0;
}

/* Mobile nav */
@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    padding: 0.5rem 1rem 0.75rem;
    flex-direction: column;
    gap: 0.15rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    animation: nav-slide-down 0.2s ease-out;
  }

  .nav-links.open {
    display: flex;
  }

  @keyframes nav-slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .nav-link {
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    border-radius: 8px;
    width: 100%;
    text-align: left;
  }

  .nav-link:hover {
    background: #f5f7ff;
  }
}

/* ===== Typography ===== */
h1 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.25;
  color: #1a1a2e;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #1a1a2e;
  margin-top: 1.75rem;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: #333;
  margin-top: 1.25rem;
}

.prose {
  color: #444;
  font-size: 0.93rem;
  line-height: 1.7;
  margin-top: 0.5rem;
}

.prose a {
  color: #2563eb;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.prose a:hover {
  border-bottom-color: #2563eb;
  text-decoration: none;
}

/* ===== Buttons ===== */
.btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(37,99,235,0.2);
}

.btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn:active {
  transform: translateY(0);
}

/* ===== Hero ===== */
.hero {
  padding: 3rem 0 1.75rem;
  text-align: center;
}

.hero h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, #1a1a2e, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: #555;
  max-width: 540px;
  margin: 0.5rem auto 1.75rem;
  line-height: 1.65;
  font-size: 1rem;
}

/* ===== Cards Grid ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 1.35rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 16px rgba(37,99,235,0.1);
  transform: translateY(-2px);
  text-decoration: none;
}

.card-sub {
  font-size: 0.72rem;
  color: #2563eb;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a2e;
}

.card-desc {
  color: #555;
  font-size: 0.85rem;
  line-height: 1.55;
}

.card-meta {
  color: #888;
  font-size: 0.78rem;
  margin-top: auto;
  padding-top: 0.4rem;
}

/* ===== Info Links Grid ===== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.info-card {
  background: #fff;
  border: 1px solid #eee;
  border-left: 3px solid #2563eb;
  border-radius: 8px;
  padding: 1rem;
  text-align: left;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.info-card:hover {
  border-color: #ddd;
  border-left-color: #1d4ed8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-1px);
  text-decoration: none;
}

.info-card strong {
  font-size: 0.9rem;
  color: #1a1a2e;
  display: block;
}

.info-card span {
  color: #777;
  font-size: 0.82rem;
  line-height: 1.4;
}

/* ===== Test UI ===== */
.test-hud {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: #666;
}

.test-timer {
  font-weight: 600;
  color: #222;
  font-size: 1.1rem;
}

.test-timer.warning {
  color: #dc2626;
}

.test-canvas {
  width: 100%;
  max-width: 380px;
  height: auto;
  display: block;
  margin: 0 auto;
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  touch-action: none;
}

.test-canvas--wide {
  max-width: 400px;
  cursor: pointer;
}

.test-hint {
  text-align: center;
  color: #999;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.test-controls {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}

/* ===== Results ===== */
.result-box {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 1.25rem;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  text-align: center;
}

.result-label {
  color: #888;
  font-size: 0.8rem;
}

.result-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.result-total {
  border-top: 1px solid #eee;
  margin-top: 1rem;
  padding-top: 1rem;
  text-align: center;
}

.result-big {
  font-size: 1.7rem;
  font-weight: 700;
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.85rem;
}

.color-good {
  color: #16a34a;
}

.color-ok {
  color: #d97706;
}

.color-bad {
  color: #dc2626;
}

/* ===== FAQ ===== */
.faq-item {
  margin-bottom: 1.25rem;
}

.faq-q {
  font-weight: 600;
  color: #111;
  font-size: 0.95rem;
}

/* Footer — see enriched footer styles below */

/* ===== Ad slots ===== */
.ad-slot {
  margin: 1.5rem 0;
  min-height: 90px;
  text-align: center;
}

/* ===== Accessibility button & panel ===== */
.a11y-btn {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #d0d0d0;
  font-size: 1.25rem;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1;
}

.a11y-btn:hover {
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.a11y-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.a11y-panel {
  position: fixed;
  bottom: 4.5rem;
  right: 1.25rem;
  width: 240px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 1rem;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.a11y-panel-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: #111;
}

.a11y-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  cursor: pointer;
  font-size: 0.85rem;
  color: #333;
}

.a11y-row:not(:last-child) {
  border-bottom: 1px solid #f0f0f0;
}

.a11y-icon {
  font-size: 1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.a11y-label {
  flex: 1;
}

.a11y-toggle {
  width: 36px;
  height: 20px;
  appearance: none;
  -webkit-appearance: none;
  background: #ccc;
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: none;
}

.a11y-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.a11y-toggle:checked {
  background: #2563eb;
}

.a11y-toggle:checked::after {
  transform: translateX(16px);
}

.a11y-toggle:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ===== Alto contraste ===== */
body.high-contrast {
  background: #111;
  color: #f0f0f0;
}

body.high-contrast .nav {
  background: #1a1a1a;
  border-color: #333;
}

body.high-contrast .nav-logo {
  color: #f0f0f0;
}

body.high-contrast .nav-link {
  color: #aaa;
}

body.high-contrast .nav-link.active {
  color: #60a5fa;
  border-bottom-color: #60a5fa;
}

body.high-contrast .card,
body.high-contrast .info-card,
body.high-contrast .result-box,
body.high-contrast .test-controls {
  background: #1a1a1a;
  border-color: #444;
}

body.high-contrast .card-title {
  color: #f0f0f0;
}

body.high-contrast .card-desc,
body.high-contrast .card-meta,
body.high-contrast .prose {
  color: #bbb;
}

body.high-contrast .info-card strong {
  color: #f0f0f0;
}

body.high-contrast .info-card span {
  color: #999;
}

body.high-contrast h2 {
  color: #ddd;
}

body.high-contrast .footer {
  background: #111;
  border-color: #333;
  color: #777;
}

body.high-contrast .btn {
  background: #3b82f6;
}

body.high-contrast .btn:hover {
  background: #2563eb;
}

body.high-contrast .test-canvas {
  background: #1a1a1a;
  border-color: #444;
}

body.high-contrast .faq-q {
  color: #e0e0e0;
}

body.high-contrast .a11y-btn {
  background: #222;
  border-color: #555;
  color: #f0f0f0;
}

body.high-contrast .a11y-panel {
  background: #1a1a1a;
  border-color: #444;
}

body.high-contrast .a11y-panel-title {
  color: #f0f0f0;
}

body.high-contrast .a11y-row {
  color: #ccc;
  border-color: #333;
}

/* ===== Texto grande ===== */
body.large-text {
  font-size: 1.15rem;
}

body.large-text h1 {
  font-size: 2rem;
}

body.large-text h2 {
  font-size: 1.35rem;
}

body.large-text .prose {
  font-size: 1.1rem;
}

body.large-text .nav-link {
  font-size: 0.9rem;
}

body.large-text .btn {
  font-size: 1rem;
  padding: 0.65rem 1.3rem;
}

/* ===== Reducir animaciones ===== */
body.reduce-motion,
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  transition-duration: 0s !important;
  animation-duration: 0s !important;
}

/* ===== Modo daltónico ===== */
body.colorblind .color-good {
  color: #2563eb;
}

body.colorblind .color-bad {
  color: #e67e22;
}

body.colorblind .test-timer.warning {
  color: #e67e22;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  h1 {
    font-size: 1.4rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .container {
    padding: 1rem 0.75rem 2rem;
  }

  body.large-text h1 {
    font-size: 1.7rem;
  }

  body.large-text .hero h1 {
    font-size: 1.8rem;
  }
}

/* ===== Accesibilidad nativa ===== */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

@media (prefers-contrast: more) {
  body {
    background: #000;
    color: #fff;
  }

  .card,
  .info-card,
  .result-box,
  .test-controls {
    border-width: 2px;
  }
}

/* ===== Section blocks (reemplaza inline styles) ===== */
.section-block {
  margin-top: 1.5rem;
}

.section-block--lg {
  margin-top: 2rem;
}

.section-heading {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  margin-top: 0;
}

/* ===== Prose list (para listas con estilo) ===== */
.prose-list {
  color: #444;
  font-size: 0.93rem;
  line-height: 1.7;
  margin-top: 0.75rem;
  padding-left: 1.25rem;
}

.prose-list li {
  margin-bottom: 0.5rem;
}

/* ===== Tabla SEO ===== */
.table-responsive {
  overflow-x: auto;
  margin: 1rem 0;
}

.seo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  line-height: 1.5;
}

.seo-table caption {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.5rem;
  text-align: left;
  caption-side: bottom;
}

.seo-table th,
.seo-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e5e5e5;
}

.seo-table th {
  font-weight: 600;
  background: #f8f8f8;
  color: #222;
  white-space: nowrap;
}

.seo-table tbody tr:hover {
  background: #fafafa;
}

body.high-contrast .seo-table th {
  background: #222;
  color: #f0f0f0;
}

body.high-contrast .seo-table td {
  border-color: #444;
}

body.high-contrast .seo-table tbody tr:hover {
  background: #1a1a1a;
}

/* ===== FAQ con details/summary ===== */
.faq-item[open] {
  margin-bottom: 1.25rem;
}

details.faq-item {
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 0.75rem;
}

details.faq-item:last-of-type {
  border-bottom: none;
}

summary.faq-q {
  font-weight: 600;
  color: #111;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

summary.faq-q::before {
  content: "▸";
  font-size: 0.8rem;
  transition: transform 0.15s;
  flex-shrink: 0;
}

details.faq-item[open]>summary.faq-q::before {
  transform: rotate(90deg);
}

summary.faq-q::-webkit-details-marker {
  display: none;
}

body.high-contrast summary.faq-q {
  color: #e0e0e0;
}

body.high-contrast details.faq-item {
  border-color: #333;
}

/* ===== Footer enriquecido ===== */
.footer {
  border-top: 1px solid #e5e5e5;
  padding: 2rem 1rem;
  text-align: center;
  color: #999;
  font-size: 0.78rem;
}

.footer-inner {
  max-width: 800px;
  margin: 0 auto;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.footer-nav a {
  color: #666;
  font-size: 0.82rem;
  text-decoration: none;
  transition: color 0.15s;
}

.footer-nav a:hover {
  color: #2563eb;
  text-decoration: none;
}

.footer-desc {
  color: #777;
  font-size: 0.82rem;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.footer-desc strong {
  font-weight: 600;
  color: #555;
}

.footer-legal {
  color: #999;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.footer-copy {
  color: #bbb;
  font-size: 0.72rem;
}

body.high-contrast .footer {
  background: #111;
  border-color: #333;
}

body.high-contrast .footer-nav a {
  color: #999;
}

body.high-contrast .footer-nav a:hover {
  color: #60a5fa;
}

body.high-contrast .footer-desc {
  color: #888;
}

body.high-contrast .footer-desc strong {
  color: #bbb;
}

body.high-contrast .footer-legal {
  color: #666;
}

body.high-contrast .footer-copy {
  color: #555;
}

/* ===== Accessibility Panel ===== */
.a11y-btn {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(37,99,235,0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.a11y-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 20px rgba(37,99,235,0.45);
}

.a11y-btn:focus-visible {
  outline: 3px solid #60a5fa;
  outline-offset: 3px;
}

.a11y-panel {
  position: fixed;
  bottom: 4.5rem;
  right: 1.25rem;
  width: 280px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  z-index: 100;
  padding: 0.75rem 0;
  animation: a11y-slide-up 0.2s ease-out;
  border: 1px solid #e5e5e5;
}

@keyframes a11y-slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.a11y-panel-title {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.25rem 1rem 0.5rem;
  border-bottom: 1px solid #eee;
  color: #1a1a1a;
}

.a11y-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.a11y-row:hover {
  background: #f5f5f5;
}

.a11y-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #f0f4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.a11y-label {
  flex: 1;
  font-size: 0.88rem;
  color: #333;
}

.a11y-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  background: #ccc;
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.a11y-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.a11y-toggle:checked {
  background: #2563eb;
}

.a11y-toggle:checked::after {
  transform: translateX(18px);
}

.a11y-toggle:focus-visible {
  outline: 3px solid #60a5fa;
  outline-offset: 2px;
}

/* Text spacing mode */
body.text-spacing {
  letter-spacing: 0.05em;
  word-spacing: 0.12em;
}

body.text-spacing p,
body.text-spacing li {
  line-height: 1.9;
}

/* Reading guide */
body.reading-guide .reading-ruler {
  display: block;
}

.reading-ruler {
  display: none;
  position: fixed;
  left: 0;
  width: 100%;
  height: 40px;
  border-top: 2px solid rgba(37,99,235,0.5);
  border-bottom: 2px solid rgba(37,99,235,0.5);
  background: rgba(37,99,235,0.06);
  pointer-events: none;
  z-index: 90;
  transition: top 0.05s;
}

/* High contrast panel */
body.high-contrast .a11y-panel {
  background: #1a1a1a;
  border-color: #333;
}

body.high-contrast .a11y-panel-title {
  color: #fff;
  border-color: #333;
}

body.high-contrast .a11y-row:hover {
  background: #222;
}

body.high-contrast .a11y-icon {
  background: #333;
}

body.high-contrast .a11y-label {
  color: #ddd;
}

body.high-contrast .a11y-toggle {
  background: #555;
}

body.high-contrast .a11y-toggle:checked {
  background: #60a5fa;
}

/* Large text mode boost */
body.large-text .a11y-label {
  font-size: 1rem;
}

/* Responsive */
@media (max-width: 600px) {
  .a11y-panel {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: 4rem;
  }

  .a11y-btn {
    bottom: 0.75rem;
    right: 0.75rem;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
}