/* =====================================================================
   tommb — gallery layout (Figma "Iteration 12 02", Dec 2026)
   Loaded after /styles.css. Adds:
   1. Home: intro, two-column grid with a one-line label under each tile.
   2. Project galleries: one slide at a time between the header and a
      caption bar (← caption + counter →). Without JavaScript the slides
      simply stack down the page.
   ===================================================================== */

/* ---------- 1. Home ---------- */
.intro {
  max-width: 34em;
  padding: 8px 0 32px;
  font-size: 20px;
  line-height: 26px;
}
.intro h1 { color: var(--text-default); }
.intro p { color: var(--text-secondary); }
@media (min-width: 800px) {
  .intro { padding: 12px 0 40px; font-size: 24px; line-height: 30px; }
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px var(--gap);
}
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px var(--gap); } }

.card > a { display: block; border-radius: var(--radius); }
.card > a:focus-visible { outline-offset: 4px; }
.card .tile > img,
.card .tile > svg { display: block; width: 100%; height: 100%; object-fit: cover; }
.card__label {
  display: block;
  padding-top: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 20px;
  transition: color .15s;
}
.card > a:hover .card__label { color: var(--text-default); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card .tile > img, .card .tile > svg { transition: transform .4s ease; }
  .card > a:hover .tile > img, .card > a:hover .tile > svg { transform: scale(1.02); }
}

/* ---------- 2. Gallery ---------- */
.close-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  white-space: nowrap;
}
.close-link:hover { color: var(--text-default); }
.close-link .close-link__text { display: none; }
@media (min-width: 800px) {
  .close-link { padding: 8px 12px; }
  .close-link .close-link__text { display: inline; }
}
.icon { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* Slides (no JS: a plain list down the page) */
.gallery { padding-bottom: 32px; }
.slide { margin-bottom: 40px; }
.slide__frame {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg, #f6f6f6);
  min-height: 240px;
}
.slide__caption { padding-top: 12px; color: var(--text-secondary); font-size: 14px; text-align: center; }

/* Art sits centred in its frame at its own aspect ratio, as large as fits */
.art { --ar: var(--ar-m, 1); width: 100%; aspect-ratio: var(--ar); }
@media (min-width: 800px) { .art { --ar: var(--ar-d, var(--ar-m, 1)); } }
.art > .block { width: 100%; height: 100%; aspect-ratio: auto; }
/* Full-stage artwork from Figma: desktop and phone versions in one <picture> */
.g-full, .g-full img { display: block; width: 100%; height: 100%; }
.g-full img { object-fit: cover; }

/* Rows: several pictures side by side on desktop, a swipeable carousel on phones */
.g-row .carousel__slide { overflow: hidden; border-radius: var(--radius); background: var(--item-bg, transparent); }
.g-row .carousel__slide + .carousel__slide { margin-left: 0; }
.g-row.g-line .carousel__slide { box-shadow: inset 0 0 0 1px var(--card-border); }
.g-row .carousel__slide img { object-fit: var(--fit, cover); }
@media (min-width: 800px) {
  .g-row .carousel__viewport { overflow: visible; scroll-snap-type: none; }
  .g-row .carousel__track { gap: var(--gap); }
  .g-row .carousel__slide { flex: 1 1 0; min-width: 0; }
  .g-row .carousel__dots { display: none; }
  /* 3 × 2 grid (Verge slides) */
  .g-row.g-grid .carousel__track { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.g-row.g-line .carousel__slide.no-line { box-shadow: none; }

/* Project details slide */
.details {
  display: grid;
  gap: 32px;
  width: 100%;
  height: 100%;
  padding: 24px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
  align-content: start;
}
.details .wordmark { width: var(--wm-m); }
.details__text { color: var(--text-body); font-size: 18px; line-height: 24px; }
.details__text p + p { margin-top: 16px; }
.details__note { color: var(--text-secondary); font-size: 14px; line-height: 20px; }
.details__list { display: grid; gap: 12px; align-content: start; margin: 0; font-size: 14px; line-height: 20px; }
.details__list dt { color: var(--text-secondary); }
.details__list dd { margin: 0; color: var(--text-default); }
.details__list a { text-decoration: underline; text-decoration-color: var(--divider); text-underline-offset: 3px; }
.details__list a:hover { text-decoration-color: currentColor; }
@media (min-width: 800px) {
  .details {
    grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: 120px;
    padding: 60px;
  }
  .details .wordmark { width: min(var(--wm-d, var(--wm-m)), 100%); }
  .details__logo { grid-column: 1; grid-row: 1; }
  .details__list { grid-column: 1; grid-row: 2; align-self: end; }
  .details__text { grid-column: 2; grid-row: 1 / span 2; font-size: 28px; line-height: 32px; max-width: 20em; }
  .details__note { font-size: 14px; line-height: 20px; }
}
@media (max-width: 799px) {
  .details { grid-template-rows: auto auto 1fr; }
  .details__text { align-self: end; }
}

/* Caption bar */
.gnav { display: none; }
.g-panels { display: none; }
@media (min-width: 800px) {
  .js .g-panels { display: block; position: absolute; inset: 0; }
  .js .slide__frame:has(> .g-panels) { position: relative; }
}

/* ----- With JavaScript: one slide at a time, filling the window ----- */
.js body.is-gallery {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.js .is-gallery .site-header { flex: none; margin-bottom: 0; }
.js .is-gallery .page { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.js .gallery {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  margin-top: 8px;
}
@media (min-width: 1024px) { .js .gallery { margin-top: 10px; } }
/* Desktop: the gallery can break out of the text grid and grow with the window,
   up to 1400px wide, staying centred on the page */
@media (min-width: 800px) {
  .js .is-gallery .gallery {
    --gw: min(1400px, 100vw - 2 * var(--gutter));
    width: var(--gw);
    margin-left: calc(50% - var(--gw) / 2);
  }
}
.js .slide {
  position: absolute;
  inset: 0;
  margin: 0;
  visibility: hidden;
  opacity: 0;
}
.js .slide.is-current { visibility: visible; opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .js .slide { transition: opacity .25s ease, visibility 0s linear .25s; }
  .js .slide.is-current { transition: opacity .25s ease, visibility 0s; }
}
.js .slide__caption { display: none; }
.js .slide__frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  container-type: size;
}
/* Fit the art inside the frame: as wide as possible without overflowing its height */
.js .slide__frame > .art { width: min(100cqw, 100cqh * var(--ar)); }
/* Desktop: the frame always has the Figma stage's shape (1104 x 639), as large as
   fits, so every composition shows exactly as designed at any window size */
@media (min-width: 800px) {
  .js .slide { display: grid; place-items: center; container-type: size; }
  .js .slide__frame { width: min(100cqw, 100cqh * 1104 / 639); height: auto; aspect-ratio: 1104 / 639; min-height: 0; }
  /* Rows laid out like the Figma stage: each picture at its own position and size */
  .g-stage { container-type: inline-size; }
  .g-row.g-stage .carousel__viewport { overflow: visible; }
  .g-row.g-stage .carousel__track { display: block; position: relative; height: 100%; gap: 0; }
  .g-row.g-stage .carousel__slide {
    position: absolute;
    left: calc(var(--x) * 100cqw / 1104);
    top: calc(var(--y) * 100cqw / 1104);
    width: calc(var(--w) * 100cqw / 1104);
    height: calc(var(--h) * 100cqw / 1104);
    border-radius: calc(var(--r) * 100cqw / 1104);
  }
  .g-row.g-stage .carousel__slide[style*="--iw"] img {
    position: absolute;
    left: calc(var(--ix) * 100cqw / 1104);
    top: calc(var(--iy) * 100cqw / 1104);
    width: calc(var(--iw) * 100cqw / 1104);
    height: calc(var(--ih) * 100cqw / 1104);
    object-fit: contain;
    object-position: center;
  }
}
/* Phones: every slide fills its frame, so pictures run full height and
   carousel dots always sit at the bottom of the frame */
@media (max-width: 799px) {
  .js .slide__frame > .art:not(.art--fit) { width: 100%; height: 100%; aspect-ratio: auto; overflow: hidden; }
  .js .slide__frame > .art:not(.art--fit) > .block { height: 100%; aspect-ratio: auto; }
  .js .art--contain .carousel__slide { box-shadow: none; background: transparent; }
  .js .art--contain .carousel__slide img { object-fit: contain; }
  /* Phone screens: fit the phone between the top of the frame and the dots */
  .js .art .carousel--phones .carousel__slide { padding-bottom: 48px; }
  .js .art .carousel--phones .carousel__slide img { max-height: 100%; }
  /* cards with a hairline: keep the pictures inside the line */
  .js .g-stage.g-line .carousel__slide { padding: 16px; }
}
.js .slide__frame > .details { width: 100%; height: 100%; overflow: auto; }
.js .slide--details .slide__frame { background: transparent; }

.js .gnav {
  flex: none;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  padding: 8px 0 16px;
}
@media (min-width: 1024px) { .js .gnav { padding: 12px 0 40px; } }
.gnav__arrow {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  color: var(--text-secondary);
}
.gnav__arrow[href]:hover { color: var(--text-default); }
.gnav__arrow[aria-disabled="true"] { color: var(--divider); cursor: default; }
.gnav__arrow--next { justify-self: end; }
.gnav__status { text-align: center; font-size: 14px; line-height: 20px; }
.gnav__caption { display: block; color: var(--text-secondary); }
.gnav__count { display: block; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.is-gallery .site-footer { display: none; }
/* Desktop: the header and the arrows line up with the edges of the artwork
   frame (its width, --fw, is measured by gallery.js) */
@media (min-width: 800px) {
  .js .is-gallery .site-header { max-width: calc(var(--fw, 1104px) + 2 * var(--gutter)); }
  .js .is-gallery .gnav { width: var(--fw, 100%); margin-left: calc(50% - var(--fw, 100%) / 2); }
  /* Narrow, tall windows: slides marked slide--extend grow to the full height,
     filled with the artwork's top and bottom edge colours; the rest keep their
     shape and float centred */
  .js .slide--extend .slide__frame {
    height: 100cqh;
    aspect-ratio: auto;
    align-content: center;
    background: linear-gradient(var(--ext-t, var(--bg)) 50%, var(--ext-b, var(--bg)) 50%);
  }
  /* ...the artwork itself stays the size it would be in the 1104 x 639 frame */
  .js .slide--extend .slide__frame > .art { width: min(100cqw, 100cqw * 639 / 1104 * var(--ar)); }
  .js .slide--details .slide__frame { display: block; background: transparent; }
  /* Photos with a taller export (or room to crop): the picture fills the whole
     frame, cropped from its taller version around the original view */
  .js .slide--extend .slide__frame > .art--tall { height: 100cqh; aspect-ratio: auto; }
  .js .art--tall .g-full img { object-fit: cover; object-position: 50% var(--pos, 50%); }
  /* Artwork made of panels: the panels run the full height behind it */
  .g-panels i {
    position: absolute; top: 0; bottom: 0;
    left: calc(var(--x) * 100cqw / 1104); width: calc(var(--w) * 100cqw / 1104);
    border-radius: calc(8 * 100cqw / 1104);
    background: linear-gradient(var(--pt) 50%, var(--pb) 50%);
  }
  .g-panels + .art { position: relative; }
  .g-panels .line { box-shadow: inset 0 0 0 1px var(--card-border); background: none; z-index: 1; pointer-events: none; }
  /* the panels are the cards, so the artwork's own card boxes step aside */
  .js .g-panels + .art .carousel, .js .g-panels + .art .carousel__slide { box-shadow: none; background: transparent; }
}

/* ---------- 3. Menu (overrides) ---------- */
/* Each project is a full-width row: the whole line is clickable */
.menu__link { display: block; width: 100%; border-radius: var(--radius); }
@media (hover: hover) {
  .menu__list .menu__link:hover { color: var(--text-secondary); }
}
