/* Theme global utilities and components */
:root {
  /* Fallback for Bootstrap large radius variable */
  --bs-border-radius-lg: 0.5rem;
  /* Air quality status colours (centralized) */
  --aq-color-green: #00ff00;
  --aq-color-yellow: #ffaa03;
  --aq-color-red: #ff0000;
  --aq-color-gray: #cfcfcf;
}

.title-small {
  font-size: 20px;
}

.text-blue {
  color: #3395af;
}

.title-small2 {
  font-size: 16px;
}

hr.shorter-divider {
  width: 25px;
  opacity: 1;
}

.grafic-title,
.news-title {
  font-family: 'Gordita', var(--font-family-heading);
  font-weight: 900;
  font-size: 16px;
  line-height: 18px;
  color: rgba(0, 0, 0, 0.5);
}

.news-title {
  color: black;
}



/* Notebook tabs background is controlled by header JS (white until data is loaded).
  Avoid binding it to body.low/medium/high to prevent initial SSR color flashes. */

.border-custom-gray {
  border-color: #b7bdbf !important;
}

.wow {
  visibility: hidden;
}

.bg-white {
  background-color: #ffffff !important;
}

.bg-black {
  background-color: #000000 !important;
}

/* Botó específic del tema: .btn-osona */
.btn-osona {
  display: inline-block;
  padding: 0 2rem;
  color: #000;
  background-color: #fff;
  border: 1px solid #000;
  border-radius: var(--bs-border-radius-lg);
  text-align: center;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.btn-osona:hover,
.btn-osona:focus {
  background-color: #ccc;
  color: #000;
  border-color: #999;
}

.btn-osona:active,
.btn-osona.active {
  background-color: #000;
  color: #fff;
  border-color: #000;
}

/* Accessibility focus ring */
.btn-osona:focus {
  outline: 3px solid rgba(0, 0, 0, 0.12);
  outline-offset: 2px;
}

/* Toxic buttons layout and info icon */
.toxic-item {
  gap: 0.5rem;
}

.btn-osona-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: 0.5rem;
  cursor: pointer;
}

.btn-osona-info img {
  display: block;
  width: 25px;
  height: 25px;
}

/* Custom select (replaces native dropdown visually) --------------------- */
.custom-select-wrapper {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
}


.custom-select-display {
  /* Minimal defaults — prefer to inherit from .btn-osona if present */
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 180ms ease;
}

/* When used together with .btn-osona, ensure spacing and square corners */
.custom-select-display.btn-osona {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2rem;
  /* similar rhythm to .btn-osona but a bit tighter */
  background-color: #fff;
  color: inherit;
  border: 1px solid #000;
  width: 100%;
  z-index: 12;
  position: relative;
  /* keep square as requested */
}

/*.custom-select-display.btn-osona.btn-sm {
  padding: 4px 0.75rem;
  font-size: 0.9rem;
}*/

.custom-select-display:focus {
  outline: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.custom-select-display .value {
  flex: 1 1 auto;
}

.custom-select-display .chev {
  margin-left: 8px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.6);
}


.custom-select-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  /* ensure it opens below the closed control */
  margin-top: 6px;
  z-index: 10;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  border-radius: 0;
  /* quadrat */
  max-height: 220px;
  overflow: auto;
  display: block;
  /* keep in DOM for a11y; hide via transform/opacity */
  transform-origin: top center;
  transform: translateY(-6px) scaleY(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 220ms cubic-bezier(.2, .9, .3, 1), opacity 180ms ease;
  padding-left: 0;
  padding-top: 7px;
  border-radius: 5px;
  border: 1px solid;
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: -7px;
  text-align: center;
}

.custom-select-wrapper.open .custom-select-list {
  transform: translateY(0) scaleY(1);
  opacity: 1;
  pointer-events: auto;
}

.custom-select-item {
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
  list-style: none;
}

.custom-select-item:hover,
.custom-select-item[aria-selected="true"] {
  background: rgba(0, 0, 0, 0.04);
}

/* Keep the native select available for form submission but hidden visually */
.custom-select-native.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* External toggle (arrow) styling to match toxic buttons */
.btn-select-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: 8px;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
}

.btn-select-toggle img {
  display: block;
  width: 16px;
  height: 16px;
}

/* Make sure the external toggle visually matches btn-osona-info when present */
.btn-select-toggle.btn-osona-info {
  width: 36px;
  height: 36px;
}

/* Smooth fade when swapping the zones image in article templates */
#zones-espanya-image {
  transition: opacity 320ms ease;
  opacity: 1;
  will-change: opacity;
}

/* Fixed background for Bellmunt image: full-bleed across the .full-section and fixed while scrolling */
.parallax-fixed {
  height: 80vh;
  min-height: 420px;
  /* ensure the image covers the width (may crop vertically) */
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  background-attachment: fixed;
  /* Compensate for the .full-section horizontal padding (1rem each side) so the image truly bleeds edge-to-edge */
  width: calc(100% + 2rem);
  margin-left: -1rem;
  margin-right: -1rem;
  position: relative;
  z-index: 0;
}

/* iOS Safari: background-attachment: fixed és inconsistent.
   Força scroll en iOS (sense tocar JS) per evitar parpelleigs i saltets.
*/
@supports (-webkit-touch-callout: none) {
  @media (max-width: 1024px) {
    .parallax-fixed {
      background-attachment: scroll;
    }
  }
}

/* Mobile fallback: background-attachment: fixed has poor support on some mobile browsers */
@media (max-width: 767px) {
  .parallax-fixed {
    background-attachment: scroll;
    background-size: cover;
    height: 40vh;
    min-height: 240px;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}



.max-w-300 {
  max-width: 300px;
}

.curved-container-100vw {
  overflow: hidden;
  width: 100vw;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  right: 50%;
  margin-right: -50vw;
  height: auto;
  overflow: hidden;
}

.curved-bottom {
  overflow: hidden;
  width: 150vw;
  position: relative;
  left: 25%;
  margin-left: -50vw;
  right: 75%;
  margin-right: -50vw;
  height: 100vh;
  border-radius: 0 0 0 0;
  transition: border-radius 0.15s linear;
}

/* Estils per als controls del gràfic (selector vertical estilitzat) */
.graph-controls select.form-select {
  display: inline-block;
  min-width: 160px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 6px 10px;
  background: #fff;
}

/* Info dropdown utilitzat a les capçaleres dels gràfics (mini-desplegable) */
.info-dropdown {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

/* Variant de la secció blava clara sol·licitada */
.blue-section--light {
  background-color: rgb(224, 232, 236);
  color: #3395af;
}

/* Petits estils d'accessibilitat helpers */
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  /* added line */
}

.full-section {
  position: relative;
  width: 100vw;
  left: 50%;
  margin-left: -50vw;
  right: 50%;
  margin-right: -50vw;
  background-color: var(--color-background-light);
  padding: 2rem 1rem;
}

.article-card__title {
  line-height: 18px;
  font-size: 16px;
}

.article-card__title a.stretched-link {
  text-decoration: none;
  line-height: inherit;
}

.mb-2rem {
  margin-bottom: 2rem;
}

/* === GLOBAL LEGEND STYLES (reusable) ===
   Use these classes to render consistent two-column legends across the theme.
   - Values in 2 columns
   - Swatch (circle) size: 14x14px
   - Text: bolder; font-size: 0.9rem
*/
.osona-legend {
  /* container for a legend */
}

.osona-legend .osona-legend-grid {
  display: flex;
  gap: 0.5rem 1rem;
  align-items: flex-start;
}

/* Fix: limitar l'alçada del gràfic "nombre-dies-ozo" per evitar que el canvas creixi indefinidament */
.nombre-dies-ozo-chart-container {
  height: 360px;
  max-height: 50vh;
  position: relative;
}
.nombre-dies-ozo-chart-container canvas#nombre-dies-ozo-chart {
  width: 100% !important;
  height: calc(100% - 60px) !important;
  display: block;
}
.threshold-value {
  font-weight: 700;
  color: red;
}

.osona-legend .osona-legend-column.left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.osona-legend .osona-legend-column.right {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 0;
}

/* Middle column for three-column legends */
.osona-legend .osona-legend-column.middle {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Compatibility: support new column class names (.col-1/.col-2/.col-3) used by the air legend generator */
.osona-legend .osona-legend-column.col-1,
#osona-air-legend .osona-air-legend-column.col-1 {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  /* First column behaves like the old .left (size driven by content) */
  flex: 0 0 auto;
}

.osona-legend .osona-legend-column.col-2,
.osona-legend .osona-legend-column.col-3,
#osona-air-legend .osona-air-legend-column.col-2,
#osona-air-legend .osona-air-legend-column.col-3 {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 0;
}

/* When rendered as an overlay inside chart containers ensure it's above decorative images */
.osona-legend--overlay {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: auto;
  z-index: 60;
  /* above chart parche (if any) */
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.0);
}

/* Specific placement for the ozó legend if needed */
#ozo-maxim-mitjanes-horaries-legend.osona-legend {
  /*position: absolute;
  bottom: 6px;
  left: 12px;
  z-index: 70;*/
  position: relative;
  padding-left: 64px;
}

.osona-legend .osona-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;

}

.osona-legend .osona-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 100%;
  flex: 0 0 14px;
  box-sizing: border-box;
}

.osona-legend .osona-legend-swatch.line-swatch {
  flex: 0 0 25px;
}

.osona-legend .osona-legend-swatch:not(.no-border) {
  border: 1px solid #000;
}

/* Backwards-compatible aliases for existing legend containers
   Ensure `#osona-air-legend` and `#paissatges-pessebre-legend` follow the same layout
*/
#osona-air-legend .osona-air-legend-grid,
#paissatges-pessebre-legend .paissatges-pessebre-legend-grid {
  display: flex;
  gap: 0.5rem 1rem;
  align-items: flex-start;
}

#osona-air-legend .osona-air-legend-column.left,
#paissatges-pessebre-legend .paissatges-pessebre-legend-column.left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 0 0 auto;
}

#osona-air-legend .osona-air-legend-column.right,
#paissatges-pessebre-legend .paissatges-pessebre-legend-column.right {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 0;
}

#osona-air-legend .osona-air-legend-item,
#paissatges-pessebre-legend .paissatges-pessebre-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

#osona-air-legend .osona-air-legend-swatch,
#paissatges-pessebre-legend .paissatges-pessebre-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 100%;
  flex: 0 0 14px;
  box-sizing: border-box;
  border: 1px solid #000;
}


#paissatges-pessebre-legend {
  padding-left: 77px;
}

/* Fix: evitar que el gràfic paissatges-pessebre creixi indefinidament
   Defineix una alçada explícita i un màxim responsive per al canvas
*/
#paissatges-pessebre-chart {
  width: 100% !important;
  height: calc(100% - 60px) !important;
  /* valor per defecte (desktop) */
  /*max-height: 60vh !important; /* never exceed viewport */
  display: block;
}

/* Contenidor immediat (si existeix) - evita que el contenidor flex forci una alçada automàtica */
.osona-regional-chart {
  /*display: flex;
  align-items: flex-start;
  gap: 1rem;
  */
}

.osona-regional-chart>canvas,
.osona-regional-chart>.chart-wrap>canvas {
  flex: 1 1 auto;
  min-height: 240px;
  max-height: 60vh;
}

@media (max-width: 767px) {
  #paissatges-pessebre-chart {
    height: 320px !important;
    max-height: 45vh !important;
  }

  #ozo-maxim-mitjanes-horaries-legend.osona-legend {
    padding-left: 0;
  }

  .osona-regional-chart {
    flex-direction: column;
  }

  .curved-bottom {
    height: 50vh;
  }

  /* Només aplicar l'estratègia bg-fixed quan el JS ha afegit explícitament .parallax-bg-fixed */
  .single-articles .curved-bottom .parallax-image.parallax-bg-fixed {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    height: 50vh;
  }

  /* Curved layout: el JS pot posar la bg a .curved-bottom directament */
  .single-articles .curved-bottom.parallax-bg-fixed {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
  }

  .single-articles .curved-bottom .parallax-image.parallax-bg-fixed img {
    display: none !important;
  }
}

/* When a legend item is hidden (aria-hidden="true"), show label struck-through */
.osona-legend-item[aria-hidden="true"] .osona-legend-label {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(0, 0, 0, 0.6);
}