/* gallery.css — "Through the lens" (#gallery-wall). Loaded after writing.css.
   A numbered mosaic of frames on the night sky. Each frame shows its photo,
   or until there is one, a painted scene for its subject. Click opens the
   viewer (static/js/gallery.js). Section padding and the sky fade stay in
   flow.css. */

#gallery-wall { padding-top: clamp(4.4rem, 8vw, 6.4rem); }
.gl-inner { position: relative; z-index: 2; max-width: 1240px; margin: 0 auto; }

/* ── heading ─────────────────────────────────────────────────────── */
.gl-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: clamp(1.8rem, 3.6vw, 2.8rem);
}
#gallery-wall .sec-label { margin-bottom: 1.5rem; }
.gl-hed {
  font-family: var(--font-serif);
  font-size: clamp(2.3rem, 4.8vw, 4.2rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -.035em;
  color: var(--dark-ink);
}
.gl-hed em { font-style: italic; color: var(--seq-metal); }
.gl-sub { margin-top: 1rem; max-width: 40ch; font-size: .98rem; line-height: 1.7; color: rgba(228, 232, 240, .62); }

.gl-filters { display: flex; flex-wrap: wrap; gap: .2rem 1.4rem; padding-bottom: .3rem; }
.gl-filter {
  position: relative;
  padding: .4rem 0;
  border: 0;
  background: none;
  font-family: var(--font-ui);
  font-size: .78rem;
  font-weight: 500;
  color: rgba(228, 232, 240, .46);
  cursor: pointer;
  transition: color .25s ease;
}
.gl-filter::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.5px;
  background: var(--seq-metal);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform .45s var(--out, cubic-bezier(.2, .75, .2, 1));
}
.gl-filter:hover { color: rgba(240, 240, 248, .85); }
.gl-filter.is-on { color: #f4f1ea; }
.gl-filter.is-on::after { transform: scaleX(1); }
.gl-filter:focus-visible { outline: 1px solid var(--seq-metal); outline-offset: 4px; }

/* ── mosaic ──────────────────────────────────────────────────────── */
.gl-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  grid-auto-rows: clamp(190px, 17vw, 236px);
  grid-auto-flow: dense;
  gap: clamp(.6rem, 1.1vw, .95rem);
}
.gl-card--tall { grid-row: span 2; }
.gl-card--wide { grid-column: span 2; }
.gl-grid.is-filtered .gl-card { grid-row: span 1; grid-column: span 1; }
.gl-grid.is-swap .gl-card:not([hidden]) { animation: glIn .55s var(--out, cubic-bezier(.2, .75, .2, 1)) both; animation-delay: calc(var(--i) * 40ms); }
@keyframes glIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.gl-card {
  position: relative;
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #0b0f17;
  color: inherit;
  text-align: left;
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
  box-shadow: 0 24px 50px rgba(0, 0, 0, .32);
  -webkit-tap-highlight-color: transparent;
}
.gl-card[hidden] { display: none; }
.gl-card::after {                       /* hairline mat inside the frame */
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  pointer-events: none;
  transition: box-shadow .4s ease;
}
.gl-card:hover::after { box-shadow: inset 0 0 0 1px rgba(232, 208, 164, .35); }
.gl-card:focus-visible { outline: 1.5px solid var(--seq-metal); outline-offset: 3px; }

.gl-card-pic { position: absolute; inset: 0; transition: transform 1.2s var(--out, cubic-bezier(.2, .75, .2, 1)); }
.gl-card:hover .gl-card-pic { transform: scale(1.045); }
.gl-card-pic::after {                   /* caption shade */
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(5, 7, 11, .32) 0%, rgba(5, 7, 11, 0) 28%, rgba(5, 7, 11, 0) 50%, rgba(5, 7, 11, .82) 100%);
}

.gl-card-top {
  position: absolute;
  top: 1rem;
  left: 1.1rem;
  right: 1.1rem;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: .7rem;
  font-family: var(--font-ui);
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, .66);
}
.gl-card-no { color: var(--seq-metal); }
.gl-card-kind::before { content: ''; display: inline-block; width: 14px; height: 1px; margin: 0 .7rem .2rem 0; background: rgba(244, 241, 234, .3); vertical-align: middle; }

.gl-card-play {
  position: absolute;
  top: .8rem;
  right: .8rem;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(6, 9, 15, .3);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background .3s ease, border-color .3s ease;
}
.gl-card-play svg { width: 14px; height: 14px; margin-left: 2px; fill: #f4f1ea; }
.gl-card:hover .gl-card-play { background: rgba(244, 241, 234, .16); border-color: rgba(244, 241, 234, .6); }

.gl-card-cap {
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  bottom: 1rem;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  transform: translateY(4px);
  transition: transform .6s var(--out, cubic-bezier(.2, .75, .2, 1));
}
.gl-card:hover .gl-card-cap { transform: none; }
.gl-card-where { font-family: var(--font-ui); font-size: .62rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: rgba(232, 208, 164, .82); }
.gl-card-title { font-family: var(--font-serif); font-size: clamp(1.1rem, 1.7vw, 1.5rem); line-height: 1.12; letter-spacing: -.02em; color: #f4f1ea; max-width: 16ch; }
.gl-card--wide .gl-card-title { max-width: 22ch; }

/* ── scenes: painted until a photo is added ──────────────────────── */
.gl-scene { display: block; overflow: hidden; background-color: #0b0f17; }
.gl-scene img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.gl-scene.has-photo::before { content: none !important; }
.gl-scene::before { content: ''; position: absolute; inset: 0; }

/* wildlife: dusk grass, out-of-focus light */
.gl-scene--wild {
  background:
    radial-gradient(circle at 72% 30%, rgba(255, 226, 168, .5) 0 2.5%, rgba(255, 226, 168, 0) 9%),
    radial-gradient(circle at 24% 22%, rgba(214, 222, 170, .16) 0 4%, transparent 9%),
    radial-gradient(circle at 58% 48%, rgba(214, 222, 170, .12) 0 3%, transparent 8%),
    radial-gradient(circle at 38% 12%, rgba(214, 222, 170, .1) 0 5%, transparent 10%),
    radial-gradient(ellipse 90% 60% at 70% 30%, rgba(174, 150, 92, .42), transparent 70%),
    linear-gradient(180deg, #2b3324 0%, #1a2216 55%, #0d120c 100%);
}
.gl-scene--wild::before {
  background:
    repeating-linear-gradient(97deg, rgba(10, 14, 8, 0) 0 9px, rgba(10, 14, 8, .55) 9px 11px, rgba(10, 14, 8, 0) 11px 23px),
    repeating-linear-gradient(83deg, rgba(10, 14, 8, 0) 0 14px, rgba(10, 14, 8, .45) 14px 16px, rgba(10, 14, 8, 0) 16px 31px);
  -webkit-mask-image: linear-gradient(180deg, transparent 52%, #000 82%);
          mask-image: linear-gradient(180deg, transparent 52%, #000 82%);
}

/* travel: a road climbing into a pass */
.gl-scene--road {
  background:
    radial-gradient(ellipse 60% 40% at 50% 42%, rgba(232, 176, 128, .45), transparent 70%),
    linear-gradient(180deg, #1e2840 0%, #4a4a63 34%, #b07f69 46%, #2a2b33 47%, #15171d 100%);
}
.gl-scene--road::before {
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(244, 225, 180, .38) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + 1px)) 0 0 / 100% 22px,
    linear-gradient(180deg, #30333d, #1b1d24);
  clip-path: polygon(46% 47%, 54% 47%, 92% 100%, 8% 100%);
  -webkit-mask-image: repeating-linear-gradient(180deg, #000 0 12px, rgba(0, 0, 0, .55) 12px 22px);
}
.gl-scene--road::after { content: none; }

/* night sky: stars and the band of the galaxy */
.gl-scene--astro {
  background:
    radial-gradient(1.2px 1.2px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 28% 62%, rgba(255, 255, 255, .9), transparent),
    radial-gradient(1.4px 1.4px at 44% 30%, #fff, transparent),
    radial-gradient(1px 1px at 63% 12%, rgba(255, 255, 255, .8), transparent),
    radial-gradient(1.2px 1.2px at 78% 44%, #fff, transparent),
    radial-gradient(1px 1px at 88% 22%, rgba(255, 255, 255, .85), transparent),
    radial-gradient(1px 1px at 56% 70%, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1px 1px at 20% 82%, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1.3px 1.3px at 70% 80%, rgba(255, 255, 255, .8), transparent),
    radial-gradient(1px 1px at 36% 8%, rgba(255, 255, 255, .7), transparent),
    linear-gradient(180deg, #060a16 0%, #0d1428 70%, #1c2238 100%);
  background-size: 120px 110px, 140px 130px, 170px 150px, 110px 160px, 190px 140px, 150px 120px, 130px 170px, 160px 100px, 200px 180px, 125px 145px, 100% 100%;
}
.gl-scene--astro::before {
  background: linear-gradient(118deg, transparent 30%, rgba(168, 176, 220, .14) 42%, rgba(232, 214, 190, .2) 50%, rgba(168, 176, 220, .12) 58%, transparent 70%);
  filter: blur(6px);
}
.gl-scene--astro::after { content: none; }

/* series: layered hills in haze */
.gl-scene--field {
  background:
    radial-gradient(ellipse 50% 35% at 68% 30%, rgba(236, 210, 160, .4), transparent 70%),
    linear-gradient(180deg, #7d8a8c 0%, #a59a84 38%, #50594f 60%, #232a24 100%);
}
.gl-scene--field::before {
  background:
    radial-gradient(ellipse 70% 40% at 20% 100%, #1b211b 60%, transparent 61%),
    radial-gradient(ellipse 60% 34% at 85% 96%, #252d26 60%, transparent 61%),
    radial-gradient(ellipse 80% 30% at 45% 78%, rgba(58, 68, 60, .9) 60%, transparent 61%);
}

/* first light: ridge against a warm sky */
.gl-scene--dawn {
  background:
    radial-gradient(circle at 62% 58%, rgba(255, 228, 176, .9) 0 3%, rgba(255, 196, 132, .4) 9%, transparent 28%),
    linear-gradient(180deg, #1d2338 0%, #5d5470 32%, #c58b70 56%, #e8b98c 64%);
}
.gl-scene--dawn::before {
  background: linear-gradient(180deg, #1e1a22, #0f0d12);
  clip-path: polygon(0 74%, 12% 62%, 22% 68%, 34% 54%, 46% 66%, 55% 60%, 70% 70%, 82% 57%, 92% 64%, 100% 60%, 100% 100%, 0 100%);
}

/* motion: long-exposure light trails */
.gl-scene--trails {
  background:
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(80, 92, 140, .4), transparent 70%),
    linear-gradient(180deg, #0a0d18 0%, #151a2c 100%);
}
.gl-scene--trails::before {
  background:
    repeating-linear-gradient(172deg, transparent 0 18px, rgba(255, 186, 120, .55) 18px 19.5px, transparent 19.5px 34px),
    repeating-linear-gradient(176deg, transparent 0 26px, rgba(255, 120, 108, .4) 26px 27.5px, transparent 27.5px 47px),
    repeating-linear-gradient(170deg, transparent 0 40px, rgba(196, 214, 255, .45) 40px 41px, transparent 41px 66px);
  filter: blur(.6px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent), linear-gradient(180deg, transparent 35%, #000 60%);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent), linear-gradient(180deg, transparent 35%, #000 60%);
          mask-composite: intersect;
}

/* ── viewer ──────────────────────────────────────────────────────── */
.gl-view {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(.8rem, 3vw, 2.4rem);
  background: rgba(3, 5, 9, .84);
  -webkit-backdrop-filter: blur(14px) saturate(.8);
  backdrop-filter: blur(14px) saturate(.8);
  opacity: 0;
  transition: opacity .3s ease;
  cursor: auto;
}
.gl-view[hidden] { display: none; }
.gl-view.is-open { opacity: 1; }
.gl-view-sheet {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr);
  width: min(100%, 1180px);
  height: min(100%, 660px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: #0a0e16;
  box-shadow: 0 50px 120px rgba(0, 0, 0, .65);
  color: var(--dark-ink);
  transform: translateY(18px) scale(.985);
  transition: transform .5s cubic-bezier(.2, .75, .2, 1);
  overflow: hidden;
}
.gl-view.is-open .gl-view-sheet { transform: none; }
.gl-view-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #05070b; touch-action: pan-y; }
.gl-view-pic { position: absolute; inset: 0; animation: glFade .55s cubic-bezier(.2, .75, .2, 1) both; }
.gl-view-pic.from-right { animation-name: glFromRight; }
.gl-view-pic.from-left { animation-name: glFromLeft; }
.gl-view-pic img { object-fit: contain; background: #05070b; }
.gl-view-pic video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
@keyframes glFade { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: none; } }
@keyframes glFromRight { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes glFromLeft { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
.gl-view-pic .gl-view-play { top: 50%; left: 50%; right: auto; width: 64px; height: 64px; transform: translate(-50%, -50%); }
.gl-view-play svg { width: 22px; height: 22px; }
.gl-view-wait {
  position: absolute;
  left: 1.3rem;
  bottom: 1.1rem;
  z-index: 3;
  font-family: var(--font-ui);
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, .6);
}

.gl-view-close {
  position: absolute;
  top: clamp(1rem, 1.8vw, 1.5rem);
  right: clamp(1.1rem, 2.2vw, 1.9rem);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem .2rem;
  border: 0;
  background: none;
  font-family: var(--font-ui);
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(240, 240, 248, .5);
  cursor: pointer;
  transition: color .25s ease;
}
.gl-view-close svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; transition: transform .45s cubic-bezier(.2, .75, .2, 1); }
.gl-view-close:hover { color: #f3e2bf; }
.gl-view-close:hover svg { transform: rotate(90deg); }
.gl-view-close:focus-visible { outline: 1px solid #f3e2bf; outline-offset: 5px; }

.gl-view-rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: clamp(4.2rem, 6vw, 5rem) clamp(1.5rem, 2.6vw, 2.3rem) clamp(1.4rem, 2.4vw, 2rem);
  border-left: 1px solid rgba(255, 255, 255, .07);
}
.gl-view-rail > * { animation: glRise .55s cubic-bezier(.2, .75, .2, 1) both; }
.gl-view-rail > :nth-child(2) { animation-delay: .05s; }
.gl-view-rail > :nth-child(3) { animation-delay: .1s; }
@keyframes glRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.gl-view-kicker { font-family: var(--font-ui); font-size: .62rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--seq-metal, #d2ba8f); white-space: pre-wrap; }
.gl-view-title { margin-top: .9rem; font-family: var(--font-serif); font-size: clamp(1.9rem, 3vw, 2.7rem); font-weight: 400; line-height: 1.04; letter-spacing: -.03em; color: var(--dark-ink); }
.gl-view-line { margin-top: 1rem; max-width: 32ch; font-size: .95rem; line-height: 1.65; color: rgba(228, 232, 240, .62); }

.gl-view-nav {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: auto;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, .09);
  animation: none !important;
}
.gl-view-count { margin-right: auto; font-family: var(--font-ui); font-size: .68rem; font-weight: 600; letter-spacing: .16em; color: rgba(228, 232, 240, .5); }
.gl-view-step {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(240, 240, 248, .6);
  cursor: pointer;
  transition: color .25s ease;
}
.gl-view-step svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .4s cubic-bezier(.2, .75, .2, 1); }
.gl-view-step--prev svg { transform: scaleX(-1); }
.gl-view-step:hover { color: #f3e2bf; }
.gl-view-step:hover svg { transform: translateX(4px); }
.gl-view-step--prev:hover svg { transform: scaleX(-1) translateX(4px); }
.gl-view-step:focus-visible { outline: 1px solid #f3e2bf; outline-offset: 2px; }

/* ── tablets and phones ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .gl-head { flex-direction: column; align-items: flex-start; gap: 1.4rem; }
  .gl-grid { grid-template-columns: 1fr 1fr; grid-auto-rows: 200px; }
}
@media (max-width: 820px) {
  .gl-view { align-items: flex-end; padding: 0; }
  .gl-view-sheet {
    display: block;
    width: 100%;
    height: auto;
    max-height: 92vh;
    max-height: 92dvh;
    padding-top: 3rem;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    transform: translateY(36px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .gl-view-close { top: .55rem; right: 1.15rem; }
  .gl-view-stage { aspect-ratio: 4 / 3; max-height: 50vh; width: 100%; }
  .gl-view-rail { padding: 1.4rem 1.25rem calc(1.2rem + env(safe-area-inset-bottom, 0px)); border-left: 0; }
  .gl-view-nav { margin-top: 1.4rem; }
}
@media (max-width: 600px) {
  #gallery-wall { padding-left: 1.15rem; padding-right: 1.15rem; }
  .gl-filters { gap: .1rem 1.1rem; }
  /* a tall frame with a pair beside it, then pairs, and the last frame full width,
     so no slot is left empty on a two-column phone grid */
  .gl-grid { grid-auto-rows: 168px; gap: .55rem; grid-auto-flow: row dense; }
  .gl-card--wide { grid-column: span 1; }
  .gl-card:last-child { grid-column: 1 / -1; }
  .gl-card { border-radius: 14px; }
  .gl-card--tall { grid-row: span 2; }
  .gl-card-top { top: .75rem; left: .8rem; right: .8rem; }
  .gl-card-kind { display: none; }
  .gl-card-cap { left: .8rem; right: .8rem; bottom: .75rem; }
  .gl-card-title { font-size: 1rem; }
  .gl-card-where { font-size: .56rem; }
  .gl-card-play { width: 32px; height: 32px; top: .6rem; right: .6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gl-card-pic, .gl-card-cap, .gl-view, .gl-view-sheet { transition: none; }
  .gl-grid.is-swap .gl-card, .gl-view-pic, .gl-view-rail > * { animation: none; }
}
