/* The photo grid: date headers, square or justified tiles, badges, selection,
   the date scrubber. Tiles are positioned by grid.js with transforms. */

.grid {
  position: relative;
  outline: none;
  touch-action: pan-y;
  contain: layout style;
}
.grid:focus-visible { box-shadow: none; }
.grid-canvas {
  position: relative;
  width: 100%;
  transform-origin: 50% 0;
  transition: transform 90ms linear;
}
.grid-empty[hidden] { display: none; }

.grid-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 16px 10px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  pointer-events: none;
}
.grid.dense .grid-header { font-size: 15px; }
.gh-label { pointer-events: auto; text-shadow: 0 1px 10px var(--shadow-ink-soft); }
.gh-check {
  display: none;
  width: 26px;
  height: 26px;
  margin-left: -4px;
  border-radius: 50%;
  color: var(--text-2);
  pointer-events: auto;
}
.gh-check svg { width: 22px; height: 22px; }
.grid.selecting .gh-check { display: inline-grid; place-items: center; }
.grid-header.all-selected .gh-check { color: var(--accent); }
@media (hover: hover) {
  .grid-header:hover .gh-check { display: inline-grid; place-items: center; }
}

.tile {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  background-color: var(--tile-bg);
  background-size: cover;
  background-position: center;
  border-radius: 2px;
  cursor: pointer;
  contain: strict;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  dynamic-range-limit: standard;
}
.grid:not(.dense) .tile { border-radius: 3px; }
@media (min-width: 600px) { .grid:not(.dense) .tile { border-radius: 6px; } }
.tile[hidden] { display: none; }
.tile-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 180ms var(--ease), transform var(--t-med) var(--ease);
  pointer-events: none;
}
.tile-img.loaded { opacity: 1; }
.grid.natural .tile-img { object-fit: cover; }
.tile::after {
  /* hover veil + selection tint */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
@media (hover: hover) {
  .tile:hover::after { background: linear-gradient(to bottom, var(--tile-veil), transparent 32%); }
}
.tile:focus-visible { box-shadow: none; }
.tile:focus-visible::after { box-shadow: inset 0 0 0 3px var(--accent); }
.tile.is-pending:not(:has(.tile-img.loaded)) {
  background-image: linear-gradient(100deg, transparent 30%, var(--shimmer) 50%, transparent 70%) !important;
  background-size: 220% 100%;
  animation: tile-shimmer 1.6s linear infinite;
}
@keyframes tile-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* badges */
.tile-hdr, .tile-video, .tile-fav, .tile-err, .tile-check { position: absolute; display: none; pointer-events: none; }
.tile.is-hdr .tile-hdr { display: inline-flex; top: 6px; right: 6px; height: 18px; padding: 0 6px; font-size: 10px; }
.tile.is-video .tile-video { display: inline-flex; right: 6px; bottom: 6px; height: 20px; gap: 3px; }
.tile-video svg { width: 10px; height: 10px; }
.tile.is-fav .tile-fav { display: block; left: 6px; bottom: 5px; color: var(--fav-ink); filter: drop-shadow(0 1px 3px var(--fav-shadow)); }
.tile.is-error .tile-err { display: grid; place-items: center; inset: 0; color: var(--muted); }
.grid.dense .tile-hdr, .grid.dense .tile-fav { display: none !important; }
.grid.dense .tile.is-video .tile-video { right: 3px; bottom: 3px; height: 16px; padding: 0 4px; font-size: 9.5px; }

/* selection */
.tile-check {
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--accent);
  pointer-events: auto;
  cursor: pointer;
}
.tile-check svg { width: 24px; height: 24px; }
.tile-check svg circle { fill: var(--check-fill); stroke: var(--check-ring); stroke-width: 1.6; }
.tile-check svg path { stroke: transparent; }
.grid.selecting .tile-check { display: block; }
@media (hover: hover) {
  .tile:hover .tile-check { display: block; opacity: .9; }
}
.tile.is-selected .tile-check svg circle { fill: var(--accent); stroke: var(--accent); }
.tile.is-selected .tile-check svg path { stroke: var(--accent-ink); }
.tile.is-selected .tile-img { transform: scale(.86); border-radius: 8px; }
.tile.is-selected { background-image: none !important; background-color: var(--accent-soft) !important; }
.grid.selecting .tile:not(.is-selected)::after { background: linear-gradient(to bottom, var(--tile-veil-soft), transparent 35%); }
.grid.dense .tile-check { top: 3px; left: 3px; width: 18px; height: 18px; }
.grid.dense .tile-check svg { width: 18px; height: 18px; }

/* "Sorted into ..." highlight after an upload */
.tile.flash::after { animation: tile-flash 1.8s var(--ease) both; }
@keyframes tile-flash {
  0%, 30% { box-shadow: inset 0 0 0 3px var(--accent); background: var(--accent-soft); }
  100% { box-shadow: inset 0 0 0 0 transparent; background: transparent; }
}

/* ---- date scrubber ------------------------------------------------------------------- */
.scrubber {
  position: fixed;
  top: 0;
  right: calc(2px + var(--safe-r));
  bottom: 0;
  z-index: var(--z-scrubber);
  width: 30px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease);
}
.scrubber.enabled.show, .scrubber.enabled.dragging { opacity: 1; pointer-events: auto; }
:root.viewer-open .scrubber { display: none; }
.scrub-thumb {
  position: absolute;
  top: 0;
  right: 4px;
  width: 22px;
  height: 40px;
  border-radius: 11px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border-strong);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor: grab;
  touch-action: none;
}
.scrub-thumb::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-top: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
}
.scrubber.dragging .scrub-thumb { cursor: grabbing; background: var(--accent); border-color: transparent; }
.scrub-bubble {
  position: absolute;
  top: 0;
  right: 36px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: var(--fs-sm);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
  pointer-events: none;
}
.scrubber.dragging .scrub-bubble:not(:empty) { opacity: 1; }
.scrub-marks { position: absolute; inset: 0; pointer-events: none; }
.scrub-year {
  position: absolute;
  top: 0;
  right: 32px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
}
.scrubber.dragging .scrub-year, .scrubber:hover .scrub-year { opacity: 1; }

/* ---- views around the grid ----------------------------------------------------------------- */
.scan-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin: 4px auto 14px;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.scan-chip .spinner { width: 16px; height: 16px; border-width: 2px; }
.view-intro { margin: 2px 0 16px; color: var(--muted); font-size: var(--fs-sm); }

/* search */
.search-bar {
  position: sticky;
  top: calc(var(--content-top) - 4px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 6px 6px 6px 16px;
  border-radius: var(--r-pill);
}
.search-bar svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  font-size: var(--fs-lg);
}
.search-input::-webkit-search-cancel-button { display: none; }
.search-suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.search-count { margin: 0 0 8px; color: var(--muted); font-size: var(--fs-sm); }

/* trash */
.trash-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.trash-info p { flex: 1 1 260px; }
