/* Photo gallery: album cards, the justified photo grid and the full-screen viewer.
   Uses the colour and spacing tokens defined in css/site.css. */

/* --- filters ---------------------------------------------------------------------------------- */
.gal-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .85rem 1rem; margin-bottom: 2rem; }
.gal-filter__field { display: flex; flex-direction: column; gap: .3rem; min-width: min(100%, 14rem); }
.gal-filter__field label { font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.gal-filter__count { margin-left: auto; align-self: center; font-size: .9rem; font-weight: 700; color: var(--muted); }

/* --- album cards: a stack of pages behind the card says "album" -------------------------------- */
.alb {
  display: flex; flex-direction: column; height: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink-soft); transition: transform .25s, box-shadow .25s;
  box-shadow: 0 -5px 0 -2px #dde3f0, 0 -10px 0 -4px #edf0f7;
  position: relative;
}
.alb:hover { transform: translateY(-5px); box-shadow: 0 -5px 0 -2px #cfd8ee, 0 -10px 0 -4px #e5eaf5, var(--shadow-md); color: var(--ink-soft); }
.alb__media {
  position: relative; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0;
  color: rgba(255, 255, 255, .85); font-size: 2.6rem; background: linear-gradient(135deg, var(--navy-800), var(--brand));
  cursor: pointer;
}
.alb__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.alb:hover .alb__media img { transform: scale(1.06); }
.alb__count {
  position: absolute; right: .75rem; bottom: .75rem; display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem;
  border-radius: 999px; background: rgba(8, 12, 24, .72); color: #fff; font-size: .78rem; font-weight: 700; backdrop-filter: blur(4px);
  z-index: 3; pointer-events: none;
}
.alb__play {
  position: absolute; inset: 0; margin: auto; width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: rgba(11, 31, 75, .85); color: #fff; font-size: 1.85rem; display: grid; place-items: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .35), 0 0 0 2px rgba(255, 255, 255, .25);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), background-color .25s, box-shadow .25s;
  cursor: pointer; z-index: 4; padding-left: 4px;
}
.alb:hover .alb__play, .alb__media:focus-visible .alb__play {
  transform: scale(1.15); background: var(--brand, #2457f5);
  box-shadow: 0 8px 30px rgba(36, 87, 245, .5), 0 0 0 3px rgba(255, 255, 255, .4);
}
.alb__media:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.alb__body { padding: 1rem 1.2rem 1.25rem; display: flex; flex-direction: column; flex-grow: 1; }
.alb__meta { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .45rem; }
.alb h3 { font-size: 1.08rem; line-height: 1.35; margin: 0; color: var(--ink); }
.alb__title-link { color: inherit; text-decoration: none; transition: color .2s; }
.alb__title-link:hover { color: var(--brand); text-decoration: underline; }
.alb-grid { padding-top: 12px; } /* room for the stacked pages above the first row of cards */

/* --- the notes and the plain pager ------------------------------------------------------------- */
.gal-note { display: flex; gap: .6rem; align-items: center; padding: .8rem 1.1rem; margin-bottom: 1.5rem; border-radius: var(--radius-sm); background: #fff8e1; color: #6b4e00; border: 1px solid #f3dc8a; font-weight: 600; }
.gal-pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; font-weight: 600; color: var(--muted); }
.album-text { max-width: 760px; margin-bottom: 2rem; }
.album-text .prose { margin-bottom: .9rem; }

/* --- the photo grid: rows of photos as wide as the page, each photo at its own proportions ------ */
.ph-grid { --row: 220px; display: flex; flex-wrap: wrap; gap: .6rem; }
.ph-grid::after { content: ""; flex-grow: 1e4; } /* the last row keeps its photos at a sensible size instead of stretching them */
.ph {
  position: relative; display: block; overflow: hidden; border-radius: 12px; background: var(--brand-50); cursor: zoom-in;
  flex: calc(var(--r) * 100) 1 calc(var(--r) * var(--row));
}
.ph i { display: block; padding-bottom: calc(100% / var(--r)); }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s, filter .3s; }
.ph:hover img, .ph:focus-visible img { transform: scale(1.05); }
.ph:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.ph__cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 1.6rem .85rem .7rem; color: #fff; font-size: .85rem; font-weight: 600; line-height: 1.3;
  background: linear-gradient(to top, rgba(8, 12, 24, .78), transparent); opacity: 0; transition: opacity .25s;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ph:hover .ph__cap, .ph:focus-visible .ph__cap { opacity: 1; }
@media (hover: none) { .ph__cap { display: none; } } /* touch screens: the caption is in the viewer */
@media (max-width: 575.98px) { .ph-grid { --row: 150px; gap: .4rem; } .ph { border-radius: 8px; } }

.ph-more { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin-top: 2rem; }
.ph-more:empty { display: none; }
.ph-more__count { margin: 0; font-size: .9rem; font-weight: 600; color: var(--muted); }
.ph-more .htmx-request, .ph-more.htmx-request { opacity: .6; pointer-events: none; }

/* --- the full-screen viewer --------------------------------------------------------------------- */
html.lb-open { overflow: hidden; }
.lb {
  position: fixed; inset: 0; z-index: 3000; display: flex; flex-direction: column; color: #fff;
  background: rgba(8, 12, 24, .96); opacity: 0; transition: opacity .2s;
}
.lb[hidden] { display: none; }
.lb.is-open { opacity: 1; }
.lb__bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem; position: relative; }
.lb__meta-box { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.lb__album-title { font-size: .92rem; font-weight: 700; color: #fff; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
.lb__count { font-size: .85rem; font-weight: 700; opacity: .75; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb__status { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; background: rgba(36, 87, 245, .35); color: #7cb3ff; padding: .15rem .55rem; border-radius: 999px; border: 1px solid rgba(124, 179, 255, .3); }
.lb__tools { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.lb__progress { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.lb__progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #ff7a1a, var(--brand, #2457f5)); transition: width .1s linear; }
.lb__btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; padding: 0;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 1.1rem; transition: background .2s, transform .15s;
  cursor: pointer;
}
.lb__btn:hover, .lb__btn:focus-visible { background: rgba(255, 255, 255, .26); color: #fff; transform: scale(1.05); }
.lb__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb__btn:disabled { opacity: .3; cursor: default; transform: none; }
.lb__btn.is-active { background: var(--brand, #2457f5); color: #fff; box-shadow: 0 0 16px rgba(36, 87, 245, .6); }
.lb__stage { position: relative; flex: 1; min-height: 0; margin: 0 4.25rem; touch-action: pan-y pinch-zoom; display: grid; place-items: center; }
.lb__img { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 6px; transition: opacity .25s, transform .25s; user-select: none; -webkit-user-drag: none; }
.lb.is-loading .lb__img { opacity: .25; }
.lb__spin { position: absolute; inset: 0; margin: auto; width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: lb-spin .8s linear infinite; display: none; }
.lb.is-loading .lb__spin { display: block; }
@keyframes lb-spin { to { transform: rotate(360deg); } }
.lb__cap { min-height: 2.8rem; padding: .6rem 1.25rem .4rem; text-align: center; font-size: 1rem; line-height: 1.4; max-width: 72ch; margin: 0 auto; color: rgba(255, 255, 255, .92); }
.lb__thumbs { display: flex; justify-content: center; align-items: center; gap: .5rem; padding: .4rem 1rem .8rem; overflow-x: auto; max-width: 100%; scrollbar-width: thin; }
.lb__thumb-btn { width: 44px; height: 32px; border-radius: 4px; border: 2px solid transparent; overflow: hidden; padding: 0; background: none; opacity: .45; transition: opacity .2s, border-color .2s, transform .2s; cursor: pointer; flex-shrink: 0; }
.lb__thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb__thumb-btn:hover, .lb__thumb-btn.is-current { opacity: 1; border-color: #fff; transform: scale(1.1); }
.lb__nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 10; }
.lb__prev { left: .85rem; }
.lb__next { right: .85rem; }
@media (max-width: 575.98px) {
  .lb__bar { padding: .5rem .75rem; }
  .lb__album-title { max-width: 140px; font-size: .82rem; }
  .lb__stage { margin: 0; }
  .lb__nav { width: 40px; height: 40px; background: rgba(8, 12, 24, .65); }
  .lb__prev { left: .4rem; }
  .lb__next { right: .4rem; }
  .lb__cap { font-size: .88rem; min-height: 2.4rem; padding-bottom: .2rem; }
  .lb__thumbs { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lb, .lb__img, .ph img, .alb, .alb__media img { transition: none; }
  .lb__spin { animation-duration: 2s; }
}
