/* Scene search — the words find what is ON SCREEN (common.js scene,
   web/src/h-vision.js). Three pieces, all in the shelf's own brass-and-ember
   language (media/dock.css tokens, repeated here because those live on .hdock):

   1. the switch inside the shelf's search bar (.hdock-find-scene),
   2. the same switch in the sidebar's search field (.media-scene-switch),
   3. the matched moments on a tile (.tile-scene-moments).

   When the switch is on, the field itself says so: an ember rim that stays
   while the caret is elsewhere, so a grid ranked by scene is never mistaken
   for a grid filtered by title. */

:root {
  --scene-brass: 198, 160, 94;
  --scene-ember: 245, 158, 11;
}

/* ── 1. The shelf bar's switch ── */
.hdock-find-scene[hidden] { display: none; }
.hdock-find-scene {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px 0 5px;
  border: 1px solid rgba(var(--scene-brass), .28);
  border-radius: calc(var(--dock-plaque, 9px) - 3px);
  background: linear-gradient(180deg, rgba(255, 236, 202, .06), rgba(0, 0, 0, .22));
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
  white-space: nowrap;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.hdock-find-scene img { width: 20px; height: 20px; opacity: .72; transition: opacity .18s ease, transform .25s cubic-bezier(.2, .8, .2, 1); }
.hdock-find-scene:hover { border-color: rgba(var(--scene-ember), .6); color: var(--text); }
.hdock-find-scene:hover img { opacity: 1; transform: rotate(-8deg) scale(1.06); }
.hdock-find-scene:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.hdock-find-scene[aria-pressed="true"] {
  border-color: rgba(var(--scene-ember), .85);
  background:
    radial-gradient(120% 140% at 20% 0%, rgba(var(--scene-ember), .42), transparent 70%),
    linear-gradient(180deg, rgba(var(--scene-ember), .22), rgba(0, 0, 0, .25));
  color: #fff4dc;
  box-shadow: inset 0 1px 0 rgba(255, 233, 196, .22), 0 0 14px -4px rgba(var(--scene-ember), .7);
}
.hdock-find-scene[aria-pressed="true"] img { opacity: 1; }

.hdock-find.is-scenes {
  /* A description is longer than a title filter, and the switch takes room
     inside the field: the field takes the room back from the rail. */
  flex: 1 4 380px;
  min-width: 260px;
  border-color: rgba(var(--scene-ember), .62);
  background:
    linear-gradient(90deg, rgba(var(--scene-ember), .1), transparent 55%),
    linear-gradient(180deg, rgba(0, 0, 0, .34), rgba(0, 0, 0, .12)),
    rgba(6, 5, 4, .62);
}
.hdock-find.is-scenes .hdock-q::placeholder { color: rgba(255, 214, 150, .55); }

/* Looking: the lens breathes until the answer lands (usually well under a
   second, so it is a flicker of life, not a spinner to wait on). */
.hdock-find.is-scene-busy .hdock-find-scene img,
.media-search-wrap.is-scene-busy .media-scene-switch img {
  animation: scene-look 1.1s ease-in-out infinite;
}
@keyframes scene-look {
  0%, 100% { transform: rotate(0) scale(1); filter: drop-shadow(0 0 0 rgba(var(--scene-ember), 0)); }
  50% { transform: rotate(-10deg) scale(1.08); filter: drop-shadow(0 0 5px rgba(var(--scene-ember), .9)); }
}

@media (max-width: 560px) {
  /* The icon is the target on a phone; the word goes, the 44px stays. */
  .hdock-find-scene { min-width: 44px; height: 32px; justify-content: center; padding: 0 6px; }
  .hdock-find-scene-lbl { display: none; }
}

/* ── 2. The sidebar field's switch ── */
.media-view .sidebar .media-search-wrap:has(.media-scene-switch:not([hidden])) input[type="search"] { padding-right: 38px; }
.media-scene-switch[hidden] { display: none; }
.media-scene-switch {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(var(--scene-brass), .25);
  border-radius: 6px;
  background: rgba(0, 0, 0, .25);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.media-scene-switch img { width: 18px; height: 18px; opacity: .7; transition: opacity .15s ease; }
.media-scene-switch:hover { border-color: rgba(var(--scene-ember), .6); }
.media-scene-switch:hover img { opacity: 1; }
.media-scene-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.media-scene-switch[aria-pressed="true"] {
  border-color: rgba(var(--scene-ember), .85);
  background: linear-gradient(180deg, rgba(var(--scene-ember), .38), rgba(var(--scene-ember), .14));
  box-shadow: 0 0 10px -3px rgba(var(--scene-ember), .75);
}
.media-scene-switch[aria-pressed="true"] img { opacity: 1; }
.media-view .sidebar .media-search-wrap.is-scenes input[type="search"] {
  border-color: rgba(var(--scene-ember), .55);
  background: linear-gradient(90deg, rgba(var(--scene-ember), .1), transparent 60%), var(--surface);
}

/* ── 3. The moments a tile matched ──
   Down the right edge under the duration: the best match lit in ember, up to
   two more beside it in the tile's usual dark glass. Each one plays from
   there; the row arrives one moment at a time, best first. */
.media-tile .tile-scene-moments {
  position: absolute;
  top: 32px;
  right: 6px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: none;
}
.media-tile .tile-scene-moment {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 4px;
  background: rgba(0, 0, 0, .74);
  color: rgba(255, 255, 255, .86);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  animation: scene-moment-in .32s cubic-bezier(.2, .8, .2, 1) backwards;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.media-tile .tile-scene-moment:nth-child(2) { animation-delay: .06s; }
.media-tile .tile-scene-moment:nth-child(3) { animation-delay: .12s; }
.media-tile .tile-scene-moment.is-best {
  border-color: rgba(var(--scene-ember), .95);
  background: linear-gradient(180deg, rgb(251, 191, 36), rgb(217, 119, 6));
  color: #1c1003;
  font-weight: 750;
  box-shadow: 0 2px 10px -2px rgba(var(--scene-ember), .8);
}
/* A play mark is a triangle, the one glyph simple enough to draw. */
.media-tile .tile-scene-moment.is-best::before {
  content: '';
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid currentColor;
}
.media-tile .tile-scene-moment:hover { transform: translateX(-2px); border-color: rgba(var(--scene-ember), .9); color: #fff; }
.media-tile .tile-scene-moment.is-best:hover { color: #000; }
.media-tile .tile-scene-moment:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@keyframes scene-moment-in {
  from { opacity: 0; transform: translateX(10px); }
}

@media (prefers-reduced-motion: reduce) {
  .hdock-find.is-scene-busy .hdock-find-scene img,
  .media-search-wrap.is-scene-busy .media-scene-switch img,
  .media-tile .tile-scene-moment { animation: none; }
  .hdock-find-scene:hover img { transform: none; }
}
