/* The heading and toolbar follow .section-heading and .section-pad (Case Studies,
   Latest) so the three sections share one left edge and type scale; only the grid
   runs wider, 10px from the page edge. */
.gallery-section { border-bottom:1px solid var(--line);padding:90px 0 10px;scroll-margin-top:100px; }
.gallery-heading { display:grid;grid-template-columns:1fr 1.1fr;align-items:end;gap:25px 70px;padding:0 7% 38px; }
.gallery-heading .eyebrow { grid-column:1/-1; }
.gallery-heading h2 { font-size:clamp(42px,5.1vw,76px);line-height:1.02; }
.gallery-heading p { color:var(--muted);font-size:15px;max-width:400px;padding-bottom:3px; }
[data-mode=simple] .gallery-section { padding-top:48px; }
[data-mode=simple] .gallery-heading { display:block;padding-inline:6%; }
[data-mode=simple] .gallery-heading h2 { font-size:32px;line-height:1.2;margin:18px 0 12px; }
[data-mode=simple] .gallery-heading p { font-size:16px;color:var(--s-body);max-width:46ch; }
.gallery-grid { margin-inline:10px;display:grid;grid-template-columns:repeat(var(--gallery-columns,6),minmax(0,1fr));grid-auto-flow:dense;grid-auto-rows:clamp(90px,8vw,142px);gap:10px; }
.gallery-grid:not([data-packed]) .gallery-item { opacity:0; }
/* Filters. Tiles are buttons with display:block, so [hidden] needs restating. */
.gallery-toolbar { display:flex;align-items:center;justify-content:space-between;gap:12px 24px;flex-wrap:wrap;padding:0 7% 22px; }
[data-mode=simple] .gallery-toolbar { padding-inline:6%; }
.gallery-count { font-size:10px;color:var(--muted); }
.gallery-item[hidden] { display:none; }
.gallery-grid[data-filtering] .gallery-item { opacity:0;transform:translateY(8px);transition:opacity .16s,transform .16s; }
[data-mode=simple] .gallery-toolbar .filters button { font-size:13px;padding:9px 14px;border-color:var(--s-line-strong);color:var(--s-ink);transition:background-color 140ms,border-color 140ms,color 140ms,transform 140ms; }
[data-mode=simple] .gallery-toolbar .filters button.active { background:var(--s-ink);border-color:var(--s-ink);color:var(--s-paper); }
[data-mode=simple] .gallery-toolbar .filters button:active { transform:translateY(1px); }
[data-mode=simple] .gallery-toolbar .filters sup { font-size:9px;margin-left:4px;font-variant-numeric:tabular-nums;opacity:.7; }
[data-mode=simple] .gallery-count { font-size:11px;color:var(--s-subtle); }
/* Fold: JS collapses the grid to 600px when it's taller, fading into the page colour
   above a Show all button. Without JS the whole gallery shows and the button stays hidden. */
.gallery-fold[data-collapsed] .gallery-grid { max-height:600px;overflow:hidden; }
.gallery-fold[data-expanding] .gallery-grid { overflow:hidden;transition:max-height .7s var(--ease); }
.gallery-more-wrap { display:none;position:relative;justify-content:center;padding:20px 0 26px; }
.gallery-fold[data-collapsed] .gallery-more-wrap { display:flex; }
.gallery-more-wrap:before { content:'';position:absolute;left:0;right:0;bottom:100%;height:200px;pointer-events:none;
  background:linear-gradient(to bottom,color-mix(in srgb,var(--paper) 0%,transparent),color-mix(in srgb,var(--paper) 85%,transparent) 65%,var(--paper)); }
.gallery-more { display:inline-flex;align-items:center;gap:10px;padding:13px 22px;border:1px solid var(--ink);background:var(--paper);color:var(--ink);font-size:13px;transition:background-color .2s,color .2s,transform .14s; }
.gallery-more [data-gallery-total] { font-variant-numeric:tabular-nums; }
.gallery-more>span:last-child { transition:transform .22s var(--ease); }
.gallery-more:active { transform:translateY(1px); }
[data-mode=simple] .gallery-more { border-color:var(--s-line-strong);color:var(--s-ink);background:var(--s-paper);font-size:14px; }
@media (hover:hover) {
  [data-mode=expressive] .gallery-more:hover { background:var(--yellow);color:#111;border-color:#111; }
  [data-mode=simple] .gallery-more:hover { border-color:var(--s-ink);background:var(--s-surface); }
  .gallery-more:hover>span:last-child { transform:translateY(2px); }
}
@media (hover:hover) {
  [data-mode=simple] .gallery-toolbar .filters button:not(.active):hover { border-color:var(--s-ink);background:var(--s-surface); }
}
.gallery-item { position:relative;display:block;min-width:0;min-height:0;padding:0;border:1px solid #aaa;background:#d1d1ce;color:#111;text-align:left;overflow:hidden;cursor:pointer;opacity:1;transition:opacity .2s,background .25s,transform .35s var(--ease),box-shadow .25s; }
.gallery-media { position:absolute;inset:0;display:grid;place-items:center;background:#c7c8c4;overflow:hidden; }
.gallery-media img,.gallery-media video { display:block;width:100%;height:100%;object-fit:cover; }
.gallery-play { position:absolute;left:50%;top:50%;display:grid;place-items:center;width:54px;height:54px;border:1px solid #fff;background:#111d;color:var(--yellow);font-size:19px;transform:translate(-50%,-50%);transition:background .2s,transform .25s; }
.gallery-item:is(:hover,:focus-visible) .gallery-play { background:#111;transform:translate(-50%,-50%) scale(1.08); }
.gallery-caption { position:absolute;z-index:2;right:0;bottom:0;left:0;display:grid;grid-template-columns:minmax(0,1fr) 28px;align-items:center;gap:12px;min-height:62px;padding:9px 15px;border-top:1px solid #aaa;background:#dededbf2;opacity:0;transform:translateY(100%);transition:opacity .2s,transform .28s var(--ease),background .2s; }
.gallery-caption .mono { font-size:8px; }
.gallery-caption strong { display:-webkit-box;overflow:hidden;font-size:13px;font-weight:550;line-height:1.2;-webkit-box-orient:vertical;-webkit-line-clamp:2; }
.gallery-caption>span:last-child { display:grid;place-items:center;width:28px;height:28px;background:#111;color:var(--yellow);font-size:18px;transition:rotate .3s,background .2s,color .2s; }
.gallery-item:is(:hover,:focus-visible) { z-index:3;background:var(--yellow);transform:translateY(-4px);box-shadow:7px 7px 0 #111;outline:0; }
.gallery-item:is(:hover,:focus-visible) .gallery-media { background:#bbbcb7; }
.gallery-item:is(:hover,:focus-visible) .gallery-caption { background:var(--yellow);opacity:1;transform:translateY(0); }
.gallery-item:is(:hover,:focus-visible) .gallery-caption>span:last-child { background:var(--yellow);color:#111;rotate:45deg; }
.gallery-dialog { width:min(1120px,calc(100% - 40px));max-height:calc(100vh - 40px);padding:0;border:1px solid #111;background:var(--paper);color:var(--ink);box-shadow:15px 15px 0 var(--yellow);overflow:hidden; }
.gallery-dialog[open] { display:grid;grid-template-columns:minmax(0,1.35fr) minmax(330px,.65fr); }
.gallery-dialog::backdrop { background:#000c;backdrop-filter:blur(4px); }
.gallery-dialog-media { display:grid;place-items:center;min-height:520px;max-height:calc(100vh - 42px);background:#111;overflow:hidden; }
.gallery-dialog-media img,.gallery-dialog-media video { display:block;width:100%;height:100%;max-height:calc(100vh - 42px);object-fit:contain; }
.gallery-dialog-media iframe { display:block;width:100%;aspect-ratio:16/9;border:0; }
.gallery-dialog-copy { align-self:center;padding:72px 52px 55px; }
.gallery-dialog .mono { color:var(--muted);font-size:9px; }
.gallery-dialog h2 { font-size:clamp(36px,5vw,64px);line-height:1;letter-spacing:-.055em;margin:20px 0; }
.gallery-dialog p { max-width:480px;color:var(--muted);font-size:16px;line-height:1.65; }
.gallery-dialog-close { position:absolute;z-index:2;right:14px;top:14px;width:42px;height:42px;border:1px solid #111;background:var(--yellow);color:#111;font-size:28px;line-height:1; }
.gallery-dialog-close:hover { background:#111;color:var(--yellow); }
[data-theme=dark] .gallery-item { border-color:#555;background:#30312e;color:var(--ink); }
[data-theme=dark] .gallery-media { background:#272825; }
[data-theme=dark] .gallery-caption { border-color:#555;background:#363733; }
[data-theme=dark] .gallery-item:is(:hover,:focus-visible) { color:#111; }
[data-theme=dark] .gallery-dialog { border-color:#777; }
[data-theme=dark] .gallery-dialog-close { border-color:var(--yellow); }
[data-mode=simple] .gallery-heading h2:before { content:'';display:inline-block;width:12px;height:24px;background:var(--yellow);border-bottom:5px solid #111;margin-right:12px; }
@media(max-width:900px) {
  .gallery-dialog[open] { grid-template-columns:1fr;overflow:auto; }
  .gallery-dialog-media { min-height:320px;max-height:55vh; }
  .gallery-dialog-media img,.gallery-dialog-media video { max-height:55vh; }
  .gallery-dialog-media iframe { max-height:55vh; }
  .gallery-dialog-copy { padding:36px 35px 40px; }
}
/* Same breakpoint and values as .section-pad / .section-heading. */
@media(max-width:760px) {
  .gallery-section { padding-top:60px; }
  .gallery-heading { display:block;padding:0 6% 28px; }
  .gallery-heading h2 { margin:25px 0;font-size:44px; }
  .gallery-heading p { font-size:14px; }
  .gallery-toolbar { padding:0 6% 18px; }
  [data-mode=simple] .gallery-section { padding-top:30px; }
  [data-mode=simple] .gallery-heading h2 { font-size:28px; }
}
@media(max-width:600px) {
  [data-mode=simple] .gallery-toolbar .filters button { font-size:12px;padding:8px 11px; }
  .gallery-grid { grid-auto-rows:110px;gap:7px; }
  .gallery-caption { grid-template-columns:minmax(0,1fr) 24px;gap:7px;min-height:54px;padding:7px 9px; }
  .gallery-caption strong { font-size:11px; }
  .gallery-caption>span:last-child { width:24px;height:24px;font-size:15px; }
  .gallery-dialog { width:calc(100% - 20px);max-height:calc(100vh - 20px);box-shadow:8px 8px 0 var(--yellow); }
  .gallery-dialog-media { min-height:240px; }
  .gallery-dialog-copy { padding:30px 24px 35px; }
}
