/* ==========================================================================
   Elegance Dark-Mode Portfolio — style.css
   - Unified warm charcoal-obsidian background (#131418) across the entire page
   - Handwritten garland Google Font ('Great Vibes') for the top-center title
   - Center-center 3x3 square grid with Dual-Layer Ambient Passepartout
   - Subtle hover pop-out micro-interaction
   - 80%–85% bottleneck gallery lightbox with pointer-drag carousel
   ========================================================================== */

:root {
  /* High-class dark palette — rich warm obsidian, never harsh pure #000000 */
  --bg-page: #131418;
  --surface-tile: #1a1c22;
  --text-primary: #ece7df;
  --text-muted: #8d887f;
  --accent-champagne: #d5c3a6;
  --border-subtle: rgba(236, 231, 223, 0.09);
  --border-hover: rgba(213, 195, 166, 0.42);
  --shadow-Rest: 0 6px 20px -6px rgba(5, 6, 8, 0.55);
  --shadow-hover: 0 18px 36px -8px rgba(4, 5, 7, 0.78), 0 0 0 1px var(--border-hover);
  --lightbox-backdrop: rgba(11, 12, 16, 0.88);
  --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  width: 100%;
  min-height: 100dvh;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Lock page scroll when gallery pop-up is open */
body.lightbox-open {
  overflow: hidden;
  touch-action: none;
}

/* ==========================================================================
   Single-Page Layout Shell
   Header, Main, and Footer share the exact same background with zero visual
   separation or dividers between them.
   ========================================================================== */
.page-shell {
  min-height: 100dvh;
  width: 100%;
  background-color: var(--bg-page);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: clamp(1.25rem, 3dvh, 2.5rem) clamp(1rem, 4vw, 3rem);
}

.site-header,
.site-main,
.site-footer {
  background: transparent;
  border: none;
  box-shadow: none;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Top-Center Garland Script Title */
.site-header {
  flex: 0 0 auto;
  padding-top: 0.25rem;
  padding-bottom: 0.75rem;
}

.site-title {
  font-family: 'Great Vibes', 'Alex Brush', cursive;
  font-weight: 400;
  font-size: clamp(2.75rem, 5vw, 4.25rem);
  line-height: 1.1;
  letter-spacing: 0.03em;
  color: var(--text-primary);
  text-align: center;
  user-select: none;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

/* Center-Center Main Showcase */
.site-main {
  flex: 1 1 auto;
  margin: auto 0;
  padding: 0.5rem 0;
}

/* Bottom-Center Footer */
.site-footer {
  flex: 0 0 auto;
  padding-top: 0.75rem;
  padding-bottom: 0.25rem;
}

.footer-text {
  font-size: clamp(0.8rem, 1.1vw, 0.95rem);
  font-weight: 300;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   3x3 Square Portfolio Matrix & Aspect-Ratio Trick
   ========================================================================== */
.portfolio-grid {
  /* Fluid sizing that keeps all 9 square boxes centered and visible on both desktop and mobile */
  width: min(88vw, 60dvh, 640px);
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.65rem, 1.6vw, 1.25rem);
  justify-content: center;
  align-items: center;
}

.grid-item {
  /* 3 columns per row subtracting the 2 inter-column gaps */
  flex: 0 0 calc((100% - (2 * clamp(0.65rem, 1.6vw, 1.25rem))) / 3);
  aspect-ratio: 1 / 1;
  position: relative;
  border-radius: 10px;
  background-color: var(--surface-tile);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-Rest);
  overflow: hidden;
  cursor: pointer;
  z-index: 1;
  transition:
    transform 0.34s var(--ease-out-expo),
    box-shadow 0.34s var(--ease-out-expo),
    border-color 0.34s var(--ease-out-expo);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Subtle pop-out & enlarge on hover (tiny amount, not a full-blown popup) */
@media (hover: hover) {
  .grid-item:hover {
    transform: translateY(-4px) scale(1.045);
    box-shadow: var(--shadow-hover);
    border-color: var(--border-hover);
    z-index: 3;
  }
}

.grid-item:active {
  transform: scale(0.985);
}

.grid-item:focus-visible {
  outline: 2px solid var(--accent-champagne);
  outline-offset: 3px;
  transform: translateY(-3px) scale(1.035);
  z-index: 3;
}

/* --------------------------------------------------------------------------
   Cool Trick for Mixed Landscape & Portrait Images Inside Square Boxes:
   1. .tile-ambient casts a softly blurred, color-matched atmospheric projection
      of the image itself across 100% of the square box so there are never stark
      empty bars.
   2. .tile-frame suspends the uncropped portrait or landscape image inside the
      square with a museum passepartout cushion and subtle cursor parallax.
   -------------------------------------------------------------------------- */
.tile-ambient {
  position: absolute;
  inset: -14%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(18px) brightness(0.42) saturate(1.25);
  transform: scale(1.15) translate3d(var(--parallax-bg-x, 0px), var(--parallax-bg-y, 0px), 0);
  transition: transform 0.35s var(--ease-out-expo), filter 0.35s var(--ease-out-expo);
  pointer-events: none;
}

/* Soft inner vignette over the ambient matte */
.tile-ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(19, 20, 24, 0.08) 0%, rgba(19, 20, 24, 0.52) 100%);
}

.grid-item:hover .tile-ambient {
  filter: blur(20px) brightness(0.52) saturate(1.35);
}

.tile-frame {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 9%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
}

.grid-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 5px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 255, 255, 0.07);
  transform: translate3d(var(--parallax-fg-x, 0px), var(--parallax-fg-y, 0px), 0);
  transition: transform 0.28s var(--ease-out-expo), box-shadow 0.34s var(--ease-out-expo);
  pointer-events: none;
  display: block;
}

/* Square images fill the square tile naturally without needing a wide matte */
.grid-item[data-orientation="square"] .tile-frame {
  padding: 0;
}

.grid-item[data-orientation="square"] .grid-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

/* Optional alternative mode: data-fit-mode="magnetic-cover" on #portfolioGrid */
.portfolio-grid[data-fit-mode="magnetic-cover"] .tile-frame {
  padding: 0;
}

.portfolio-grid[data-fit-mode="magnetic-cover"] .grid-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pan-x, 50%) var(--pan-y, 50%);
  border-radius: 0;
  transition: object-position 0.25s ease-out;
}

/* ==========================================================================
   Gallery Lightbox Pop-up Overlay
   - Covers 80%–85% (83%) of available width or height, whichever is the bottleneck
   - Shadows the rest of the page
   - Supports mouse drag & touch swipe across all 9 images
   - Closes on pointer-out click (clicking anywhere outside the active image)
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: var(--lightbox-backdrop);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.32s var(--ease-out-expo),
    visibility 0.32s var(--ease-out-expo);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.lightbox.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lightbox.is-dragging {
  cursor: grabbing;
}

.lightbox-track {
  display: flex;
  width: 100%;
  height: 100%;
  will-change: transform;
  transition: transform 0.42s var(--ease-out-expo);
}

.lightbox.is-dragging .lightbox-track {
  transition: none;
}

.lightbox-slide {
  flex: 0 0 100vw;
  width: 100vw;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Active gallery image covers 83% (within 80%–85%) of the bottleneck viewport dimension */
.lightbox-img {
  max-width: 83vw;
  max-height: 83dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow:
    0 28px 70px -12px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(236, 231, 223, 0.14);
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.32s var(--ease-out-expo);
}

.lightbox.is-dragging .lightbox-img {
  cursor: grabbing;
}

/* Side "<" and ">" Navigation Buttons (visible only while gallery is active) */
.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 103;
  width: clamp(2.6rem, 4.2vw, 3.25rem);
  height: clamp(2.6rem, 4.2vw, 3.25rem);
  border-radius: 50%;
  background: rgba(26, 28, 34, 0.72);
  border: 1px solid rgba(236, 231, 223, 0.16);
  color: var(--text-primary);
  font-family: inherit;
  font-size: clamp(1.1rem, 1.8vw, 1.35rem);
  font-weight: 300;
  line-height: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition:
    transform 0.25s var(--ease-out-expo),
    background-color 0.25s var(--ease-out-expo),
    border-color 0.25s var(--ease-out-expo),
    color 0.25s var(--ease-out-expo);
}

.lightbox-prev {
  left: clamp(0.65rem, 2.4vw, 2.25rem);
}

.lightbox-next {
  right: clamp(0.65rem, 2.4vw, 2.25rem);
}

@media (hover: hover) {
  .lightbox-nav:hover {
    background: rgba(36, 39, 48, 0.92);
    border-color: var(--border-hover);
    color: var(--accent-champagne);
    transform: translateY(-50%) scale(1.08);
  }
}

.lightbox-nav:active {
  transform: translateY(-50%) scale(0.95);
}

.lightbox-nav:focus-visible {
  outline: 2px solid var(--accent-champagne);
  outline-offset: 3px;
}

.lightbox-counter {
  position: fixed;
  bottom: clamp(1rem, 2.4dvh, 1.75rem);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: rgba(236, 231, 223, 0.65);
  pointer-events: none;
  z-index: 102;
}

/* ==========================================================================
   Responsive Adjustments for Mobile & Tablet Viewports
   ========================================================================== */
@media (max-width: 768px) {
  .portfolio-grid {
    width: min(92vw, 520px);
    gap: 0.65rem;
  }

  .grid-item {
    flex: 0 0 calc((100% - (2 * 0.65rem)) / 3);
    border-radius: 8px;
  }

  .tile-frame {
    padding: 7%;
  }
}

@media (max-width: 480px) {
  .page-shell {
    padding: 1rem 0.75rem;
  }

  .portfolio-grid {
    width: min(94vw, 390px);
    gap: 0.5rem;
  }

  .grid-item {
    flex: 0 0 calc((100% - (2 * 0.5rem)) / 3);
    border-radius: 7px;
  }
}
