@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #090909;
  --surface:      #141414;
  --surface2:     #1c1c1c;
  --border:       #252525;
  --text:         #e2e2e2;
  --text-muted:   #686868;
  --text-dim:     #444;
  --accent:       #c8a86e;
  --gap:          6px;
  --radius:       3px;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(9, 9, 9, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  transition: color 0.2s;
  user-select: none;
}

.logo:hover { color: var(--accent); }

#breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow: hidden;
}

.bc-home {
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
}
.bc-home:hover { color: var(--text); }

.bc-sep {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.bc-current {
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main ────────────────────────────────────────────────────────────────── */

main {
  padding: 36px 28px;
  min-height: calc(100vh - 53px);
}

/* ── Loading / Empty ─────────────────────────────────────────────────────── */

.state-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 40vh;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ───────────────────────────────────────────────────────────────── */

.error-view {
  max-width: 520px;
  margin: 80px auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.error-view h2 {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--text);
}

.error-view p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 10px;
}

.error-view code {
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 3px;
  word-break: break-all;
}

/* ── Gallery Grid (home) ─────────────────────────────────────────────────── */

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

.gallery-card {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.25, 0, 0, 1),
              filter 0.4s ease;
  filter: brightness(0.65) saturate(0.9);
  will-change: transform;
}

.gallery-card:hover img {
  transform: scale(1.05);
  filter: brightness(0.85) saturate(1);
}

.gallery-card-placeholder {
  width: 100%;
  height: 100%;
  background: var(--surface2);
}

.gallery-card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 48px 18px 18px;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, transparent 100%);
  pointer-events: none;
}

.gallery-card-name {
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 3px;
}

.gallery-card-desc {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  margin: 3px 0 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-count {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Gallery header ──────────────────────────────────────────────────────── */

.gallery-header {
  margin-bottom: 28px;
  max-width: 640px;
}

.gallery-title {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 8px;
}

.gallery-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* ── Masonry grid ────────────────────────────────────────────────────────── */

.masonry {
  columns: 4 220px;
  gap: var(--gap);
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: var(--gap);
  cursor: pointer;
  border-radius: var(--radius);
  display: block;
  overflow: hidden;
}

/* ── Blur-up loader ──────────────────────────────────────────────────────── */

.img-wrap {
  position: relative;
  width: 100%;
  min-height: 80px;
  background: var(--surface2);
  overflow: hidden;
}

/* Shimmer while nothing has loaded yet */
.img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.045) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  z-index: 3;
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* Blurred EXIF thumbnail */
.img-wrap::before {
  content: '';
  position: absolute;
  inset: -12px;
  background-image: var(--thumb, none);
  background-size: cover;
  background-position: center;
  filter: blur(14px);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.img-wrap.has-thumb::before { opacity: 1; }
.img-wrap.has-thumb::after  { opacity: 0; animation: none; }

/* Full-res image */
.img-wrap img {
  position: relative;
  z-index: 2;
  width: 100%;
  display: block;
  opacity: 0;
  filter: brightness(0.88);
  transition: opacity 0.5s ease,
              transform 0.35s cubic-bezier(0.25, 0, 0, 1),
              filter 0.3s ease;
  will-change: transform, opacity;
}

.img-wrap.loaded img    { opacity: 1; }
.img-wrap.loaded::before { opacity: 0; }
.img-wrap.loaded::after  { opacity: 0; }

.masonry-item:hover .img-wrap img {
  transform: scale(1.025);
  filter: brightness(1);
}

@keyframes shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #07070a;
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: 1fr;
  overflow: hidden;
  animation: lb-enter 0.2s ease;
}

@keyframes lb-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox.hidden { display: none; }

.lb-image-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px 36px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

/* White mat frame */
.lb-image-area img {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  object-fit: contain;
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow:
    0 0 0 14px #f3efe9,
    0 0 0 15px rgba(0,0,0,0.15),
    0 24px 80px rgba(0,0,0,0.75),
    0 4px 20px rgba(0,0,0,0.5);
}

.lb-image-area img.loaded { opacity: 1; }

.lb-img-spinner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  pointer-events: none;
}

.lb-img-spinner.hidden { display: none; }

/* ── Lightbox meta panel ─────────────────────────────────────────────────── */

.lb-meta {
  background: #0b0b0e;
  border-left: 1px solid rgba(255,255,255,0.05);
  overflow-y: auto;
  padding: 60px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.lb-meta::-webkit-scrollbar { width: 3px; }
.lb-meta::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.lb-filename {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
  line-height: 1.5;
  margin-bottom: 4px;
}

.lb-filesize {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.meta-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.meta-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.meta-section-label {
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.2);
  margin-bottom: 2px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.meta-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.meta-value {
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 400;
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-value.wrap {
  white-space: normal;
  text-overflow: unset;
  text-align: right;
}

.meta-no-exif {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.2);
  font-style: italic;
}

/* ── Lightbox controls ───────────────────────────────────────────────────── */

.lb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  color: rgba(255,255,255,0.6);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.lb-close:hover {
  background: rgba(255,255,255,0.13);
  border-color: rgba(255,255,255,0.2);
  color: #fff;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.55);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 14px 11px;
  border-radius: 6px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
  backdrop-filter: blur(8px);
}

.lb-image-area:hover .lb-nav { opacity: 1; }
.lb-nav:hover { background: rgba(255,255,255,0.12); color: #fff; }
.lb-nav:disabled { opacity: 0 !important; cursor: default; pointer-events: none; }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }

.lb-counter {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.25);
  user-select: none;
  background: rgba(0,0,0,0.4);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  main { padding: 24px 18px; }
  .masonry { columns: 3 160px; }
  .galleries-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

  .lightbox {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .lb-image-area {
    padding: 52px 20px 12px;
  }

  .lb-image-area img {
    max-height: 56vh;
    box-shadow:
      0 0 0 10px #f3efe9,
      0 0 0 11px rgba(0,0,0,0.12),
      0 16px 48px rgba(0,0,0,0.7);
  }

  .lb-meta {
    background: #0b0b0e;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding: 14px 18px 18px;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0 28px;
    max-height: 38vh;
    overflow-y: auto;
  }

  .lb-filename { width: 100%; margin-bottom: 2px; }
  .lb-filesize { width: 100%; margin-bottom: 14px; }

  .meta-section {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 20px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    width: 100%;
  }

  .meta-section-label { width: 100%; margin-bottom: 0; }
  .meta-row { flex-direction: column; gap: 1px; min-width: 80px; }
  .meta-value { text-align: left; }
  .meta-value.wrap { text-align: left; }

  .lb-nav.prev { left: 6px; }
  .lb-nav.next { right: 6px; }
  .lb-image-area:hover .lb-nav,
  .lb-image-area .lb-nav { opacity: 1; }
}

@media (max-width: 600px) {
  header { padding: 12px 16px; }
  main { padding: 16px 12px; }

  .galleries-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .masonry { columns: 2 130px; }

  .masonry { columns: 2 130px; }

  .lb-image-area img {
    max-height: 50vh;
    box-shadow:
      0 0 0 8px #f3efe9,
      0 0 0 9px rgba(0,0,0,0.1),
      0 10px 30px rgba(0,0,0,0.6);
  }

  .lb-nav { padding: 10px 9px; }
}
