/* ==========================================================================
   Photography wall — black & white, 3 staggered rows, slow right-to-left drift
   ========================================================================== */

:root {
  --font-ui: "Helvetica Neue", "Inter", "Segoe UI", system-ui, -apple-system,
             "PingFang SC", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* layout ---------------------------------------------------------------- */
  --stage-w: 82vw;                            /* the wall takes most of the page */
  --tile-w: clamp(170px, min(calc(var(--stage-w) * 0.24), 34vh), 470px);
  --gap: clamp(9px, 1.1vw, 22px);
  --photo-ratio: 3 / 2;                       /* match the originals (change to 4 / 3 if needed) */

  /* light (day) palette --------------------------------------------------- */
  --bg: #f6f5f2;
  --fg: #121211;
  --muted: #77746c;
  --line: rgba(18, 18, 17, 0.14);
  --tile-bg: #e7e5df;
  --shadow: 0 1px 2px rgba(18, 18, 17, 0.08), 0 8px 26px rgba(18, 18, 17, 0.05);

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #080808;
  --fg: #f2f0eb;
  --muted: #8b887f;
  --line: rgba(242, 240, 235, 0.15);
  --tile-bg: #151515;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 12px 34px rgba(0, 0, 0, 0.35);

  color-scheme: dark;
}

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

html { height: 100%; }

body {
  min-height: 100svh;
  margin: 0;
  padding: clamp(16px, 2.7vh, 34px) clamp(18px, 3.6vw, 56px) clamp(14px, 2.2vh, 26px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 24px);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.7s var(--ease), color 0.7s var(--ease);
}

/* film grain ------------------------------------------------------------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: 0.055;
  mix-blend-mode: multiply;
  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.82' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
  background-size: 180px 180px;
}

[data-theme="dark"] .grain {
  opacity: 0.085;
  mix-blend-mode: screen;
}

/* top bar ---------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.65em;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.brand__name {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: none;
}
.brand__sep  { color: var(--muted); }
.brand__role { color: var(--muted); }

.topbar__right {
  display: inline-flex;
  align-items: center;
  gap: clamp(10px, 1.4vw, 20px);
}

.clock {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 0.3s var(--ease), border-color 0.3s var(--ease),
              transform 0.3s var(--ease);
}

.theme-toggle:hover { background: var(--line); }
.theme-toggle:active { transform: scale(0.94); }

.theme-toggle .icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* only one icon is visible at a time */
.icon--moon { display: none; }
[data-theme="dark"] .icon--sun { display: none; }
[data-theme="dark"] .icon--moon { display: block; }

/* stage ------------------------------------------------------------------ */
.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  width: var(--stage-w);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 6.5%, #000 93.5%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, #000 6.5%, #000 93.5%, transparent 100%);
}

.stage.is-dragging,
.stage.is-dragging .tile { cursor: grabbing; }

.row {
  overflow: hidden;
  display: block;
}

.track {
  display: flex;
  width: max-content;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.set {
  display: flex;
  gap: var(--gap);
  padding-right: var(--gap); /* makes one set exactly setW wide, seam hidden */
}

/* tiles ------------------------------------------------------------------ */
.tile {
  position: relative;
  flex: 0 0 auto;
  display: block;
  width: var(--tile-w);
  aspect-ratio: var(--photo-ratio);
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--tile-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform 1.6s var(--ease), filter 0.6s var(--ease);
  user-select: none;
  -webkit-user-drag: none;
}

.tile:hover img,
.tile:focus-visible img {
  transform: scale(1.045);
}

.tile__meta {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 26px 12px 10px;
  color: #fff;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: left;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
  pointer-events: none;
}

.tile__meta span:last-child {
  color: rgba(255, 255, 255, 0.66);
  white-space: nowrap;
}

.tile:hover .tile__meta,
.tile:focus-visible .tile__meta {
  opacity: 1;
  transform: none;
}

.tile:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
}

/* hover / focus pause and dragging are handled in js/main.js */

/* footer ----------------------------------------------------------------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.footer__hint { text-align: right; }

/* lightbox --------------------------------------------------------------- */
.lightbox {
  width: min(90vw, 1500px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  overflow: visible;
}

.lightbox[open] {
  display: grid;
  place-items: center;
  animation: lb-in 0.4s var(--ease) both;
}

.lightbox::backdrop {
  background: rgba(246, 245, 242, 0.93);
  backdrop-filter: blur(18px) saturate(0.9);
  -webkit-backdrop-filter: blur(18px) saturate(0.9);
}

[data-theme="dark"] .lightbox::backdrop {
  background: rgba(6, 6, 6, 0.94);
}

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

.lb-figure {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 16px;
}

.lb-image {
  display: block;
  max-width: 100%;
  max-height: 76vh;
  width: auto;
  height: auto;
  background: var(--tile-bg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.22);
  -webkit-touch-callout: default;
  user-select: auto;
}

.lb-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#lbMeta { color: var(--muted); }

.lb-save {
  display: inline-flex;
  align-items: center;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 0.25s var(--ease);
}

.lb-save:hover { background: var(--line); }

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

.lb-hint {
  display: none;
  margin: 0;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-align: center;
}

@media (hover: none), (pointer: coarse) {
  .lb-hint { display: block; }

  .lb-save {
    padding: 10px 16px;
    font-size: 10px;
  }
}

.lb-close,
.lb-nav {
  position: fixed;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 0.25s var(--ease), transform 0.25s var(--ease);
}

.lb-close:hover,
.lb-nav:hover { background: var(--line); }
.lb-close:active,
.lb-nav:active { transform: scale(0.94); }

.lb-close {
  top: clamp(16px, 3vw, 32px);
  right: clamp(16px, 3vw, 34px);
  width: 40px;
  height: 40px;
}

.lb-nav {
  top: 50%;
  translate: 0 -50%;
  width: 46px;
  height: 46px;
}

.lb-nav--prev { left: clamp(12px, 2.4vw, 32px); }
.lb-nav--next { right: clamp(12px, 2.4vw, 32px); }

.lb-close svg,
.lb-nav svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-close:focus-visible,
.lb-nav:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

/* misc ------------------------------------------------------------------- */
.noscript {
  position: fixed;
  inset: auto 0 50% 0;
  text-align: center;
  color: var(--muted);
}

.empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-align: center;
}

/* responsive ------------------------------------------------------------- */
@media (max-width: 900px) {
  :root {
    --stage-w: 88vw;
    --tile-w: clamp(150px, min(calc(var(--stage-w) * 0.38), 25vh), 360px);
    --gap: clamp(7px, 1.3vw, 16px);
  }
}

@media (max-width: 700px) {
  /* two labels do not fit on a small tile */
  .tile__meta span:last-child { display: none; }
  .tile__meta { font-size: 8.5px; padding: 20px 9px 8px; }

  /* phones navigate the lightbox by swiping instead */
  .lb-nav { display: none; }
}

@media (max-width: 560px) {
  :root {
    --stage-w: 94vw;
    --tile-w: clamp(120px, min(calc(var(--stage-w) * 0.46), 21vh), 300px);
    --gap: 7px;
  }

  .brand__role,
  .brand__sep { display: none; }

  .lb-nav { width: 38px; height: 38px; }
  .lb-image { max-height: 68vh; }
}

/* landscape phones: keep three rows on screen */
@media (max-height: 540px) {
  :root {
    --tile-w: clamp(88px, 24vh, 200px);
    --gap: 6px;
  }

  body { padding-block: 10px; gap: 8px; }
  .topbar { font-size: 9px; }
}

/* motion & contrast preferences ------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .tile img,
  .theme-toggle,
  .lightbox { transition: none !important; }
  .lightbox[open] { animation: none; }
}
