/* Anecdote — Gallery. A calm uniform wall of every key-work image.
 * Square tiles cropped around each image's stored focal point, a sticky
 * search/filter bar, and three choreographed moments:
 *   1. the build   — tiles cascade in as they enter the viewport
 *   2. the filter  — leavers shrink away in place while survivors GLIDE
 *                    to their new grid position (FLIP, driven from gallery.js)
 *   3. the open    — a clicked image grows out of its square into the
 *                    shared lightbox (clone flight, driven from gallery.js)
 * Everything respects prefers-reduced-motion.
 */

.ga-page [hidden] { display: none !important; } /* site-wide lesson: author display rules must never beat [hidden] */

.ga-page { background: var(--bg); }
.ga-main { max-width: 1560px; margin: 0 auto; padding: 0 26px 64px; }

/* ═══ sticky search + filter bar ═══ */
.ga-bar {
  position: sticky; top: 0; z-index: 60;
  background: var(--bg);
  padding: 14px 0 10px;
  border-bottom: 1px solid rgba(var(--ink-rgb),.14);
  margin-bottom: 22px;
}
.ga-bar-row { display: flex; align-items: center; gap: 14px; }
.ga-bar-row--search { margin-bottom: 10px; }

.ga-search {
  position: relative; flex: 1; max-width: 620px;
  display: flex; align-items: center;
}
.ga-search-ico { position: absolute; left: 14px; color: var(--mute); pointer-events: none; }
.ga-search input {
  width: 100%; padding: 10px 38px 10px 38px;
  font: 500 14px/1.3 Inter, sans-serif; color: var(--ink);
  background: var(--paper, var(--bg)); border: 1px solid rgba(var(--ink-rgb),.22); border-radius: 999px;
  outline: none; transition: border-color .18s ease, box-shadow .18s ease;
  -webkit-appearance: none; appearance: none;
}
.ga-search input::-webkit-search-cancel-button { display: none; }
.ga-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196, 74, 42, .12); }
.ga-search input::placeholder { color: var(--mute); font-weight: 400; }
.ga-search-clear {
  position: absolute; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: none; color: var(--mute); font-size: 12px; cursor: pointer;
}
.ga-search-clear:hover { color: var(--ink); background: rgba(var(--ink-rgb),.1); }

.ga-count { font: 600 12px/1 Inter, sans-serif; color: var(--mute); letter-spacing: .02em; white-space: nowrap; }
.ga-shuffle {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border: 1px solid rgba(var(--ink-rgb),.22); border-radius: 999px;
  background: none; color: var(--ink); font: 600 12px/1 Inter, sans-serif; cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
  white-space: nowrap;
}
.ga-shuffle:hover { border-color: var(--ink); }
.ga-shuffle:active svg { transform: rotate(180deg); }
.ga-shuffle svg { transition: transform .35s ease; }

/* section chips — the dictionary's .dict-finder-chip design (dictionary.css),
   with an on-state added for filtering */
.ga-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.ga-seczip { white-space: nowrap; transition: background .16s ease, border-color .16s ease, color .16s ease; }
.ga-seczip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* year range — two overlapped native ranges over a drawn track */
.ga-years { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.ga-year-label { font: 600 11.5px/1 Inter, sans-serif; color: var(--mute); font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }
.ga-range { position: relative; width: clamp(140px, 18vw, 240px); height: 24px; }
.ga-range-track {
  position: absolute; left: 0; right: 0; top: 50%; height: 2px; transform: translateY(-50%);
  background: rgba(var(--ink-rgb),.18); border-radius: 2px;
}
.ga-range-fill {
  position: absolute; top: 50%; height: 2px; transform: translateY(-50%);
  background: var(--accent); border-radius: 2px;
}
.ga-range input[type="range"] {
  position: absolute; inset: 0; width: 100%; margin: 0;
  -webkit-appearance: none; appearance: none; background: none; pointer-events: none;
}
.ga-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--ink); cursor: grab;
  transition: transform .15s ease;
}
.ga-range input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
.ga-range input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; border-color: var(--accent); }
.ga-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto; width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--ink); cursor: grab;
}
.ga-clearall {
  padding: 6px 12px; border: 0; border-radius: 999px; background: none;
  color: var(--accent); font: 600 12px/1 Inter, sans-serif; cursor: pointer; white-space: nowrap;
}
.ga-clearall:hover { text-decoration: underline; }

/* ═══ the wall ═══ */
.ga-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 28px;
}
.ga-tile {
  position: relative; padding: 0; border: 0; background: rgba(var(--ink-rgb),.07);
  aspect-ratio: 1 / 1; overflow: hidden; cursor: zoom-in;
  /* the build: each tile starts sunken and fades up when it enters the viewport
     (gallery.js adds .is-in with a small stagger) */
  opacity: 0; transform: translateY(14px) scale(.98);
  transition: opacity .45s cubic-bezier(.2,.6,.25,1), transform .45s cubic-bezier(.2,.6,.25,1);
}
.ga-tile.is-in { opacity: 1; transform: none; }
/* filter choreography: survivors get an inline FLIP transform from gallery.js,
   then glide back to identity through this transition */
.ga-tile.is-gliding { transition: transform .42s cubic-bezier(.3,.7,.2,1); }
.ga-tile img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .5s cubic-bezier(.2,.6,.25,1);
}
.ga-tile:hover img { transform: scale(1.045); }
/* leaving clones (spawned by gallery.js at the tile's old rect) */
.ga-ghost {
  position: absolute; overflow: hidden; pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.ga-ghost img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ga-ghost.is-out { opacity: 0; transform: scale(.86); }

/* hover chrome: caption + save (hover devices only — touch gets the lightbox) */
.ga-tile-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 10px;
  background: linear-gradient(to top, rgba(12,10,8,.72), rgba(12,10,8,0));
  color: #f4f1ea; text-align: left;
  font: 600 12px/1.35 Inter, sans-serif;
  opacity: 0; transform: translateY(6px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}
.ga-tile-cap b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ga-tile-cap span { display: block; font-weight: 500; font-size: 11px; opacity: .78; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ga-tile-save {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  padding: 7px 13px; border: 0; border-radius: 999px;
  background: var(--accent); color: #fff;
  font: 700 12px/1 Inter, sans-serif; cursor: pointer;
  opacity: 0; transform: translateY(-6px);
  transition: opacity .22s ease, transform .22s ease, background .15s ease;
}
.ga-tile-save:hover { background: #a93d21; }
@media (hover: hover) {
  .ga-tile:hover .ga-tile-cap,
  .ga-tile:focus-visible .ga-tile-cap { opacity: 1; transform: none; }
  .ga-tile:hover .ga-tile-save,
  .ga-tile:focus-visible .ga-tile-save { opacity: 1; transform: none; }
}

/* the open: the clicked image's clone flies from its square to the lightbox's
   fitted frame; the lightbox's own backdrop dims beneath (one dark layer) */
.ga-fly {
  position: fixed; z-index: 500; overflow: hidden;
  pointer-events: none;   /* NO shadow — it used to fall on the card's text while the clone hovered */
  transition: left .38s cubic-bezier(.3,.75,.25,1), top .38s cubic-bezier(.3,.75,.25,1),
              width .38s cubic-bezier(.3,.75,.25,1), height .38s cubic-bezier(.3,.75,.25,1),
              opacity .18s ease;
}
.ga-fly img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ga-fly.is-landing { border-radius: 0; }

/* empty + foot */
.ga-empty { padding: 90px 20px; text-align: center; }
.ga-empty-title { font: 800 22px/1.2 Inter, sans-serif; color: var(--ink); margin-bottom: 10px; }
.ga-empty-sub { font: 400 14px/1.6 Inter, sans-serif; color: var(--mute); max-width: 460px; margin: 0 auto; }
.ga-foot {
  padding: 46px 0 10px; text-align: center;
  font: 600 12px/1 Inter, sans-serif; color: var(--mute); letter-spacing: .04em;
}

/* ═══ responsive ═══ */
@media (max-width: 1100px) {
  .ga-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
}
@media (max-width: 699px) {
  .ga-main { padding: 0 14px 48px; }
  .ga-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .ga-bar { padding: 8px 0 8px; margin-bottom: 14px; }
  .ga-bar-row--search { flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
  .ga-search { max-width: none; flex-basis: 100%; }
  .ga-search input { padding-top: 8px; padding-bottom: 8px; }
  .ga-count { order: 2; }
  .ga-shuffle { order: 3; margin-left: auto; padding: 7px 13px; }
  .ga-bar-row--filters { flex-wrap: wrap; gap: 8px; }
  /* chips: one finger-scrollable row instead of a tall wrap */
  .ga-chips {
    flex-wrap: nowrap; overflow-x: auto; flex-basis: 100%;
    gap: 6px; padding-bottom: 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .ga-chips::-webkit-scrollbar { display: none; }
  .ga-seczip { flex: 0 0 auto; }
  .ga-years { margin-left: 0; flex-basis: 100%; }
  .ga-range { flex: 1; width: auto; }
  /* touch: keep the save pill reachable without hover */
  .ga-tile-save { opacity: 1; transform: none; padding: 6px 11px; font-size: 11px; }
}

/* ═══ reduced motion: no cascade, no glide, no flight ═══ */
@media (prefers-reduced-motion: reduce) {
  .ga-tile { opacity: 1; transform: none; transition: none; }
  .ga-tile.is-gliding { transition: none; }
  .ga-tile img { transition: none; }
  .ga-fly, .ga-ghost { transition: none; }
}
