* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

:root {
  --cols: 12;            /* must match COLS in wall.js */
  --cw: 190px;           /* tile width  (4:5) */
  --ch: 238px;           /* tile height */
  --gap: 30px;           /* spacing between hung pieces */
  --accent: #ff3b3b;
  --mono: "Space Mono", ui-monospace, Menlo, monospace;
  --grot: "Space Grotesk", system-ui, sans-serif;
}

body {
  font-family: var(--grot);
  background: #070707;
  overflow: hidden;
  user-select: none;
  cursor: default;
}

/* ── Dark gallery wall (FALLEN — "the depths of the screen") ─────────── */
.bg-concrete {
  position: fixed; inset: 0; z-index: -4;
  background: #0a0a0a url("concrete.jpg") center center / cover no-repeat;
  filter: grayscale(1) brightness(0.22) contrast(1.15);
}
.bg-grade {
  position: fixed; inset: 0; z-index: -3; pointer-events: none;
  background: radial-gradient(120% 110% at 50% 40%, rgba(30,30,32,0.5) 0%, rgba(0,0,0,0.85) 100%);
}
.fx { position: fixed; inset: 0; pointer-events: none; z-index: -1; }
.grain {
  inset: -12%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
  mix-blend-mode: overlay;
  opacity: 0.08;
  animation: grain 0.55s steps(5) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0); } 20% { transform: translate(-3%,2%); }
  40% { transform: translate(2%,-3%); } 60% { transform: translate(-2%,-2%); }
  80% { transform: translate(3%,1%); } 100% { transform: translate(0,0); }
}
.vignette {
  background: radial-gradient(120% 105% at 50% 46%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.6) 100%);
  mix-blend-mode: multiply;
}

/* ── Surfable grid ──────────────────────────────────────────────────── */
.viewport { position: fixed; inset: 0; overflow: hidden; cursor: grab; touch-action: none; }
.viewport:active { cursor: grabbing; }
.grid {
  position: absolute; top: 0; left: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cw));
  gap: var(--gap);
  will-change: transform;
}
/* infinite mode: tiles are absolutely positioned and driven by per-tile transforms */
.grid.free { display: block; will-change: auto; }
.grid.free .tile { position: absolute; top: 0; left: 0; transition: filter .3s ease; }
.tile {
  position: relative;
  width: var(--cw); height: var(--ch);
  background: #141414;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
  filter: brightness(0.82) saturate(0.98);
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:hover { filter: brightness(1) saturate(1.02); }

/* ── HUD + hint ─────────────────────────────────────────────────────── */
.hud {
  position: fixed; left: 0; right: 0; top: 18px; text-align: center;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: rgba(236,236,236,0.9); text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  pointer-events: none; z-index: 6;
}
.hint {
  position: fixed; left: 0; right: 0; bottom: 16px; text-align: center;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(236,236,236,0.5); text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  transition: opacity .8s ease; z-index: 6;
}
.hint.gone { opacity: 0; }

/* ── Full-piece viewer ──────────────────────────────────────────────── */
.viewer {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 7vh;                   /* keep tall/vertical pieces clear of the caption */
  background: rgba(6,6,6,0.9); backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; transition: opacity .32s ease;
}
.viewer.open { opacity: 1; pointer-events: auto; cursor: zoom-out; }
.viewer img {
  max-height: 80vh; max-width: 88vw;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7);
  transform: scale(0.97); transition: transform .32s cubic-bezier(.22,.61,.36,1);
}
.viewer.open img { transform: scale(1); }
.viewer-cap {
  position: fixed; left: 0; right: 0; bottom: 26px; text-align: center;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase;
  color: rgba(236,236,236,0.82); text-shadow: 0 1px 6px rgba(0,0,0,0.9);
}
.viewer-cap .det { color: var(--accent); text-decoration: none; margin-left: 10px; }
.viewer-cap .det:hover { text-decoration: underline; }

/* ── Nav ────────────────────────────────────────────────────────────── */
.nav {
  position: fixed; z-index: 7;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(236,236,236,0.7); text-decoration: none;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9); transition: color .2s ease;
}
.nav:hover { color: #fff; }
.nav.left { left: 22px; top: 16px; }
.nav.right { right: 22px; top: 16px; }

body { animation: rise 1s ease both; }
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 720px) { :root { --cw: 130px; --ch: 162px; --gap: 18px; } }
