/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #fefefe;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 300;
  margin-bottom: 1rem;
  color: #222;
}

h1 {
  font-size: 2.5rem;
  font-weight: 200;
}

h2 {
  font-size: 2rem;
}

p {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: #555;
}

a {
  color: #333;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #666;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Minimal CSS-only hamburger navigation (inner pages only) */
.site-nav {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
}

/* Hamburger icon */
.nav-burger {
  display: block;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
}

.nav-burger span {
  display: block;
  width: 22px;
  height: 2px;
  margin: 4px 0;
  background: #333;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

/* Menu, hidden until the (visually hidden) checkbox is toggled */
.nav-menu {
  list-style: none;
  margin: 0;
  padding: 0.5rem 1.5rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  text-align: right;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
}

.nav-menu a {
  display: inline-block;
  padding: 0.4rem 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  transition: color 0.2s ease;
}

.nav-menu a:hover {
  color: #333;
}

.nav-toggle:checked ~ .nav-menu {
  opacity: 1;
  transform: translateY(0);
}

/* Hamburger -> X when open */
.nav-toggle:checked ~ .nav-burger span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav-toggle:checked ~ .nav-burger span:nth-child(2) {
  opacity: 0;
}
.nav-toggle:checked ~ .nav-burger span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Prominent, image-only hero used by the home (home-hero series) and topic
   pages — links through to the photo/series, full width, no crop. */
.captioned-hero {
  display: block;
  margin: 0 0 var(--jgrid-gap, 6px);
  overflow: hidden;
}

.captioned-hero img {
  width: 100%;
  height: auto; /* natural ratio, no crop */
  display: block;
  transition: transform 0.5s ease;
}

.captioned-hero:hover img {
  transform: scale(1.02);
}

/* Topic pages (Revision 5): small title on top, prominent hero, then a
   description placed below the hero or after the Nth photo row. */
.captioned-title {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #333;
  margin: 0 0 1.5rem;
}

.captioned-desc {
  max-width: 46rem;
  margin: 1.5rem auto;
  color: #555;
  font-size: 1.05rem;
  line-height: 1.7;
  text-align: center;
}

/* A description dropped between justified rows. */
.jgrid-interlude {
  width: 100%;
}

/* Home footer: keep "View All" and add the About link beside it */
.home-footer {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-top: 3rem;
}

.home-footer a {
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.home-footer a:hover {
  color: #333;
}

/* Archive pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin: 2.5rem 0 1rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
}

.pagination a {
  color: #666;
  transition: color 0.2s ease;
}

.pagination a:hover {
  color: #333;
}

.pagination .is-disabled {
  color: #ccc;
}

.page-numbers {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.9rem;
}

.page-numbers .is-current {
  color: #111;
  font-weight: 600;
}

/* Main content */
main {
  padding: 3rem 0;
}

/* Justified, no-crop home gallery.
   Each row fills the content width edge-to-edge; photos keep their exact aspect
   ratio (no cropping). `--r` is the photo's aspect ratio (width/height): flex-grow
   makes each item's width proportional to its ratio, and `aspect-ratio: var(--r)`
   then gives every item in a row the same height — so the row re-justifies to any
   viewport width with no runtime JavaScript. */
.jgrid {
  display: flex;
  flex-direction: column;
  gap: var(--jgrid-gap, 6px);
  margin: 2rem 0;
}

.jrow {
  display: flex;
  gap: var(--jgrid-gap, 6px);
}

.jitem {
  flex: var(--r, 1.5) 1 0;
  aspect-ratio: var(--r, 1.5);
  position: relative;
  display: block;
  overflow: hidden;
  background: #f8f8f8;
}

.jitem img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* box ratio == photo ratio, so this scales without cropping */
  display: block;
  transition: transform 0.4s ease, opacity 0.2s ease;
}

.jitem:hover img {
  transform: scale(1.03);
  opacity: 0.95;
}

/* Hero: a single photo on its own full-width row (naturally tall, never cropped). */
.jrow--hero .jitem {
  flex: 1 1 100%;
}

/* Underfilled rows (last row, or one cut short by a hero) keep natural size and
   left-align rather than stretching a lone photo to full width. */
.jrow--partial .jitem {
  flex: 0 0 auto;
  height: var(--jgrid-h, 300px);
}

/* On narrow screens, keep rows from packing too many tiny photos. */
@media (max-width: 640px) {
  .jrow {
    flex-wrap: wrap;
  }
  .jitem {
    flex-basis: 45%;
  }
  .jrow--hero .jitem {
    flex-basis: 100%;
  }
  /* On mobile the rows wrap, so partial rows behave like the rest. */
  .jrow--partial .jitem {
    flex: 1 1 45%;
    height: auto;
  }
}

/* Collection masonry items (detail pages) */
.photo-item {
  position: relative;
  overflow: hidden;
  background: #f8f8f8;
  transition: transform 0.2s ease;
}

.photo-item:hover {
  transform: translateY(-5px);
}

.photo-item img,
.photo-item picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: opacity 0.2s ease;
}

.photo-item:hover img {
  opacity: 0.9;
}

/* Photo detail page */
.photo-detail {
  margin: 2rem 0;
}

/* Sidebar layout: photos left, details right — 80/20 */
.photo-detail.layout-sidebar {
  display: grid;
  grid-template-columns: 4fr 1fr;
  gap: 3rem;
  align-items: start; /* let the details column stick while the photos scroll */
}

.photo-main img,
.photo-main picture img {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
}

/* Masonry mosaic of the collection's other photos, below the main image.
   CSS columns keep each photo's natural aspect ratio (no crop) with no JS. */
.collection-masonry {
  columns: 220px;
  column-gap: var(--jgrid-gap, 6px);
  margin-top: var(--jgrid-gap, 6px);
}

.collection-masonry .photo-item {
  break-inside: avoid;
  margin: 0 0 var(--jgrid-gap, 6px);
  border: 0;
  background: transparent;
}

.collection-masonry .photo-item img {
  width: 100%;
  height: auto; /* natural height -> no cropping */
  object-fit: initial;
  display: block;
}

/* Clean, calm details sidebar that stays in view on desktop. */
.layout-sidebar .photo-info {
  padding: 0.25rem 0;
  position: sticky;
  top: 1.5rem;
}

.photo-meta {
  background: transparent;
  padding: 1.25rem 0 0;
  margin: 1.25rem 0 0;
  border-top: 1px solid #eee;
}

/* Small title under the main image (below/drawer/popover layouts) + caption */
.photo-title {
  font-size: 1.15rem;
  font-weight: 500;
  margin: 1rem 0 0;
}

.layout-sidebar .photo-info .photo-title {
  margin-top: 0;
}

/* "top" layout: small title above the main image */
.photo-title--top {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #333;
}

.photo-caption {
  color: #666;
  font-size: 0.95rem;
  margin: 0.4rem 0 0;
}

.photo-byline {
  color: #999;
  margin-bottom: 1.5rem;
}

.photo-desc-lead {
  margin-top: 1rem;
}

/* "below" layout: details stacked under the photos, comfortably narrow */
.photo-info--below {
  max-width: 65ch;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #eee;
}

/* Drawer layout: details collapse behind a small toggle (CSS-only) */
.details-drawer {
  margin-top: 1.5rem;
  border-top: 1px solid #eee;
}

.drawer-toggle {
  display: inline-block;
  cursor: pointer;
  padding: 1rem 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
}

.drawer-toggle:hover {
  color: #333;
}

.drawer-toggle .when-open {
  display: none;
}

.details-toggle:checked ~ .drawer-toggle .when-open {
  display: inline;
}

.details-toggle:checked ~ .drawer-toggle .when-closed {
  display: none;
}

.drawer-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.35s ease;
}

.drawer-panel .photo-info {
  max-width: 65ch;
  padding-bottom: 1.5rem;
}

.details-toggle:checked ~ .drawer-panel {
  max-height: 2000px;
  opacity: 1;
}

/* Popover layout: photos only; details slide in from the right on request */
.popover-trigger {
  position: fixed;
  bottom: 1.25rem; /* bottom-right, clear of the top-right hamburger nav */
  right: 1.25rem;
  z-index: 90;
  width: 2.4rem;
  height: 2.4rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #ddd;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  color: #333;
  cursor: pointer;
}

/* Backdrop and panel sit ABOVE the fixed hamburger nav (z-index 100) so the
   close button is never trapped under it; opening the panel also covers the
   hamburger, and a click on it lands on the backdrop and closes the panel. */
.popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.details-popover {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 110;
  height: 100vh;
  width: min(360px, 85vw);
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  padding: 3.25rem 1.75rem 2rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

/* Top-left of the panel: away from the top-right hamburger, always clickable. */
.popover-close {
  position: absolute;
  top: 0.6rem;
  left: 1.25rem;
  font-size: 1.6rem;
  line-height: 1;
  color: #666;
  cursor: pointer;
}

.popover-toggle:checked ~ .popover-backdrop {
  opacity: 1;
  visibility: visible;
}

.popover-toggle:checked ~ .details-popover {
  transform: translateX(0);
}

.photo-meta h3 {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
}

.photo-meta dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
}

.photo-meta dt {
  font-weight: 500;
  color: #333;
}

.photo-meta dd {
  color: #666;
}

/* About page */
.about {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 4rem;
  margin: 2rem 0;
}

/* Without a portrait the text would stretch to two thirds of a wide screen;
   keep it to a readable measure instead. */
.about--no-portrait {
  grid-template-columns: minmax(0, 36rem);
}

.author-photo {
  aspect-ratio: 4/5;
  overflow: hidden;
}

.author-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.author-info h1 {
  margin-bottom: 1.5rem;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }
  
  nav {
    gap: 1.5rem;
  }
  
  .photo-detail.layout-sidebar {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .photo-detail .photo-info {
    position: static;
  }

  .about {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

/* Photo overlay */
.photo-overlay {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.9);
  justify-content: center;
  align-items: center;
}

.overlay-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.overlay-content img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

.close-overlay {
  position: absolute;
  top: -40px;
  right: 0;
  color: white;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
}

.close-overlay:hover {
  opacity: 0.7;
}

/* Photo clickable cursor */
.photo-clickable img {
  cursor: pointer;
}

/* Full list page */
.full-list {
  max-width: 800px;
  margin: 0 auto;
}

.full-list-item {
  display: flex;
  align-items: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid #eee;
}

.full-list-item:last-child {
  border-bottom: none;
}

.full-list-item .date {
  width: 120px;
  font-size: 0.8rem;
  color: #999;
  font-family: monospace;
}

.full-list-item .title {
  flex: 1;
  font-size: 1.1rem;
  color: #333;
}

.full-list-item:hover .title {
  color: #666;
}

/* Full list with thumbnails */
.full-list-with-thumbnails {
  max-width: 900px;
  margin: 0 auto;
}

.full-list-item-with-thumb {
  display: flex;
  align-items: center;
  padding: 2rem 0;
  border-bottom: 1px solid #eee;
  gap: 2rem;
}

.full-list-item-with-thumb:last-child {
  border-bottom: none;
}

.full-list-item-with-thumb .thumb {
  width: 120px;
  height: 80px;
  flex-shrink: 0;
  overflow: hidden;
  background: #f8f8f8;
}

.full-list-item-with-thumb .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.full-list-item-with-thumb:hover .thumb img {
  transform: scale(1.05);
}

.full-list-item-with-thumb .item-info {
  flex: 1;
}

.full-list-item-with-thumb .title {
  margin-bottom: 0.5rem;
}

.full-list-item-with-thumb .title a {
  font-size: 1.2rem;
  font-weight: 300;
  color: #333;
  transition: color 0.2s ease;
}

.full-list-item-with-thumb:hover .title a {
  color: #666;
}

.full-list-item-with-thumb .meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.full-list-item-with-thumb .date {
  font-size: 0.9rem;
  color: #666;
}

.full-list-item-with-thumb .type {
  font-size: 0.8rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@media (max-width: 480px) {
  h1 {
    font-size: 2rem;
  }
  
  main {
    padding: 2rem 0;
  }

  .full-list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .full-list-item .date {
    width: auto;
  }
  
  .full-list-item-with-thumb {
    padding: 1.5rem 0;
    gap: 1rem;
  }
  
  .full-list-item-with-thumb .thumb {
    width: 80px;
    height: 60px;
  }
}