/* ============================================================
   RB Photography – Finalized Grid Gallery Stylesheet
   ============================================================ */

/* === Root theme variables === */
:root {
  color-scheme: dark light;
  --bg-light: #f8f8f8;
  --bg-dark: #0f0f10;
  --text-light: #0f0f10;
  --text-dark: #f8f8f8;
  --accent: #888;
  --shadow: rgba(0, 0, 0, 0.25);
}

/* Automatic light/dark background + text */
body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-dark);
  transition: background 0.3s ease, color 0.3s ease;
}

@media (prefers-color-scheme: light) {
  body {
    background-color: var(--bg-light);
    color: var(--text-light);
  }
}

/* === Header === */
header {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}
#title {
  font-size: 1.8rem;
  font-weight: 600;
  margin: 0;
}
.muted {
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* === Loading + Empty states === */
.loading,
.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--accent);
  font-size: 1rem;
}

/* ============================================================
   Row-major Grid Layout (replaces Masonry)
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  padding: 0.5rem;
  grid-auto-flow: row;
  list-style: none;
  margin: 0;
}

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

.grid li {
  display: block;
  width: 100%;
  margin: 0;
}

figure {
  margin: 0 auto;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 4px var(--shadow);
  transition: transform 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  max-width: 100%;
  flex-direction: column;
}

figure:hover {
  transform: translateY(-2px);
}

/* ============================================================
   Thumbnails
   ============================================================ */
.thumb {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 0;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Fade in after load */
.thumb[data-loaded="true"] {
  opacity: 1;
  transform: scale(1);
}

/* Skeleton placeholder */
.skeleton {
  background: #222;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 0.9; }
}

/* === Captions (capture date) === */
.caption {
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  color: var(--accent);
  padding: 0.35rem 0.25rem 0.2rem;
  line-height: 1.2;
}
.caption time {
  white-space: nowrap;
}

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lb-img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0,0,0,0.6);
}

.lb-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.lb-close:hover,
.lb-close:focus {
  background: rgba(255,255,255,0.25);
  outline: none;
}

/* ============================================================
   Accessibility helpers
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Keyboard focus */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Sidebar Layout
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  padding: 1.25rem 1rem;
  box-sizing: border-box;
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (prefers-color-scheme: light) {
  .sidebar { border-right-color: rgba(0,0,0,0.08); }
}

.content {
  min-width: 0;
}

/* Brand area */
.brand-title {
  font-size: 1.6rem;
  margin: 0 0 0.25rem 0;
}

.brand-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.25rem 0.5rem;
}
.brand-logo img {
  max-width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}

/* Contact block */
.contact {
  margin-top: 0.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}
.contact-name {
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}
.contact-line { margin: 0; }
.contact-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.contact-link:hover,
.contact-link:focus-visible {
  text-decoration: underline;
}

/* Sidebar ↔ content rhythm */
.content .grid {
  padding: 1rem 1rem 2rem;
}

/* ============================================================
   Mobile / Tablet adjustments
   ============================================================ */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  @media (prefers-color-scheme: light) {
    .sidebar { border-bottom-color: rgba(0,0,0,0.08); }
  }

  .content {
    background-color: #fff;
  }
  .content .grid {
    padding: 0.75rem;
    background-color: #fff;
  }

  .grid li figure {
    background-color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    border-radius: 6px;
  }

  .thumb {
    border-radius: 6px;
    display: block;
  }

  .contact {
    text-align: center;
    margin-top: 0.5rem;
  }
  .contact-name,
  .contact-line {
    display: block;
    text-align: center;
  }
  .contact-link {
    display: inline-block;
    text-align: center;
  }
}
