/* ==========================================================================
   1. RESETS I ESTILS GENERALS
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.6;
  color: #212529;
  background-color: #fcfcfc;
}

/* ==========================================================================
   2. CAPÇALERA I PEU DE PÀGINA
   ========================================================================== */
.header {
  background-color: #ffffff;
  border-bottom: 1px solid #e9ecef;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  /* color: #0066cc; */
  color: black;
  text-decoration: none;
}

.main-nav a {
  margin-left: 1.5rem;
  color: #495057;
  text-decoration: none;
  font-weight: 500;
}

.main-nav a:hover {
  color: #0066cc;
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  background-color: #f8f9fa;
  border-top: 1px solid #e9ecef;
  margin-top: 4rem;
  color: #6c757d;
  font-size: 0.9rem;
}

/* ==========================================================================
   3. ESTRUCTURA (GRID DE 3 COLUMNES EN DESKTOP)
   ========================================================================== */
.layout-container {
  display: grid;
  grid-template-columns: 250px 1fr 300px;
  gap: 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Sticky positioning per a les sidebars en fer scroll */
.sidebar-left,
.sidebar-right {
  position: sticky;
  top: 5rem;
  align-self: start;
}

/* ==========================================================================
   4. SIDEBAR ESQUERRA: ÍNDEX DE CONTINGUTS (DESKTOP)
   ========================================================================== */
.table-of-contents {
  background-color: #ffffff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.toc-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 1rem;
  color: #212529;
  border-bottom: 2px solid #f1f3f5;
  padding-bottom: 0.5rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin-bottom: 0.75rem;
}

.toc-list li:last-child {
  margin-bottom: 0;
}

.toc-list a {
  color: #495057;
  text-decoration: none;
  font-size: 0.92rem;
  transition: color 0.15s ease;
  display: block;
}

.toc-list a:hover {
  color: #0066cc;
  text-decoration: underline;
}

/* ==========================================================================
   5. ÍNDEX DESPLEGABLE PER A MÒBIL (<details>)
   ========================================================================== */
.toc-mobile {
  display: none; /* Amagat per defecte a Desktop */
  background-color: #ffffff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.toc-mobile-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #212529;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.toc-mobile-title::-webkit-details-marker {
  display: none;
}

.toc-mobile-title .toc-icon {
  font-size: 0.75rem;
  color: #0066cc;
  transition: transform 0.2s ease;
}

.toc-mobile[open] .toc-icon {
  transform: rotate(180deg);
}

.toc-mobile[open] .toc-list {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f3f5;
}

/* ==========================================================================
   6. COLUMNA CENTRAL: CONTINGUT PRINCIPAL
   ========================================================================== */
.main-content {
  min-width: 0;
}

.article h1 {
  font-size: 2.2rem;
  margin-top: 0;
  margin-bottom: 1rem;
  line-height: 1.25;
}

.article section {
  margin-bottom: 2.5rem;
  scroll-margin-top: 6rem;
}

.featured-image-container {
  margin: 0 0 2rem 0;
  width: 100%;
}

.featured-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  object-fit: cover;
  /* Mantenim una proporció d'aspecte de 16:9 per evitar salt de contingut (CLS) */
  aspect-ratio: 16 / 9; 
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.featured-image-caption {
  font-size: 0.85rem;
  color: #6c757d;
  margin-top: 0.5rem;
  text-align: center;
  font-style: italic;
}

.article h2 {
  font-size: 1.5rem;
  color: #343a40;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}
/* Ajusta els 80px a l'alçada exacta de la teva capçalera/header */
h2[id],
section[id] {
  scroll-margin-top: 70px;
}
/* Executive Summary styling */
.executive-summary {
  background-color: #f8f9fa;
  border-left: 4px solid #0066cc;
  padding: 1.25rem 1.5rem;
  border-radius: 0 8px 8px 0;
  margin-bottom: 2rem;
}

.executive-summary h2 {
  font-size: 1.15rem;
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
  color: #0066cc;
}

/* Box CTA Calculadora */
.calculator-cta-box {
  background-color: #e7f1ff;
  border: 1px solid #b6d4fe;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2rem 0;
  text-align: center;
}

.calculator-cta-box h3 {
  margin-top: 0;
  color: #004085;
}

.btn-primary {
  display: inline-block;
  background-color: #0066cc;
  color: #ffffff;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  margin-top: 0.5rem;
  transition: background-color 0.2s ease;
}

.btn-primary:hover {
  background-color: #0052a3;
}

/* ==========================================================================
   ENLLAÇOS INTERNS DINS DEL CONTINGUT DE L'ARTICLE (P I LI)
   ========================================================================== */
.article p a,
.article li a:not(.toc-list a),
.main-content p a,
.main-content li a:not(.toc-list a) {
  color: #0066cc;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(0, 102, 204, 0.4);
  text-underline-offset: 3px;
  background-color: rgba(0, 102, 204, 0.05);
  padding: 0.1em 0.3em;
  border-radius: 4px;
  transition: all 0.2s ease;
}

/* Efecte Hover & Focus */
.article p a:hover,
.article li a:not(.toc-list a):hover,
.main-content p a:hover,
.main-content li a:not(.toc-list a):hover {
  color: #004085;
  background-color: rgba(0, 102, 204, 0.12);
  text-decoration-color: #004085;
}

/* Icona indicativa d'enllaç/article relacionat */
.article p a::after,
.article li a:not(.toc-list a)::after,
.main-content p a::after,
.main-content li a:not(.toc-list a)::after {
  content: " ↗";
  font-size: 0.85em;
  display: inline-block;
  transition: transform 0.15s ease;
}

.article p a:hover::after,
.article li a:not(.toc-list a):hover::after,
.main-content p a:hover::after,
.main-content li a:not(.toc-list a):hover::after {
  transform: translate(2px, -2px);
}
/* ==========================================================================
   7. PUBLICITAT (DESKTOP I MÒBIL)
   ========================================================================== */
.ad-scaffolding {
  background-color: #f8f9fa;
  border: 2px dashed #ced4da;
  border-radius: 8px;
  width: 100%;
  min-height: 30vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ad-label {
  color: #adb5bd;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Per defecte en Desktop: Amaguem la publicitat interna del mòbil */
.ad-scaffolding-mobile {
  display: none;
  margin-bottom: 2.5rem;
}

/* ==========================================================================
   8. RESPONSIVE / ADAPTACIÓ MÒBIL
   ========================================================================== */
@media (max-width: 992px) {
  .layout-container {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  /* Amaguem les dues sidebars externes en mòbil */
  .sidebar-left,
  .sidebar-right {
    display: none;
  }

  /* Mostrem l'índex desplegable i la publicitat mòbil sota l'índex */
  .toc-mobile,
  .ad-scaffolding-mobile {
    display: block;
  }

  .ad-scaffolding-mobile .ad-scaffolding {
    min-height: 150px;
  }
}