@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@300;400&display=swap');

:root {
  --bg: #0e0d0b;
  --surface: #161512;
  --border: #2a2720;
  --text: #e8e0d0;
  --muted: #6b6456;
  --accent: #c8a96e;
  --gap: 6px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  overflow: hidden;
}

#shell { display: flex; height: 100vh; width: 100vw; }

/* ── Gallery ── */
#gallery-wrap {
  flex: 1;
  overflow-y: scroll;
  overflow-x: hidden;
}
#gallery-wrap::-webkit-scrollbar { width: 4px; }
#gallery-wrap::-webkit-scrollbar-track { background: transparent; }
#gallery-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* JS-driven masonry: columns are flex children, tiles stack inside each.
   The column count is set by script.js (targetColumnCount). */
#mosaic {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  padding: var(--gap);
}
.mcol {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ── Tile (shared) ── */
.tile {
  position: relative;
  overflow: hidden;
  border-radius: 3px;
  display: block;
  background: var(--surface);
}

/* ── Image tile ── */
.tile > img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.4s ease;
  filter: saturate(0.82) brightness(0.9);
}
.tile:hover > img {
  transform: scale(1.04);
  filter: saturate(1.1) brightness(1.0);
}
.image-tile > img { cursor: zoom-in; }

/* ── Link badge (top-right corner) ── */
.link-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(14, 13, 11, 0.72);
  border: 1px solid rgba(200, 169, 110, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none; /* tile click handles navigation */
}
/* A linked image's badge is itself clickable (opens the source). */
a.link-badge-active {
  pointer-events: auto;
  cursor: pointer;
  text-decoration: none;
}
a.link-badge-active:hover {
  background: rgba(200, 169, 110, 0.92);
}
a.link-badge-active:hover svg { stroke: #0e0d0b; }
.link-badge svg {
  width: 12px;
  height: 12px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tile.has-link .link-badge {
  opacity: 1;
  transform: scale(1);
}
/* subtle border glow for linked tiles */
.tile.has-link {
  cursor: pointer;
}
.tile.has-link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(200, 169, 110, 0);
  transition: box-shadow 0.3s ease;
  pointer-events: none;
  z-index: 6;
}
.tile.has-link:hover::after {
  box-shadow: inset 0 0 0 1.5px rgba(200, 169, 110, 0.45);
}

/* ── Video tile ── */
.video-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: #000;
}
.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(200,169,110,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 4;
}
.play-badge svg { width: 18px; height: 18px; fill: #0e0d0b; margin-left: 2px; stroke: none; }
.tile.video-tile:hover .play-badge { opacity: 0; transform: translate(-50%,-50%) scale(0.8); }
.video-cover {
  position: absolute;
  inset: 0;
  cursor: pointer;
  z-index: 3;
  transition: opacity 0.3s ease;
}
.video-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.75) saturate(0.8);
  transition: filter 0.3s ease;
}
.video-cover:hover img { filter: brightness(0.55) saturate(0.9); }

/* ── Shared hover overlay (metadata) ── */
.overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(10, 9, 7, 0.93) 0%,
    rgba(10, 9, 7, 0.3) 40%,
    transparent 65%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px 12px 12px;
  pointer-events: none;
  z-index: 5;
}
.tile:hover .overlay { opacity: 1; }
.overlay .ts {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.overlay .desc {
  font-size: 11px;
  line-height: 1.55;
  color: var(--text);
  font-weight: 300;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.overlay .media-type {
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(200,169,110,0.4);
  border-radius: 2px;
  padding: 1px 5px;
  display: inline-block;
  margin-bottom: 5px;
  width: fit-content;
}

/* ── Local video placeholder (no poster supplied) ── */
.video-placeholder {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 50% 45%, #1c1a16 0%, #0b0a08 100%);
}
.video-wrap > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 2;
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(8, 7, 5, 0.92);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
.lightbox.open {
  opacity: 1;
  visibility: visible;
}
.lightbox-figure {
  margin: 0;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transform: scale(0.94);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.lightbox.open .lightbox-figure { transform: scale(1); }
.lightbox-img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}
.lightbox-cap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  max-width: 70ch;
}
.lightbox-cap .lb-ts {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.lightbox-cap .lb-desc {
  font-size: 13px;
  line-height: 1.6;
  font-weight: 300;
  color: var(--text);
}
.lightbox-cap .lb-link {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid rgba(200, 169, 110, 0.4);
  border-radius: 2px;
  padding: 3px 9px;
  transition: background 0.2s ease, color 0.2s ease;
}
.lightbox-cap .lb-link:hover {
  background: var(--accent);
  color: #0e0d0b;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 22px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(40, 37, 31, 0.6);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.lightbox-close:hover {
  background: rgba(200, 169, 110, 0.9);
  color: #0e0d0b;
  transform: rotate(90deg);
}

/* ── Sentinel ── */
#sentinel {
  text-align: center;
  padding: 24px;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--muted);
  text-transform: uppercase;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tile { animation: fadeUp 0.4s ease both; }
