/*
Theme Name: Photoblog
Description: Minimal single-photo-per-post theme — dark/centered-column update
Author: Stephen (updated by sdiverdi)
Version: 1.1
*/

* {
  box-sizing: border-box;
}

/* Dark theme base */
html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #000;            /* black background */
  color: #fff;                 /* white text */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Links */
a {
  color: #fff;
  text-decoration: none;
  outline: none;
}
a:hover,
a:focus {
  text-decoration: underline;
}

/* Header / footer */
header, footer {
  padding: 1.25rem 1.5rem;
  text-align: center;
}header h1, footer p {
  margin: 0;
  color: #fff;
  font-weight: 500;
}

/* Main layouts
   - index page uses .photo-grid but becomes a single centered column
   - single-photo view uses .single-photo and will be full-viewport centered
*/

/* Photo list (main page) — justified grid of recent photos */
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 1rem;
  margin: 0 auto;
  width: 100%;
  max-width: 1400px;
  align-items: stretch;
}

/* Grid item: fixed row height, flexible width based on image aspect ratio (computed by JS) */

/* Grid item: tiles sized by JS. Use a minimum row height and never crop images.
   JS sets an explicit tile width and height; images are contained inside. */
.photo-item {
  position: relative;
  overflow: hidden;
  flex: 0 0 auto; /* JS will set exact width */
  background: #070707;
  border-radius: 4px;
  display: block;
}

.photo-item a {
  display: block;
  height: 100%;
}

.photo-item img {
  height: 100%;
  width: auto;
  display: block;
  object-fit: contain; /* never crop */
  margin: 0 auto;      /* center smaller images */
}

/* Small lower-right label for photo author/tag */
.photo-label {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.75rem;
  /* fixed height + flex centering for pixel-perfect vertical centering */
  height: 18px; /* explicitly match the small visual badge height */
  line-height: normal;
  padding: 0 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  text-transform: none;
  pointer-events: none;
  z-index: 2;
}

/* Optical nudge: lift the text slightly so ascenders/descenders appear visually centered */
.photo-label-text {
  display: inline-block;
  transform: translateY(-0.08em);
}

.photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0.5rem;
  color: rgba(255,255,255,0.9);
}

/* Title below thumbnail */
.photo h2 {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  color: #fff;
}

/* Single-photo view: make the image fill the browser area while preserving aspect ratio.
   We'll center it both horizontally and vertically, and allow caption below (optional). */
.single-photo {
  /* Force single-photo view to exactly match the viewport on desktop
     and hide any vertical overflow so no vertical scrollbar appears. */
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0 auto;
  width: 100%;
}

/* If the `single-photo` class is added to the <body> by WordPress (via body_class()),
   avoid turning the whole page into a flex container — only target the main element. */
body.single-photo {
  display: block;
}

/* The figure occupies the available viewport area for precise centering */
.single-photo figure {
  margin: 0;
  width: 100%;
  /* let the figure grow so very tall images are shown in full (page can scroll) */
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Fit the photo to the browser entirely (contain to preserve full image) */
.single-photo img {
  display: block;
  max-width: 100vw;
  /* do not constrain height so the full image is visible at its scaled
     width and original aspect ratio; allow page scrolling for tall images */
  max-height: none;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Caption styling on dark background */
.single-photo figcaption,
.single-photo .caption,
.photo figcaption {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.95);
  text-align: center;
  line-height: 1.4;
  /* Optional subtle backdrop for readability on top of dark photographs */
  background: rgba(0,0,0,0.35);
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

/* Footer small note color */
footer p {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
}

/* A11y focus outline */
:focus {
  outline: 3px solid rgba(255,255,255,0.12);
  outline-offset: 2px;
}

/* Responsive tweaks */
/* Two-column layout for single-photo view: image left, info panel right */
.single-photo .photo-layout {
  display: flex;
  gap: 2rem;
  align-items: center;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.single-photo .photo-left {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.single-photo .photo-left img {
  display: block;
  max-width: calc(100vw - 380px);
  max-height: calc(100vh - 4rem);
  width: auto;
  height: auto;
  object-fit: contain;
}

.single-photo .photo-info {
  flex: 0 0 340px;
  width: 340px;
  color: rgba(255,255,255,0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.photo-title {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.photo-description {
  margin-bottom: 1rem;
  line-height: 1.45;
  background: rgba(0,0,0,0.35);
  padding: 0.5rem;
  border-radius: 4px;
}

.photo-tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.photo-tags li { background: rgba(255,255,255,0.06); padding: 0.25rem 0.5rem; border-radius: 3px; font-size: 0.9rem; }
.tags-heading { margin: 0 0 0.5rem; font-size: 0.95rem; font-weight: 600; color: rgba(255,255,255,0.9); }

@media (max-width: 800px) {
  .single-photo .photo-layout { flex-direction: column; padding: 1rem; }
  .single-photo .photo-left img { max-width: 100%; max-height: none; width: 100%; height: auto; }
  .single-photo .photo-info { width: 100%; flex: 0 0 auto; }
}
@media (max-width: 640px) {
  .photo img {
    max-height: calc(100vh - 5.5rem);
  }
  .photo h2 { font-size: 0.9rem; }

  /* Mobile: make the main index a single full-width column
     - Force .photo-grid to stack vertically
     - Ensure each .photo-item and its image span the viewport width */
  .photo-grid {
    flex-direction: column;
    gap: 12px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .photo-item {
    flex: 0 0 auto;
    width: 100% !important;
    max-width: 100%;
    border-radius: 0; /* full-bleed look on tiny screens */
    background: transparent;
    overflow: visible; /* don't crop tall images on mobile */
    /* Reset any explicit inline sizes set by the justified layout JS */
    height: auto !important;
    flex-basis: auto !important;
    flex: 0 0 auto !important;
  }

  .photo-item a { display: block; height: auto; }

  .photo-item img {
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    display: block;
    object-fit: contain;
    margin: 0;
  }
}

/* Mobile: overlay photo info on top of fullscreen image */
@media (max-width: 640px) {
  .single-photo {
    min-height: 100vh;
    height: 100vh;
    padding: 0;
    overflow: hidden;
    overflow-x: hidden;
  }

  .single-photo .photo-layout {
    display: block;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100vh;
    max-width: none;
    position: relative;
    left: 0;
    right: 0;
  }

  .single-photo .photo-left {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .single-photo .photo-left img,
  .single-photo img {
    max-width: 100%;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
  }

  /* Overlay the info panel on top of the image, centered horizontally and stacked above nav */
  .single-photo .photo-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 84px; /* leave room for nav buttons */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0 1rem;
    gap: 0.5rem;
    pointer-events: none; /* allow clicks to fall through except on interactive children */
    z-index: 10001;
    color: #fff;
  }

  .single-photo .photo-info * { pointer-events: auto; }

  .photo-title,
  .photo-description,
  .photo-tags-wrap {
    background: rgba(0,0,0,0.38);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    text-align: left;
    max-width: 94%;
    box-sizing: border-box;
  }

  .photo-description { margin-top: 0.25rem; }

  .photo-tags { justify-content: center; }

  /* Ensure close button is above everything */
  .photo-close { z-index: 10002; }

  /* Slightly raise nav buttons if device has a bottom safe area */
  .photo-nav-edge { z-index: 10000; }
}

/* Edge navigation buttons (tall, skinny) for single-photo view */
.photo-nav-edge {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  color: #fff;
  text-decoration: none;
  font-size: 2rem;
  z-index: 9999;
  -webkit-tap-highlight-color: transparent;
}
.photo-nav-left { left: 8px; border-radius: 4px 0 0 4px; }
.photo-nav-right { right: 8px; border-radius: 0 4px 4px 0; }

@media (max-width: 800px) {
  .photo-nav-edge { width: 40px; height: 120px; font-size: 1.6rem; }
}

/* On very narrow screens place the two edge buttons together at bottom center
   so page content can scroll underneath them. */
@media (max-width: 640px) {
  .photo-nav-edge {
    top: auto;
    bottom: 12px;
    transform: none;
    width: 56px;
    height: 56px;
    font-size: 1.6rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  /* Center them as a small pair. Use left:50% and translateX offsets so
     both anchors sit next to each other. */
  .photo-nav-left,
  .photo-nav-right { left: 50%; }
  .photo-nav-left { transform: translateX(-64px); }
  .photo-nav-right { transform: translateX(8px); }
}

/* Close button (upper-right corner) for single-photo view */
.photo-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  line-height: 1;
  border-radius: 50%;
  z-index: 10000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.photo-close:hover,
.photo-close:focus {
  background: rgba(0,0,0,0.7);
}

@media (max-width: 640px) {
  .photo-close { top: 12px; right: 12px; width: 40px; height: 40px; font-size: 20px; }
}

/* Now showing filters under the site title */
.now-showing {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.9);
}
.now-showing__item {
  margin-right: 0.6rem;
  color: rgba(255,255,255,0.85);
}
.now-showing__item a { color: inherit; }
.now-showing__item.active {
  font-weight: 700;
  text-decoration: underline;
  color: #fff;
}

/* Mobile: allow a single tap to hide/show overlays (close, info, nav) */
@media (max-width: 640px) {
  .single-photo .photo-close,
  .single-photo .photo-info,
  .single-photo .photo-nav-edge {
    transition: opacity 180ms ease, transform 180ms ease;
  }

  .single-photo.overlays-hidden .photo-close,
  .single-photo.overlays-hidden .photo-info,
  .single-photo.overlays-hidden .photo-nav-edge {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
  }
}