/* ============================================================
   OpenEB5 · Country page — 8-module wireframe layout
   Usa exclusivamente tokens de tokens.css. Sin colores nuevos.
   v1.1.0
   ============================================================ */

/* ── M1 · Hero ───────────────────────────────────────────── */
.cty-hero {
  position: relative;
  background: var(--c-navy-800);
  color: var(--c-text-on-dark);
  padding: var(--sp-12) 0 var(--sp-10);
  overflow: hidden;
}
.cty-hero::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--overlay-hero);
  pointer-events: none;
  z-index: 0;
}
.cty-hero > .container { position: relative; z-index: 1; }

.cty-hero__top {
  display: flex; align-items: center; gap: var(--sp-4);
  margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.cty-hero__flag {
  width: 72px; height: 54px; flex: none;
  border-radius: var(--r-sm); overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,.22);
}
.cty-hero__flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cty-eyebrow {
  font-family: var(--ff-body);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-green-500);
}
.cty-hero__title {
  font-family: var(--ff-display);
  font-size: clamp(30px, 4.2vw, 50px);
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  color: var(--c-white);
  margin: 0 0 var(--sp-5);
  max-width: 20ch;
}
.cty-hero__sub {
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
  color: var(--c-text-on-dark-mute);
  max-width: 68ch;
  margin: 0 0 var(--sp-8);
}

/* Métricas rápidas
   OJO: base.css declara ul[role='list'] { margin:0 } con especificidad (0,1,1),
   que le gana a una clase sola (0,1,0) y borraba el margen inferior. Por eso
   los selectores de listas de este archivo llevan el elemento delante. */
ul.cty-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: var(--sp-4);
  margin: 0 0 var(--sp-8);
  padding: 0; list-style: none;
}
.cty-metric {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  backdrop-filter: blur(3px);
}
.cty-metric__label {
  display: block;
  font-size: var(--fs-xs);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: var(--fw-semibold);
  color: var(--c-green-500);
  margin-bottom: var(--sp-2);
}
.cty-metric__value {
  display: block;
  font-size: var(--fs-xl);
  line-height: var(--lh-snug);
  font-weight: var(--fw-bold);
  color: var(--c-white);
  margin-bottom: var(--sp-1);
}
.cty-metric__note {
  display: block;
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--c-text-on-dark-mute);
}

.cty-hero__ctas { display: flex; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-7); }

.cty-trust {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  border-top: 1px solid rgba(255,255,255,.16);
  padding-top: var(--sp-5);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--c-text-on-dark-mute);
  max-width: 82ch;
}
.cty-trust svg { flex: none; margin-top: 2px; color: var(--c-green-500); }

/* ── Secciones genéricas ─────────────────────────────────── */
.cty-section { padding: var(--section-py-sm) 0; }
@media (min-width: 900px) { .cty-section { padding: var(--section-py-md) 0; } }
.cty-section--paper { background: var(--c-paper); }

.cty-head { max-width: 76ch; margin: 0 0 var(--sp-8); }
.cty-head--center { margin-left: auto; margin-right: auto; text-align: center; }
.cty-head__title {
  font-family: var(--ff-display);
  font-size: clamp(26px, 3vw, 38px);
  line-height: var(--lh-snug);
  font-weight: var(--fw-bold);
  color: var(--c-text-strong);
  margin: var(--sp-2) 0 var(--sp-4);
}
.cty-head__lead {
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
  color: var(--c-text);
  margin: 0;
}
.cty-head .cty-eyebrow { color: var(--c-green-700); }

/* ── Grids de tarjetas ───────────────────────────────────── */
ul.cty-cards, ol.cty-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
  gap: var(--sp-5);
  list-style: none; margin: 0; padding: 0;
}
.cty-card {
  background: var(--c-white);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-base) var(--easing), box-shadow var(--t-base) var(--easing);
}
.cty-section--paper .cty-card { background: var(--c-white); }
.cty-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.cty-card__title {
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  font-weight: var(--fw-semibold);
  color: var(--c-text-strong);
  margin: 0 0 var(--sp-3);
}
.cty-card__body { font-size: var(--fs-base); line-height: var(--lh-relaxed); color: var(--c-text); }
.cty-card__body p { margin: 0 0 var(--sp-3); }
.cty-card__body p:last-child { margin-bottom: 0; }
.cty-card__body ul { margin: 0; padding-left: 0; list-style: none; }
.cty-card__body li {
  position: relative; padding-left: var(--sp-6);
  margin-bottom: var(--sp-2);
  color: var(--c-text-mute);
  font-size: var(--fs-base);
}
.cty-card__body li::before {
  content: ""; position: absolute; left: 6px; top: 9px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-green-500);
}
.cty-card__body li:last-child { margin-bottom: 0; }
.cty-card__body strong { color: var(--c-text-strong); font-weight: var(--fw-semibold); }

/* Tarjetas numeradas (M4 · trazabilidad de fondos) */
.cty-cards--steps { counter-reset: ctystep; }
/* El número va en flujo normal, no absoluto: así no depende del padding-top
   de la tarjeta, que en móvil lo pisaba el shorthand .cty-card { padding }
   y el círculo terminaba encima del título. */
.cty-card--step { counter-increment: ctystep; }
.cty-card--step::before {
  content: counter(ctystep);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  margin: 0 0 var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--c-navy-700); color: var(--c-white);
  font-size: var(--fs-sm); font-weight: var(--fw-bold);
  line-height: 1;
}
.cty-card--step .cty-card__title { margin-top: 0; }

/* ── Paneles (legal / documentación) ─────────────────────── */
.cty-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: var(--sp-5);
  margin-top: var(--sp-6);
}
.cty-panel {
  background: var(--c-paper-2);
  border: 1px solid var(--c-border-soft);
  border-left: 3px solid var(--c-green-500);
  border-radius: var(--r-md);
  padding: var(--sp-6);
}
.cty-section--paper .cty-panel { background: var(--c-white); }
.cty-panel__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--c-text-strong);
  margin: 0 0 var(--sp-3);
}
.cty-panel__body { font-size: var(--fs-base); line-height: var(--lh-relaxed); color: var(--c-text); }
.cty-panel__body p { margin: 0 0 var(--sp-3); }
.cty-panel__body p:last-child { margin-bottom: 0; }
.cty-panel__body ul { margin: 0 0 var(--sp-3); padding-left: 0; list-style: none; }
.cty-panel__body li {
  position: relative; padding-left: var(--sp-6); margin-bottom: var(--sp-2);
  color: var(--c-text-mute);
}
.cty-panel__body li::before {
  content: ""; position: absolute; left: 6px; top: 9px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--c-green-500);
}
.cty-panel__body strong { color: var(--c-text-strong); font-weight: var(--fw-semibold); }

/* ── Tablas embebidas ────────────────────────────────────── */
.cty-table { overflow-x: auto; margin: var(--sp-3) 0 var(--sp-4); -webkit-overflow-scrolling: touch; }
.cty-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: min(460px, 100%); }
.cty-table th, .cty-table td {
  border: 1px solid var(--c-border-soft);
  padding: var(--sp-3) var(--sp-4);
  text-align: left; vertical-align: top;
  line-height: var(--lh-normal);
}
.cty-table th { background: var(--c-navy-700); color: var(--c-white); font-weight: var(--fw-semibold); }
.cty-table tr:nth-child(even) td { background: var(--c-paper); }

/* ── Banda de proyectos ──────────────────────────────────── */
.cty-projects {
  background: var(--c-navy-700); color: var(--c-text-on-dark);
  padding: var(--sp-9) 0;
}
.cty-projects__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-6); flex-wrap: wrap;
}
.cty-projects h2 {
  font-family: var(--ff-display); font-size: var(--fs-2xl);
  color: var(--c-white); margin: 0 0 var(--sp-2); line-height: var(--lh-snug);
}
.cty-projects p { margin: 0; color: var(--c-text-on-dark-mute); max-width: 62ch; line-height: var(--lh-relaxed); }

/* ── M6 · FAQ ────────────────────────────────────────────── */
.cty-faq { max-width: 900px; margin: 0 auto; }
.cty-faq__item {
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-md);
  background: var(--c-white);
  margin-bottom: var(--sp-3);
  overflow: hidden;
}
.cty-faq__item[open] { box-shadow: var(--shadow-sm); border-color: var(--c-green-500); }
.cty-faq__q {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  font-size: var(--fs-md); font-weight: var(--fw-semibold);
  color: var(--c-text-strong); line-height: var(--lh-snug);
  transition: background var(--t-fast) var(--easing);
}
.cty-faq__q::-webkit-details-marker { display: none; }
.cty-faq__q:hover { background: var(--c-paper); }
.cty-faq__q:focus-visible { outline: 2px solid var(--c-green-500); outline-offset: -2px; }
.cty-faq__icon { flex: none; width: 20px; height: 20px; color: var(--c-green-700); transition: transform var(--t-base) var(--easing); }
.cty-faq__item[open] .cty-faq__icon { transform: rotate(45deg); }
.cty-faq__a {
  padding: 0 var(--sp-6) var(--sp-5);
  font-size: var(--fs-base); line-height: var(--lh-relaxed); color: var(--c-text);
}
.cty-faq__a p { margin: 0; }

/* ── M7 · CTA + formulario ───────────────────────────────── */
.cty-cta { background: var(--c-navy-800); color: var(--c-text-on-dark); padding: var(--section-py-sm) 0; }
@media (min-width: 900px) { .cty-cta { padding: var(--section-py-md) 0; } }
.cty-cta__grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-9); }
@media (min-width: 980px) { .cty-cta__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-12); align-items: start; } }
.cty-cta h2 {
  font-family: var(--ff-display); font-size: clamp(26px, 3vw, 38px);
  color: var(--c-white); margin: var(--sp-2) 0 var(--sp-4); line-height: var(--lh-snug);
}
.cty-cta__lead { font-size: var(--fs-md); line-height: var(--lh-relaxed); color: var(--c-text-on-dark-mute); margin: 0 0 var(--sp-6); }
.cty-cta__buttons { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.cty-cta .cty-eyebrow { color: var(--c-green-500); }

/* ── Responsive ──────────────────────────────────────────── */

/* Las pistas de grid deben poder achicarse: por defecto min-width:auto usa
   el min-content del hijo como piso, y eso era lo que empujaba la página. */
.cty-cta__grid { grid-template-columns: minmax(0, 1fr); }
.cty-cta__grid > *, .contact-form, .form-row, .form-field { min-width: 0; }
.contact-form .form-field input,
.contact-form .form-field select,
.contact-form .form-field textarea { width: 100%; min-width: 0; max-width: 100%; }
/* h3 global del form (30px) queda enorme dentro de la tarjeta. Scoped al país. */
.cty-cta .contact-form h3 { font-size: var(--fs-xl); line-height: var(--lh-snug); }
/* Nombres largos de organismos e IDs no rompen el layout. */
.cty-hero__title, .cty-head__title, .cty-card__title,
.cty-panel__title, .cty-faq__q, .cty-cta h2 { overflow-wrap: anywhere; }

@media (max-width: 768px) {
  .cty-hero { padding: var(--sp-9) 0 var(--sp-8); }
  .cty-hero__title { max-width: none; }

  /* Padding lateral propio: el global de 24px deja el texto muy al borde. */
  .cty-hero > .container,
  .cty-section > .container,
  .cty-projects > .container,
  .cty-cta > .container { padding-left: 20px; padding-right: 20px; }

  /* Encabezado: bandera y eyebrow alineados a la izquierda y legibles. */
  .cty-hero__top { gap: var(--sp-3); align-items: center; }
  .cty-hero__flag { width: 56px; height: 42px; }
  .cty-eyebrow { line-height: var(--lh-snug); }

  ul.cty-metrics { grid-template-columns: 1fr; }

  /* Botones: apilados, ancho completo, 12px entre ellos.
     .btn trae white-space:nowrap; acá el label puede partir. */
  .cty-hero__ctas,
  .cty-cta__buttons {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .cty-hero__ctas .btn,
  .cty-cta__buttons .btn,
  .cty-projects .btn {
    width: 100%;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }
  .cty-projects__inner { flex-direction: column; align-items: flex-start; }
  .cty-projects__inner > * { min-width: 0; width: 100%; }

  /* El botón de envío traía white-space:nowrap: su min-content fijaba un
     piso de 340px que, más los 40px de padding del form a cada lado,
     empujaba la página 50px. */
  .contact-form { padding: var(--sp-5); }
  .contact-form .btn { white-space: normal; text-align: center; }
  .cty-cta .contact-form h3 { font-size: var(--fs-lg); }

  .cty-card { padding: var(--sp-5); }
  .cty-faq__q { padding: var(--sp-4) var(--sp-5); font-size: var(--fs-base); }
  .cty-faq__a { padding: 0 var(--sp-5) var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  .cty-card, .cty-faq__icon { transition: none; }
  .cty-card:hover { transform: none; }
}
