.gallery-page {
  padding-bottom: clamp(2.4rem, 5vw, 4.5rem);
}

.gallery-intro {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  min-height: clamp(14rem, 23vw, 20rem);
  gap: .45rem;
  padding: .38rem;
  border: 1px solid var(--rule);
  background: var(--ink);
  box-shadow: .24rem .3rem 0 #100d0b93;
}

.gallery-intro-copy {
  display: flex;
  position: relative;
  isolation: isolate;
  flex-direction: column;
  justify-content: center;
  gap: .9rem;
  padding: clamp(1.45rem, 4vw, 3.4rem);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 10% 12%, #a34a3b, transparent 80%),
    linear-gradient(135deg, #783b33, #391f1c);
}

.gallery-intro-copy::before,
.gallery-intro-art::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.gallery-intro-copy::before {
  z-index: -1;
  background: radial-gradient(circle, #21120f75 .8px, transparent 1.5px) 0 0 / 6px 6px;
  mask-image: radial-gradient(ellipse at left top, #000, transparent 76%);
}

.gallery-intro h1 {
  font: 400 clamp(4.4rem, 9.2vw, 8.25rem)/.87 var(--display);
  letter-spacing: -.025em;
  text-transform: uppercase;
  transform: skew(-6deg);
  transform-origin: left bottom;
  text-shadow: .035em .05em var(--ink);
}

.gallery-intro p {
  max-width: 29ch;
  color: #f5ded3;
  font-size: clamp(1rem, 1.55vw, 1.19rem);
}

.gallery-intro-art {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(circle, #21120f75 .8px, transparent 1.5px) 0 0 / 6px 6px,
    linear-gradient(118deg, #351e1899, transparent 50%, #8c56363b),
    radial-gradient(ellipse at 76% 21%, #d8915b, transparent 60%),
    linear-gradient(153deg, #694331, #35201a);
}

.gallery-intro-art::after {
  background: repeating-linear-gradient(169deg, transparent 0 7px, #2e1b1552 8px 9px, transparent 10px 12px);
  mask-image: linear-gradient(112deg, #000, transparent 37%);
}

.gallery-section { margin-top: clamp(1.6rem, 4vw, 3.1rem); }

.gallery-section-heading {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: .85rem;
}

.gallery-section-heading::after {
  flex: 1;
  height: 1px;
  content: "";
  background: var(--rule);
}

.gallery-section-heading h2 {
  font: 400 clamp(1.38rem, 3vw, 2rem)/1.12 var(--display);
  letter-spacing: .035em;
  text-transform: uppercase;
}

.gallery-album-tray {
  border: 1px solid var(--rule);
  background: #171210;
}

.gallery-album-list {
  display: flex;
  align-items: stretch;
  gap: .55rem;
  margin: 0;
  padding: .55rem;
  overflow-x: auto;
  list-style: none;
  scrollbar-color: var(--rule) #171210;
  scroll-snap-type: x proximity;
}

.gallery-album-list li {
  flex: 0 0 min(78vw, 16rem);
  scroll-snap-align: start;
}

.gallery-album-button {
  display: grid;
  grid-template-columns: 2.85rem minmax(0, 1fr);
  align-items: center;
  gap: .72rem;
  width: 100%;
  min-height: 4.15rem;
  height: 100%;
  padding: .5rem;
  border: 1px solid var(--rule);
  background: #2a1e19;
  color: var(--paper);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.gallery-album-button:hover,
.gallery-album-button:focus-visible {
  border-color: var(--amber);
  background: #402820;
}

.gallery-album-button:focus-visible { outline-offset: -2px; }

.gallery-album-cover {
  display: block;
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid #bc856371;
  background:
    repeating-linear-gradient(141deg, #341f1b 0 3px, transparent 4px 7px),
    #654137;
}

.gallery-album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.gallery-album-name,
.gallery-album-count {
  display: block;
  overflow-wrap: anywhere;
}

.gallery-album-name { font-weight: 750; }
.gallery-album-count { color: var(--muted); font-size: .82rem; }

.gallery-album-status {
  display: flex;
  align-items: center;
  min-height: 4.4rem;
  padding: .75rem 1rem;
  color: var(--muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
  align-items: start;
  gap: .8rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.gallery-grid > li { min-width: 0; }

.gallery-card {
  display: grid;
  position: relative;
  isolation: isolate;
  width: 100%;
  padding: .27rem;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  border-color: var(--amber);
  box-shadow: .16rem .22rem 0 #ffbf7870;
}

.gallery-card:focus-visible { outline-offset: 3px; }

.gallery-card-frame {
  display: grid;
  position: relative;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background:
    radial-gradient(circle, #b37f5a32 .5px, transparent 1px) 0 0 / 6px 6px,
    #2d211b;
}

.gallery-card-frame img,
.gallery-card-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transition: transform 230ms ease;
}

.gallery-card:hover .gallery-card-frame:not(.gallery-thumbnail-concealed) :is(img, video) { transform: scale(1.045); }

.gallery-thumbnail-concealed > :is(img, video) {
  filter: blur(1.15rem) brightness(.53);
  transform: scale(1.2);
}

.gallery-safety-badge,
.gallery-warning-rating {
  padding: .2rem .48rem;
  border: 1px solid #af7358;
  background: #281912;
  color: #ffce9d;
  font-size: .79rem;
  font-weight: 800;
  letter-spacing: .045em;
  line-height: 1.15;
}

.gallery-safety-badge {
  position: absolute;
  inset: .5rem auto auto .5rem;
}

.gallery-album-cover .gallery-safety-badge {
  inset: 50% auto auto 50%;
  width: max-content;
  max-width: calc(100% - .24rem);
  padding: .15rem .12rem;
  border-color: #af735877;
  font-size: .51rem;
  text-align: center;
  transform: translate(-50%, -50%);
}

.gallery-video-label {
  position: absolute;
  right: .5rem;
  bottom: .48rem;
  padding: .15rem .4rem;
  background: var(--amber);
  color: var(--ink);
  font-size: .76rem;
  font-weight: 750;
}

.gallery-card-caption {
  display: grid;
  gap: .18rem;
  min-width: 0;
  padding: .7rem .62rem;
}

.gallery-card-title {
  overflow-wrap: anywhere;
  font-weight: 750;
}

.gallery-card-meta,
.gallery-media-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .12rem .45rem;
  color: var(--muted);
  font-size: .85rem;
  overflow-wrap: anywhere;
}

.gallery-card-meta time::before,
.gallery-media-meta time::before {
  margin-inline-end: .45rem;
  color: var(--amber);
  content: "·";
}

.gallery-load-status {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.gallery-load-status .loader {
  --size: .6px;
  display: none;
  flex: none;
}

.gallery-state.is-loading .loader { display: inline-block; }

.gallery-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: .8rem;
  min-height: 9.15rem;
  padding: clamp(1.1rem, 3vw, 2.2rem);
  border: 1px dashed var(--rule);
  background:
    linear-gradient(90deg, #241916 30%, #24191694 69%, transparent),
    radial-gradient(circle, #94695150 .7px, transparent 1.3px) 0 0 / 7px 7px,
    #2b1d18;
  color: var(--muted);
}

.gallery-control {
  display: inline-grid;
  min-height: 2.75rem;
  align-items: center;
  padding: .35rem .7rem;
  border: 1px solid #936a51;
  background: #241a16;
  color: var(--paper);
  cursor: pointer;
  font: 700 .88rem/1.2 var(--text);
}

.gallery-control:hover:not(:disabled) {
  border-color: var(--amber);
  color: var(--amber);
}

.gallery-control:disabled { opacity: .46; cursor: default; }

body:has(.gallery-dialog[open]) { overflow: hidden; }

.gallery-dialog {
  width: min(94vw, 65rem);
  max-width: none;
  max-height: 94dvh;
  padding: .4rem;
  overflow: auto;
  border: 1px solid #9a6f54;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 .75rem 3rem #0009;
}

.gallery-dialog::backdrop { background: #100d0bc7; }
.gallery-dialog[open] { animation: gallery-dialog-enter 170ms ease-out both; }

@keyframes gallery-dialog-enter {
  from { opacity: 0; translate: 0 .45rem; }
  to { opacity: 1; translate: 0; }
}

.gallery-dialog-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .8rem;
  padding: .24rem .25rem .55rem .65rem;
}

.gallery-dialog-bar h2 {
  font-size: clamp(1.07rem, 2.2vw, 1.34rem);
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.gallery-close {
  width: 2.75rem;
  padding: 0;
  font-size: 1.45rem;
  font-weight: 400;
}

.gallery-album-content {
  min-height: 8rem;
  padding: .65rem;
  border-top: 1px solid var(--rule);
}

.gallery-dialog-description {
  color: var(--paper);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.gallery-album-content .gallery-dialog-description { margin-bottom: .8rem; }
.gallery-album-empty { padding: .5rem 0; color: var(--muted); }

.gallery-media-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 4rem;
  overflow: hidden;
  background: #080605;
}

.gallery-media-preview {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  min-height: inherit;
}

.gallery-media-concealed {
  min-height: clamp(12rem, 35vw, 22rem);
}

.gallery-media-concealed .gallery-media-preview :is(img, video) {
  filter: blur(clamp(1.25rem, 4vw, 3rem)) brightness(.48);
  transform: scale(1.2);
}

.gallery-media-warning {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .7rem;
  padding: .65rem;
  background: #2317149c;
  color: var(--paper);
  text-align: center;
}

.gallery-warning-message { max-width: 34ch; }

.gallery-media-stage img,
.gallery-media-stage video {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(64dvh, 52rem);
  object-fit: contain;
}

.gallery-media-stage img { pointer-events: none; }
.gallery-media-info { display: grid; gap: .4rem; padding: .68rem; }

.gallery-viewer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding-top: .55rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: .88rem;
}

.gallery-page [hidden],
.gallery-dialog [hidden] { display: none; }

@media (max-width: 700px) {
  .gallery-intro { grid-template-columns: minmax(0, 1fr) minmax(0, .7fr); }
  .gallery-intro-art { background-size: auto, cover, auto; }
  .gallery-intro h1 { font-size: clamp(3.55rem, 11vw, 5.2rem); }
}

@media (max-width: 480px) {
  .gallery-intro {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(6.6rem, 24vw);
  }

  .gallery-intro-copy { padding: 1.35rem 1.15rem; }
  .gallery-intro-art { background-position: center, 92% 69%, center; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.15rem), 1fr)); gap: .46rem; }
  .gallery-card-caption { padding: .48rem .35rem; }
  .gallery-card-meta { display: grid; gap: 0; font-size: .78rem; }
  .gallery-card-meta time::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-dialog[open] { animation: none; }
  .gallery-album-button,
  .gallery-card,
  .gallery-card-frame :is(img, video) { transition: none; }
}
