/* ===== PÁGINA DE ESPECIALIDADES ===== */
:root {
  /* Los colores de cada departamento vienen de la base de datos (tabla departamentos) */
  --azul-inst: #1a3a5c;
  --rojo-inst: #c0392b;
  --tinta: #1f2933;
  --gris: #5b6670;
  --linea: #dfe3e8;
  --fondo: #f3f4f6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Open Sans', sans-serif; color: var(--tinta); overflow-x: hidden;
  /* La imagen de fondo se define en la vista (igual que en Historia) */
  background-color: #dfe5ec; background-size: cover; background-position: center;
  background-repeat: no-repeat; background-attachment: fixed;
}

/* Tarjeta blanca sobre el fondo, igual que .contenido-historia */
.esp-pagina {
  max-width: 1200px; width: calc(100% - 48px); margin: 30px auto;
  background: #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
h1, h2, h3, .esp-btn, .tab { font-family: 'Montserrat', sans-serif; }

.esp-contenedor { max-width: 1120px; margin: 0 auto; padding: 0 40px; }

/* ---------- INTRO + RUTA ---------- */
.esp-intro { background: #fff; border-bottom: 1px solid var(--linea); padding: 48px 0 40px; }
.esp-intro h1 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 900; color: var(--azul-inst); line-height: 1.1; }
.esp-intro .lead { margin-top: 12px; max-width: 62ch; font-size: 1.02rem; line-height: 1.65; color: var(--gris); }

.ruta { margin-top: 36px; display: grid; grid-template-columns: 1fr auto 1fr auto 1.15fr; align-items: start; gap: 0; }
.ruta-paso { background: var(--fondo); border-radius: 12px; padding: 20px 20px 18px; position: relative; }
.ruta-paso .grado {
  font-family: 'Montserrat', sans-serif; font-weight: 900; font-size: 1.9rem; line-height: 1;
  color: var(--azul-inst);
}
.ruta-paso h3 { font-size: .95rem; font-weight: 800; margin: 10px 0 6px; color: var(--tinta); }
.ruta-paso p { font-size: .86rem; line-height: 1.55; color: var(--gris); }
.ruta-puntos { display: flex; gap: 6px; margin-top: 14px; }
.ruta-puntos span { width: 14px; height: 14px; border-radius: 50%; }
.ruta-puntos .p-grande { width: 26px; height: 26px; border: 4px solid #fff; background: var(--azul-inst); box-shadow: 0 0 0 2px var(--azul-inst); }

.ruta-paso.final { background: var(--azul-inst); }
.ruta-paso.final .grado, .ruta-paso.final h3 { color: #fff; }
.ruta-paso.final p { color: rgba(255,255,255,.8); }

.ruta-decision {
  align-self: center; display: flex; flex-direction: column; align-items: center;
  padding: 0 10px; min-width: 110px; text-align: center;
}
.ruta-decision::before {
  content: ''; display: block; width: 100%; height: 2px; margin-bottom: 8px;
  background: repeating-linear-gradient(90deg, var(--gris) 0 6px, transparent 6px 11px);
}
.ruta-decision div { display: flex; flex-direction: column; align-items: center; }
.ruta-decision span { font-family: 'Montserrat', sans-serif; font-size: .78rem; font-weight: 700; color: var(--tinta); line-height: 1.3; }
.ruta-decision small { font-size: .72rem; color: var(--gris); margin-top: 3px; line-height: 1.35; }

/* ---------- PESTAÑAS DE DEPARTAMENTO ---------- */
.esp-deptos { padding: 40px 0 56px; background: var(--fondo); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tab {
  --c: var(--azul-inst);
  background: #fff; border: 2px solid var(--linea); border-radius: 10px;
  padding: 14px 18px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  transition: border-color .15s, background .15s;
}
.tab strong { font-size: 1rem; font-weight: 800; color: var(--c); }
.tab small { font-family: 'Open Sans', sans-serif; font-size: .8rem; color: var(--gris); }
.tab:hover { border-color: var(--c); }
.tab[aria-selected="true"] { background: var(--c); border-color: var(--c); }
.tab[aria-selected="true"] strong, .tab[aria-selected="true"] small { color: #fff; }
.tab:focus-visible, .esp-card:focus-visible, .video-facade:focus-visible, .modal-cerrar:focus-visible, .esp-btn:focus-visible {
  outline: 3px solid #f1c40f; outline-offset: 2px;
}

.panel { margin-top: 28px; }
.panel[hidden] { display: none; }
.panel-desc { max-width: 70ch; color: var(--gris); line-height: 1.6; margin-bottom: 22px; }
.panel-desc strong { color: var(--tinta); }

/* ---------- TARJETAS ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.esp-card {
  --c: var(--azul-inst);
  background: #fff; border: 1px solid var(--linea); border-radius: 12px; overflow: hidden;
  text-align: left; cursor: pointer; font: inherit; color: inherit;
  display: flex; flex-direction: column;
  transition: border-color .15s, transform .15s;
}
.esp-card:hover { border-color: var(--c); transform: translateY(-3px); }

.esp-media { aspect-ratio: 4 / 3; position: relative; background: var(--c); overflow: hidden; }
.esp-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.esp-media.sin-foto {
  display: flex; align-items: center; justify-content: center;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.07) 0 14px, transparent 14px 28px);
  background-color: var(--c);
}
.esp-media.sin-foto span { font-size: 3.4rem; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }

.esp-cuerpo { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.esp-cuerpo h3 { font-size: 1rem; font-weight: 800; color: var(--tinta); line-height: 1.3; }
.esp-cuerpo p {
  font-size: .86rem; line-height: 1.55; color: var(--gris);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.esp-cuerpo .ver { margin-top: auto; padding-top: 6px; font-family: 'Montserrat', sans-serif; font-size: .78rem; font-weight: 800; color: var(--c); }

/* ---------- MODAL ---------- */
.modal {
  --c: var(--azul-inst);
  border: none; border-radius: 14px; padding: 0; width: min(880px, 94vw); max-height: 92vh;
  margin: auto; color: var(--tinta); box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.modal::backdrop { background: rgba(15, 25, 40, .6); }
.modal[open] { animation: abrir .2s ease; }
@keyframes abrir { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.modal-fotos { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; grid-template-rows: 100%; height: 260px; overflow: hidden; background: var(--c); }
.modal-fotos img { width: 100%; height: 100%; min-height: 0; object-fit: cover; display: block; }
.modal-fotos.sin-foto {
  height: 140px; display: flex; align-items: center; justify-content: center; font-size: 3.6rem;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.07) 0 14px, transparent 14px 28px);
}

.modal-cerrar {
  position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 1.3rem; cursor: pointer; line-height: 1;
}
.modal-cerrar:hover { background: rgba(0,0,0,.75); }

.modal-cuerpo { padding: 26px 30px 30px; }
.modal-depto { display: inline-block; font-family: 'Montserrat', sans-serif; font-size: .75rem; font-weight: 700; color: #fff; background: var(--c); padding: 4px 10px; border-radius: 999px; }
.modal-cuerpo h2 { font-size: 1.6rem; font-weight: 900; margin: 10px 0 12px; color: var(--tinta); line-height: 1.2; }
.modal-cuerpo > p { line-height: 1.7; color: #3d4852; max-width: 72ch; }
.modal-cuerpo h3 { font-size: 1rem; font-weight: 800; margin: 24px 0 10px; color: var(--c); }

.aprendes { list-style: none; display: grid; gap: 8px; }
.aprendes li { position: relative; padding-left: 26px; line-height: 1.55; font-size: .94rem; }
.aprendes li::before {
  content: ''; position: absolute; left: 4px; top: .5em; width: 10px; height: 10px; border-radius: 2px;
  background: var(--c); transform: rotate(45deg);
}

.video-facade {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border: none; padding: 0;
  border-radius: 10px; overflow: hidden; cursor: pointer; background: #000;
}
.video-facade img { width: 100%; height: 100%; object-fit: cover; opacity: .85; display: block; }
.video-facade .play {
  position: absolute; inset: 0; margin: auto; width: 72px; height: 50px; border-radius: 12px;
  background: var(--rojo-inst); display: flex; align-items: center; justify-content: center;
}
.video-facade .play::after { content: ''; border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent #fff; margin-left: 4px; }
.video-facade:hover .play { background: #a93226; }
.video-frame { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; display: block; }

.modal-nota { margin-top: 22px; padding: 12px 16px; background: var(--fondo); border-radius: 8px; font-size: .88rem; color: var(--gris); }

/* ---------- LLAMADO FINAL ---------- */
.esp-cta { background: var(--azul-inst); color: #fff; padding: 44px 0; }
.esp-cta .esp-contenedor { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.esp-cta h2 { font-size: 1.4rem; font-weight: 800; }
.esp-cta p { color: rgba(255,255,255,.8); margin-top: 6px; }
.esp-btn {
  display: inline-block; background: var(--rojo-inst); color: #fff; text-decoration: none;
  font-size: .85rem; font-weight: 800; padding: 12px 26px; border-radius: 6px; transition: background .15s;
}
.esp-btn:hover { background: #a93226; }

footer {
  background: #13304d; color: rgba(255,255,255,.65); text-align: center;
  padding: 14px; font-family: 'Montserrat', sans-serif; font-size: 11.5px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  .ruta { grid-template-columns: 1fr; gap: 0; }
  .ruta-decision { flex-direction: row; gap: 10px; padding: 10px 0 10px 24px; min-width: 0; text-align: left; align-self: stretch; }
  .ruta-decision::before { width: 2px; height: 34px; margin: 0; background: repeating-linear-gradient(180deg, var(--gris) 0 6px, transparent 6px 11px); }
  .ruta-decision div { align-items: flex-start; justify-content: center; }
  .tabs { grid-template-columns: 1fr; }
  .modal-fotos { height: 190px; }
  .modal-cuerpo { padding: 22px 20px 24px; }
  .esp-pagina { width: calc(100% - 20px); margin: 10px auto; border-radius: 14px; }
  .esp-contenedor { padding: 0 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
