/* ————————————————————————————————— light table ————————————————————————————— */

:root {
  --bg: #0d0d0f;
  --surface: #16161a;
  --line: rgba(255, 255, 255, 0.07);
  --line-bright: rgba(255, 255, 255, 0.3);
  --ink: #e9e7e2;
  --ink-dim: #8b897f;
  --amber: #ffb454;
  --mono: "Fragment Mono", "SF Mono", ui-monospace, monospace;
  --serif: "Instrument Serif", Georgia, serif;

  /* base (zoom = 1) cell geometry — JS reads these */
  --cw: 384px;
  --ch: 216px;
  --gap: 8px;
  --row-gap: 8px;
  --pad-x: 16px;
  --pad-top: 16px;
  --pad-bottom: 16px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

/* faint vignette + grain over everything, under the UI */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background:
    radial-gradient(120% 90% at 50% 0%, transparent 60%, rgba(0, 0, 0, 0.5) 100%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ————————————————————————————————— grid ——————————————————————————————————— */

#viewport {
  position: fixed;
  inset: 0;
  overflow: auto;
  cursor: grab;
  /* touch pan + pinch are implemented in JS; any browser-owned gesture would
     pointercancel them mid-way */
  touch-action: none;
  overscroll-behavior: none;
  outline: none;
  z-index: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
#viewport.dragging { cursor: grabbing; }
#viewport::-webkit-scrollbar { width: 10px; height: 10px; }
#viewport::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
#viewport::-webkit-scrollbar-corner { background: transparent; }

#canvas {
  width: max-content;
  padding: var(--pad-top) var(--pad-x) var(--pad-bottom);
}

.deck-row {
  display: flex;
  gap: var(--gap);
  margin-bottom: var(--row-gap);
  width: max-content;
  min-height: var(--ch); /* an empty deck (mid re-export) keeps the row pitch uniform */
  animation: row-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i) * 45ms);
}
.deck-row:last-child { margin-bottom: 0; }

@keyframes row-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.slide {
  position: relative;
  width: var(--cw);
  height: var(--ch);
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.slide:hover {
  border-color: var(--line-bright);
  box-shadow: 0 6px 40px rgba(0, 0, 0, 0.55);
}
.slide:focus-visible {
  /* CSS zoom scales used lengths; dividing by the zoom level (--z, set from JS)
     keeps the ring at a constant 2 screen px even on a 7% fit view */
  outline: calc(2px / var(--z, 1)) solid var(--amber);
  outline-offset: calc(2px / var(--z, 1));
}
.slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
  -webkit-user-drag: none;
  user-select: none;
}
.slide img.loaded { opacity: 1; }

/* ————————————————————————————————— chrome ————————————————————————————————— */

#hud {
  position: fixed;
  right: 24px;
  bottom: 22px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(22, 22, 26, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
#hud button {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 999px;
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
#hud button:hover { background: rgba(255, 255, 255, 0.08); color: var(--amber); }
#hud button:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }
#zoomPct { min-width: 56px; color: var(--ink-dim); font-size: 11px; }

#zoomSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 150px;
  height: 30px;
  margin: 0 4px 0 10px;
  background: transparent;
  cursor: pointer;
}
#zoomSlider:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 999px; }
#zoomSlider::-webkit-slider-runnable-track {
  height: 2px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
}
#zoomSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--ink);
  transition: background 0.12s ease;
}
#zoomSlider:hover::-webkit-slider-thumb,
#zoomSlider:active::-webkit-slider-thumb { background: var(--amber); }
#zoomSlider::-moz-range-track {
  height: 2px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
}
#zoomSlider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  transition: background 0.12s ease;
}
#zoomSlider:hover::-moz-range-thumb,
#zoomSlider:active::-moz-range-thumb { background: var(--amber); }

/* ———————————————————————————————— lightbox ———————————————————————————————— */

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lightbox[hidden] { display: none; }

#lightboxBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 10, 0.93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

#lightbox figure {
  position: relative;
  z-index: 1;
  max-width: min(92vw, calc(88vh * 16 / 9));
  max-width: min(92vw, calc(88svh * 16 / 9)); /* iOS: exclude Safari toolbars */
  touch-action: pan-y; /* keep horizontal pointer sequences alive for swipe nav */
  animation: lb-in 0.22s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes lb-in {
  from { opacity: 0; transform: scale(0.965); }
  to   { opacity: 1; transform: none; }
}
#lightboxImg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 88vh;
  max-height: 88svh;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.7);
}
#lightbox button {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(22, 22, 26, 0.7);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
#lightbox button:hover { background: rgba(255, 255, 255, 0.1); color: var(--amber); border-color: var(--line-bright); }
#lightbox button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
#lightbox button:disabled { opacity: 0.25; cursor: default; }
#lightbox button:disabled:hover { background: rgba(22, 22, 26, 0.7); color: var(--ink); border-color: var(--line); }

#lightboxClose { top: 22px; right: 24px; }
#lightboxPrev { left: 24px; top: 50%; transform: translateY(-50%); }
#lightboxNext { right: 24px; top: 50%; transform: translateY(-50%); }

/* ———————————————————————————————— misc ———————————————————————————————————— */

@media (max-width: 720px) {
  #lightboxPrev, #lightboxNext { display: none; } /* swipe/keys still work */
}

@media (prefers-reduced-motion: reduce) {
  .deck-row { animation: none; }
  #lightbox figure { animation: none; }
  .slide img { transition: none; }
}

/* ————————————————————— disclaimer header ————————————————————————————————— */

#disclaimer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 16px 24px 26px;
  pointer-events: none;          /* never blocks a click on the wall behind it */
  background: linear-gradient(to bottom,
              rgba(13, 13, 15, 0.95) 0%,
              rgba(13, 13, 15, 0.78) 55%,
              transparent 100%);
}
#disclaimer p {
  max-width: 780px;
  font-size: 11.5px;
  line-height: 1.65;
  letter-spacing: 0.015em;
  color: var(--ink-dim);
  text-wrap: pretty;
}

@media (max-width: 720px) {
  #disclaimer { padding: 12px 16px 22px; }
  #disclaimer p { font-size: 11px; }
}
