/* ==========================================================================
   base.css — structure of the site (pages at the top of the folder: index.html, publications.html, gallery.html).
   Only mechanics live here (reset, uncropped media frames, modal, slider, lightbox,
   gallery rows, marquee, reveal). The look is in style.css, in this same folder.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: hidden; overflow-x: clip; }   /* nothing may make the page wider than the screen (on a phone that shrinks the page and loosens the top bar) */
body { margin: 0; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: clip; }
img, video, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, h4, p, figure, ul { margin: 0; }
ul { padding: 0; list-style: none; }
[id] { scroll-margin-top: var(--nav-h, 84px); }
html.is-locked { overflow: hidden; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Media frames: a frame always has the proportions of what it holds ---------- */
.m { margin: 0; aspect-ratio: var(--ar); overflow: hidden; }
.m > img, .m > video { width: 100%; height: 100%; object-fit: cover; }
/* A row of frames with different proportions and the same height: give each child its --ar */
.jrow { display: flex; gap: var(--gap, 20px); align-items: flex-start; }
.jrow > * { flex: var(--ar) 1 0%; min-width: 0; }

/* ---------- Reveal on scroll (site.js adds .is-in) ---------- */
.js [data-reveal] { opacity: 0; transform: translateY(20px); transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1); transition-delay: var(--d, 0s); }
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* ---------- Marquee (site.js clones .marquee__group and sets --mq-w / --mq-t) ---------- */
.marquee { overflow: hidden; white-space: nowrap; }
.marquee__track { display: flex; width: max-content; animation: marquee var(--mq-t, 40s) linear infinite; }
.marquee__group { display: flex; flex: none; align-items: center; }
.marquee.is-draggable { cursor: grab; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.marquee.is-dragging { cursor: grabbing; }
@keyframes marquee { to { transform: translateX(calc(-1 * var(--mq-w, 50%))); } }

/* ---------- Full-screen menu ---------- */
.menu { position: fixed; inset: 0; z-index: 90; visibility: hidden; opacity: 0; transition: opacity 0.3s, visibility 0s 0.3s; overflow-y: auto; }
.menu.is-open { visibility: visible; opacity: 1; transition: opacity 0.3s; }

/* ---------- Research detail modal (markup is created by site.js) ---------- */
.modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; visibility: hidden; opacity: 0; transition: opacity 0.3s, visibility 0s 0.3s; }
.modal.is-open { visibility: visible; opacity: 1; transition: opacity 0.3s; }
.modal__backdrop { position: absolute; inset: 0; }
.modal__panel { position: relative; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); width: min(1280px, 100% - 32px); height: min(820px, 100dvh - 32px); overflow: hidden; transform: translateY(18px) scale(0.985); transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.modal.is-open .modal__panel { transform: none; }
.modal__media { position: relative; min-width: 0; min-height: 0; }
.modal__content { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.modal__close { position: absolute; top: 12px; right: 12px; z-index: 3; width: 44px; height: 44px; display: grid; place-items: center; }
.modal__close svg, .slider__btn svg, .vlb__nav svg { width: 20px; height: 20px; }
.slider { position: absolute; inset: 0; }
.slider__track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.slider__track::-webkit-scrollbar { display: none; }
/* slides show the whole picture or movie, never a crop */
.slide { position: relative; flex: 0 0 100%; min-width: 0; scroll-snap-align: center; }
.slide > img, .slide > video { position: absolute; left: var(--slide-pad, 0px); top: var(--slide-pad, 0px); width: calc(100% - 2 * var(--slide-pad, 0px)); height: calc(100% - 2 * var(--slide-pad, 0px)); object-fit: contain; }
/* When its proportions are known (site.js sets --ar = width / height), the picture's box is exactly the picture:
   as large as fits in the slide, centred, never cropped, so the look can round its corners (--slide-radius). */
.slide { container-type: size; }
.slide > .is-fit { left: 50%; top: 50%; translate: -50% -50%; width: min(100cqw - 2 * var(--slide-pad, 0px), (100cqh - 2 * var(--slide-pad, 0px)) * var(--ar)); height: auto; aspect-ratio: var(--ar); border-radius: var(--slide-radius, 0px); }
.slider__btn { position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px; display: grid; place-items: center; }
.slider__btn--prev { left: 12px; }
.slider__btn--next { right: 12px; }
.slider__btn[disabled] { opacity: 0.3; pointer-events: none; }
.slider__dots { position: absolute; left: 0; right: 0; bottom: 14px; z-index: 2; display: flex; justify-content: center; gap: 7px; }
.slider__dots button { width: 8px; height: 8px; border-radius: 50%; }
.slider.is-single .slider__btn, .slider.is-single .slider__dots { display: none; }
@media (max-width: 860px) {
  .modal__panel { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, min(42dvh, calc((100vw - 44px) / 1.5 + 40px))) minmax(0, 1fr); width: calc(100% - 20px); height: calc(100dvh - 20px); --strip: 56px; padding-top: var(--strip); }   /* the strip at the top holds the close button, so it never covers a picture */
  .modal__panel > .modal__close { top: 6px; right: 6px; }
  /* phones: the picture area is just tall enough for a 3:2 picture plus the row of dots, and each picture sits
     at its top, close under the close button (no empty band above it) */
  .modal__media { --slide-top: 4px; --dots-zone: 36px; }
  .slide > .is-fit { top: var(--slide-top); translate: -50% 0; width: min(100cqw - 2 * var(--slide-pad, 0px), (100cqh - var(--slide-top) - var(--dots-zone)) * var(--ar)); }
  .slider__btn { top: calc(var(--slide-top) + (100% - var(--slide-top) - var(--dots-zone)) / 2); }
}

/* ---------- Lightbox for movies and gallery photos (markup is created by site.js) ---------- */
.vlb { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; visibility: hidden; opacity: 0; transition: opacity 0.3s, visibility 0s 0.3s; background: rgba(12, 12, 12, 0.94); color: #fff; }
.vlb.is-open { visibility: visible; opacity: 1; transition: opacity 0.3s; }
.vlb video, .vlb img { max-width: min(1500px, 100% - 32px); max-height: calc(100dvh - 110px); width: auto; height: auto; background: #000; }
.vlb [hidden] { display: none; }
.vlb__nav { position: absolute; top: 50%; width: 48px; height: 48px; margin-top: -24px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.12); }
.vlb__nav--prev { left: 14px; }
.vlb__nav--next { right: 14px; }
.vlb .modal__close { border-radius: 50%; background: rgba(255, 255, 255, 0.12); }
[data-zoom] .shot img { cursor: zoom-in; }

/* ---------- Gallery rows. Photos are never cropped: each tile takes its own photo's
   proportions (--ar = width / height, set per figure). In a row the width is shared in
   proportion to --ar, so both tiles come out the same height. ---------- */
.pairs { display: grid; gap: var(--pair-gap, 16px); }
.pair { display: flex; gap: var(--pair-gap, 16px); align-items: flex-start; }
.shot { position: relative; margin: 0; overflow: hidden; }
.shot img, .shot video { width: 100%; height: 100%; object-fit: cover; }
.shot figcaption { position: absolute; left: 10px; bottom: 10px; right: 10px; display: flex; }
.pair > .shot { flex: var(--ar, 1.5) 1 0px; min-width: 0; aspect-ratio: var(--ar, 1.5); }
/* One tall photo next to two stacked photos: two equal columns like every other row.
   The stacked photos keep their own proportions; the tall one is the only tile that is
   trimmed (as Alberto asked), just enough to span exactly the two of them plus the gap. */
.pair--tall { align-items: stretch; }
.pair--tall > .shot { flex: 1 1 0px; aspect-ratio: auto; }
.pair--tall > .shot img { position: absolute; inset: 0; }
.pair__stack { flex: 1 1 0px; min-width: 0; display: grid; gap: var(--pair-gap, 16px); align-content: start; }
.pair__stack .shot { aspect-ratio: var(--ar, 1.5); }
@media (max-width: 560px) {
  .pair { flex-direction: column; }
  .pair > .shot, .pair > .pair__stack { flex: none; width: 100%; }
  .pair--tall > .shot { aspect-ratio: var(--ar, 0.75); }   /* on its own row: shown whole */
  .pair--tall > .shot img { position: static; }
}

/* ---------- Publication thumbnails keep their own proportions ---------- */
.pub__thumb img, .pub__thumb video { width: 100%; height: auto; }
.pub__thumb.is-link { cursor: pointer; }

/* ---------- Magnetic dots (site.js draws them on a canvas behind the words) ---------- */
[data-dots].has-dots { position: relative; isolation: isolate; }
[data-dots].has-dots u { background: none; animation: none; text-decoration: none; }
canvas.dots { position: absolute; left: -64px; top: -64px; z-index: -1; max-width: none; pointer-events: none; }


@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js [data-reveal] { opacity: 1; transform: none; transition: none; }
  .marquee__track { animation: none; }
}
