:root {
  --gallery-bg: #f4f5f7;
  --gallery-ink: #111111;
  --gallery-muted: #6b7280;
  --gallery-gap: 6px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--gallery-bg);
}

body {
  background: var(--gallery-bg);
  color: var(--gallery-ink);
  font-family: Arial, "Noto Sans Thai", sans-serif;
  margin: 0;
  min-height: 100vh;
}

button {
  font: inherit;
}

.gallery-intro {
  padding: 38px clamp(16px, 4vw, 64px) 30px;
  position: relative;
  text-align: center;
}

.gallery-kicker {
  color: var(--gallery-muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.gallery-title {
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  letter-spacing: -.035em;
  margin: 0;
}

.gallery-meta {
  align-items: center;
  color: var(--gallery-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: .95rem;
  gap: 8px 18px;
  justify-content: center;
  margin: 12px 0 0;
}

.gallery-location {
  color: #111111;
  font-weight: 700;
}

.gallery-search-link {
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  bottom: 22px;
  color: #111111;
  display: inline-flex;
  font-size: .82rem;
  font-weight: 700;
  gap: 7px;
  padding: 8px 12px;
  position: absolute;
  right: clamp(16px, 4vw, 64px);
  text-decoration: none;
}

.gallery-search-link:hover { background: #111111; color: #ffffff; }
.gallery-search-link svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-width: 2; width: 18px; }

.gallery-shell {
  padding: 0 var(--gallery-gap) var(--gallery-gap);
}

.gallery-collection {
  opacity: 0;
  transition: opacity .25s ease;
}

.gallery-collection.ready {
  opacity: 1;
}

.gallery-layout-justified {
  display: flex;
  flex-direction: column;
  gap: var(--gallery-gap);
}

.gallery-row {
  display: flex;
  gap: var(--gallery-gap);
  overflow: hidden;
  width: 100%;
}

.gallery-layout-grid {
  display: grid;
  gap: var(--gallery-gap);
  grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 20vw, 290px), 1fr));
}

.gallery-layout-grid .gallery-photo {
  aspect-ratio: 1 / 1;
  width: 100%;
}

.gallery-layout-columns {
  column-count: 4;
  column-gap: var(--gallery-gap);
}

.gallery-layout-columns .gallery-photo {
  break-inside: avoid;
  margin: 0 0 var(--gallery-gap);
  width: 100%;
}

.gallery-layout-columns .gallery-photo img {
  height: auto;
}

.gallery-layout-carousel {
  display: flex;
  gap: clamp(10px, 1.5vw, 22px);
  overflow-x: auto;
  padding: 8px clamp(16px, 5vw, 72px) 18px;
  scroll-behavior: smooth;
  scroll-padding-inline: clamp(16px, 5vw, 72px);
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.gallery-layout-carousel .gallery-photo {
  flex: 0 0 clamp(250px, 36vw, 520px);
  height: clamp(320px, 58vh, 620px);
  scroll-snap-align: center;
}

.gallery-carousel-controls {
  display: none;
  gap: 8px;
  justify-content: center;
  padding: 12px 0 6px;
}

.gallery-shell-carousel .gallery-carousel-controls {
  display: flex;
}

.gallery-carousel-controls button {
  align-items: center;
  background: #111111;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-size: 1.35rem;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.gallery-carousel-controls button:hover,
.gallery-carousel-controls button:focus-visible {
  background: #303030;
}

.gallery-photo {
  background: #e5e7eb;
  border: 0;
  cursor: zoom-in;
  display: block;
  flex: 0 0 auto;
  margin: 0;
  overflow: hidden;
  padding: 0;
  position: relative;
}

.gallery-photo img {
  display: block;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: filter .25s ease, opacity .2s ease, transform .25s ease;
  width: 100%;
}

.gallery-photo img.is-loaded {
  opacity: 1;
}

.gallery-photo[hidden] {
  display: none !important;
}

.gallery-photo:hover img,
.gallery-photo:focus-visible img {
  filter: brightness(.88);
  transform: scale(1.025);
}

.gallery-photo:focus-visible {
  outline: 3px solid #9eff22;
  outline-offset: -3px;
}

.gallery-loading,
.gallery-empty {
  align-items: center;
  color: var(--gallery-muted);
  display: flex;
  justify-content: center;
  min-height: 45vh;
  padding: 32px;
  text-align: center;
}

.gallery-loading[hidden] {
  display: none;
}

.gallery-state {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.gallery-state-card {
  background: #ffffff;
  border: 1px solid #e1e5ea;
  border-radius: 16px;
  box-shadow: 0 18px 55px rgba(17, 24, 39, .08);
  max-width: 560px;
  padding: clamp(28px, 6vw, 54px);
  text-align: center;
  width: 100%;
}

.gallery-state-card h1 {
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  margin: 0 0 14px;
}

.gallery-state-card p:last-child {
  color: var(--gallery-muted);
  line-height: 1.7;
  margin: 0;
}

.gallery-lightbox {
  align-items: center;
  background: rgba(0, 0, 0, .94);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: clamp(12px, 3vw, 36px);
  position: fixed;
  z-index: 100;
}

.gallery-lightbox[hidden] {
  display: none;
}

.gallery-lightbox img {
  display: block;
  max-height: calc(100vh - 48px);
  max-width: 100%;
  object-fit: contain;
}

.gallery-lightbox-close {
  align-items: center;
  background: rgba(255, 255, 255, .14);
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  font-size: 2rem;
  height: 44px;
  justify-content: center;
  line-height: 1;
  position: fixed;
  right: 18px;
  top: 18px;
  width: 44px;
  z-index: 102;
}

.gallery-lightbox-loading {
  color: #ffffff;
  left: 50%;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .gallery-intro {
    padding-bottom: 22px;
    padding-top: 28px;
  }

  .gallery-search-link {
    margin: 14px 0 0 auto;
    position: static;
    width: max-content;
  }

  .gallery-layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-layout-columns {
    column-count: 2;
  }

  .gallery-layout-carousel .gallery-photo {
    flex-basis: 82vw;
    height: 56vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
