/* ==========================================================================
   Notícies: blocs de dins del text (galeries, abans i després, xifres...) i visor de fotos.
   El fan servir la web (noticia_detall.php) i l'editor de la intranet, perquè es vegi igual.
   L'HTML dels blocs és a intranet.adf301.cat/inc/noticies_comu.php.
   ========================================================================== */

.contingut-html {
  --groc: #f7b500;
  --groc-fosc: #e0a400;
  --groc-clar: #fff6dc;
  --ocre: #8a6400;
  --fosc: #1d1d1b;
  --text-2: #55595c;
  --linia: #d6d8d6;
  --fons-2: #f4f5f3;
  /* Els blocs grans surten de la columna de lectura */
  --ample: min(1080px, 100vw - 48px);
}

.contingut-html figure {
  margin: 0;
}

.contingut-html figcaption {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.5;
}

.contingut-html hr {
  width: 72px;
  height: 3px;
  margin: 40px auto;
  border: 0;
  background: var(--groc);
}

.contingut-html mark {
  padding: 0 3px;
  background: #ffe59a;
  color: inherit;
}

/* --- Foto amb peu --- */
.contingut-html .foto {
  margin: 32px 0;
}

.contingut-html .foto img {
  width: auto;
  max-height: 85vh;
  margin: 0 auto;
}

.contingut-html .foto--ampla {
  width: var(--ample);
  margin-inline: calc(50% - var(--ample) / 2);
}

.contingut-html .foto--ampla img {
  width: 100%;
  object-fit: cover;
}

.contingut-html .foto--esquerra,
.contingut-html .foto--dreta {
  width: 45%;
  margin-top: 6px;
  margin-bottom: 18px;
}

.contingut-html .foto--esquerra {
  float: left;
  margin-right: 28px;
}

.contingut-html .foto--dreta {
  float: right;
  margin-left: 28px;
}

.contingut-html .foto--esquerra img,
.contingut-html .foto--dreta img {
  width: 100%;
}

/* El que ve després d'una foto al costat i no és text corregut comença a sota */
.contingut-html::after {
  content: "";
  display: block;
  clear: both;
}

.contingut-html h2,
.contingut-html .galeria,
.contingut-html .comparador,
.contingut-html .quadre,
.contingut-html .xifres,
.contingut-html .cronologia,
.contingut-html .foto--ampla,
.contingut-html .video,
.contingut-html .video-propi,
.contingut-html .mapa {
  clear: both;
}

/* --- Galeries --- */
.contingut-html .galeria {
  --espai: 8px;
  width: var(--ample);
  margin: 36px calc(50% - var(--ample) / 2);
}

.contingut-html .galeria figure {
  position: relative;
  overflow: hidden;
  background: var(--fons-2);
}

.contingut-html .galeria img {
  width: 100%;
  height: 100% !important;
  margin: 0;
  object-fit: cover;
}

.contingut-html .galeria figcaption {
  position: absolute;
  inset: auto 0 0;
  margin: 0;
  padding: 28px 12px 10px;
  background: linear-gradient(transparent, rgba(15, 15, 14, 0.8));
  color: #fff;
  font-size: 0.8125rem;
  line-height: 1.4;
  pointer-events: none;
}

/* Mosaic: files de la mateixa alçada, sense retallar (les files i --r surten de noticies_mosaic()) */
.contingut-html .galeria__fila {
  display: flex;
  gap: var(--espai);
  max-width: calc(var(--s, 3) * 560px);
  margin: 0 auto;
}

.contingut-html .galeria__fila + .galeria__fila {
  margin-top: var(--espai);
}

.contingut-html .galeria__fila figure {
  flex: var(--r, 1.5) 1 0;
  aspect-ratio: var(--r, 1.5);
  min-width: 0;
}

/* Graella: quadrats iguals */
.contingut-html .galeria--graella {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--espai);
}

.contingut-html .galeria--graella figure {
  aspect-ratio: 1;
}

/* Carrusel */
.contingut-html .galeria--carrusel {
  display: flex;
  gap: var(--espai);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.contingut-html .galeria--carrusel figure {
  flex: none;
  max-width: 88%;
  height: min(60vh, 520px);
  scroll-snap-align: center;
}

.contingut-html .galeria--carrusel img {
  width: auto;
  max-width: 100% !important;
}

.carrusel-marc {
  position: relative;
}

.carrusel-boto {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 46px;
  height: 46px;
  margin-top: -32px;
  border: 0;
  background: var(--groc, #f7b500);
  color: #000;
  font-size: 1rem;
  cursor: pointer;
}

.carrusel-boto:hover {
  background: #e0a400;
}

.carrusel-boto[disabled] {
  opacity: 0;
  pointer-events: none;
}

.carrusel-boto--ant {
  left: calc(50% - var(--ample) / 2);
}

.carrusel-boto--seg {
  right: calc(50% - var(--ample) / 2);
}

/* --- Abans i després --- */
.contingut-html .comparador {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: var(--ample);
  margin: 36px calc(50% - var(--ample) / 2);
}

.contingut-html .comparador img {
  width: 100%;
  margin: 0;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.contingut-html .comparador.actiu {
  --p: 50%;
  /* Que hi càpiga sencer a la pantalla, també amb fotos verticals */
  --ample: min(1080px, 100vw - 48px, 80vh * var(--ratio, 1.5));
  display: block;
  overflow: hidden;
  user-select: none;
}

.contingut-html .comparador.actiu img {
  aspect-ratio: var(--ratio, 1.5);
}

.contingut-html .comparador.actiu figure + figure {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 var(--p));
}

.contingut-html .comparador.actiu figcaption {
  position: absolute;
  top: 14px;
  left: 14px;
  margin: 0;
  padding: 3px 12px;
  background: rgba(20, 20, 18, 0.82);
  color: #fff;
  font-weight: 600;
}

.contingut-html .comparador.actiu figure + figure figcaption {
  right: 14px;
  left: auto;
  background: var(--groc);
  color: #000;
}

.comparador__linia {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--p);
  width: 4px;
  margin-left: -2px;
  background: #fff;
  pointer-events: none;
}

.comparador__linia::after {
  content: "\2039\00a0\203a";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  color: #1d1d1b;
  font: 700 1.5rem/42px "Segoe UI", Arial, sans-serif;
  text-align: center;
}

.comparador input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  touch-action: pan-y;
}

.comparador input:focus-visible + .comparador__linia::after {
  outline: 3px solid #f7b500;
  outline-offset: 2px;
}

/* --- Quadres --- */
.contingut-html .quadre {
  margin: 32px 0;
  padding: 20px 24px;
  border: 1px solid var(--linia);
  border-left: 5px solid var(--fosc);
  background: var(--fons-2);
}

.contingut-html .quadre > strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.125rem;
}

.contingut-html .quadre > :last-child {
  margin-bottom: 0;
}

.contingut-html .quadre--avis {
  border-color: #ecd38c;
  border-left-color: var(--groc);
  background: var(--groc-clar);
}

.contingut-html .quadre--perill {
  border-color: #e6b9b9;
  border-left-color: #a51d1d;
  background: #fbeaea;
}

.contingut-html .quadre--be {
  border-color: #b9dcc4;
  border-left-color: #1e6b34;
  background: #eaf5ee;
}

/* --- Xifres --- */
.contingut-html .xifres {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 24px;
  margin: 36px 0;
  padding: 24px 0;
  border-top: 3px solid var(--groc);
  border-bottom: 1px solid var(--linia);
}

.contingut-html .xifres dt {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.15;
}

.contingut-html .xifres dd {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.45;
}

/* --- Cronologia --- */
.contingut-html .cronologia {
  margin: 32px 0;
  padding: 0;
  list-style: none;
}

.contingut-html .cronologia li {
  position: relative;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 36px;
  margin: 0;
  padding-bottom: 20px;
}

.contingut-html .cronologia li::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 104px;
  z-index: 1;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--groc);
}

.contingut-html .cronologia li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  bottom: -10px;
  left: 109px;
  width: 3px;
  background: var(--linia);
}

.contingut-html .cronologia strong {
  text-align: right;
}

/* --- Cita destacada --- */
.contingut-html .cita {
  margin: 40px 0;
  padding: 0;
  border: 0;
  color: var(--fosc);
  font-size: 1.5rem;
  font-style: normal;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.contingut-html .cita::before {
  content: "\201C";
  display: block;
  height: 44px;
  color: var(--groc);
  font: 700 5rem/1 Georgia, serif;
}

.contingut-html .cita p {
  margin: 0;
}

.contingut-html .cita cite {
  display: block;
  margin-top: 12px;
  color: var(--text-2);
  font-size: 0.9375rem;
  font-style: normal;
  font-weight: 400;
}

/* --- Desplegable --- */
.contingut-html .plegable {
  margin: 16px 0;
  padding: 0 20px;
  border: 1px solid var(--linia);
}

.contingut-html .plegable summary {
  margin: 0 -20px;
  padding: 14px 20px;
  font-weight: 700;
  cursor: pointer;
}

.contingut-html .plegable summary:hover {
  background: var(--fons-2);
}

.contingut-html .plegable summary::marker {
  color: var(--ocre);
}

/* --- Botó --- */
.contingut-html .crida {
  margin: 32px 0;
  text-align: center;
}

.contingut-html .crida .boto {
  display: inline-block;
  padding: 13px 28px;
  border: 2px solid var(--groc);
  background: var(--groc);
  color: #000;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}

.contingut-html .crida .boto:hover {
  border-color: var(--groc-fosc);
  background: var(--groc-fosc);
}

/* --- Documents --- */
.contingut-html .adjunts {
  margin: 28px 0;
  padding: 0;
  border-top: 1px solid var(--linia);
  list-style: none;
}

.contingut-html .adjunts li {
  margin: 0;
  border-bottom: 1px solid var(--linia);
}

.contingut-html .adjunts a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 8px;
  color: var(--fosc);
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}

.contingut-html .adjunts a::before {
  content: "\f019";
  color: var(--ocre);
  font: 900 1.1rem/1 "Font Awesome 6 Free";
}

.contingut-html .adjunts a:hover {
  background: var(--fons-2);
  text-decoration: underline;
}

.contingut-html .adjunts small {
  margin-left: auto;
  color: var(--text-2);
  font-weight: 400;
  white-space: nowrap;
}

/* --- Vídeos i mapa --- */
.contingut-html .video {
  position: static;
  margin: 32px 0;
  aspect-ratio: auto;
  background: none;
}

.contingut-html .video iframe {
  position: static;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
}

.contingut-html .video--vertical {
  max-width: 340px;
  margin-inline: auto;
}

.contingut-html .video--vertical iframe {
  aspect-ratio: 9 / 16;
}

.contingut-html .video-propi {
  margin: 32px 0;
}

.contingut-html .video-propi video {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto;
  background: #000;
}

.contingut-html .mapa {
  margin: 32px 0;
}

.contingut-html .mapa iframe {
  display: block;
  width: 100%;
  height: 380px;
  border: 1px solid var(--linia);
}

/* --- Portada --- */
.article__media--sencera img {
  width: auto;
  max-width: 100%;
  max-height: 900px;
  margin: 0 auto;
  aspect-ratio: auto;
}

.article__media figcaption,
.peu-portada {
  padding-top: 8px;
  background: #fff;
  color: #55595c;
  font-size: 0.875rem;
}

.peu-portada {
  margin: -24px 0 32px;
  padding: 0;
}

.portada-noticia {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: min(74vh, 660px);
  overflow: hidden;
  background: #1d1d1b;
  color: #fff;
}

.portada-noticia > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portada-noticia::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(15, 15, 14, 0.15) 0%, rgba(15, 15, 14, 0.3) 40%, rgba(15, 15, 14, 0.88) 100%);
}

.portada-noticia .contenidor {
  position: relative;
  z-index: 1;
  width: 100%;
  padding-top: 120px;
  padding-bottom: 36px;
}

.portada-noticia h1 {
  max-width: 900px;
  margin: 0 0 16px;
  color: #fff;
  font-size: clamp(1.7rem, 4vw, 2.9rem);
  line-height: 1.15;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.4);
}

.portada-noticia .molla,
.portada-noticia .molla a,
.portada-noticia .article__meta {
  margin-bottom: 10px;
  color: #fff;
}

.portada-noticia .molla li + li::before,
.portada-noticia .article__meta i {
  color: #f7b500;
}

/* --- Visor de fotos --- */
.ampliable {
  cursor: zoom-in;
}

.ampliable:focus-visible {
  outline: 3px solid #f7b500;
  outline-offset: -3px;
}

.visor {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: rgba(12, 12, 11, 0.96);
  color: #fff;
}

.visor[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.visor__cap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 0.9375rem;
}

.visor__marc {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 72px;
  touch-action: pan-y pinch-zoom;
}

.visor__marc img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.visor__peu {
  min-height: 56px;
  margin: 0;
  padding: 14px 24px 18px;
  text-align: center;
}

.visor button {
  width: 46px;
  height: 46px;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.visor button:hover {
  background: #f7b500;
  color: #000;
}

.visor__ant,
.visor__seg {
  position: absolute;
  top: 50%;
  margin-top: -23px;
}

.visor__ant {
  left: 12px;
}

.visor__seg {
  right: 12px;
}

@media (max-width: 640px) {
  .contingut-html {
    --ample: calc(100vw - 32px);
  }

  .contingut-html .comparador.actiu {
    --ample: calc(100vw - 32px);
  }

  .contingut-html .foto--esquerra,
  .contingut-html .foto--dreta {
    float: none;
    width: auto;
    margin: 28px 0;
  }

  /* El mosaic passa a dues columnes; amb un nombre senar de fotos, la primera és gran */
  .contingut-html .galeria--mosaic {
    --espai: 6px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--espai);
  }

  .contingut-html .galeria__fila {
    display: contents;
  }

  .contingut-html .galeria__fila figure {
    aspect-ratio: 1;
  }

  .contingut-html .galeria--senar .galeria__fila:first-child figure:first-child {
    grid-column: 1 / -1;
    aspect-ratio: 3 / 2;
  }

  .contingut-html .galeria--graella {
    --espai: 6px;
    grid-template-columns: 1fr 1fr;
  }

  .contingut-html .galeria--carrusel figure {
    height: 62vw;
  }

  .contingut-html .cronologia li {
    grid-template-columns: 1fr;
    gap: 0;
    padding-left: 28px;
  }

  .contingut-html .cronologia li::before {
    left: 0;
  }

  .contingut-html .cronologia li:not(:last-child)::after {
    left: 5px;
  }

  .contingut-html .cronologia strong {
    text-align: left;
  }

  .contingut-html .cita {
    font-size: 1.25rem;
  }

  .visor__marc {
    padding: 0;
  }

  .visor__ant,
  .visor__seg {
    top: auto;
    bottom: 10px;
  }

  .visor__peu {
    min-height: 68px;
    padding: 14px 70px;
    font-size: 0.875rem;
  }
}
