/* Sara Guerra — public site. Minimal, image-led; typography does the work. */
:root {
  --fg: #111;
  --muted: #6b6b6b; /* 5.3:1 on --bg, 4.8:1 on --tile (WCAG 1.4.3; was #8c8c8c, 3.4:1) */
  --bg: #fff;
  --line: #e6e6e6;
  --tile: #f3f3f3;
  --gap: clamp(14px, 1.5vw, 24px);
  --header-h: 3.25rem;
  --font: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
/* Keyboard focus and #anchors land below the sticky header, not under it (WCAG 2.4.11). */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + var(--gap)); }
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word; /* long emails and links reflow at 320 px (WCAG 1.4.10) */
}
main { flex: 1; padding: 0 var(--gap) calc(var(--gap) * 3); }
a { color: inherit; text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { font-size: inherit; font-weight: inherit; margin: 0; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gap); top: var(--gap); background: var(--bg); z-index: 20; padding: 0.25em 0.5em; }

/* Header ---------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  min-height: var(--header-h);
  padding: var(--gap);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
}
.site-nav { display: flex; gap: 1.25em; }
/* Larger hit areas for the short header links without moving them (WCAG 2.5.8). */
.site-name, .site-nav a { padding: 0.2em 0; }
/* On very short windows (zoomed in, phones in landscape) the header scrolls away. */
@media (max-height: 30rem) { .site-header { position: static; } }
.site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }

/* Index ----------------------------------------------------------------- */
.index {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--gap) * 2.5) var(--gap);
  align-items: start;
}
.index-item a:hover { text-decoration: none; }
.index-item a:hover .caption-title { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.index-figure { margin: 0; background: var(--tile); }
.index-figure img { width: 100%; transition: opacity 0.2s ease; }
.index-item a:hover img { opacity: 0.88; }
.placeholder { aspect-ratio: 4 / 3; }
.caption { margin: 0.55em 0 0; }
.caption-meta { color: var(--muted); }
.empty { color: var(--muted); }

@media (max-width: 1100px) { .index { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .index { grid-template-columns: 1fr; gap: calc(var(--gap) * 2); } }

/* Project --------------------------------------------------------------- */
.project-head { margin: 0 0 var(--gap); }
.project-head p { margin: 0; }

/* Groups: each project is a sequence of groups with a layout, width and spacing. */
.g { --cols: 3; }
.g.cols-2 { --cols: 2; }
.g.cols-4 { --cols: 4; }
.g.s-small { margin-bottom: var(--gap); }
.g.s-medium { margin-bottom: calc(var(--gap) * 3); }
.g.s-large { margin-bottom: calc(var(--gap) * 6); }
.g.w-full { margin-left: calc(var(--gap) * -1); margin-right: calc(var(--gap) * -1); }
.g.w-narrow { max-width: 56rem; }
.g-text.w-narrow { max-width: 40em; }
.g-text.w-page { max-width: 64em; }
.media { margin: 0; }
.media, .slide, .hero-main { position: relative; }
.media img { width: 100%; height: auto; background: var(--tile); }
/* Videos take an image's place in every layout: the same box (width/height attributes give the
   aspect ratio before anything loads), the poster until they play. */
video { display: block; max-width: 100%; height: auto; }
.media video { width: 100%; height: auto; background: var(--tile); }
.media figcaption, .slide figcaption, .hero-main figcaption {
  margin-top: 0.45em; color: var(--muted); font-size: 13px; max-width: 40ch;
}

/* Text */
.g-text-body { font-size: 15px; }
.g-text-body a { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.g-text-body .note { margin-top: 1.5em; }

/* Slider (horizontal) */
.gallery {
  display: flex; gap: var(--gap);
  height: calc(100svh - var(--header-h) - 9rem);
  min-height: 320px;
  margin: 0 calc(var(--gap) * -1);
  padding: 0 var(--gap);
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding: 0 var(--gap);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
/* The gallery is a focusable region (arrow keys scroll it): an inset ring, since it spans the
   page edges (WCAG 2.4.7). */
.gallery:focus-visible { outline: 1px solid var(--fg); outline-offset: -1px; }
.slide {
  flex: 0 0 auto; height: 100%; margin: 0;
  display: flex; flex-direction: column;
  scroll-snap-align: start;
}
.slide img, .slide video { height: calc(100% - 1.8em); width: auto; max-width: none; background: var(--tile); }
/* Banners and panoramas (wider than 2:1) would become huge strips at full gallery height:
   show them whole, at the viewport's width, centred vertically instead. */
.slide-wide { justify-content: center; }
.slide-wide img, .slide-wide video { width: min(88vw, 2560px); height: auto; max-height: calc(100% - 1.8em); object-fit: contain; }
.gallery-controls { display: flex; align-items: center; gap: 1rem; margin-top: 0.75rem; }
/* Shown by site.js when the gallery overflows: the row keeps its space while hidden, so revealing
   it after the first paint moves nothing (CLS). */
.gallery-controls[hidden] { display: flex; visibility: hidden; }
.gallery-controls button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  min-width: 1.75rem; min-height: 1.75rem; /* WCAG 2.5.8 */
}
.gallery-controls button:disabled { color: var(--line); cursor: default; }
.gallery-count { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4em; text-align: center; }

/* Grid: equal columns, natural proportions */
.grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap); align-items: start; }

/* Masonry: columns filled top to bottom, natural heights */
.masonry { column-count: var(--cols); column-gap: var(--gap); }
.masonry .media { break-inside: avoid; margin-bottom: var(--gap); }

/* Stack: one under another */
.stack { display: flex; flex-direction: column; gap: var(--gap); }

/* Row: same height, filling the width (flex-grow = aspect ratio, set by site.js) */
.row { display: flex; gap: var(--gap); align-items: flex-start; }
.row .media { flex: 1 1 0; min-width: 0; }
/* Where typed attr() is supported the ratio applies before site.js runs (no layout shift);
   elsewhere this declaration is ignored and site.js sets it. */
.row .media { flex-grow: attr(data-ratio type(<number>), 1); }

/* Bento: mixed tile sizes on a square grid, images cropped to fill their tiles */
.bento {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: clamp(120px, calc(70vw / var(--cols)), 420px);
  grid-auto-flow: dense; gap: var(--gap);
}
.bento .media { position: relative; overflow: hidden; }
.bento .media img, .bento .media video { width: 100%; height: 100%; object-fit: cover; }
.bento .media figcaption {
  position: absolute; left: 0; bottom: 0; margin: 0; padding: 0.4em 0.6em; max-width: none;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  color: var(--fg); /* over an image: muted grey could fall below 4.5:1 */
}
.bento .media:nth-child(6n + 1) { grid-column: span 2; grid-row: span 2; }
.bento .media:nth-child(6n + 4) { grid-column: span 2; }
.bento.cols-2 .media:nth-child(6n + 1), .g.cols-2 .bento .media:nth-child(6n + 1) { grid-row: span 1; }

/* Hero + thumbnails */
.hero-main img, .hero-main video { width: 100%; height: auto; max-height: calc(100svh - var(--header-h) - 8rem); object-fit: contain; object-position: left top; background: none; }
.hero-thumbs { display: flex; gap: 0.5rem; margin-top: var(--gap); overflow-x: auto; scrollbar-width: thin; }
/* Positioned: the still of an animated image (site.js) is laid over its thumbnail. */
.hero-thumb { position: relative; flex: 0 0 auto; padding: 0; border: 0; background: none; cursor: pointer; opacity: 0.55; transition: opacity 0.15s; }
.hero-thumb img { display: block; height: 64px; width: auto; }
.hero-thumb:hover, .hero-thumb[aria-current="true"] { opacity: 1; }
.hero-thumb:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; opacity: 1; }

.project-nav {
  display: flex; justify-content: space-between; gap: var(--gap);
  margin-top: calc(var(--gap) * 4); padding-top: var(--gap);
  border-top: 1px solid var(--line);
}
.project-nav .next { text-align: right; }

@media (max-width: 720px) {
  .gallery {
    flex-direction: column; height: auto; min-height: 0;
    margin: 0; padding: 0; overflow: visible; scroll-snap-type: none;
    gap: calc(var(--gap) * 1.5);
  }
  .slide { height: auto; }
  .slide img, .slide-wide img, .slide video, .slide-wide video { width: 100%; height: auto; max-height: none; }
  .gallery-controls { display: none !important; }
  .g { --cols: 2; }
  .g.cols-2 { --cols: 2; }
  .masonry { column-count: 1; }
  .row { flex-direction: column; }
  .row .media { flex: none !important; width: 100%; }
  .bento { grid-auto-rows: 42vw; }
  .bento .media:nth-child(6n + 1) { grid-row: span 1; }
  .hero-thumb img { height: 48px; }
}

button.share {
  font: inherit; color: var(--muted); background: none; border: 0; padding: 0; margin-top: 0.35em; cursor: pointer;
  min-height: 24px; /* WCAG 2.5.8 */
}
/* Shown by site.js where sharing or copying works: the line is kept while hidden, so revealing
   it after the first paint moves nothing (CLS). */
button.share[hidden] { display: inline-block; visibility: hidden; }
button.share:hover, button.share:focus-visible { color: var(--fg); text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }

/* Pause/play for videos that play like a GIF and for animated images (WCAG 2.2.2), added by
   site.js over the media's top-left corner (positioned, so it moves nothing). */
.video-toggle {
  position: absolute; top: 0; left: 0; margin: 0.5rem; z-index: 1;
  min-width: 24px; min-height: 24px; padding: 0.25em 0.7em; border: 0; border-radius: 999px;
  font: inherit; font-size: 13px; color: var(--fg); cursor: pointer;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.video-toggle:hover { background: var(--bg); }
.video-toggle:focus-visible { outline-offset: 2px; }
/* A paused animated image, or the thumbnail of one (always still): site.js draws a still on a
   canvas laid over it (same box and object-fit, set via CSSOM); the image stays in place,
   transparent, for its alt text. */
.media-still { position: absolute; top: 0; left: 0; display: block; max-width: none; pointer-events: none; }
img.is-still { opacity: 0; }

/* Info ------------------------------------------------------------------ */
.info { max-width: 40em; }
.info-body { font-size: clamp(17px, 1.6vw, 22px); line-height: 1.35; }
.info-body a { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.info-contacts { list-style: none; padding: 0; margin: 2em 0 0; }
/* WCAG 2.5.8: stacked links need a 24 px target (the line box alone is ~23 px at 17 px text). */
.info-contacts a { display: inline-block; min-height: 24px; padding-block: 2px; }

/* Footer ---------------------------------------------------------------- */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5em 1.5em;
  padding: var(--gap); color: var(--muted);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 0.4em 1.25em; }
.footer-links a:hover { color: var(--fg); }

/* Analytics opt-out ---------------------------------------------------- */
.exclude { max-width: 34em; padding-top: 6vh; }
.exclude button.share { color: var(--fg); text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }

/* Error ----------------------------------------------------------------- */
.error { padding-top: 12vh; max-width: 30em; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
