/*
Theme Name: Spacious Child
Template: spacious
Version: 1.1
*/

/* ==========================================================================
   IPESFA – Modernización visual (child theme)
   - Mobile-first
   - Cambios graduales y reversibles (solo CSS)
   - Compatible con Gutenberg (.wp-block-*)
   - Última revisión: 2026-04-27
   ========================================================================== */

/* ---------- Design tokens (8px spacing) ---------- */
:root {
  /* Tipografía */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Layout */
  --container-max: 1200px;
  --gutter: clamp(16px, 4vw, 32px);

  /* Espaciado (múltiplos de 8px) */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;

  /* Paleta institucional minimal */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #3F4656;
  --dark: #3F4656;
  --muted: #4b5563;
  --light: #f3f4f6;
  --border: #e6e8eb;
  --accent: #5FA9B3;
  --accent-hover: #4d8e95;
  --accent-soft: #edf7f8;
  --accent-contrast: #ffffff;

  /* UI */
  --radius-1: 10px;
  --radius-2: 14px;
  --radius: 12px;
  --shadow-0: none;
  --shadow-1: 0 1px 2px rgba(17, 24, 39, 0.08), 0 8px 24px rgba(17, 24, 39, 0.06);

  /* Tipografía fluida (clamp) */
  --text-base: clamp(16px, 0.35vw + 15px, 18px);
  --text-sm: clamp(14px, 0.25vw + 13px, 16px);
  --text-lg: clamp(18px, 0.6vw + 16px, 22px);
  --h1: clamp(28px, 2.4vw + 18px, 44px);
  --h2: clamp(24px, 1.9vw + 16px, 36px);
  --h3: clamp(20px, 1.2vw + 16px, 28px);
  --h4: clamp(18px, 0.8vw + 15px, 24px);
  --h5: clamp(16px, 0.5vw + 14px, 20px);
  --h6: clamp(15px, 0.4vw + 13px, 18px);

  /* Accesibilidad */
  --focus: #1d4ed8;
}


/* ==========================================================================
   LAYOUT NORMALIZATION
   Spacious applies body classes (narrow-1218, wide-1218, narrow-978,
   wide-978) plus sidebar classes (no-sidebar, no-sidebar-full-width,
   no-sidebar-content-stretched) that change #page width, body padding,
   .inner-wrap max-width, and overflow per page. This forces ONE
   consistent layout across ALL pages so the header never shifts.
   ========================================================================== */

/* Stable scrollbar gutter prevents ~15px shift between pages
   with/without scrollbar (short page vs long page). */
html {
  scrollbar-gutter: stable;
}

/* Body: kill the 30px padding "frame" from Spacious.
   Beat ALL layout-class variants with matching specificity. */
body,
body.wide-978,
body.wide-1218,
body.narrow-978,
body.narrow-1218 {
  padding: 0;
  background: var(--bg);
}

/* Kill overflow:hidden that Spacious sets on no-sidebar layouts.
   It removes the scrollbar on those pages, shifting centered content. */
body.no-sidebar-full-width,
body.no-sidebar {
  overflow: visible;
}

body,
button,
input,
select,
textarea {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  word-wrap: break-word;
}

/* #page: full width, no shadow, ALL layout classes including narrow-1218 (default). */
#page,
.wide-1218 #page,
.narrow-1218 #page,
.narrow-978 #page,
.wide-978 #page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  box-shadow: none;
}

/* .inner-wrap: single consistent container for ALL layout classes. */
.inner-wrap,
.wide-1218 .inner-wrap,
.narrow-1218 .inner-wrap,
.narrow-978 .inner-wrap,
.wide-978 .inner-wrap {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  box-sizing: border-box;
}

/* Override Spacious @media that sets #page{width:97%} + .inner-wrap{width:94%}. */
@media screen and (max-width: 1308px) {
  #page,
  .wide-1218 #page,
  .narrow-1218 #page,
  .narrow-978 #page,
  .wide-978 #page {
    width: 100%;
  }
  .inner-wrap,
  .wide-1218 .inner-wrap,
  .narrow-1218 .inner-wrap,
  .narrow-978 .inner-wrap,
  .wide-978 .inner-wrap {
    width: 100%;
  }
}

/* Stretched content layout override. */
body.no-sidebar-content-stretched #main .inner-wrap {
  max-width: var(--container-max);
}

/* HOME: prevent any wrapper from creating a white gap above the hero.
   The fixed header (position:fixed in header.css) takes #masthead's bar
   out of flow, but the <header> element itself may still contribute
   margin/padding from the parent theme.  Zero everything. */
body.home #page {
  padding-top: 0;
  margin-top: 0;
}
body.home #masthead.ipesfa-hdr {
  min-height: 0;
  height: 0;
  padding: 0;
  margin: 0;
  border: 0;
}
body.home #main {
  margin-top: 0;
  padding-top: 0;
}

/* Texto */
p {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text);
}

/* Headings (elimina padding-bottom antiguo, usa márgenes modernos) */
h1,
h2,
h3,
h4,
h5,
h6 {
  padding-bottom: 0;
  margin: 0 0 var(--space-2);
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--h1); line-height: 1.15; }
h2 { font-size: var(--h2); line-height: 1.2; }
h3 { font-size: var(--h3); line-height: 1.25; }
h4 { font-size: var(--h4); line-height: 1.3; }
h5 { font-size: var(--h5); line-height: 1.35; }
h6 { font-size: var(--h6); line-height: 1.35; color: var(--muted); }

/* Justificado de texto en áreas de contenido editorial.
   Solo párrafos — headings, listas y nav no se ven afectados. */
.entry-content p,
.bib-prose p,
.page-content p,
.post-content p {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* Excepción: agregar clase "no-justify" en Gutenberg → Avanzado → Clases CSS adicionales.
   Se aplica al <article> vía post_class() y anula el justificado de esa entrada. */
article.no-justify .entry-content p,
article.no-justify .bib-prose p {
  text-align: left;
  hyphens: none;
  -webkit-hyphens: none;
}

/* Fix: bloques Gutenberg con fondo (group, cover) dentro del entry-content.
   Cuando están en alignfull/alignwide se estiran al viewport sin padding propio,
   causando que el texto llegue al borde del contenedor. */
.entry-content .wp-block-group.has-background,
.entry-content .wp-block-cover.has-background {
  padding-left: clamp(24px, 4vw, 64px);
  padding-right: clamp(24px, 4vw, 64px);
}

/* En bloques columns dentro de full-width: deshabilitar hifenación agresiva
   ya que las columnas son angostas y hyphens las hace ilegibles. */
.entry-content .wp-block-columns .wp-block-column p {
  hyphens: manual;
  -webkit-hyphens: manual;
}

/* Links */
a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}
a:hover {
  color: var(--accent-hover);
}
/* Pisa el outline punteado de Spacious (a:focus { outline: thin dotted }).
   :focus-visible maneja el caso de teclado por separado. */
a:focus,
button:focus,
[role="button"]:focus,
input[type="submit"]:focus,
input[type="button"]:focus,
input[type="reset"]:focus {
  outline: none;
}
*:focus:not(:focus-visible) {
  outline: none !important;
}
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid var(--focus);
  outline: 3px solid color-mix(in srgb, var(--focus) 70%, transparent);
  outline-offset: 2px;
}

/* Separadores */
hr,
.wp-block-separator {
  background-color: var(--border);
  height: 1px;
  margin: var(--space-4) 0;
}

/* Imágenes: limpia márgenes y mejora estética */
img {
  margin-bottom: 0;
}
.entry-content img,
.wp-block-image img {
  border-radius: var(--radius-1);
}

/* ---------- Header + navegación ---------- */
#header-meta {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

#header-text-nav-container {
  border-bottom: 1px solid var(--border);
}

#header-text-nav-wrap {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

/* Branding */
#site-title a {
  color: var(--text);
  font-size: clamp(22px, 2vw + 14px, 34px);
  font-weight: 700;
}
#site-title a:hover {
  color: var(--accent);
}
#site-description {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* Flex layout (desktop) sin tocar HTML */
@supports (display: flex) {
  #header-text-nav-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  #header-left-section,
  #header-right-section {
    float: none;
  }

  #header-left-section {
    margin-right: 0;
  }

  #header-text {
    padding: 0;
  }
}

/* Navegación (desktop) */
.main-navigation {
  padding-top: 0;
}
.main-navigation li {
  font-family: var(--font-sans);
  margin-left: 20px;
}
.main-navigation a {
  color: var(--text);
  line-height: 1.8;
}
.main-navigation a:hover {
  color: var(--accent);
}

/* Dropdown: menos "vidrio" */
.main-navigation ul li ul {
  background: var(--surface);
  border-top: 2px solid var(--accent);
  box-shadow: var(--shadow-1);
  border-radius: var(--radius-1);
  overflow: hidden;
}
.main-navigation ul li ul li {
  border-bottom: 1px solid var(--border);
}
.main-navigation ul li ul li a {
  font-size: var(--text-sm);
  color: var(--text);
  padding: 10px 12px;
}
.main-navigation ul li ul li a:hover {
  background: #f3f4f6;
}

/* ---------- Menú móvil (<=768px) ---------- */
@media screen and (max-width: 768px) {
  .site-header .menu-toggle {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-1);
    font-size: 16px;
    font-weight: 600;
    padding: 12px 14px;
  }

  .site-header .menu-toggle:hover {
    background: #f3f4f6;
  }

  .main-small-navigation ul {
    border: 1px solid var(--border);
    border-radius: var(--radius-1);
    overflow: hidden;
  }

  .main-small-navigation li {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .main-small-navigation li:hover {
    background: #f3f4f6;
  }

  .main-small-navigation a {
    color: var(--text);
    padding: 12px 14px;
  }

  .main-small-navigation ul ul a {
    padding-left: 28px;
  }

  .main-small-navigation ul ul ul a {
    padding-left: 40px;
  }

  .sub-toggle {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    top: 10px;
    right: 12px;
  }

  .main-small-navigation li.current-menu-item > .sub-toggle {
    background: var(--surface);
  }
}

/* ---------- Botones / formularios ---------- */
.spacious-button,
input[type="reset"],
input[type="button"],
input[type="submit"],
button,
.wp-block-button__link {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  padding: 10px 16px;
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-0);
  margin-bottom: 0;
}

.spacious-button:hover,
input[type="reset"]:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
button:hover,
.wp-block-button__link:hover {
  box-shadow: var(--shadow-0);
  filter: brightness(0.95);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
textarea,
select {
  width: 100%;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-1);
  padding: 12px 12px;
  margin: 0 0 var(--space-3);
  line-height: 1.4;
}

label {
  display: block;
  margin: 0 0 var(--space-1);
  font-weight: 600;
  color: var(--text);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  border-color: var(--focus);
  border-color: color-mix(in srgb, var(--focus) 55%, var(--border));
  outline: 3px solid var(--focus);
  outline: 3px solid color-mix(in srgb, var(--focus) 30%, transparent);
  outline-offset: 2px;
}

/* ---------- Contenido + Gutenberg ---------- */
.entry-content > * + * {
  margin-top: var(--space-3);
}

.post .entry-title,
.page .entry-title {
  font-size: var(--h3);
  line-height: 1.25;
}

.post .entry-title a,
.page .entry-title a {
  color: var(--text);
}

.post .entry-title a:hover,
.page .entry-title a:hover {
  color: var(--accent);
}

.post .entry-meta {
  border: 1px solid var(--border);
  border-radius: var(--radius-1);
  background: #f9fafb;
  font-size: var(--text-sm);
}

.post .entry-meta .read-more-link {
  background: transparent;
  float: none;
}

.read-more,
.more-link {
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}

/* Quote */
blockquote,
.wp-block-quote {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-1);
  padding: var(--space-3);
  background: #fbfbfc;
}

/* Tables */
table,
.wp-block-table table {
  border-color: var(--border);
}
th,
td,
.wp-block-table th,
.wp-block-table td {
  border-color: var(--border);
}

/* Captions */
.wp-block-image figcaption,
figure figcaption {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

/* Columns gap (Gutenberg) */
.wp-block-columns {
  gap: var(--space-3);
}

/* Cover: texto más legible */
.wp-block-cover .wp-block-cover__inner-container {
  padding: var(--space-4) var(--space-3);
}

/* Footer */
#colophon {
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.footer-socket-wrapper {
  border-top: 1px solid var(--border);
}

/* ---------- Widgets / cards (sidebar + footer) ---------- */
#secondary .widget,
#colophon .widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
  padding: var(--space-3);
}

#secondary .widget-title,
#colophon .widget-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

a#scroll-up {
  background-color: #5FA9B3;
  opacity: 0.85;
}
a#scroll-up:hover {
  background-color: #4d9aa5;
  opacity: 1;
}