/* UI layer for the canvas stage, media tiles, tooltip, and filter controls.
 * The restrained glass surfaces preserve the archive's airy visual language. */
:root { --bg: #0e0e0f; --radius: 18px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; width: 100%; overflow: hidden;
  background: var(--bg); color: #ddd;
  overscroll-behavior: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  font: 12px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
}
body { position: fixed; inset: 0; }
#stage {
  position: absolute; inset: 0; overflow: hidden; touch-action: none;
  cursor: grab; contain: strict;
  background: radial-gradient(120% 90% at 50% 40%, #151517 0%, var(--bg) 70%);
}
#stage.dragging { cursor: grabbing; }
.tile {
  position: absolute; left: 0; top: 0; display: block;
  transform-origin: 0 0; will-change: transform;
  border-radius: var(--radius); overflow: hidden;
  background: #1a1a1c;
  box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.04);
  -webkit-user-drag: none; user-select: none; outline: none;
  contain: layout paint;
}
.tile img, .tile video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; display: block; pointer-events: none;  /* tile is sized to the item's aspect: never crop */
  -webkit-user-drag: none;
}
.tile img { opacity: 0; transition: opacity .35s ease; }
.tile img.ready { opacity: 1; }
.tile video { opacity: 0; transition: opacity .3s ease; }
.tile video.playing { opacity: 1; }
@media (hover: hover) {
  #stage:not(.dragging) .tile:hover { box-shadow: 0 14px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.12); }
}
#tip {
  position: fixed; left: 0; top: 0; z-index: 10; pointer-events: none;
  max-width: min(300px, calc(100vw - 24px));
  padding: 9px 12px 10px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.42; letter-spacing: .005em; color: rgba(255,255,255,.88);
  background: rgba(22,22,24,.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 12px 32px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.08);
  opacity: 0; transform: translate3d(var(--x,0), var(--y,0), 0) scale(.97);
  transition: opacity .18s ease, transform .18s ease; will-change: transform, opacity;
}
#tip.on { opacity: 1; transform: translate3d(var(--x,0), var(--y,0), 0) scale(1); }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: #555; font-size: 13px; }

.filters {
  position: fixed; top: max(18px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left));
  z-index: 20; width: min(360px, calc(100vw - 36px)); pointer-events: none;
  touch-action: pan-y;
}
.filters button { font: inherit; color: inherit; }
.filters-toggle {
  min-height: 38px; padding: 0 15px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px;
  color: rgba(255,255,255,.78); background: rgba(22,22,24,.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 8px 28px rgba(0,0,0,.28); cursor: pointer; pointer-events: auto;
}
.filters.active .filters-toggle {
  color: #f3f3f3; border-color: rgba(255,255,255,.2); background: rgba(38,38,41,.86);
}
.filters-panel {
  margin-top: 9px; padding: 16px; border: 1px solid rgba(255,255,255,.08); border-radius: 18px;
  background: rgba(18,18,20,.86);
  -webkit-backdrop-filter: blur(24px) saturate(1.25); backdrop-filter: blur(24px) saturate(1.25);
  box-shadow: 0 18px 48px rgba(0,0,0,.42);
  opacity: 0; visibility: hidden; transform: translateY(-5px) scale(.985);
  transform-origin: top left; transition: opacity .16s ease, transform .16s ease, visibility .16s;
  pointer-events: none; max-height: min(76vh, 520px); overflow-y: auto; overscroll-behavior: contain;
}
.filters.open .filters-panel {
  opacity: 1; visibility: visible; transform: translateY(0) scale(1); pointer-events: auto;
}
.filter-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.filters-result { color: rgba(255,255,255,.55); letter-spacing: .01em; }
.filters-clear {
  min-height: 30px; padding: 0; border: 0; color: rgba(255,255,255,.78); background: none; cursor: pointer;
}
.filters-clear:disabled { color: rgba(255,255,255,.25); cursor: default; }
.filters fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.filters fieldset + fieldset { margin-top: 17px; }
.filters legend {
  margin: 0 0 9px; padding: 0; color: rgba(255,255,255,.42);
  font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip {
  min-height: 34px; padding: 0 11px; border: 1px solid rgba(255,255,255,.08); border-radius: 999px;
  color: rgba(255,255,255,.62); background: rgba(255,255,255,.035); cursor: pointer;
}
.filter-chip.selected {
  color: #f2f2f2; border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.13);
}
.filter-chip:focus-visible, .filters-toggle:focus-visible, .filters-clear:focus-visible {
  outline: 2px solid rgba(255,255,255,.72); outline-offset: 2px;
}
.filter-empty {
  position: fixed; left: 50%; top: 50%; z-index: 5; transform: translate(-50%, -50%);
  color: rgba(255,255,255,.38); font-size: 13px; pointer-events: none;
}
@media (max-width: 520px) {
  .filters {
    top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
    width: min(360px, calc(100vw - 24px));
  }
  .filters-panel { padding: 14px; max-height: calc(100vh - 72px - env(safe-area-inset-top)); }
  .filter-chip { min-height: 38px; padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .filters-panel { transition: none; }
}
