:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --fg-muted: #6b6b6b;
  --border: #e5e5e5;
  --tile-bg: #eeeeee;
  --overlay-from: rgba(0, 0, 0, 0);
  --overlay-to: rgba(0, 0, 0, 0.75);
  --max-width: 1400px;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f0f0f0;
    --fg-muted: #a0a0a0;
    --border: #2a2a2a;
    --tile-bg: #1e1e1e;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.lightbox-open {
  overflow: hidden;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-title {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem;
}

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
  text-align: center;
}

.site-footer a {
  color: var(--fg-muted);
  text-decoration: underline;
}

.site-footer a:hover {
  color: var(--fg);
}

/* Gallery grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}

.tile {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--tile-bg);
  text-decoration: none;
  aspect-ratio: 1 / 1;
  cursor: zoom-in;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.tile:hover img,
.tile:focus-visible img {
  transform: scale(1.05);
}

.empty-state {
  color: var(--fg-muted);
  text-align: center;
  padding: 3rem 1rem;
}

.empty-state code {
  background: var(--tile-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

/* Lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.9);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-figure {
  margin: 0;
  max-width: min(100%, 1200px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  border-radius: 6px;
  object-fit: contain;
}

.lightbox-figure figcaption {
  color: #f0f0f0;
  text-align: center;
  padding: 1rem 0.5rem 0;
  max-width: 65ch;
}

.lightbox-title {
  margin: 0 0 0.3rem;
  font-size: 1.2rem;
}

.lightbox-location {
  margin: 0 0 0.5rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.lightbox-location::before {
  content: "📍 ";
}

.lightbox-description {
  margin: 0 0 0.5rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
  font-size: 0.95rem;
}

.lightbox-permalink {
  display: inline-block;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  text-decoration: underline;
}

.lightbox-permalink:hover {
  color: #fff;
}

/* Permalink page */

.photo-page {
  max-width: 1100px;
}

.photo-figure {
  margin: 0;
}

.photo-figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  background: var(--tile-bg);
}

.photo-figure figcaption {
  padding: 1.25rem 0.25rem;
}

.photo-figure h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.photo-location {
  margin: 0 0 0.75rem;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.photo-location::before {
  content: "📍 ";
}

.photo-description {
  margin: 0;
  line-height: 1.6;
  max-width: 65ch;
}

.photo-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 0.25rem 3rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.photo-nav-link {
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--fg-muted);
  white-space: nowrap;
}

.photo-nav-link:hover {
  color: var(--fg);
}

.photo-nav-back {
  font-weight: 600;
  color: var(--fg);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
}

.lightbox-prev {
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
}

.lightbox-next {
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  main {
    padding: 0.75rem;
  }

  .lightbox {
    padding: 1rem;
  }

  .lightbox-prev,
  .lightbox-next {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .photo-nav {
    font-size: 0.85rem;
  }
}
