/* egor's wallpapers — gallery-quiet, dark only. The images are the color. */

:root {
  --bg: #0a0a0b;
  --bg-2: #111113;
  --fg: #ecebe8;
  --mute: #8b8a86;
  --dim: #55544f;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);

  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;

  --gutter: clamp(16px, 3vw, 40px);
  --radius: 4px;

  /* motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);      /* expo-ish: fast in, long settle */
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  background: var(--bg);
  color: var(--fg);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scrollbar-color: #2a2a2d var(--bg);
}
body { margin: 0; min-height: 100vh; background: var(--bg); overflow-x: hidden; }
html.locked { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.dim { color: var(--mute); }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; border-radius: 2px; }
::selection { background: rgba(255, 255, 255, 0.18); }

/* ---------- film grain (cinematic, costs almost nothing) ---------- */
.grain {
  position: fixed; inset: -50%; z-index: 100; pointer-events: none; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

/* ---------- header ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  padding: 18px var(--gutter) 0;
  transition: transform 0.6s var(--ease-out), background-color 0.4s, backdrop-filter 0.4s;
}
.bar::after {
  content: ''; position: absolute; inset: auto 0 0; height: 1px; background: var(--line);
  opacity: 0; transition: opacity 0.4s;
}
.bar.scrolled {
  background: rgba(10, 10, 11, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
}
.bar.scrolled::after { opacity: 1; }
.bar.hide { transform: translateY(-100%); }
.bar-row { display: flex; align-items: center; gap: 16px; }
.bar-row.sub { margin-top: 14px; gap: 12px; }

.mark {
  font-family: var(--serif); font-size: 30px; line-height: 1; letter-spacing: -0.01em; white-space: nowrap;
  transition: font-size 0.5s var(--ease-out);
}
.mark em { font-style: italic; color: var(--mute); }
.bar.scrolled .mark { font-size: 24px; }
.count { color: var(--mute); padding-top: 6px; }
.actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px;
  border-radius: 999px; font-size: 13px; white-space: nowrap;
  transition: background-color 0.25s, color 0.25s, border-color 0.25s, transform 0.4s var(--ease-out);
}
.btn:active { transform: scale(0.96); }
.btn.ghost { border: 1px solid var(--line-2); color: var(--fg); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.2); }
.btn.solid { background: var(--fg); color: #0a0a0b; font-weight: 500; }
.btn.solid:hover { background: #fff; }
.btn.solid .dim { color: rgba(10, 10, 11, 0.55); }
#shuffle svg { transition: transform 0.6s var(--ease-out); }
#shuffle:hover svg { transform: rotate(180deg); }

.chips {
  position: relative; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  margin-left: -10px; padding-bottom: 14px; flex: 1; min-width: 0;
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative; z-index: 1; height: 30px; padding: 0 10px; border-radius: 999px;
  color: var(--mute); font-size: 13px; white-space: nowrap; transition: color 0.3s;
}
.chip:hover { color: var(--fg); }
.chip[aria-pressed='true'] { color: var(--fg); }
.chip sup { font-family: var(--mono); font-size: 9px; margin-left: 3px; color: var(--dim); vertical-align: 6px; }
.chip-pill {
  position: absolute; left: 0; top: 0; height: 30px; width: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.55s var(--ease-out), width 0.55s var(--ease-out);
}
.sort {
  height: 30px; padding: 0 2px 0 10px; margin-bottom: 14px; color: var(--mute);
  display: inline-flex; align-items: center; gap: 6px; transition: color 0.3s;
}
.sort:hover { color: var(--fg); }
.sort::after { content: '↓'; display: inline-block; transition: transform 0.5s var(--ease-out); }
.sort.asc::after { transform: rotate(180deg); }

/* ---------- masonry grid ---------- */
main { padding: 10px var(--gutter) 0; }
.grid { position: relative; min-height: 60vh; }
.tile {
  position: absolute; left: 0; top: 0; display: block;
  will-change: transform;
}
.grid.animating .tile { transition: transform 0.9s var(--ease-out); }
.tile.gone { visibility: hidden; pointer-events: none; }
.par { width: 100%; height: 100%; transform: translate3d(0, var(--py, 0px), 0); }
.card {
  width: 100%; height: 100%;
  opacity: 0; transform: translate3d(0, 56px, 0) scale(0.96);
  clip-path: inset(14% 0 0 0 round var(--radius));
}
.card.in {
  opacity: 1; transform: none; clip-path: inset(0 0 0 0 round var(--radius));
  transition: opacity 0.9s var(--ease-soft), transform 1.3s var(--ease-out), clip-path 1.3s var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.card.out {
  opacity: 0; transform: scale(0.92); transition: opacity 0.35s, transform 0.5s var(--ease-out);
  transition-delay: 0ms;
}
.tilt {
  position: relative; width: 100%; height: 100%; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-2);
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--s, 1));
  transition: transform 0.7s var(--ease-out), box-shadow 0.7s var(--ease-out);
  box-shadow: 0 0 0 0 transparent;
}
.lq { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(14px); transform: scale(1.15); }
.tile picture, .tile img { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile img {
  object-fit: cover; opacity: 0; transform: scale(1.06); filter: blur(10px);
  transition: opacity 0.8s var(--ease-soft), transform 1.4s var(--ease-out), filter 0.9s var(--ease-soft);
}
.tile img.ok { opacity: 1; transform: none; filter: none; }
.lit {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; mix-blend-mode: soft-light;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.55), transparent 55%);
  transition: opacity 0.5s;
}
.meta {
  position: absolute; inset: auto 0 0; padding: 36px 12px 10px; display: flex; align-items: flex-end; gap: 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), transparent);
  opacity: 0; transform: translateY(6px); transition: opacity 0.4s, transform 0.6s var(--ease-out);
}
.meta b { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.meta .mono { margin-left: auto; color: rgba(255, 255, 255, 0.7); white-space: nowrap; }
.new {
  position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 7px; border-radius: 999px; font: 500 10px/1.4 var(--mono); letter-spacing: 0.06em; text-transform: lowercase;
  background: rgba(10, 10, 11, 0.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: var(--fg);
}
.new::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px #fff; animation: pulse 2.4s var(--ease-io) infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

@media (hover: hover) and (pointer: fine) {
  .tile:hover .tilt {
    --s: 1.025;
    box-shadow: 0 30px 70px -22px color-mix(in srgb, var(--c) 75%, transparent), 0 0 0 1px rgba(255, 255, 255, 0.06);
    transition: transform 0.25s var(--ease-out), box-shadow 0.7s var(--ease-out);
  }
  .tile:hover .lit, .tile:hover .meta { opacity: 1; transform: none; }
}
.tile:focus-visible { outline: none; }
.tile:focus-visible .tilt { outline: 1px solid var(--fg); outline-offset: 3px; }
.tile.held .card { visibility: hidden; }

.empty[hidden] { display: none; }
.empty { display: grid; place-items: center; gap: 12px; text-align: center; padding: 18vh 0; color: var(--mute); }
.empty em { font: italic 44px/1 var(--serif); color: var(--fg); }

.foot {
  display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between;
  padding: 80px var(--gutter) 36px; color: var(--dim);
}
.foot a { color: var(--mute); transition: color 0.3s; }
.foot a:hover { color: var(--fg); }

/* ---------- lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 50; overflow: hidden; touch-action: none; }
.lb[hidden] { display: none; }
.lb-amb { position: absolute; inset: 0; background: #070708; opacity: 0; }
.amb {
  position: absolute; inset: -20%; opacity: 0;
  background:
    radial-gradient(45% 50% at 18% 22%, var(--a0, #222), transparent 70%),
    radial-gradient(45% 50% at 82% 20%, var(--a1, #222), transparent 70%),
    radial-gradient(50% 55% at 20% 82%, var(--a2, #222), transparent 70%),
    radial-gradient(50% 55% at 80% 84%, var(--a3, #222), transparent 70%),
    var(--a4, #111);
  filter: blur(70px) saturate(1.35);
  transition: opacity 1.1s var(--ease-soft);
  animation: drift 26s var(--ease-io) infinite alternate;
}
.amb.on { opacity: 1; }
@keyframes drift {
  from { transform: rotate(0deg) scale(1); }
  to { transform: rotate(8deg) scale(1.12); }
}
.lb-shade { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 45%, rgba(8, 8, 9, 0.35), rgba(8, 8, 9, 0.82)); }

.lb-stage { position: absolute; inset: 0; }
.fig {
  position: absolute; margin: 0; transform-origin: 0 0; will-change: transform, opacity;
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, 0.8);
  border-radius: 2px; overflow: hidden; background: #000;
}
.fig img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; }
.fig .hi { opacity: 0; transition: opacity 0.6s var(--ease-soft); }
.fig .hi.ok { opacity: 1; }
.fig .spin {
  position: absolute; right: 12px; bottom: 12px; width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: spin 0.8s linear infinite;
  transition: opacity 0.3s;
}
.fig .hi.ok ~ .spin { opacity: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.lb-close, .lb-nav {
  position: absolute; z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  color: var(--fg); background: rgba(10, 10, 11, 0.35); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background-color 0.25s, transform 0.5s var(--ease-out), opacity 0.4s;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, 0.12); }
.lb-close { top: 16px; right: 16px; }
.lb-nav { top: 50%; margin-top: -22px; }
.lb-nav.prev { left: 16px; } .lb-nav.next { right: 16px; }
.lb-nav.prev:hover { transform: translateX(-3px); } .lb-nav.next:hover { transform: translateX(3px); }
.lb-close svg, .lb-nav svg { width: 18px; height: 18px; }

.lb-info {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  padding: 18px 24px calc(20px + env(safe-area-inset-bottom));
}
.lb-text { min-width: 0; flex: 1; }
.lb-idx { color: rgba(255, 255, 255, 0.5); }
.lb-title { margin: 2px 0 2px; font: 400 32px/1.05 var(--serif); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-spec { margin: 0; color: rgba(255, 255, 255, 0.62); }
.lb-spec i { font-style: normal; color: rgba(255, 255, 255, 0.28); margin: 0 6px; }
.lb-actions { display: flex; gap: 8px; }
.lb-actions .btn.ghost { background: rgba(10, 10, 11, 0.3); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.lb-chrome { opacity: 0; }
.lb.ready .lb-chrome { opacity: 1; transform: none; transition: opacity 0.6s var(--ease-soft) 0.15s, transform 0.8s var(--ease-out) 0.15s; }
.lb-info.lb-chrome { transform: translateY(14px); }
.lb.ready .lb-info.lb-chrome { transform: none; }
.lb.leaving .lb-chrome { opacity: 0; transition: opacity 0.25s; }
.lb.idle .lb-chrome { opacity: 0; transition: opacity 0.8s; }
.lb.idle { cursor: none; }
.swap { animation: swap 0.6s var(--ease-out); }
@keyframes swap { from { opacity: 0; transform: translateY(8px); } }

/* ---------- intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; place-items: center; overflow: hidden;
  cursor: pointer;
}
.intro-img {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  clip-path: inset(50% 50% 50% 50%); transform: scale(1.25); filter: brightness(0.55) saturate(1.1);
}
.intro-word { position: relative; text-align: center; }
.intro-word .w { display: inline-block; overflow: hidden; vertical-align: bottom; padding: 0 0.04em 0.12em; }
.intro-word .w > span { display: inline-block; transform: translateY(110%); }
.intro-title { font: 400 clamp(56px, 11vw, 168px)/0.95 var(--serif); letter-spacing: -0.02em; margin: 0; }
.intro-title .w:last-child { font-style: italic; }
.intro-meta { margin-top: 18px; display: flex; justify-content: center; gap: 14px; color: var(--mute); opacity: 0; }
.intro-line { position: absolute; left: 0; bottom: 0; height: 1px; width: 100%; background: var(--fg); transform: scaleX(0); transform-origin: 0 50%; opacity: 0.5; }

/* ---------- misc ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 70; transform: translate(-50%, 20px); opacity: 0;
  padding: 9px 14px; border-radius: 999px; background: var(--fg); color: #0a0a0b; font-size: 13px; font-weight: 500;
  transition: opacity 0.3s, transform 0.5s var(--ease-out); pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 40px var(--gutter); color: var(--mute); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 640px) {
  .mark { font-size: 26px; }
  .bar.scrolled .mark { font-size: 22px; }
  .count { display: none; }
  #shuffle span { display: none; }
  #shuffle { width: 34px; padding: 0; justify-content: center; }
  .lb-nav { display: none; }
  .lb-title { font-size: 26px; }
  .lb-info { gap: 14px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
  .lb-actions { width: 100%; }
  .lb-actions .btn { flex: 1; justify-content: center; }
  .lb-close { top: 12px; right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0ms !important; }
  .card { opacity: 1; transform: none; clip-path: none; }
  .tilt { transform: none !important; }
  .grain { animation: none; }
}
