/* Project gallery lightbox: dark navy glass stage, theme typography, teal accents. */

html.gallery-open { overflow: hidden; }

.gallery {
  --g-pad: clamp(16px, 2.6vw, 48px);
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: var(--g-pad);
  border: 0;
  background: transparent;
  color: var(--white);
  overflow: hidden;
}
.gallery[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(12px, 1.6vw, 24px);
  animation: gallery-in 320ms var(--ease) both;
}
.gallery::backdrop {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(31, 142, 173, 0.18), transparent 60%),
    rgba(12, 20, 29, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
@keyframes gallery-in { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: none; } }

/* ---------- Top bar ---------- */
.gallery__bar { display: flex; align-items: center; gap: 16px 24px; }
.gallery__heading { display: grid; gap: 4px; min-width: 0; margin-right: auto; }
.gallery__eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-on-dark-muted);
}
.gallery__eyebrow::before { content: ""; width: 32px; height: 3px; background: var(--teal); flex: none; }
.gallery__title {
  font-size: clamp(1.25rem, 1rem + 0.8vw, 1.75rem);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--white);
}
.gallery__counter {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1rem, 0.9rem + 0.4vw, 1.25rem);
  letter-spacing: -0.02em;
  color: var(--white);
}
.gallery__counter-sep { color: var(--text-on-dark-muted); }

/* ---------- Buttons ---------- */
.gallery__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--white);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.gallery__btn .icon { width: 20px; height: 20px; stroke-width: 2; }
.gallery__btn:hover { background: var(--white); border-color: var(--white); color: var(--navy); }
.gallery__btn:active { transform: scale(0.94); }
.gallery__btn:focus-visible { outline: 3px solid var(--teal-200); outline-offset: 3px; }
.gallery__close { flex: none; }
.gallery__close:hover { transform: rotate(90deg); }

/* ---------- Stage ---------- */
.gallery__stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(12px, 2vw, 32px);
  min-height: 0;
}
.gallery__figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 12px;
  height: 100%;
  min-height: 0;
  margin: 0;
}
.gallery__frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.gallery__img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 220ms var(--ease), transform 260ms var(--ease);
}
.gallery__frame { height: 100%; }
.gallery__frame::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--teal);
  border-radius: 50%;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
  animation: gallery-spin 800ms linear infinite;
  pointer-events: none;
}
.gallery__frame.is-loading::after { opacity: 1; transition-delay: 250ms; }
@keyframes gallery-spin { to { transform: rotate(360deg); } }
.gallery__caption { font-size: var(--fs-body); line-height: 1.45; text-align: center; color: var(--text-on-dark-muted); }
.gallery__caption[hidden] { display: none; }

/* ---------- Thumbnails ---------- */
.gallery__thumbs {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.gallery__thumbs::-webkit-scrollbar { display: none; }
.gallery__thumbs[hidden] { display: none; }
.gallery__thumb {
  display: block;
  width: clamp(72px, 8vw, 128px);
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--navy);
  overflow: hidden;
  opacity: 0.55;
  transition: opacity var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery__thumb:hover { opacity: 0.9; }
.gallery__thumb.is-active { opacity: 1; border-color: var(--teal); }
.gallery__thumb:focus-visible { outline: 3px solid var(--teal-200); outline-offset: 2px; }

/* ---------- Small screens: arrows overlay the image bottom corners ---------- */
@media (max-width: 719px) {
  .gallery__stage { grid-template-columns: minmax(0, 1fr); position: relative; align-content: center; }
  .gallery__figure { grid-template-rows: auto auto; height: auto; align-content: center; }
  .gallery__frame { height: auto; aspect-ratio: 16 / 9; }
  .gallery__nav { position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px; background: rgba(12, 20, 29, 0.6); }
  .gallery__nav:active { transform: scale(0.94); }
  .gallery__nav--prev { left: 8px; }
  .gallery__nav--next { right: 8px; }
  .gallery__eyebrow { display: none; }
  .gallery__thumbs { justify-content: flex-start; }
}
@media (max-height: 520px) {
  .gallery__thumbs { display: none; }
}

/* ---------- Trigger in the case-study hero ---------- */
.case-hero__more-link { position: relative; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.case-hero__more-link img { transition: transform 600ms var(--ease); }
.case-hero__more-link::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(12, 20, 29, 0.35), transparent 60%);
  transition: opacity var(--t-med) var(--ease);
}
.case-hero__more-link:hover img { transform: scale(1.06); }
.case-hero__more-count {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background: rgba(12, 20, 29, 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: var(--white);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 20px;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease);
}
.case-hero__more-count .icon { width: 14px; height: 14px; stroke-width: 2; }
.case-hero__more-link:hover .case-hero__more-count { background: var(--teal); }
.case-hero__more-link:focus-visible { outline: 3px solid var(--white); outline-offset: 3px; }
