/* ============================================
   TMConstruction PRO — gallery, lightbox, before/after
   Uses theme CSS variables defined in main.css :root
   ============================================ */

/* ===== Before/After slider ===== */
.tmc-before-after {
  margin: 32px 0;
  --tmc-ba-height: 460px;
}
.tmc-ba-frame {
  position: relative;
  width: 100%;
  height: var(--tmc-ba-height);
  overflow: hidden;
  border-radius: var(--radius-lg);
  user-select: none;
  background: var(--surface);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  cursor: ew-resize;
}
.tmc-ba-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.tmc-ba-clip {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  overflow: hidden;
  will-change: width;
}
.tmc-ba-clip .tmc-ba-img {
  width: var(--tmc-ba-frame-width, 100%);
  /* Set in JS to match the parent frame width */
}
.tmc-ba-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 4px;
  background: rgba(255,255,255,0.95);
  transform: translateX(-50%);
  z-index: 3;
  outline: none;
}
.tmc-ba-handle:focus-visible .tmc-ba-handle-knob {
  box-shadow: 0 0 0 4px rgba(245,166,35,0.45);
}
.tmc-ba-handle-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -1px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  cursor: ew-resize;
  user-select: none;
}
.tmc-ba-label {
  position: absolute;
  top: 16px;
  background: rgba(15,26,31,0.7);
  color: #ffffff;
  padding: 4px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 100px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.tmc-ba-label--before { left: 16px; }
.tmc-ba-label--after  { right: 16px; }
.tmc-ba-caption {
  text-align: center;
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

@media (max-width: 768px) {
  .tmc-before-after { --tmc-ba-height: 340px; }
}
@media (max-width: 480px) {
  .tmc-before-after { --tmc-ba-height: 260px; }
  .tmc-ba-handle-knob { width: 38px; height: 38px; }
}

/* ===== Projects Gallery ===== */
.tmc-gallery-section {
  padding: 24px 0 80px;
  background: var(--bg-page);
}
.tmc-gallery-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 32px;
}
.tmc-filter-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}
.tmc-filter-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.tmc-filter-btn.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--on-accent);
}

.tmc-gallery-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(3, 1fr);
}
.tmc-gallery-grid[data-columns="2"] { grid-template-columns: repeat(2, 1fr); }
.tmc-gallery-grid[data-columns="4"] { grid-template-columns: repeat(4, 1fr); }

.tmc-gallery-item {
  position: relative;
  display: block;
  aspect-ratio: 4/3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  transition: transform var(--transition), box-shadow var(--transition);
}
.tmc-gallery-item:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.tmc-gallery-item.is-hidden { display: none; }
.tmc-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}
.tmc-gallery-item:hover img { transform: scale(1.06); }
.tmc-gallery-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
}
.tmc-gallery-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px 22px;
  background: linear-gradient(to top, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0.40) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition), transform var(--transition);
}
.tmc-gallery-item:hover .tmc-gallery-overlay { opacity: 1; transform: translateY(0); }
.tmc-gallery-title {
  font-family: 'Playfair Display', serif;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
}
.tmc-gallery-excerpt { color: rgba(255,255,255,0.85); font-size: 0.85rem; line-height: 1.5; }

@media (max-width: 1024px) { .tmc-gallery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .tmc-gallery-grid { grid-template-columns: 1fr; } }

/* Light-scheme tweaks for gallery */
body.tmc-scheme-pure_white .tmc-filter-btn,
body.tmc-scheme-light_navy .tmc-filter-btn,
body.tmc-scheme-light_teal .tmc-filter-btn { background: #ffffff; }
body.tmc-scheme-pure_white .tmc-gallery-item,
body.tmc-scheme-light_navy .tmc-gallery-item,
body.tmc-scheme-light_teal .tmc-gallery-item {
  background: #ffffff;
  border-color: var(--border-soft);
  box-shadow: 0 2px 12px rgba(15,23,42,0.04);
}

/* ===== Lightbox ===== */
.tmc-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10,15,20,0.94);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.tmc-lightbox.is-open { display: flex; opacity: 1; }
.tmc-lightbox-figure {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.tmc-lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.tmc-lightbox-caption {
  font-family: 'Playfair Display', serif;
  color: #ffffff;
  font-size: 1.1rem;
  text-align: center;
}
.tmc-lightbox-close,
.tmc-lightbox-prev,
.tmc-lightbox-next {
  position: absolute;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  color: #ffffff;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.tmc-lightbox-close:hover,
.tmc-lightbox-prev:hover,
.tmc-lightbox-next:hover { background: rgba(255,255,255,0.20); }
.tmc-lightbox-close { top: 24px; right: 24px; }
.tmc-lightbox-prev  { left: 24px; top: 50%; transform: translateY(-50%); }
.tmc-lightbox-next  { right: 24px; top: 50%; transform: translateY(-50%); }

@media (max-width: 600px) {
  .tmc-lightbox-close,
  .tmc-lightbox-prev,
  .tmc-lightbox-next { width: 40px; height: 40px; }
  .tmc-lightbox-prev { left: 12px; }
  .tmc-lightbox-next { right: 12px; }
  .tmc-lightbox-close { top: 12px; right: 12px; }
}
