/* ==========================================================================
   St. Trinnean's School — Vista de publicación (publicacion.php)
   Hoja propia con prefijo .pub- para no afectar el resto del sitio.
   ========================================================================== */

:root {
  --pub-navy: #001871;
  --pub-navy-90: #14297f;
  --pub-accent: #f57b51;
  --pub-ink: #1d2433;
  --pub-muted: #5b6475;
  --pub-line: #e3e6ee;
  --pub-soft: #f4f6fa;
  --pub-radius: 14px;
  --pub-shadow: 0 10px 30px -12px rgba(0, 24, 113, .25);
}

/* ---------- Ruta de navegación ---------- */
.pub-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .5rem;
  font-size: .9rem;
}
.pub-breadcrumbs a { color: var(--pub-navy); }
.pub-breadcrumbs .breadcrumb_last {
  color: var(--pub-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pub-breadcrumbs__sep { color: #9aa2b1; }

/* ---------- Contenedor general ---------- */
.pub {
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--pub-ink);
  padding: 2.5rem 0 4rem;
  background: #fff;
}
.pub .container { max-width: 1140px; }

/* ---------- Encabezado ---------- */
.pub-header {
  text-align: center;
  max-width: 900px !important;
  margin-bottom: 2rem;
}
.pub-header__title {
  margin: 0;
  color: var(--pub-navy);
  font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.01em;
  text-transform: none;
  overflow-wrap: anywhere;
}
.pub-header__lead {
  margin: .9rem auto 0;
  max-width: 46rem;
  color: var(--pub-muted);
  font-size: clamp(1.05rem, 1rem + .35vw, 1.25rem);
  line-height: 1.55;
}

/* ---------- Galería ---------- */
.pub-gallery { margin-bottom: 2.5rem; }

.pub-stage {
  position: relative;
  border-radius: var(--pub-radius);
  overflow: hidden;
  background: #0b1430;
  box-shadow: var(--pub-shadow);
}

.pub-track {
  position: relative;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  outline: none;
}
.pub-track::-webkit-scrollbar { display: none; }
.pub-track:focus-visible { box-shadow: inset 0 0 0 3px var(--pub-accent); }

.pub-slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  margin: 0;
  aspect-ratio: 3 / 2;
  max-height: 78vh;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  overflow: hidden;
}
@supports not (aspect-ratio: 1 / 1) {
  .pub-slide { height: 0; padding-top: 66.6667%; }
}

/* Fondo difuminado de la misma foto: rellena los costados de fotos verticales */
.pub-slide__bg {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  object-fit: cover;
  filter: blur(28px) saturate(1.15) brightness(.7);
  transform: translateZ(0);
}

.pub-slide__zoom {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.pub-slide__zoom:focus-visible { outline: 3px solid var(--pub-accent); outline-offset: -3px; }

.pub-slide__img {
  position: relative;
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .35);
}

/* Flechas */
.pub-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: var(--pub-navy);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
  cursor: pointer;
  transition: transform .2s ease, background-color .2s ease, opacity .2s ease;
}
.pub-arrow:hover { background: #fff; transform: scale(1.06); }
.pub-arrow:focus-visible { outline: 3px solid var(--pub-accent); outline-offset: 2px; }
.pub-arrow[disabled] { opacity: .35; cursor: default; transform: none; }
.pub-arrow--prev { left: 16px; }
.pub-arrow--next { right: 16px; }

.pub-zoom-hint {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: .8rem;
  pointer-events: none;
}

/* Leyenda + contador */
.pub-gallery__bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .85rem;
  min-height: 1.5rem;
}
.pub-caption {
  margin: 0;
  color: var(--pub-muted);
  font-size: .95rem;
  line-height: 1.5;
}
.pub-counter {
  flex: none;
  margin: 0 0 0 auto;
  color: var(--pub-navy);
  font-size: .95rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Miniaturas */
.pub-thumbs {
  position: relative;
  display: flex;
  gap: .6rem;
  margin-top: .85rem;
  padding: 4px 2px 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.pub-thumb {
  flex: 0 0 auto;
  width: 96px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--pub-soft);
  opacity: .55;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: opacity .2s ease, outline-color .2s ease;
}
.pub-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pub-thumb:hover { opacity: .9; }
.pub-thumb.is-active { opacity: 1; outline-color: var(--pub-navy); }
.pub-thumb:focus-visible { opacity: 1; outline-color: var(--pub-accent); }

/* ---------- Cuerpo del texto ---------- */
.pub-body { max-width: 780px !important; }
.pub-prose {
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--pub-ink);
  overflow-wrap: break-word;
}
.pub-prose p,
.pub-prose li,
.pub-prose span,
.pub-prose div {
  color: var(--pub-ink);
  font-size: inherit;
  line-height: inherit;
}
.pub-prose p,
.pub-prose ul,
.pub-prose ol { margin: 0 0 1.15em; }
.pub-prose a { color: var(--pub-navy); text-decoration: underline; text-underline-offset: 2px; }
.pub-prose img { max-width: 100%; height: auto; border-radius: 8px; }
.pub-prose h2, .pub-prose h3, .pub-prose h4 { color: var(--pub-navy); margin: 1.6em 0 .6em; line-height: 1.3; }

/* ---------- Secciones: videos y documentos ---------- */
.pub-section { max-width: 900px !important; margin-top: 3rem; }
.pub-section__title {
  margin: 0 0 1.1rem;
  padding-bottom: .6rem;
  border-bottom: 2px solid var(--pub-line);
  color: var(--pub-navy);
  font-size: 1.35rem;
  font-weight: 700;
}

.pub-videos { display: grid; gap: 1.75rem; }
.pub-video { margin: 0; }
.pub-video__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--pub-radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--pub-shadow);
}
@supports not (aspect-ratio: 1 / 1) {
  .pub-video__frame { height: 0; padding-top: 56.25%; }
}
.pub-video__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pub-video figcaption { margin-top: .6rem; color: var(--pub-muted); font-size: .95rem; }

.pub-docs { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.pub-doc {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .95rem 1.1rem;
  border: 1px solid var(--pub-line);
  border-radius: 12px;
  background: #fff;
  color: var(--pub-ink);
  text-decoration: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.pub-doc:hover,
.pub-doc:focus-visible {
  border-color: var(--pub-navy);
  box-shadow: var(--pub-shadow);
  color: var(--pub-ink);
  text-decoration: none;
  transform: translateY(-1px);
}
.pub-doc:focus-visible { outline: 3px solid var(--pub-accent); outline-offset: 2px; }
.pub-doc__icon { flex: none; width: 32px; height: 32px; object-fit: contain; }
.pub-doc__text { display: flex; flex-direction: column; min-width: 0; }
.pub-doc__name { font-weight: 500; overflow-wrap: anywhere; }
.pub-doc__type { color: var(--pub-muted); font-size: .85rem; }
.pub-doc__arrow { flex: none; margin-left: auto; color: var(--pub-navy); }

/* ---------- Pie del artículo ---------- */
.pub-footer {
  max-width: 900px !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem !important;
  border-top: 1px solid var(--pub-line);
}
.pub-back {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .7rem 1.2rem;
  border-radius: 999px;
  background: var(--pub-navy);
  color: #fff;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .2s ease;
}
.pub-back:hover, .pub-back:focus-visible { background: var(--pub-navy-90); color: #fff; text-decoration: none; }
.pub-back:focus-visible { outline: 3px solid var(--pub-accent); outline-offset: 2px; }

/* ---------- Vista ampliada (lightbox) ---------- */
.pub-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  background: #050a1c;
  color: #fff;
}
.pub-lightbox[hidden] { display: none; }
.pub-lightbox__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
}
.pub-lightbox__count { font-size: .95rem; opacity: .85; font-variant-numeric: tabular-nums; }
.pub-lightbox__close,
.pub-lightbox__nav {
  display: grid;
  place-items: center;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color .2s ease;
}
.pub-lightbox__close { width: 46px; height: 46px; }
.pub-lightbox__close:hover, .pub-lightbox__nav:hover { background: rgba(255, 255, 255, .24); }
.pub-lightbox__close:focus-visible, .pub-lightbox__nav:focus-visible { outline: 3px solid var(--pub-accent); outline-offset: 2px; }
.pub-lightbox__stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 72px;
  touch-action: pan-y;
}
.pub-lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.pub-lightbox__caption {
  margin: 0;
  padding: .85rem 1rem 1.25rem;
  text-align: center;
  font-size: .95rem;
  opacity: .9;
  min-height: 3rem;
}
.pub-lightbox__nav {
  position: absolute;
  top: 50%;
  width: 54px;
  height: 54px;
  margin-top: -27px;
}
.pub-lightbox__nav--prev { left: 12px; }
.pub-lightbox__nav--next { right: 12px; }
body.pub-noscroll { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 767.98px) {
  .pub { padding: 1.5rem 0 3rem; }
  .pub-header { margin-bottom: 1.25rem; }
  /* La galería ocupa todo el ancho de la pantalla en móviles */
  .pub-gallery { padding-left: 0 !important; padding-right: 0 !important; }
  .pub-stage { border-radius: 0; box-shadow: none; }
  .pub-slide { aspect-ratio: 4 / 3.4; max-height: 72vh; }
  .pub-arrow { width: 40px; height: 40px; margin-top: -20px; }
  .pub-arrow--prev { left: 8px; }
  .pub-arrow--next { right: 8px; }
  .pub-gallery__bar,
  .pub-thumbs { padding-left: 15px; padding-right: 15px; }
  .pub-thumb { width: 72px; height: 50px; }
  .pub-zoom-hint { display: none; }
  .pub-prose { font-size: 1.05rem; line-height: 1.7; }
  .pub-lightbox__stage { padding: 0; }
  .pub-lightbox__nav { width: 44px; height: 44px; margin-top: -22px; background: rgba(0, 0, 0, .35); }
}

/* Usuarios que prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
  .pub-track, .pub-thumbs { scroll-behavior: auto; }
  .pub-arrow, .pub-doc, .pub-thumb, .pub-back { transition: none; }
}

/* Impresión: solo contenido */
@media print {
  .pub-arrow, .pub-zoom-hint, .pub-thumbs, .pub-back, .pub-lightbox { display: none !important; }
  .pub-stage { box-shadow: none; background: none; }
  .pub-slide__bg { display: none; }
}
