body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    font-family: var(--font-body);
    /*background-color: #f4f4f4;*/
}


.gallery-title {
    text-align: center;
    margin-bottom: 15px;
}

.gallery-container {
    max-width: 1024px;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.gallery img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border: 1px solid black;
    border-radius: var(--radius);
    cursor: pointer;
}

.gallery img:hover {
    opacity:80%;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
}

.modal-content {
    margin: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 90%;
    height: 90%;
    position: relative; /* For positioning buttons */
    border: 2px solid green;
}

.modal-content img {
    display: block;
    max-height: 100%;
    width: auto;
    max-width: 100%;
    border-radius: var(--radius);
}

.close {
    color: #fefefe;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 15px;
    right: 35px;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* Navigation Buttons */
.prev, .next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 15px;
    border: none;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.6;
    /*transition: opacity 0.3s ease;*/
    height: 30%;
}

.prev:hover, .next:hover {
    opacity: 1;
}

.prev {
    left: 15px;
}

.next {
    right: 15px;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .gallery {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 5px;
    }

    .modal-content {
        margin: 15px;
        width: 85%;
        height: 85%;
        /*
        max-width: 95%;
        max-height: 95%;
        */
    }

    .close {
        top: 10px;
        right: 20px;
        font-size: 24px;
    }

    .prev, .next {
        padding: 10px;
        font-size: 18px;
    }

    .prev {
        left: 10px;
    }

    .next {
        right: 10px;
    }
}

/* ── gallery page (gallery.html) ── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.page {
  max-width: 1024px;
  width: 100%;
  padding: 32px 20px 64px;
}

/* ── header ── */
.site-header {
  text-align: center;
  margin-top: 16px;
  margin-bottom: 40px;
}

.site-header .home-link {
  display: inline-block;
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

.site-header .home-link:hover { color: var(--color-text); }

.site-header h2 {
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.08em;
}

/* ── filter bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
}

.filter-btn {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 5px 14px;
  border: 1px solid #ccc;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--color-accent);
  border-color: var(--color-border);
  color: #fff;
}

/* ── gallery grid ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
  background: #e8e8e6;
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.gallery-item:hover img,
.gallery-item:hover video {
  transform: scale(1.04);
  opacity: 0.88;
}

/* play icon overlay for video items */
.gallery-item:has(video)::after {
  content: '▶';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 10px rgba(0,0,0,0.55);
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1;
}

.gallery-item:has(video):hover::after {
  opacity: 0.6;
}

.gallery-item .item-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.04em;
  color: #fff;
  background: #000;
  opacity: 0;
  transition: opacity 0.2s;
  text-align: center;
}

.gallery-item:hover .item-label { opacity: 1; }

/* ── lightbox overlay ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20, 20, 20, 0.92);
  align-items: center;
  justify-content: center;
}

.lightbox.open { display: flex; }

.lightbox-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 60px 80px;
}

.lightbox-img-wrap {
  position: relative;
  max-width: 680px;
  max-height: 80vh;
  width: 100%;
}

.lightbox-img-wrap img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 2px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}

/* lightbox video — native aspect ratio, no cropping */
#lightboxVideo {
  display: none;
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 2px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}

/* widen the wrap when showing a video (e.g. 16:9 or wider) */
.lightbox-img-wrap.is-video {
  max-width: min(90vw, 960px);
}

/* tap-to-pause overlay — only active on touch devices when video is open */
#lightboxVideoTap {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  cursor: pointer;
}

.lightbox-img-wrap.is-video #lightboxVideoTap { display: block; }

/* play/pause flash hint */
#lightboxVideoHint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 42px;
  color: rgba(255, 255, 255, 0.9);
  pointer-events: none;
  z-index: 4;
  opacity: 0;
}

#lightboxVideoHint.flash {
  animation: video-hint-fade 0.55s ease forwards;
}

@keyframes video-hint-fade {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1);   }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.55); }
}

.lightbox-caption {
  position: absolute;
  bottom: -28px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 16px;
  letter-spacing: 0.06em;
  color: #fff;
}

/* counter */
.lightbox-counter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}

/* close */
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  font-size: 24px;
  color: var(--color-text-faint);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  font-family: var(--font-body);
  transition: color 0.15s;
  z-index: 10;
}

.lightbox-close:hover { color: #f7f7f5; }

/* arrows */
.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.07);
  border: 1px solid #fff;
  color: #ccc;
  font-size: 27px;
  width: 44px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-body);
}

.lightbox-arrow:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.lightbox-arrow.prev { left: 20px; }
.lightbox-arrow.next { right: 20px; }

/* ── navigation ── */
.section-container {
  margin-top: 48px;
  margin-bottom: 32px;
}

.section-title {
  text-align: center;
}

#toc {
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

#toc li {
  margin: 0;
}

#toc li a {
  display: block;
  width: 100%;
  padding: 7px 16px;
  text-align: center;
  color: var(--color-link);
  text-decoration: none;
  font-weight: bold;
  font-family: var(--font-body);
  box-sizing: border-box;
  opacity: 1;
}

#toc li a:hover {
  color: var(--color-inv-text);
  background: var(--color-inv-bg);
}

/* ── video carousel (gallery.html) ── */
.gallery-video-section {
  margin-bottom: 40px;
}

/* ── responsive ── */
@media (max-width: 720px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .lightbox-inner { padding: 50px 60px; }
  .lightbox-arrow { width: 36px; height: 52px; font-size: 16px; }
  .lightbox-arrow.prev { left: 10px; }
  .lightbox-arrow.next { right: 10px; }
}

@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .lightbox-inner { padding: 44px 48px; }
  .lightbox-img-wrap { max-width: 100%; }
}