/**
 * Neuroeducador — main.css
 * Variables, reset, tipografía, layout, utilidades.
 */

/* ============================================================
   CUSTOM PROPERTIES
   ============================================================ */

:root {
  /* Paleta base */
  --white:       #ffffff;
  --bg:          #fafafa;
  --surface:     #f4f4f2;
  --border:      #e5e7eb;
  --black:       #111111;
  --text:        #1c1c1e;
  --text-muted:  #6b7280;
  --text-light:  #9ca3af;

  /* Acento principal */
  --accent:      #e63946;
  --accent-dark: #c1121f;
  --accent-bg:   #fde8ea;

  /* Colores por categoría */
  --cat-lectura:    #e63946;
  --cat-memoria:    #4361ee;
  --cat-motor:      #06d6a0;
  --cat-talento:    #f77f00;
  --cat-neurotec:   #4cc9f0;

  /* Tipografía */
  --font:        'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:   'JetBrains Mono', 'Courier New', monospace;

  --text-xs:    0.75rem;
  --text-sm:    0.875rem;
  --text-base:  1rem;
  --text-lg:    1.125rem;
  --text-xl:    1.25rem;
  --text-2xl:   1.5rem;
  --text-3xl:   1.875rem;
  --text-4xl:   2.25rem;
  --text-5xl:   3rem;

  --fw-normal:   400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-extrabold:800;

  --lh-tight:   1.2;
  --lh-snug:    1.35;
  --lh-normal:  1.6;
  --lh-relaxed: 1.75;

  /* Espaciado */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Layout */
  --container:  1200px;
  --container-max: 1200px;
  --container-narrow: 760px;
  --toc-width:  240px;

  /* Bordes */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 28px rgba(0,0,0,.11), 0 4px 10px rgba(0,0,0,.07);

  /* Transiciones */
  --t-fast: 150ms ease;
  --t-base: 250ms ease;
  --t-slow: 400ms ease;

  /* Header — barra única */
  --header-h:     104px;
  --header-total: 52px;
}

/* ============================================================
   RESET MODERNO
   ============================================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-total) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: var(--fw-normal);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,h2,h3,h4,h5,h6 { margin: 0; font-weight: var(--fw-bold); line-height: var(--lh-tight); color: var(--black); }
p { margin: 0 0 var(--sp-4); }
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-dark); }
img, video { max-width: 100%; height: auto; display: block; }
ul, ol { padding: 0; margin: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }
svg { flex-shrink: 0; }

/* ============================================================
   SKIP LINK
   ============================================================ */

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--sp-4);
  background: var(--black);
  color: var(--white);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  z-index: 9999;
}
.skip-link:focus { left: var(--sp-4); }

/* ============================================================
   BARRA DE PROGRESO DE LECTURA
   ============================================================ */

#reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--accent);
  z-index: 9999;
  transition: width 80ms linear;
  pointer-events: none;
}

/* ============================================================
   CONTENEDOR
   ============================================================ */

.neu-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 768px) {
  .neu-container { padding: 0 16px; }
}

/* ============================================================
   HEADER
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  height: var(--header-h);
  gap: var(--sp-8);
}

/* Logo */
.site-logo { display: flex; align-items: center; text-decoration: none; }
.site-logo__text {
  font-size: var(--text-xl);
  font-weight: var(--fw-extrabold);
  color: var(--black);
  letter-spacing: -0.03em;
  font-family: "gilbert-color", sans-serif;
}
.site-logo__text span { color: var(--accent); }
.site-logo img { height: 32px; width: auto; }

/* ── Nav principal ──────────────────────────────────────── */
.site-nav {
  flex: 1;
  overflow: visible; /* necesario para que el dropdown no se recorte */
}
.site-nav__menu {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Ítems de nivel 1 */
.site-nav__menu > li > a,
.site-nav__menu > li > .dropdown__trigger {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--r-md);
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
  text-decoration: none;
}
.site-nav__menu > li > a:hover,
.site-nav__menu > li > .dropdown__trigger:hover,
.site-nav__menu > li.current-menu-item > a,
.site-nav__menu > li.current-page-ancestor > a,
.site-nav__menu > li.current-menu-ancestor > a,
.site-nav__menu > li.menu-item--has-dropdown:hover > .dropdown__trigger {
  color: var(--black);
  background: var(--surface);
}

/* ── Dropdown ────────────────────────────────────────────── */
.menu-item--has-dropdown {
  position: relative;
}

.dropdown__menu {
  /* Oculto por defecto */
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: auto;
  right: auto;
  width: max-content;
  max-width: 90vw;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  list-style: none;
  padding: var(--sp-2) 0;
  margin: 0;
  z-index: 300;
}

/* Prevenir desbordamiento derecho */
.menu-item--has-dropdown:not(:nth-last-child(-n+3)) .dropdown__menu {
  left: 0;
  right: auto;
}
.menu-item--has-dropdown:nth-last-child(-n+3) .dropdown__menu {
  left: auto;
  right: 0;
}

/* Abrir al hover en desktop o al recibir foco */
.menu-item--has-dropdown:hover > .dropdown__menu,
.menu-item--has-dropdown:focus-within > .dropdown__menu,
.menu-item--has-dropdown.is-dropdown-open > .dropdown__menu {
  display: block;
}

/* Flecha del trigger rota al abrir */
.menu-item--has-dropdown:hover > .dropdown__trigger svg,
.menu-item--has-dropdown:focus-within > .dropdown__trigger svg {
  transform: rotate(180deg);
  transition: transform var(--t-fast);
}
.dropdown__trigger svg {
  transition: transform var(--t-fast);
}

/* Ítems del dropdown */
.dropdown__item {
  white-space: nowrap;
}
.dropdown__item > a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--text);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.dropdown__item > a:hover {
  background: var(--surface);
  color: var(--black);
}

/* Punto de color de categoría */
.dropdown__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Acciones del header */
.site-header__actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  color: var(--text-muted);
  transition: color var(--t-fast), background var(--t-fast);
}
.header-icon-btn:hover { color: var(--black); background: var(--surface); }

/* Menú hamburguesa */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  padding: var(--sp-2);
  border-radius: var(--r-md);
}
.menu-toggle__bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--black);
  border-radius: 2px;
  transition: transform var(--t-base), opacity var(--t-fast);
}
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* .site-header__categories y .category-nav-bar eliminados — barra única */

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
  background: var(--black);
  color: rgba(255,255,255,0.6);
}

.site-footer__main {
  padding: var(--sp-8) 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.footer-main-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-8);
  flex-wrap: wrap;
}

.footer-logo {
  font-size: var(--text-xl);
  font-weight: var(--fw-extrabold);
  color: var(--white);
  letter-spacing: -0.03em;
  text-decoration: none;
}
.footer-logo span { color: var(--accent); }

.footer-nav-links {
  display: flex;
  gap: var(--sp-6);
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-nav-links a {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  transition: color var(--t-fast);
}
.footer-nav-links a:hover { color: var(--white); }

.site-footer__bottom {
  padding: var(--sp-4) 0;
}

.footer-copyright {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.3);
  margin: 0;
  text-align: center;
}
.footer-copyright a { color: rgba(255,255,255,0.45); }

/* ============================================================
   GRIDS
   ============================================================ */

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

.neu-grid--3col { grid-template-columns: repeat(3, 1fr); }

/* Grid asimétrico: grande izquierda + 2 apilados derecha */
.neu-grid--asymmetric {
  grid-template-columns: 1fr 380px;
  grid-template-rows: auto auto;
  align-items: start;
}
.neu-grid--asymmetric > :first-child {
  grid-column: 1;
  grid-row: 1 / 3;
}
/* Fuerza los dos secundarios a la columna derecha */
.neu-grid--asymmetric > :nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}
.neu-grid--asymmetric > :nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

@media (max-width: 1100px) {
  .neu-grid--asymmetric {
    grid-template-columns: 1fr 1fr;
  }
  .neu-grid--asymmetric > :first-child,
  .neu-grid--asymmetric > :nth-child(2),
  .neu-grid--asymmetric > :nth-child(3) {
    grid-column: auto;
    grid-row: auto;
  }
}
@media (max-width: 768px) {
  .neu-grid--3col { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .neu-grid--3col,
  .neu-grid--asymmetric { grid-template-columns: 1fr; }
}

/* ============================================================
   SECCIÓN EDITORIAL
   ============================================================ */

.editorial-section { padding: 32px 0; }

.editorial-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.editorial-section__title {
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--black);
  position: relative;
  padding-left: var(--sp-4);
}
.editorial-section__title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 2px;
  background: var(--section-accent, var(--accent));
}

.editorial-section__link {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--accent);
  white-space: nowrap;
}
.editorial-section__link:hover { color: var(--accent-dark); }

/* ============================================================
   PAGINACIÓN
   ============================================================ */

.archive-pagination { margin-top: var(--sp-12); }
.archive-pagination .nav-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.archive-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--t-fast);
}
.archive-pagination .page-numbers:hover { border-color: var(--accent); color: var(--accent); }
.archive-pagination .page-numbers.current { background: var(--accent); border-color: var(--accent); color: var(--white); }
.archive-pagination .page-numbers.dots { border-color: transparent; cursor: default; }

/* ============================================================
   ESTADO VACÍO
   ============================================================ */

.no-results {
  text-align: center;
  padding: var(--sp-20) 0;
}
.no-results p { color: var(--text-muted); font-size: var(--text-lg); }

/* ============================================================
   BADGE DE CATEGORÍA
   ============================================================ */

.category-badge {
  display: inline-block;
  padding: 3px var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--white);
  text-decoration: none;
  line-height: 1.5;
}

/* ============================================================
   UTILIDADES
   ============================================================ */

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }

/* ============================================================
   RESPONSIVE HEADER — MOBILE
   ============================================================ */

@media (max-width: 768px) {
  .menu-toggle { display: flex; }

  .site-nav {
    display: none;
    position: fixed;
    top: var(--header-h);   /* barra única, solo --header-h */
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-4);
    z-index: 199;
  }
  .site-nav.is-open { display: block; }
  .site-nav__menu { flex-direction: column; align-items: stretch; }
  .site-nav__menu li a {
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--text-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* En mobile el dropdown se muestra inline (position: static) */
  .menu-item--has-dropdown.is-dropdown-open > .dropdown__menu {
    display: block;
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: var(--surface);
    min-width: 0;
    padding: var(--sp-1) 0 var(--sp-2);
    margin: 0;
  }
  .menu-item--has-dropdown.is-dropdown-open .dropdown__item > a {
    padding: var(--sp-2) var(--sp-6);
    font-size: var(--text-sm);
  }

  .footer-main-inner { flex-direction: column; align-items: flex-start; gap: var(--sp-4); }
  .footer-nav-links { gap: var(--sp-4); }
}
