/* Journal Styling */

:root {
  --gap: 18px; /* spacing between items */
  --frame: 12px; /* white border/frame thickness */
  --radius: 10px; /* rounded corners for frames and lightbox */
  --overlay-bg: rgba(0, 0, 0, 0.95);
  --shadow1: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow2: 0 12px 30px rgba(0, 0, 0, 0.12);
  --grid-row: 6px; /* base row height for masonry math */
}

.container {
  margin: 0 auto;
  padding: 40px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Masonry Grid =====
   One column on mobile. JS sets row spans for masonry effect.
*/
.gallery {
  display: grid;
  grid-auto-flow: dense;
  gap: var(--gap);
  grid-template-columns: 1fr; /* ✅ mobile: 1 column */
  grid-auto-rows: var(--grid-row);
  align-items: start;
}
@media (min-width: 768px) {
  .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
} /* tablet: 3 */
@media (min-width: 1024px) {
  .gallery {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
} /* desktop: 4 */

.gallery__item {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* White frame + shadow like the reference layout */
.frame {
  height: 100%;
  display: block;
}

.thumb {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* ===== Lightbox (with transitions) ===== */
.lightbox {
  position: fixed;
  inset: 0;
  display: flex; /* keep layout stable for animation */
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  padding: 24px;
  z-index: 1000;

  /* transition baseline */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 500ms ease,
    visibility 500ms step-end;
}

/* When open, fade in and enable interactions */
.lightbox.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 500ms ease,
    visibility 0ms step-start;
}

/* Popout content zoom + fade */
.lightbox__inner {
  position: relative;
  max-width: min(92vw, 1400px);
  max-height: 92vh;

  transform: scale(0.98);
  opacity: 0;
  transition:
    transform 500ms ease,
    opacity 500ms ease;
}
.lightbox.open .lightbox__inner {
  transform: scale(1);
  opacity: 1;
}

.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 70vh; /* you had 70vh; left as-is */
  width: auto;
  height: auto;
}

.lightbox__close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 0;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  background-color: transparent;

  transition:
    background-color 180ms ease,
    transform 180ms ease; /* small polish */
}

.body--lock {
  overflow: hidden;
}

.lightbox__meta {
  padding: 40px 0;
}
.lightbox__meta h2 {
  color: var(--Grey100);
  font-size: 16px;
  margin-bottom: 4px;
}
.lightbox__meta p {
  color: var(--Grey300);
  font-size: 12px;
}

/* Mobile container padding */
@media (max-width: 768px) {
  .container {
    padding: 24px;
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .lightbox,
  .lightbox__inner,
  .lightbox__close {
    transition: none !important;
  }
}

/* --- iOS tap highlight (blue flash) --- */
.lightbox,
.lightbox * {
  -webkit-tap-highlight-color: transparent; /* removes blue tap highlight on iOS */
}

/* --- Remove default focus ring on the close button --- */
.lightbox__close {
  outline: none;
  -webkit-appearance: none; /* normalize iOS button appearance */
  appearance: none;
}

/* For mouse/touch clicks: keep it clean */
.lightbox__close:focus {
  outline: none;
  box-shadow: none;
}

/* For keyboard users: provide a custom, visible focus style */
.lightbox__close:focus-visible {
  outline: 2px solid #fff; /* or your brand color */
  outline-offset: 2px;
  border-radius: 999px; /* match your button shape */
}

/* On touch-only devices, even :focus-visible can appear after taps;
   suppress it there while keeping keyboard focus on desktops */
@media (hover: none) and (pointer: coarse) {
  .lightbox__close:focus,
  .lightbox__close:focus-visible {
    outline: none;
    box-shadow: none;
  }
}

/* (Firefox only) remove inner dotted focus on old engines */
.lightbox__close::-moz-focus-inner {
  border: 0;
}
