/* Edumeal SDG grid ([edumeal_sdg], /yap/). Markup: edumeal-sdg.php. Popup: sdg.js.
   Sizes are in poster units (the UN poster is 757.6 units from the first to the last tile
   column), so the header and the grid scale together like the image they replace:
   --u = one poster unit, measured against the grid's own width (container query units). */

.sdg-grid {
  container-type: inline-size;
  width: 80%; /* 20% narrower than the column, centred (Michael, 2026-11-14) */
  margin-inline: auto;
  --u: calc(100cqi / 757.6);
  --hu: var(--u); /* header unit: larger on phones, where the grid is only 3 tiles wide */
}

.sdg-grid__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- Header: UN emblem · CÍLE · small wheel · UDRŽITELNÉHO / ROZVOJE ----
   Poster: everything 66 units tall; "UDRŽITELNÉHO" and "ROZVOJE" justified to the same width.
   Poppins 700 cap height = 0.702 em, so font-size = cap height / 0.702. The two stacked lines
   are sized so both are equally wide in Poppins (caps 22.95 + gap 6.7 + caps 36.35 = 66). */
.sdg-grid__header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: calc(15 * var(--hu));
  margin: 0 0 calc(29.5 * var(--u));
}
.sdg-grid__emblem { flex: none; width: calc(78.1 * var(--hu)); line-height: 0; }
.sdg-grid__emblem svg,
.sdg-grid__title-wheel svg,
.sdg-grid__wheel svg { display: block; width: 100%; height: auto; }

.sdg-grid .sdg-grid__title {
  display: flex;
  align-items: center;
  gap: calc(7.2 * var(--hu));
  margin: 0;
  padding: 0;
  font-family: var(--heading-font, poppins), sans-serif;
  font-weight: 700;
  font-size: calc(94 * var(--hu));
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #179bd8; /* the poster's UN blue */
}
.sdg-grid__title-big,
.sdg-grid__title-top,
.sdg-grid__title-bottom {
  display: block;
  white-space: nowrap;
  /* box = cap height to baseline. Poppins 700 with line-height 1: caps start 0.048 em below the
     box top and the baseline sits 0.25 em above its bottom (measured). */
  margin: -0.048em 0 -0.25em;
}
@supports (text-box: trim-both cap alphabetic) {
  .sdg-grid__title-big,
  .sdg-grid__title-top,
  .sdg-grid__title-bottom { margin: 0; text-box: trim-both cap alphabetic; }
}
.sdg-grid__title-wheel { flex: none; width: calc(66 * var(--hu)); line-height: 0; }
.sdg-grid__title-stack { display: flex; flex-direction: column; gap: calc(6.7 * var(--hu)); }
.sdg-grid__title-top { font-size: calc(32.7 * var(--hu)); }
.sdg-grid__title-bottom { font-size: calc(51.8 * var(--hu)); }

/* ---- Tiles: 6 per row (poster gaps 12.5 × 9.7 units), 3 per row on phones ---- */
.sdg-grid__tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: calc(9.7 * var(--u)) calc(12.5 * var(--u));
  margin: 0;
  padding: 0;
  list-style: none;
}
.sdg-grid__cell { margin: 0; padding: 0; min-width: 0; }
.sdg-grid__cell::before,
.sdg-grid__cell::marker { content: none; }

.sdg-grid .sdg-grid__tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: var(--sdg-color);
  color: inherit;
  line-height: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.sdg-grid__tile svg { display: block; width: 100%; height: 100%; }
.sdg-grid .sdg-grid__tile:focus-visible {
  z-index: 2;
  outline: 3px solid var(--primary-blue-dark, #236192);
  outline-offset: 2px;
}
/* The popup script moves focus (to × on open, back to the tile on close). After a tap or click,
   Safari (iOS, iPadOS, macOS) then matches :focus-visible and drew a ring round the tile.
   html[data-edumeal-input] is "pointer" after a tap/click and "keyboard" after a key (sdg.js and
   yap-gen-fn), so only keyboard users get the ring. */
html[data-edumeal-input="pointer"] .sdg-grid .sdg-grid__tile:focus-visible { outline: none; }
.sdg-grid__wheel { display: block; line-height: 0; }

/* Desktop (fine pointer that can hover): the tile grows 30% from its centre and casts the popup
   backdrop's grey as a shadow over the neighbours it partly covers. */
@media (hover: hover) and (pointer: fine) {
  .sdg-grid .sdg-grid__tile {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .sdg-grid .sdg-grid__tile:hover,
  .sdg-grid .sdg-grid__tile:focus-visible {
    z-index: 2;
    transform: scale(1.3);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
  }
  /* focus handed back by the script after a mouse close: the tile settles unless still hovered */
  html[data-edumeal-input="pointer"] .sdg-grid .sdg-grid__tile:focus-visible:not(:hover) {
    z-index: auto;
    transform: none;
    box-shadow: none;
  }
}
/* Touch (phones, tablets): no growth, no shadow, no animation; only the .ubtn press. */
@media (hover: none), (pointer: coarse) {
  .sdg-grid .sdg-grid__tile:active {
    transform: translateY(1px);
    filter: brightness(0.92);
  }
}

/* ---- Popup additions (the rest is the Generace YAP popup: .yap-gen-modal*, .mm-card) ---- */
.sdg-modal .yap-gen-modal__card.mm-card { border-color: var(--sdg-color); }
.sdg-modal__tile {
  width: 100%;
  aspect-ratio: 1;
  background-color: var(--sdg-color);
  line-height: 0;
}
.sdg-modal__tile svg { display: block; width: 100%; height: 100%; }
.sdg-modal .sdg-modal__more {
  margin: 8px 0 0;
  font-family: var(--body-font, proxima-nova), sans-serif;
  font-size: var(--text-medium, 18px);
  line-height: 1.5;
}
.sdg-modal .sdg-modal__more a {
  font-weight: 700;
  color: var(--primary-blue-dark, #236192);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.sdg-modal .sdg-modal__more a:hover { text-decoration-thickness: 2px; }
.sdg-modal .sdg-modal__more a:focus-visible {
  outline: 3px solid var(--primary-blue-dark, #236192);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (max-width: 767px) {
  /* phones: full column (80% made the tiles too small to read), capped so large phones do not get giant tiles */
  .sdg-grid { width: 100%; max-width: 480px; --hu: calc(100cqi / 640); }
  .sdg-grid__tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .sdg-grid__header { margin-bottom: 20px; }
  .sdg-modal__tile { width: 160px; }
}
@media (max-width: 479px) {
  .sdg-modal__tile { width: 140px; }
}
