/* The public photo gallery (lib/gallery-page.js), on every dojo's website. It takes its colours from the page it sits
   in: text is the page's own colour, lines and quiet text are tints of it, and the accent is the site's accent
   (--accent on the starter site, --red on San Yama's). Only the full-screen viewer has colours of its own (a photo
   is always shown on black). */
.gal {
  --gal-accent: var(--accent, var(--red, #d11d2b));
  --gal-line: color-mix(in srgb, currentColor 16%, transparent);
  --gal-quiet: color-mix(in srgb, currentColor 66%, transparent);
  --gal-fill: color-mix(in srgb, currentColor 6%, transparent);
  --gal-radius: 12px;
  display: grid; gap: 1.4rem; min-width: 0;
}
.gal a { color: inherit; text-decoration: none; }
.gal img { display: block; max-width: 100%; }
.gal-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.gal-empty { margin: 2rem 0; color: var(--gal-quiet); font-size: 1.1rem; }

/* hero mosaic: one large tile and four small */
.gal-hero { display: grid; grid-template-columns: 2fr 1fr 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 8px; aspect-ratio: 2.1 / 1; }
.gal-hero > div { position: relative; overflow: hidden; border-radius: var(--gal-radius); background: var(--gal-fill); min-height: 0; }
.gal-hero__big { grid-row: span 2; }
.gal-hero .gal-link, .gal-hero img { width: 100%; height: 100%; }
.gal-hero img { object-fit: cover; transition: transform .5s cubic-bezier(.22, 1, .36, 1); }
.gal-hero .gal-link:hover img { transform: scale(1.03); }
.gal-hero__cap { position: absolute; inset: auto 0 0 0; display: grid; gap: .5rem; justify-items: start; padding: 3rem 1.2rem 1.1rem; color: #fff; font-size: 1.05rem; line-height: 1.4; background: linear-gradient(transparent, rgba(0, 0, 0, .78)); pointer-events: none; }
.gal-hero__cap .gal-chip { background: var(--gal-accent); border-color: transparent; color: #fff; }

/* Photos / Events */
.gal-switch { display: inline-flex; justify-self: start; padding: 4px; gap: 4px; border: 1px solid var(--gal-line); border-radius: 999px; }
.gal-switch a { padding: .45rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: .95rem; color: var(--gal-quiet); }
.gal-switch a[aria-current] { background: var(--gal-accent); color: #fff; }

/* the strip of events */
.gal-strip { display: flex; gap: 1.1rem; overflow-x: auto; padding: .3rem .2rem .6rem; scrollbar-width: thin; }
.gal-story { flex: 0 0 auto; width: 96px; display: grid; justify-items: center; gap: .3rem; text-align: center; font-size: .82rem; line-height: 1.25; }
.gal-story__ring { width: 78px; height: 78px; padding: 3px; border-radius: 50%; border: 2px solid var(--gal-line); overflow: hidden; }
.gal-story.is-on .gal-story__ring, .gal-story:hover .gal-story__ring { border-color: var(--gal-accent); }
.gal-story__ring img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.gal-story__name { font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gal-story__n { color: var(--gal-quiet); font-size: .76rem; }

/* one event's heading */
.gal-focus { padding: 1.1rem 1.3rem; border: 1px solid var(--gal-line); border-left: 4px solid var(--gal-accent); border-radius: var(--gal-radius); background: var(--gal-fill); }
.gal-focus h2 { margin: 0 0 .2rem; font-size: clamp(1.3rem, 3vw, 1.8rem); }
.gal-focus p { margin: .2rem 0; max-width: 70ch; }
.gal-focus__meta { color: var(--gal-quiet); }
.gal .gal-focus__all { display: inline-block; margin-top: .5rem; font-weight: 600; color: var(--gal-accent); }

/* category chips and the order */
.gal-filters { display: flex; align-items: center; gap: 1rem; min-width: 0; flex-wrap: wrap; }
.gal-chips--kind { flex: 0 0 auto; }
.gal-chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .2rem; flex: 1; min-width: 0; scrollbar-width: none; }
.gal-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .4rem; padding: .32rem .85rem; border: 1px solid var(--gal-line); border-radius: 999px; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.gal-chip__n { font-weight: 500; color: var(--gal-quiet); font-size: .8rem; }
a.gal-chip:hover { border-color: var(--gal-accent); }
.gal-chip.is-on { background: var(--gal-accent); border-color: var(--gal-accent); color: #fff; }
.gal-chip.is-on .gal-chip__n { color: rgba(255, 255, 255, .8); }
.gal-order { flex: 0 0 auto; font-size: .88rem; font-weight: 600; color: var(--gal-quiet); white-space: nowrap; }
.gal-order:hover { color: var(--gal-accent); }

/* the photos: rows of tiles that keep each photo's own shape (a tile grows with its width ÷ height) */
.gal-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.gal-grid::after { content: ""; flex: 10 1 0; }
.gal-tile { margin: 0; flex: var(--r, 1.5) 1 calc(var(--r, 1.5) * 210px); min-width: 0; max-width: calc(var(--r, 1.5) * 420px); }
.gal-tile .gal-link { display: block; overflow: hidden; border-radius: var(--gal-radius); background: var(--gal-fill); aspect-ratio: var(--r, 1.5); }
.gal-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s cubic-bezier(.22, 1, .36, 1); }
.gal-tile .gal-link:hover img { transform: scale(1.04); }
/* a video: its platform's still (cropped to the tile, which hides the bars some stills carry) under a play mark */
.gal-link--video { position: relative; display: block; background: #16161a; }
.gal-play { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .62); border: 2px solid rgba(255, 255, 255, .85); padding-left: 3px; transition: background .2s, scale .2s; pointer-events: none; }
.gal-link--video:hover .gal-play { background: var(--gal-accent); scale: 1.08; }
.gal-story__ring, .gal-album__img { position: relative; }
.gal-link:focus-visible { outline: 3px solid var(--gal-accent); outline-offset: 2px; }
.gal-tile figcaption { padding: .45rem .15rem 0; font-size: .86rem; line-height: 1.4; color: var(--gal-quiet); overflow-wrap: anywhere; }
.gal .gal-tile__event { display: block; color: var(--gal-accent); font-weight: 600; overflow-wrap: anywhere; }

/* event albums */
.gal-albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.1rem; }
.gal-album { display: grid; border: 1px solid var(--gal-line); border-radius: var(--gal-radius); overflow: hidden; background: var(--gal-fill); }
.gal-album:hover { border-color: var(--gal-accent); }
.gal-album__img { aspect-ratio: 3 / 2; overflow: hidden; }
.gal-album__img img { width: 100%; height: 100%; object-fit: cover; }
.gal-album__body { display: grid; gap: .15rem; padding: .8rem 1rem 1rem; font-size: .88rem; color: var(--gal-quiet); }
.gal-album__body strong { font-size: 1.05rem; color: inherit; filter: none; }
.gal .gal-album__body strong { color: currentColor; }
.gal-album { color: inherit; }

/* paging */
.gal-pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding-top: .6rem; }
.gal-pager a { font-weight: 600; padding: .6rem 1.1rem; border: 1px solid var(--gal-line); border-radius: 999px; justify-self: start; }
.gal-pager a[rel="next"] { justify-self: end; }
.gal-pager a:hover { border-color: var(--gal-accent); color: var(--gal-accent); }
.gal-pager__at { color: var(--gal-quiet); font-size: .9rem; }

@media (max-width: 640px) {
  .gal { gap: 1.1rem; }
  .gal-hero { grid-template-columns: 1fr 1fr; grid-template-rows: auto; aspect-ratio: auto; gap: 6px; }
  .gal-hero__big { grid-column: span 2; grid-row: auto; aspect-ratio: 4 / 3; }
  .gal-hero__small { aspect-ratio: 1; }
  .gal-grid { gap: 6px; }
  .gal-tile { flex-basis: calc(var(--r, 1.5) * 170px); max-width: none; }
  .gal-tile figcaption { font-size: .8rem; }
  .gal-pager { grid-template-columns: 1fr 1fr; }
  .gal-pager__at { grid-column: span 2; grid-row: 2; text-align: center; }
}

/* ---- the full-screen viewer (gallery-viewer.js) ---- */
.gal-view { position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: rgba(8, 8, 9, .97); color: #fff; font-family: inherit; }
.gal-view[hidden] { display: none; }
.gal-view__bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; font-size: .9rem; color: rgba(255, 255, 255, .75); }
.gal-view button { font: inherit; color: #fff; background: rgba(255, 255, 255, .1); border: 0; border-radius: 999px; cursor: pointer; display: grid; place-items: center; }
.gal-view button:hover { background: rgba(255, 255, 255, .22); }
.gal-view button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.gal-view__close { width: 44px; height: 44px; font-size: 1.5rem; line-height: 1; }
.gal-view__stage { position: relative; min-height: 0; margin: 0 .5rem; touch-action: pan-y; }
/* The photo fills the stage whatever its own size (it sits out of flow, so a tall photo can't push the caption off). */
.gal-view__stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
/* a video plays in its platform's own player, as large as fits at its own shape */
.gal-view__stage iframe { position: absolute; inset: 0; margin: auto; border: 0; outline: 0; width: min(100%, calc((100vh - 190px) * var(--vr, 1.7778))); width: min(100%, calc((100dvh - 190px) * var(--vr, 1.7778))); aspect-ratio: var(--vr, 1.7778); max-height: 100%; background: #000; }
.gal-view__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 1.6rem; }
.gal-view__nav[data-dir="-1"] { left: .8rem; }
.gal-view__nav[data-dir="1"] { right: .8rem; }
.gal-view__nav[disabled] { opacity: .25; cursor: default; }
.gal-view__info { padding: .9rem 1.2rem 1.2rem; text-align: center; display: grid; gap: .3rem; justify-items: center; }
.gal-view__cap { margin: 0; font-size: 1.02rem; line-height: 1.45; max-width: 80ch; }
.gal-view__meta { margin: 0; font-size: .85rem; color: rgba(255, 255, 255, .7); }
.gal-view__meta a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 640px) {
  .gal-view__nav { top: auto; bottom: .4rem; transform: none; width: 44px; height: 44px; }
  .gal-view__info { padding: .8rem 3.6rem 1rem; }
}
@media (prefers-reduced-motion: reduce) { .gal img { transition: none; } }
