:root {
  --color-bg: #f6f7f4;
  --color-surface: #ffffff;
  --color-text: #1a1f16;
  --color-muted: #4a5544;
  --color-accent: #2d6a4f;
  --color-accent-dark: #1b4332;
  --color-warn: #bc6c25;
  --font: "DM Sans", system-ui, sans-serif;
  --font-display: "Outfit", "DM Sans", system-ui, sans-serif;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(27, 67, 50, 0.08);
  --max: 72rem;
  --bp-nav: 901px;
  --touch-min: 2.75rem;
  --pad-inline: max(1rem, env(safe-area-inset-left, 0px));
  --pad-inline-end: max(1rem, env(safe-area-inset-right, 0px));
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1rem, 0.92rem + 0.35vw, 1.08rem);
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

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

a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--color-accent-dark);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left));
  top: max(1rem, env(safe-area-inset-top));
  z-index: 100;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  background: var(--color-accent-dark);
  color: #fff;
}

.wrap {
  width: min(100% - var(--pad-inline) - var(--pad-inline-end), var(--max));
  margin-inline: auto;
  padding-inline: 0;
}

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid rgba(27, 67, 50, 0.12);
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
}

.header-shell {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.55rem 0 0.75rem;
  /* Ancla el escalado del título al ancho útil del header (más fiel que solo vw) */
  container-type: inline-size;
  min-width: 0;
}

.header-title {
  margin: 0;
  padding: 0.35rem 0 0.45rem;
  text-align: left;
  font-family: var(--font-display);
  /* Una sola línea: el tamaño sube/baja con el espacio disponible */
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
  /* Fallback: viewport (navegadores sin cqi en contenedor) */
  font-size: clamp(0.38rem, 0.16rem + 3.1vw, 2rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.035em;
  color: var(--color-accent-dark);
}

/* Título fluido al ancho real del bloque cabecera (responsive “de verdad”) */
@supports (font-size: 1cqi) {
  .header-title {
    font-size: clamp(0.38rem, 2.85cqi, 2rem);
  }
}

/* Tres líneas (inicio): anular nowrap del título y dejar que <br> marque el salto */
.header-title.header-title--stacked {
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}

@media (max-width: 640px) {
  .header-title.header-title--stacked {
    font-size: clamp(0.92rem, 0.4rem + 4.2vw, 1.52rem);
    line-height: 1.18;
    letter-spacing: -0.03em;
  }
}

.header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.nav-toggle {
  display: none;
  font: inherit;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 0.5rem 0.85rem;
  border: 1px solid rgba(27, 67, 50, 0.25);
  border-radius: 8px;
  background: var(--color-surface);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
  align-items: center;
  justify-content: center;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
  justify-content: center;
}

.site-nav a {
  font-size: clamp(0.88rem, 0.82rem + 0.2vw, 0.92rem);
  font-weight: 500;
  text-decoration: none;
  color: var(--color-muted);
  padding: 0.5rem 0.35rem;
  border-radius: 6px;
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--color-accent-dark);
  background: rgba(45, 106, 79, 0.08);
  outline: none;
}

.site-nav a:focus-visible {
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
}

.site-nav a.active {
  color: var(--color-accent-dark);
  font-weight: 700;
  border-bottom: 2px solid var(--color-accent);
}

.main {
  flex: 1;
  padding: clamp(1.25rem, 3vw, 2rem) 0 clamp(2rem, 5vw, 3.5rem);
}

/* Inicio: menos aire sobre el hero para ver banner + imagen sin tanto scroll */
.page-inicio .main {
  padding-top: clamp(0.6rem, 1.8vw, 1rem);
}

.hero {
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 55%, #40916c 100%);
  color: #f8fff4;
  padding: clamp(1rem, 3vw, 1.65rem) 0;
  margin-bottom: clamp(1rem, 3vw, 1.75rem);
}

.hero .wrap {
  max-width: min(100% - var(--pad-inline) - var(--pad-inline-end), 62rem);
}

.hero-inner {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  gap: clamp(1rem, 3vw, 2rem);
  flex-wrap: nowrap;
}

.hero-logo-wrap {
  flex: 0 0 auto;
  align-self: flex-start;
}

.hero-logo-wrap:empty {
  display: none;
}

.hero-logo-wrap:empty ~ .hero-copy {
  flex: 1 1 100%;
  min-width: 0;
}

.hero-logo {
  height: auto;
  width: clamp(140px, 42vw, 260px);
  max-width: 100%;
  object-fit: contain;
  object-position: center center;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.25));
}

/* Escritorio: columna ~1/3 del ancho; logo a la altura del bloque de texto */
@media (min-width: 641px) {
  .hero-inner {
    align-items: stretch;
  }

  .hero-logo-wrap {
    flex: 0 0 clamp(12rem, 38%, 28rem);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    min-width: 0;
    min-height: 0;
  }

  .hero-logo {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center center;
  }
}

.hero-copy {
  flex: 1 1 0;
  min-width: 0;
  text-align: left;
}

.hero .tag {
  margin: 0 0 0.45rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.hero h1 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.35rem, 4.2vw, 2.05rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.hero-lead {
  font-size: clamp(0.95rem, 0.92rem + 0.25vw, 1.08rem);
  line-height: 1.45;
  opacity: 0.95;
  margin: 0 0 1rem;
}

@media (min-width: 641px) {
  .hero h1 {
    font-size: clamp(1.15rem, 2.75vw, 1.82rem);
    line-height: 1.2;
  }

  .hero-lead {
    font-size: clamp(0.88rem, 0.86rem + 0.22vw, 1.02rem);
    line-height: 1.42;
  }
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero-cta-block {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  max-width: 100%;
}

.hero-deadline {
  margin: 0;
  text-align: center;
  font-size: clamp(0.88rem, 0.82rem + 0.2vw, 0.95rem);
  font-weight: 600;
  color: #fff;
  opacity: 0.92;
  letter-spacing: 0.02em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch-min);
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: clamp(0.9rem, 0.85rem + 0.2vw, 0.95rem);
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}

.btn-primary {
  background: #f4f9f4;
  color: var(--color-accent-dark);
}

.btn-primary:hover {
  background: #fff;
}

.btn-ghost {
  background: transparent;
  color: #f8fff4;
  border-color: rgba(255, 255, 255, 0.45);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.section {
  margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
}

.section h2 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  margin: 0 0 1rem;
  color: var(--color-accent-dark);
}

.section h3 {
  font-size: clamp(1.05rem, 2.5vw, 1.15rem);
  margin: 1.5rem 0 0.5rem;
}

.prose {
  max-width: 48rem;
  width: 100%;
}

/* Inicio: «Por qué es muy importante» — centrado como el menú (mismo .wrap), texto justificado */
.section-por-que .prose {
  width: min(100%, 48rem);
  max-width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
  overflow-wrap: break-word;
  word-break: break-word;
}

.section-por-que .prose h2 {
  text-align: center;
  text-wrap: balance;
}

.section-por-que .prose ul,
.section-por-que .prose li {
  text-align: justify;
  text-justify: inter-word;
}

.prose h1 {
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  line-height: 1.25;
  color: var(--color-accent-dark);
  margin-top: 0;
}

.prose h2 {
  font-size: clamp(1.2rem, 3vw, 1.45rem);
  margin: 1.75rem 0 0.75rem;
  color: var(--color-accent-dark);
}

.prose h2[id] {
  scroll-margin-top: 5rem;
}

.prose h3 {
  font-size: clamp(1.05rem, 2.4vw, 1.2rem);
  margin: 1.35rem 0 0.5rem;
  color: var(--color-accent-dark);
}

.prose ul {
  padding-left: 1.25rem;
}

.prose li > p {
  margin: 0.65rem 0.25rem 0.65rem 0;
  line-height: 1.6;
}

.prose li > p:last-child {
  margin-bottom: 0;
}

.fullbleed-wrap {
  width: 100%;
  margin: clamp(0.75rem, 4vw, 2rem) 0;
  padding: 0;
  line-height: 0;
}

.fullbleed-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.25rem);
  box-shadow: var(--shadow);
  border: 1px solid rgba(27, 67, 50, 0.08);
}

.card h3 {
  margin-top: 0;
  font-size: 1.05rem;
}

.small {
  font-size: 0.9rem;
  color: var(--color-muted);
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent-dark);
  background: rgba(45, 106, 79, 0.12);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.meta-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.meta-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(27, 67, 50, 0.1);
}

.doc-table {
  width: 100%;
  min-width: min(32rem, 100%);
  border-collapse: collapse;
  font-size: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.doc-table th,
.doc-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid rgba(27, 67, 50, 0.1);
  vertical-align: top;
}

.doc-table th {
  background: rgba(45, 106, 79, 0.12);
  font-weight: 600;
}

.doc-table th[scope="row"] {
  white-space: nowrap;
  max-width: 40%;
}

@media (max-width: 520px) {
  .doc-table th[scope="row"] {
    white-space: normal;
  }
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * min(1rem, var(--pad-inline)));
  padding-inline: min(1rem, var(--pad-inline));
  max-width: 100vw;
  scrollbar-gutter: stable;
}

.table-scroll:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.table-scroll .doc-table {
  min-width: min(100%, 28rem);
}

@media (min-width: 640px) {
  .table-scroll .doc-table {
    min-width: 100%;
  }
}

.callout {
  border-left: 4px solid var(--color-warn);
  background: #fff9f0;
  padding: clamp(0.85rem, 2vw, 1rem) clamp(1rem, 3vw, 1.25rem);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
}

.callout strong {
  color: var(--color-accent-dark);
}

.figure {
  margin: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--color-surface);
}

.figure figcaption {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.site-footer {
  background: #e8ede5;
  border-top: 1px solid rgba(27, 67, 50, 0.12);
  padding: clamp(1.5rem, 4vw, 2rem) 0;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  margin-top: auto;
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: clamp(1rem, 3vw, 1.5rem);
  align-items: flex-start;
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
}

.footer-legal a {
  font-weight: 500;
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
}

@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .site-nav {
    flex: 1 1 100%;
    width: 100%;
    display: none;
  }

  .site-nav.is-open {
    display: block;
  }

  .site-nav ul {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0.5rem 0 1rem;
    gap: 0;
  }

  .site-nav a {
    display: flex;
    width: 100%;
    padding: 0.65rem 0.5rem;
    border-radius: 8px;
  }

  .site-nav a.active {
    border-bottom: none;
    background: rgba(45, 106, 79, 0.08);
  }
}

@media (min-width: 901px) {
  .nav-toggle {
    display: none;
  }

  .site-nav {
    flex: 1 1 auto;
    width: 100%;
    display: block;
    margin-left: 0;
  }

  .site-nav ul {
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .hero-inner {
    flex-wrap: wrap;
  }

  .hero-logo-wrap {
    flex: 1 1 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    align-self: center;
  }
}

@media (max-width: 540px) {
  .hero-inner {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
  }

  .hero-copy {
    text-align: left;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-cta-block {
    width: 100%;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .footer-grid {
    flex-direction: column;
  }
}

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

@media print {
  .site-header,
  .nav-toggle,
  .site-footer {
    position: static;
  }

  .site-nav {
    display: none;
  }

  .main {
    padding: 0;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
  }
}
