/* La Era Static Site Optimization Overrides (v1)
 * Fixes CLS, header bloat, sticky-bar gap, dark-mode logo, empty wrappers,
 * placeholder boxes, desktop sticky 300px article rail, and manual AdSense containers.
 */

/* 1. Sticky bar must be fixed overlay, never occupy 49px of flow height */
#site-sticky-bar.sticky-bar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 40;
}

/* 2. Collapse bloated / redundant header utility strip on homepages & clean tagline spacing */
header#site-header-full .utility-strip {
  display: none !important;
}

header#site-header-full .logo-tagline {
  margin-top: 0.4rem !important;
  line-height: 1.3 !important;
  color: var(--color-muted-foreground) !important;
}

header#site-header-full .masthead-inner {
  padding-block: 0.65rem !important;
}

header#site-header-full .time-strip-inner {
  padding-block: 0.35rem !important;
}

/* 3. Fix invisible footer wordmark in dark mode */
footer.site-footer .max-w-md svg {
  fill: var(--color-foreground) !important;
  color: var(--color-foreground) !important;
}

/* 4. Remove empty legacy ad wrappers and empty comments borders */
.homepage-ad:empty,
.section-ad:empty,
.section-card-ad:empty,
.article-ad:empty,
article .mt-12.border-t:empty,
div.mx-auto.max-w-4xl.px-4.py-6:empty {
  display: none !important;
}

/* 5. Hide generic grey placeholder-article.svg boxes so imageless stories look editorial */
figure:has(> img[src*="placeholder-article.svg"]),
div.overflow-hidden:has(> figure > img[src*="placeholder-article.svg"]) {
  display: none !important;
}

/* 6. Fix mx.laera.cl legacy 3-column section grid (drop dead empty 3rd column) */
@media (min-width: 1280px) {
  .section-index-grid {
    grid-template-columns: minmax(0, 1fr) 18.75rem !important;
  }
  .section-index-grid > aside.hidden.xl\:block {
    display: none !important;
  }
}

/* 7. Widen desktop article rail to 300px (18.75rem) for high-CPM 300x600 / 300x250 units */
@media (min-width: 1024px) {
  .article-shell {
    grid-template-columns: minmax(0, 1fr) 18.75rem !important;
    gap: 2.5rem !important;
    align-items: start !important;
  }
  .article-rail {
    display: block !important;
    position: sticky !important;
    top: 4.5rem !important;
    padding-top: 1.5rem !important;
    width: 18.75rem !important;
  }
}

@media (min-width: 1280px) {
  .article-shell {
    grid-template-columns: minmax(0, 1fr) minmax(0, 48rem) 18.75rem !important;
  }
  .article-layout {
    grid-column: 2 !important;
    width: 100% !important;
  }
  .article-rail {
    grid-column: 3 !important;
  }
}

/* 8. Stabilize section & card grids (prevent SemaforSectionLayout cold-load CLS) */
.story-figure {
  aspect-ratio: 4 / 3;
  background: var(--color-muted);
}

.hero-figure img,
.editorial-lead-image img {
  aspect-ratio: 4 / 3;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.top-row,
.image-row,
.deck-grid {
  align-items: start;
}

/* Fix dark-mode yellow highlight clash on feature briefing card */
.dark .feature-newsletter {
  background: hsl(0 0% 10%) !important;
  border-color: var(--color-border) !important;
}

.dark .feature-cta-mark {
  background: hsl(42 45% 24%) !important;
  color: var(--color-foreground) !important;
}

/* Tighten homepage top padding now that sticky ghost bar is gone */
.semafor {
  padding-top: 1.25rem !important;
}

@media (min-width: 1280px) {
  .semafor {
    padding-top: 1.75rem !important;
  }
}

/* 9. Performance: defer off-screen layout/paint for lower sections */
.editorial-block,
.recirculation {
  content-visibility: auto;
  contain-intrinsic-size: auto 520px;
}

/* 10. Zero-CLS Manual AdSense Slot Styling */
.laera-ad {
  contain: layout style;
  margin: 1.75rem auto;
  padding: 0.75rem 0;
  width: 100%;
  border-block: 1px solid var(--color-border);
  text-align: center;
}

.laera-ad.laera-ad-rail {
  margin: 0;
  padding: 0;
  border-block: 0;
  width: 300px;
}

.laera-ad.laera-ad-inarticle {
  margin: 2rem auto;
  border-block: 1px dashed var(--color-border);
  padding: 1rem 0;
}

.laera-ad.laera-ad-multiplex {
  max-width: 56rem;
  margin: 2rem auto;
  padding: 1rem 1rem 0.5rem;
  border-block: 1px solid var(--color-border);
}

.laera-ad-label {
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-muted-foreground);
  opacity: 0.75;
}

.laera-ad-box {
  width: 100%;
  min-height: 100px;
  overflow: hidden;
  display: block;
}

.laera-ad-inarticle .laera-ad-box,
.laera-ad-multiplex .laera-ad-box {
  min-height: 280px;
}

.laera-ad-rail .laera-ad-box {
  width: 300px;
  min-height: 600px;
}

@media (min-width: 768px) {
  .laera-ad-banner .laera-ad-box {
    max-width: 970px;
    margin-inline: auto;
    min-height: 100px;
  }
}

.laera-ad.is-unfilled {
  display: none !important;
}

/* 11. Compact static explorer CTA replacing dead newsletter forms */
.laera-rss-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  border: 1px solid var(--color-foreground);
  background: var(--color-foreground);
  color: var(--color-background) !important;
  padding: 0.6rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none !important;
  transition: opacity 0.15s ease;
}

.laera-rss-cta:hover {
  opacity: 0.85;
}
