/* mightyjax Galleries viewer. Photo-first, calm, light neutral; system fonts only. CSP: style-src 'self'. */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --ink: #1c1b19;
  --muted: #5d5a54;
  --line: #d9d6cf;
  --field-line: #8a867e;
  --error: #9b2c1f;
  --focus: #2f5d8a;
  --tile-bg: #ebe8e2;
  --lb-bg: #0e0e0d;
  --lb-ink: #f2f0ec;
  --lb-muted: #b5b1a9;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --row-h: 260px;
  --gap: 6px;
  --page-pad: clamp(16px, 4vw, 48px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --fade: 320ms;
  --gold-top: #d6bb80;
  --gold-mid: #b0904f;
  --gold-low: #7d6230;
  --gold-glow: rgba(176, 144, 79, 0.35);
  --mark-rest: 0.3;
  color-scheme: light;
}

/* theme.js sets data-theme before first paint; the lightbox keeps its own dark palette in both themes. */
:root[data-theme="dark"] {
  --bg: #141412;
  --surface: #1d1c1a;
  --ink: #f2f0ec;
  --muted: #a9a59d;
  --line: #34322e;
  --field-line: #77736b;
  --error: #f0a497;
  --focus: #8db4dc;
  --tile-bg: #22211e;
  --gold-top: #f5e3b8;
  --gold-mid: #c8a96e;
  --gold-low: #a08544;
  --gold-glow: rgba(200, 169, 110, 0.5);
  --mark-rest: 0.22;
  color-scheme: dark;
}

.theme-toggle {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 160ms var(--ease);
}

.theme-toggle:hover { border-color: var(--ink); }

.brand {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 2;
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font: 500 0.875rem/1 var(--font-body);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-decoration: none;
}

.brand:hover { color: var(--muted); }
:root[data-theme="dark"] .theme-icon-moon,
:root:not([data-theme="dark"]) .theme-icon-sun { display: none; }

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h1, p { margin: 0; }

button { font: inherit; color: inherit; }

svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* ---------- states ---------- */

#app { min-height: 100vh; min-height: 100dvh; }

.view-loading,
.view-locked,
.view-notice {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--page-pad);
}

.loading-text {
  color: var(--muted);
  font-size: 0.9375rem;
  opacity: 0;
  animation: appear var(--fade) var(--ease) 600ms forwards;
}

@keyframes appear { to { opacity: 1; } }

/* ---------- buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.button:hover { background: var(--ink); color: var(--bg); }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: progress; background: transparent; color: var(--muted); border-color: var(--line); }

.button-quiet { gap: 8px; border-color: var(--line); }
.button-quiet[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.button-quiet[aria-pressed="true"] .heart-icon { fill: currentColor; }

/* ---------- password form ---------- */

.unlock {
  width: min(100%, 340px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.unlock-icon { align-self: center; color: var(--muted); margin-bottom: 18px; }

.unlock-title {
  font: 400 1.75rem/1.2 var(--font-display);
  letter-spacing: -0.005em;
  text-align: center;
  margin-bottom: 32px;
}

.field-label {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.field {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

.field:focus-visible { outline-offset: 2px; border-color: var(--focus); }
.field[aria-invalid="true"] { border-color: var(--error); }
.field:read-only { color: var(--muted); }

.field-group { display: flex; flex-direction: column; margin-bottom: 20px; }

.field-error {
  margin-top: 10px;
  color: var(--error);
  font-size: 0.875rem;
}

.unlock .button { margin-top: 20px; width: 100%; }

/* ---------- locked page mark ----------
   The MightyJax hollow M (same intro as mightyjax.com's loader): on the first lock of a visit the
   gold outline draws itself in, stars come up, then the M settles faint and the form rises over it.
   data-mark="draw" plays that once; "rest" is the settled state (later locks, or any key or tap). */

.view-locked { position: relative; overflow: hidden; isolation: isolate; }
.view-locked .unlock { position: relative; z-index: 1; }

.lock-stage { position: absolute; inset: 0; z-index: 0; pointer-events: none; }

.lock-art {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(100%, 84vh, 760px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
}

.lock-mark {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: var(--mark-rest);
  filter: drop-shadow(0 0 14px var(--gold-glow));
}

.lock-gold-top { stop-color: var(--gold-top); }
.lock-gold-mid { stop-color: var(--gold-mid); }
.lock-gold-low { stop-color: var(--gold-low); }

.lock-mark-line { stroke: url(#lock-gold); stroke-width: 2.2; stroke-dasharray: 1000; stroke-dashoffset: 0; }

.lock-mark-gleam {
  stroke: var(--gold-top);
  stroke-width: 3.4;
  stroke-dasharray: 40 960;
  animation: mark-gleam 7s linear infinite;
}

.lock-mark-gleam-fine {
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-dasharray: 10 990;
  animation-duration: 4.6s;
  animation-direction: reverse;
}

.lock-stars { position: absolute; inset: 0; }

.lock-star {
  position: absolute;
  width: var(--star, 24px);
  height: var(--star, 24px);
  filter: drop-shadow(0 0 10px var(--gold-glow));
  animation: mark-twinkle 2.4s ease-in-out var(--twinkle, 0s) infinite;
}

.lock-star svg { display: block; width: 100%; height: 100%; fill: var(--gold-top); stroke: none; }
:root:not([data-theme="dark"]) .lock-star svg { fill: var(--gold-mid); }

.lock-star:nth-child(1) { top: 8%;  left: 14%; --star: 30px; --twinkle: 0s; }
.lock-star:nth-child(2) { top: 16%; left: 82%; --star: 24px; --twinkle: 0.4s; }
.lock-star:nth-child(3) { top: 40%; left: 4%;  --star: 20px; --twinkle: 1.1s; }
.lock-star:nth-child(4) { top: 62%; left: 90%; --star: 28px; --twinkle: 0.7s; }
.lock-star:nth-child(5) { top: 84%; left: 12%; --star: 22px; --twinkle: 1.6s; }
.lock-star:nth-child(6) { top: 88%; left: 76%; --star: 26px; --twinkle: 0.2s; }
.lock-star:nth-child(7) { top: 2%;  left: 50%; --star: 40px; --twinkle: 0.9s; }
.lock-star:nth-child(8) { top: 46%; left: 94%; --star: 18px; --twinkle: 1.3s; }

#locked[data-mark="draw"] .lock-art { animation: mark-in 1.4s var(--ease) backwards; }
#locked[data-mark="draw"] .lock-mark { animation: mark-rest 0.9s var(--ease) 1.5s backwards; }
#locked[data-mark="draw"] .lock-mark-line { animation: mark-draw 1.6s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
#locked[data-mark="draw"] .lock-mark-gleam { animation: mark-gleam 7s linear infinite, mark-fade-in 0.6s ease 1.2s backwards; }
#locked[data-mark="draw"] .lock-mark-gleam-fine { animation: mark-gleam 4.6s linear infinite reverse, mark-fade-in 0.6s ease 1.2s backwards; }
#locked[data-mark="draw"] .lock-stars { animation: mark-fade-in 0.9s ease 0.8s backwards; }
#locked[data-mark="draw"] .unlock { animation: mark-form-in 0.7s var(--ease) 1.5s backwards; }

@keyframes mark-in { from { transform: translate(-50%, -50%) scale(0.94); } }
@keyframes mark-draw { from { stroke-dashoffset: 1000; } }
@keyframes mark-rest { from { opacity: 1; } }
@keyframes mark-fade-in { from { opacity: 0; } }
@keyframes mark-form-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes mark-gleam { to { stroke-dashoffset: -1000; } }
@keyframes mark-twinkle {
  0%, 100% { opacity: 0.18; transform: scale(0.55) rotate(0deg); }
  18% { opacity: 1; transform: scale(1.15) rotate(12deg); }
  34% { opacity: 0.35; transform: scale(0.75) rotate(2deg); }
  54% { opacity: 0.95; transform: scale(1.05) rotate(-8deg); }
  70% { opacity: 0.22; transform: scale(0.65) rotate(0deg); }
  84% { opacity: 0.7; transform: scale(0.95) rotate(6deg); }
}

/* ---------- notices ---------- */

.notice { max-width: 420px; text-align: center; }

.notice-title {
  font: 400 1.625rem/1.25 var(--font-display);
  letter-spacing: -0.005em;
}

.notice-title:focus { outline: none; }

.notice-detail { margin-top: 10px; color: var(--muted); }

.notice .button { margin-top: 28px; }

/* ---------- gallery ---------- */

.view-gallery { padding: 0 var(--page-pad) 64px; }

.gallery-head {
  max-width: 1600px;
  margin: 0 auto;
  padding: clamp(40px, 8vw, 96px) 0 clamp(24px, 4vw, 40px);
  text-align: center;
}

.gallery-title {
  font: 400 clamp(1.875rem, 1.2rem + 2.6vw, 3rem)/1.15 var(--font-display);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.gallery-count {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.gallery-actions:not(:has(> :not([hidden]))) { display: none; }

/* Select mode keeps one action (Download N) and Cancel; the layout switch stays. */
.gallery-actions.is-selecting > #fav-filter,
.gallery-actions.is-selecting > #download-all { display: none; }
#download-selected { min-width: 9.5em; font-variant-numeric: tabular-nums; }
#download-selected:disabled { cursor: default; }

/* Grid / Filmstrip / Showcase: one hollow pill, the chosen half filled with ink. */
.layout-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.layout-option {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.layout-option:hover { color: var(--ink); }
.layout-option[aria-pressed="true"] { background: var(--ink); color: var(--bg); cursor: default; }

.fav-count { color: inherit; font-variant-numeric: tabular-nums; opacity: 0.7; }

.dl-bar { margin-top: 16px; font-size: 0.875rem; }
.dl-bar:not(:has(> :not([hidden]))) { display: none; }
.dl-remaining { color: var(--muted); font-variant-numeric: tabular-nums; }
.dl-error { color: var(--error); }

.fav-form { max-width: 360px; margin: 28px auto 0; text-align: left; }
.fav-row { display: flex; gap: 8px; }
.fav-row .field { flex: 1; min-width: 0; }
.fav-status { min-height: 1.5em; margin-top: 6px; color: var(--muted); font-size: 0.875rem; }

/* Justified rows: each tile grows in proportion to its aspect ratio (--ar, set via CSSOM) so rows fill the
   width at roughly --row-h; aspect-ratio reserves the box before the image decodes (no layout shift). */
.grid {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  justify-content: center;
}

.grid::after { content: ""; flex-grow: 1000000; }

.tile {
  --ar: 1.5;
  flex: var(--ar) 1 calc(var(--ar) * var(--row-h));
  max-width: calc(var(--ar) * var(--row-h) * 2);
  aspect-ratio: var(--ar);
  min-width: 0;
  position: relative;
  background: var(--tile-bg);
  overflow: hidden;
}

.tile-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.tile-button:focus-visible { outline-offset: -3px; outline-color: var(--surface); box-shadow: inset 0 0 0 5px var(--focus); }

.tile-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--fade) var(--ease), transform 600ms var(--ease);
}

.tile.is-loaded .tile-img { opacity: 1; }
.tile.is-broken { background: var(--line); }
.tile-button:hover .tile-img { transform: scale(1.015); }

/* Heart: shown on hover or focus, always shown once picked or on touch screens. */
.tile-heart {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(14, 14, 13, 0.4);
  color: #ffffff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms var(--ease), background-color 160ms var(--ease);
}

.tile:hover .tile-heart,
.tile-heart:focus-visible,
.tile-heart[aria-pressed="true"] { opacity: 1; }
.tile-heart:hover { background: rgba(14, 14, 13, 0.65); }
.tile-heart:focus-visible { outline: 2px solid #ffffff; outline-offset: -4px; box-shadow: 0 0 0 2px var(--focus); }
.heart[aria-pressed="true"] .heart-icon { fill: currentColor; }

/* Select mode: a check badge on every selectable tile; a chosen photo steps back inside an ink ring. */
.grid.is-selecting .tile-button { cursor: pointer; }
.grid.is-selecting .tile-button[aria-disabled="true"] { cursor: not-allowed; }
.grid.is-selecting .tile-button[aria-disabled="true"] .tile-img { opacity: 0.4; }

.tile-check {
  position: absolute;
  top: 10px;
  left: 10px;
  display: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid #ffffff;
  border-radius: 999px;
  background: rgba(14, 14, 13, 0.3);
  color: transparent;
  pointer-events: none;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}

.check-icon { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.grid.is-selecting .tile-button:not([aria-disabled="true"]) .tile-check { display: grid; }
.tile.is-selected .tile-check { border-color: #ffffff; background: #ffffff; color: #1c1b19; }
.grid .tile.is-selected .tile-img { transform: scale(0.92); }
.grid.is-selecting .tile-button:hover .tile-img { transform: none; }
.grid.is-selecting .tile.is-selected .tile-button .tile-img { transform: scale(0.92); }
.tile.is-selected::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--ink);
  pointer-events: none;
}

/* Filmstrip: one large photo per row, centred, capped at 1200px and at most ~88% of the viewport tall. The box
   is reserved from --ar like the grid's, so neither the thumbnail nor the web-size swap moves anything. */
.grid.is-filmstrip {
  max-width: 1200px;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
}

.grid.is-filmstrip::after { content: none; }

.grid.is-filmstrip .tile {
  flex: none;
  width: min(100%, calc(var(--ar) * 88vh));
  max-width: none;
}

.grid.is-filmstrip .tile-button:hover .tile-img { transform: none; }
.grid.is-filmstrip.is-selecting .tile.is-selected .tile-button .tile-img { transform: scale(0.96); }

/* ---------- reverie (opening) ---------- */

/* The track gives the page its scroll length; the stage stays fixed over it while viewer-reverie.js maps scroll
   progress to each card's transform (set via CSSOM every frame). --rv-title and --rv-shade are set the same way. */
.reverie-track { height: 400vh; }

.reverie {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  color: var(--lb-ink);
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity var(--fade) var(--ease);
}

.reverie::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--lb-bg);
  opacity: var(--rv-shade, 1);
}

/* Shade under the title so it reads on any photo. */
.reverie::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(14, 14, 13, 0.45), rgba(14, 14, 13, 0) 70%);
  opacity: var(--rv-title, 1);
  pointer-events: none;
}

.reverie.is-leaving { opacity: 0; }

/* Its own stacking context, so the cards' z-order never rises above the title or Skip. */
.reverie-deck {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.rv-card {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  overflow: hidden;
  border-radius: 3px;
  background: #22211e;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  transform-origin: 50% 50%;
  will-change: transform;
}

.rv-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--fade) var(--ease);
  -webkit-user-drag: none;
}

.rv-card.is-loaded img { opacity: 1; }

.reverie-title {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: min(90vw, 960px);
  translate: -50% -50%;
  font: 400 clamp(2.25rem, 1.2rem + 4.5vw, 5rem)/1.05 var(--font-display);
  letter-spacing: -0.015em;
  text-align: center;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.35);
  overflow-wrap: anywhere;
  opacity: var(--rv-title, 1);
  pointer-events: none;
}

/* A still line under the title: there is more below. */
.reverie-cue {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 1;
  width: 1px;
  height: 48px;
  background: linear-gradient(var(--lb-ink), rgba(242, 240, 236, 0));
  opacity: calc(var(--rv-title, 1) * 0.7);
  pointer-events: none;
}

.reverie-skip {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 1;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid rgba(242, 240, 236, 0.4);
  border-radius: 999px;
  background: rgba(14, 14, 13, 0.35);
  color: var(--lb-ink);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}

.reverie-skip:hover { border-color: var(--lb-ink); background: rgba(242, 240, 236, 0.08); }
.reverie-skip:focus-visible { outline-color: var(--lb-ink); }
.gallery-title:focus { outline: none; }

/* ---------- lightbox ---------- */

.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--lb-bg);
  color: var(--lb-ink);
  overflow: hidden;
}

.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  animation: appear 200ms var(--ease);
}

.lightbox::backdrop { background: var(--lb-bg); }

.lb-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 12px 12px 12px clamp(16px, 3vw, 28px);
  padding-top: max(12px, env(safe-area-inset-top));
}

.lb-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
}

.lb-counter {
  color: var(--lb-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lb-stage {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-height: 0;
  padding: 8px clamp(12px, 7vw, 96px) clamp(16px, 4vw, 40px);
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}

.lb-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 1;
  transition: opacity 220ms var(--ease);
  -webkit-user-drag: none;
}

.lb-stage.is-loading .lb-img,
.lb-stage.is-broken .lb-img { opacity: 0; }

.lb-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(242, 240, 236, 0.4);
  border-radius: 999px;
  background: rgba(14, 14, 13, 0.35);
  color: var(--lb-ink);
  cursor: pointer;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}

.lb-button:hover { border-color: var(--lb-ink); background: rgba(242, 240, 236, 0.08); }
.lb-button:disabled { opacity: 0.3; cursor: default; }
.lb-button:disabled:hover { border-color: rgba(242, 240, 236, 0.4); background: rgba(14, 14, 13, 0.35); }
.lb-button:focus-visible { outline-color: var(--lb-ink); }

.lb-close { border-color: transparent; background: transparent; }

.lb-actions { display: flex; gap: 8px; }

/* Download count and errors float over the photo while the lightbox is open. */
.lightbox .dl-bar {
  position: absolute;
  top: 76px;
  left: 50%;
  translate: -50% 0;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(14, 14, 13, 0.7);
  text-align: center;
  white-space: nowrap;
  z-index: 1;
}
.lightbox .dl-remaining { color: var(--lb-muted); }
.lightbox .dl-error { color: #f0a497; }

/* ---------- download PIN ---------- */

.pin-dialog {
  width: min(360px, calc(100% - 32px));
  padding: 28px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(14, 14, 13, 0.3);
}

.pin-dialog::backdrop { background: rgba(14, 14, 13, 0.55); }
.pin-title { margin: 0 0 20px; font: 400 1.5rem/1.2 var(--font-display); }
.pin-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

.lb-nav { display: contents; }

.lb-prev,
.lb-next {
  position: fixed;
  top: 50%;
  translate: 0 -50%;
  width: 52px;
  height: 52px;
}

.lb-prev { left: clamp(12px, 2vw, 28px); }
.lb-next { right: clamp(12px, 2vw, 28px); }

/* ---------- showcase ---------- */

/* Three rows of cards on a curved wall; viewer-showcase.js sets each slot's transform. Transitions run only while a
   row is stepping or snapping (data-motion), so drags and wheel moves follow the input directly. */
.showcase {
  --sc-w: clamp(160px, 22vw, 320px);
  --sc-h: calc(var(--sc-w) * 2 / 3);
  max-width: 1600px;
  margin: 8px auto 0;
  padding: 28px 0;
  overflow: hidden;
  background: var(--lb-bg);
  border-radius: 4px;
}

.sc-row {
  position: relative;
  height: calc(var(--sc-h) + 24px);
  margin: 0;
  padding: 0;
  list-style: none;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.sc-slot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--sc-w);
  height: var(--sc-h);
  margin: calc(var(--sc-h) / -2) 0 0 calc(var(--sc-w) / -2);
  will-change: transform;
}

.sc-row[data-motion="step"] .sc-slot { transition: transform 900ms var(--ease); }
.sc-row[data-motion="snap"] .sc-slot { transition: transform var(--fade) var(--ease); }
.sc-row .sc-slot.is-jump { transition: none; }

.sc-card {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: #1d1c1a;
  cursor: pointer;
}

.sc-card:focus-visible { outline: 2px solid var(--lb-ink); outline-offset: 3px; }

.sc-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--fade) var(--ease);
  -webkit-user-drag: none;
}

.sc-slot.is-loaded .sc-img { opacity: 1; }

.sc-pill {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(14 14 13 / 0.6);
  color: var(--lb-ink);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  :root { --row-h: 120px; --gap: 3px; }
  .view-gallery { padding: 0 3px 40px; }
  .showcase { --sc-w: clamp(104px, 30vw, 160px); padding: 16px 0; }
  .gallery-head { padding-left: 16px; padding-right: 16px; }

  .lightbox[open] { grid-template-rows: auto minmax(0, 1fr) auto; }
  .lb-stage { padding: 0; }
  .lb-nav {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .lb-prev,
  .lb-next { position: static; translate: none; width: 48px; height: 48px; }
  .lb-bar { gap: 8px; }
  .lb-actions { gap: 4px; }
  .lightbox .dl-bar { top: 68px; }
}

@media (hover: none) {
  .tile-button:hover .tile-img { transform: none; }
  .tile-heart { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
  .tile-button:hover .tile-img { transform: none; }
  .lock-star { animation: none !important; opacity: 0.6; }
  .lock-mark-gleam { display: none; }
}
