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

:root {
  --cols: 3;
  --grid-gap: 16px;
  --page-gutter: 24px;
  --bg: #000000;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --lightbox-bg: rgba(0, 0, 0, 0.95);
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Profile Header ---- */

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px var(--page-gutter) 52px;
  max-width: 1200px;
  margin-inline: auto;
  width: 100%;
  text-align: center;
}

.avatar {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 20px;
}

.name {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tagline {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 10px;
  max-width: 28em;
  text-align: center;
  line-height: 1.55;
}

/* ---- Photo Grid ---- */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px var(--page-gutter) 96px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--grid-gap);
}

.grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
  border-radius: 2px;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.55s ease, transform 0.2s ease, filter 0.2s ease;
}

/* Fade in once the image has loaded *and* the tile has entered the viewport */
.grid-item.is-loaded.is-revealed img {
  opacity: 1;
}

.grid-item:hover img {
  transform: scale(1.03);
  filter: brightness(1.15);
}

@media (prefers-reduced-motion: reduce) {
  .grid-item img {
    opacity: 1;
    transition: transform 0.2s ease, filter 0.2s ease;
  }
}

/* ---- Lightbox ---- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--lightbox-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 56px 16px 32px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  width: min(100%, 90vw);
  flex-shrink: 0;
}

.lightbox-img {
  max-width: 90vw;
  /* Leave room for caption + location/date below (lightbox scrolls if needed) */
  max-height: min(68vh, calc(100dvh - 200px));
  object-fit: contain;
  border-radius: 2px;
  user-select: none;
}

.lightbox-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
  margin-top: 20px;
  padding: 0 20px 8px;
  max-width: 640px;
  width: 100%;
  flex-shrink: 0;
}

.lightbox-caption {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-primary);
  margin: 0 0 12px;
  width: 100%;
}

.lightbox-caption.is-empty {
  display: none;
}

.lightbox-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.lightbox-location {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pin-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 2rem;
  cursor: pointer;
  z-index: 1010;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s ease;
  padding: 4px 8px;
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 3rem;
  cursor: pointer;
  z-index: 1010;
  opacity: 0.5;
  transition: opacity 0.15s ease;
  padding: 8px 16px;
  line-height: 1;
  user-select: none;
}

.lightbox-nav:hover {
  opacity: 1;
}

.lightbox-prev {
  left: 12px;
}

.lightbox-next {
  right: 12px;
}

/* ---- Responsive ---- */

@media (max-width: 1199px) {
  .photo-grid {
    --cols: min(var(--cols-cfg, 3), 3);
  }
}

@media (max-width: 899px) {
  .photo-grid {
    --cols: 2;
  }
}

@media (max-width: 599px) {
  :root {
    --page-gutter: 18px;
    --grid-gap: 14px;
  }

  .photo-grid {
    --cols: 1;
  }

  .profile-header {
    padding: 48px var(--page-gutter) 40px;
    text-align: center;
  }

  .avatar {
    width: 96px;
    height: 96px;
    margin-bottom: 18px;
  }

  .name {
    font-size: 1.2rem;
  }

  main {
    padding: 4px var(--page-gutter) 72px;
  }

  .lightbox-nav {
    font-size: 2rem;
    padding: 8px 10px;
  }

  .lightbox-img {
    max-height: min(52vh, calc(100dvh - 220px));
  }
}

/* Hide scrollbar when lightbox is open */
body.lightbox-open {
  overflow: hidden;
}
