/* Responsive, image-first stylesheet
   Replaces styles.css in the repository. Key goals:
   - Gallery uses responsive grid that adapts to viewport width.
   - Images are the primary visual focus (full-bleed thumbnails in grid cells).
   - Header and contact card layout collapse/stack on small screens.
   - Filters are usable on small screens (horizontal scroll).
   - Lightbox/canvas scales to fit viewport while preserving aspect ratio.
   - Performance & accessibility: images are block-level, lazy-loading friendly,
     and will honor any srcset/sizes the gallery script may provide.
*/

/* Basic reset and sensible defaults */
* { box-sizing: border-box; }
html,body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: #111;
  background: #fff;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  line-height: 1.35;
}

/* Utility wrapper to center content and provide gutters */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 8px 12px;
  background: #111;
  color: #fff;
  z-index: 9999;
  display: inline-block;
  margin-bottom: 8px;
}

/* Header layout - desktop: two-column-ish (title + controls), mobile: stacked */
.header-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
  padding: 20px 0;
}

/* Site title */
.site-title {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.05;
}
.site-sub {
  margin: 6px 0 0 0;
  color: #555;
  font-size: 0.95rem;
}

/* Contact card (right column) */
.contact-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  border: 1px solid rgba(0,0,0,0.06);
}
.contact-title {
  margin: 0 0 8px 0;
  font-size: 1rem;
}
.contact-bio {
  margin: 0 0 12px 0;
  color: #444;
  font-size: 0.95rem;
}
.contact-list { margin: 0 0 12px 0; padding: 0; list-style: none; font-size:0.95rem; }
.contact-list li { margin-bottom: 6px; }

/* Press logos scaled and wrapped */
.press-logos { display:flex; gap:8px; padding:0; margin:0; list-style:none; }
.press-logos img { height:28px; width:auto; display:block; }

/* Filters toolbar */
.filters {
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top: 12px;
}
.filter-btn {
  appearance: none;
  border: 1px solid #ddd;
  background: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}
.filter-btn[aria-pressed="true"],
.filter-btn:focus {
  border-color: #111;
  background: #111;
  color: #fff;
  outline: none;
}

/* Main gallery container
   Using CSS Grid with auto-fill + minmax so grid cells adapt to viewport.
   This keeps images as the primary visual focus and allows the gallery to
   "flow" naturally across screen sizes.
*/
.masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-rows: 8px; /* small base row size used with row-span technique if needed */
  gap: 8px;
  margin: 18px 0 48px 0;
  align-items: start;
}

/* Generic gallery item container — gallery JS should wrap image in an element like this */
.masonry-item {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: #f5f5f5;
}

/* If the script uses <img> tags, make images fluid and crop to fill cell */
.masonry-item img,
.masonry-item canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover; /* crop to fill while preserving center */
  object-position: center center;
  vertical-align: middle;
}

/* If the script uses background images on elements */
.masonry-item.bg {
  background-size: cover;
  background-position: center center;
  padding-top: 66.666%; /* default 3:2 aspect placeholder; JS can override with inline style if needed */
}

/* Lightweight caption overlay support */
.masonry-item .caption {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  padding: 6px 8px;
  font-size: 0.85rem;
  border-radius: 4px;
  display: none; /* shown on :hover for pointer devices */
}
@media (hover: hover) {
  .masonry-item:hover .caption { display:block; }
}

/* Make filters usable on very small screens with horizontal scroll */
.filters {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}
.filters::-webkit-scrollbar { height: 8px; }

/* Lightbox styles — allow canvas or image to scale while preserving aspect ratio */
.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2,2,2,0.8);
  z-index: 10000;
  padding: 16px;
}
.lightbox[aria-hidden="false"] { display:flex; }
.lb-shell {
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  width: 100%;
  height: auto;
  display:flex;
  align-items:center;
  justify-content:center;
  position: relative;
}
.lb-viewport {
  width: 100%;
  max-height: calc(100vh - 160px);
  display:flex;
  align-items:center;
  justify-content:center;
}
#lb-canvas {
  width: 100%;
  height: auto;
  max-width: 1100px;
  max-height: calc(100vh - 160px);
  background: #000;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}

/* Lightbox controls */
.lb-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display:flex;
  gap:8px;
}
.lb-close, .lb-prev, .lb-next {
  appearance:none;
  border: none;
  background: rgba(255,255,255,0.06);
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
}
.lb-close:focus, .lb-prev:focus, .lb-next:focus { outline: 2px solid #fff; outline-offset: 3px; }

/* Footer spacing */
main { padding-bottom: 24px; }

/* Responsive adjustments */
@media (min-width: 900px) {
  .masonry { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
  .header-grid { grid-template-columns: 1fr 360px; }
  .site-title { font-size: 1.75rem; }
}

@media (max-width: 899px) {
  /* Stack header pieces vertically on smaller screens */
  .header-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: center;
  }

  /* Make the contact card full width and visually lighter on mobile */
  .contact-card {
    order: 3;
    width: 100%;
    border: none;
    padding: 12px;
    background: #fafafa;
  }

  /* Move filters to top under title */
  .filters { order: 2; }
}

/* Very small phones — make grid single column for maximum image focus if preferred */
@media (max-width: 480px) {
  .masonry { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .site-title { font-size: 1.25rem; }
}

/* Accessibility: focus outlines for keyboard users */
a:focus, button:focus { outline: 3px solid rgba(0,0,0,0.12); outline-offset: 2px; }

/* Helpers for JS-driven row span technique (optional)
   If gallery.js calculates row spans based on image aspect ratio and grid-auto-rows,
   it can set inline style: element.style.gridRowEnd = `span ${rows}`;
*/
