/* =========================
   twc-gallery（Grid + tiles）
   ========================= */
.twc-gallery {
  width: 100%;
  margin: 0 auto;
}

.twc-gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.twc-gallery__item {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  cursor: zoom-in;
}

.twc-gallery__item:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.twc-gallery__media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.twc-gallery__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s ease;
}

.twc-gallery__item:hover .twc-gallery__img,
.twc-gallery__item:focus-within .twc-gallery__img {
  transform: scale(1.2);
}

/* 小圖圖說：左下疊字 + 漸層半透明 */
.twc-gallery__overlay {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  padding: 12px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0));
  pointer-events: none;
}

.twc-gallery__caption {
  color: #ffffff;
  font-size: 1.2rem;
  line-height: 1.4;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

@media (max-width: 768px) {
  .twc-gallery__grid { gap: 12px; }
  .twc-gallery__overlay { padding: 10px 12px; }
  .twc-gallery__caption { font-size: 0.8rem; }
}

/* =========================
   twc-lightbox（AA-friendly）
   ========================= */
.twc-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease;
  z-index: 9999;
}

.twc-lightbox.is-active {
  opacity: 1;
  visibility: visible;
}

/* 開啟時鎖背景捲動 */
body.twc-lightbox--open {
  overflow: hidden;
}

.twc-lightbox__content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  cursor: default;
}

.twc-lightbox__header {
  width: 100%;
  max-width: 90vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.twc-lightbox__caption {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  padding-left: 2px;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  max-width: calc(90vw - 60px);
}

.twc-lightbox__close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.12);
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.twc-lightbox__close:hover {
  background: rgba(255,255,255,.18);
}

.twc-lightbox__close:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.twc-lightbox__img {
  max-width: 90vw;
  max-height: calc(90vh - 120px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  background: transparent;
}