/*
  Responsive layer for the public site. Loaded after site.css (minified Tailwind build, never edited by hand)
  and before forms.css, so it only adds what site.css lacks and fixes specificity gaps in its media queries.
  CSP: no inline styles anywhere; everything lives in this file.

  1. Base: safe areas, long strings, media     4. Archive
  2. Header, footer and cookie banner          5. Detail page
  3. Home                                      6. Short viewports and wide screens
*/

/* 1. Base --------------------------------------------------------------------------------------------- */
.wrap {
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
img, svg, video { max-width: 100%; }
h1, h2, h3, .pager-title, .card-meta, .facts dd, .legal-body p, .legal-body li { overflow-wrap: anywhere; }
h2, h3 { hyphens: manual; }
.card-body, .related-item > div, .quick-facts, .detail-body { min-width: 0; }
/* Text links that sit alone on a line get a 44px hit area without changing the layout. */
.discovery-card h2 a, .related-item h3 a, .related-item .topic a, .facts a { display: inline-block; padding-block: 11px; margin-block: -11px; }

/* 2. Header, footer and cookie banner ------------------------------------------------------------------ */
.site-footer-inner { padding-bottom: calc(26px + env(safe-area-inset-bottom)); }
.footer-note { overflow-wrap: anywhere; }
.mobile-menu nav { max-width: calc(100vw - 2 * var(--gutter)); }
.cookie-banner {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 760px) {
  .cookie-banner {
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
  }
}

/* 4. Archive ------------------------------------------------------------------------------------------- */
/* site.css resets the featured first card only with a weaker selector, so on phones it kept its
   desktop 8-column span and stretched the grid to ~900px. Match its specificity here. */
@media (max-width: 760px) {
  .archive-grid > .discovery-card:first-child:nth-last-child(n+4) {
    flex-direction: column;
    grid-column: 1;
  }
  .archive-grid > .discovery-card:first-child:nth-last-child(n+4) .image-link { flex: none; }
  .archive-filters > div, .archive-filters .button { min-width: 0; }
}

/* On very narrow phones the cost select and the search button no longer share a row, so
   "Cualquier coste" is never clipped. */
@media (max-width: 420px) {
  .archive-filters { grid-template-columns: 1fr; }
  .archive-filters .button { width: 100%; }
}

/* 6. Short viewports and wide screens ----------------------------------------------------------------- */
@media (max-height: 500px) and (orientation: landscape) {
  .site-header-inner { min-height: 56px; }
  /* Keep the full consent text, but lay the banner out as a compact bar: text left, buttons right. */
  .cookie-banner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 220px);
    column-gap: 20px;
    max-width: none;
    max-height: calc(100dvh - 16px);
  }
  .cookie-banner::before { grid-column: 1 / -1; }
  .cookie-banner h2, .cookie-banner p { grid-column: 1; }
  .cookie-banner .cookie-actions { grid-column: 2; grid-row: 2 / span 2; flex-direction: column; align-self: center; }
}
@media (min-width: 1700px) {
  .wrap { max-width: 1480px; }
}
