/* ===== Dish effects (EXPERIMENT: exp/dish-effects) =====
   Loaded by the menu page only when at least one dish has an effect (and by the
   menu editor's live preview). A dish WITHOUT an effect never gets the wrapper
   below, so its markup and layout are exactly what they were.

   Hosts (all carry data-fx="<whitelisted effect>" + --fx-x/--fx-y/--fx-i/--fx-s):
     .dish-thumb-wrap          row thumbnail (menu page)
     .dish-lightbox-imgwrap    lightbox (public/js/index.js clones the overlay in)
     .ed-fx-stage              menu-editor live preview
   Each hosts an <img> plus one `.dish-fx` overlay of <i> particles.

   Release 1 ships three effects: glow, zoom, steam (see PARTICLES in js/dish-fx.js).
   shimmer is written but deferred; haze/sparkle/bubbles were removed after the photo
   evaluation -- they read as image defects, stickers and dust on real dish photos.

   Performance rules: ONLY transform + opacity are animated (compositor-only, no
   layout/paint per frame); no filter/blur, no mix-blend-mode; soft edges come from
   radial-gradients. Everything pauses when the tab is hidden
   (html[data-fx-paused], set by dish-fx.js) or the photo is scrolled away (.fx-off).
   Overlays are pointer-events:none, so tap-to-zoom/keyboard handling is untouched.
   Variables: --fx-x/--fx-y = origin (%), --fx-i = intensity (.2-1), --fx-s = speed
   multiplier (.5-2; durations are base / --fx-s). */

/* ---------- hosts ---------- */
.menu-card .dish-thumb-wrap {
  position: relative; display: block; flex-shrink: 0;
  width: 84px; height: 84px;
  border-radius: var(--dish-photo-radius); overflow: hidden;
  /* same hairline + soft shadow as a bare .dish-thumb (base.css); the shadow moves to the
     wrapper because the wrapper clips its contents */
  box-shadow: 0 0 0 1px rgba(127, 127, 127, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
}
.menu-card .dish-thumb-wrap img.dish-thumb { display: block; box-shadow: none; }
/* the wrapper clips, so the keyboard focus ring must sit INSIDE the photo or it is cut off */
.menu-card .dish-thumb-wrap img.dish-thumb:focus-visible { outline-offset: -3px; }
@media (max-width: 600px) {
  .menu-card .dish-thumb-wrap { width: 72px; height: 72px; }
}
/* brand layout places the thumbnail by grid cell, not DOM order (brand.css) */
html[data-brand-mode] .menu-card .dish-thumb-wrap { grid-column: 2; grid-row: 1 / span 2; }

.dish-lightbox-imgwrap[data-fx] { overflow: hidden; } /* the zoom effect scales the photo past its box */

.dish-fx {
  position: absolute; inset: 0; overflow: hidden; border-radius: inherit;
  pointer-events: none; direction: ltr; /* the origin is a position ON the photo: never mirrored by RTL */
  opacity: var(--fx-i, 0.8);
}
.dish-fx i { position: absolute; display: block; pointer-events: none; opacity: 0; }
[data-fx="zoom"] > .dish-fx { display: none; }

/* ---------- pausing ---------- */
html[data-fx-paused] [data-fx] .dish-fx i,
html[data-fx-paused] [data-fx="zoom"] > img,
[data-fx].fx-off .dish-fx i,
[data-fx="zoom"].fx-off > img { animation-play-state: paused; }

/* ---------- steam: soft wisps rising from the origin ---------- */
[data-fx="steam"] .dish-fx i {
  width: 28%; height: 44%;
  left: calc(var(--fx-x, 50%) - 14%); top: calc(var(--fx-y, 45%) - 44%);
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 62%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.5) 38%, rgba(255, 255, 255, 0) 70%);
  animation: fxSteam calc(4.2s / var(--fx-s, 1)) ease-out infinite;
}
[data-fx="steam"] .dish-fx i:nth-child(1) { margin-left: -11%; animation-delay: calc(-0.2s / var(--fx-s, 1)); }
[data-fx="steam"] .dish-fx i:nth-child(2) { margin-left: 7%;   animation-delay: calc(-1.6s / var(--fx-s, 1)); animation-duration: calc(4.8s / var(--fx-s, 1)); }
[data-fx="steam"] .dish-fx i:nth-child(3) { margin-left: -2%;  animation-delay: calc(-3s / var(--fx-s, 1)); animation-duration: calc(3.8s / var(--fx-s, 1)); }
@keyframes fxSteam {
  0%   { transform: translate(0, 40%) scale(0.6, 0.7); opacity: 0; }
  20%  { opacity: 0.95; }
  55%  { transform: translate(6%, -25%) scale(0.95, 1); }
  100% { transform: translate(-4%, -90%) scale(1.3, 1.15); opacity: 0; }
}

/* ---------- shimmer: a diagonal light sweep, then a pause ----------
   DEFERRED TO RELEASE 2: "shimmer" is not in the PARTICLES whitelist (js/dish-fx.js), so
   nothing can save or render it today and these rules are inert. Kept because they work --
   see the note on DEFERRED there, including the ~0.45 default intensity it needs. */
[data-fx="shimmer"] .dish-fx i {
  top: -20%; bottom: -20%; left: 0; width: 38%;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.7) 50%, rgba(255, 255, 255, 0) 100%);
  opacity: 1;
  animation: fxShimmer calc(4.6s / var(--fx-s, 1)) ease-in-out infinite;
}
@keyframes fxShimmer {
  0%   { transform: translateX(-140%) skewX(-18deg); }
  45%, 100% { transform: translateX(340%) skewX(-18deg); }
}

/* ---------- glow: a slow warm radial pulse at the origin ---------- */
[data-fx="glow"] .dish-fx i {
  inset: 0;
  background: radial-gradient(circle at var(--fx-x, 50%) var(--fx-y, 45%), rgba(255, 200, 100, 0.9) 0%, rgba(255, 150, 50, 0.4) 34%, rgba(255, 120, 30, 0) 68%);
  transform-origin: var(--fx-x, 50%) var(--fx-y, 45%);
  animation: fxGlow calc(5s / var(--fx-s, 1)) ease-in-out infinite;
}
@keyframes fxGlow {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

/* ---------- zoom: a calm push-in and back on the photo itself ----------
   zoom is the only effect that moves the PHOTO, which is also the tap target
   (84px, opens the lightbox). Two things keep it from being a moving target:
     1. the cycle rests at both ends -- stationary for ~30% of it (two windows of
        1.35s at the 9s default), so a finger or an automated click has somewhere
        to land, and
     2. it stops outright while a pointer or the keyboard is on it (below). A mouse
        has to arrive before it can click, so by the time the click lands the photo
        is already still. */
[data-fx="zoom"] > img {
  transform-origin: var(--fx-x, 50%) var(--fx-y, 45%);
  animation: fxZoom calc(9s / var(--fx-s, 1)) ease-in-out infinite;
}
@keyframes fxZoom {
  0%, 15%  { transform: scale(1); }
  50%, 65% { transform: scale(calc(1 + 0.18 * var(--fx-i, 0.8))); }
  100%     { transform: scale(1); }
}
[data-fx="zoom"]:hover > img,
[data-fx="zoom"]:active > img,
[data-fx="zoom"]:focus-within > img { animation-play-state: paused; }

/* ---------- reduced motion: no animation at all ---------- */
@media (prefers-reduced-motion: reduce) {
  [data-fx] .dish-fx { display: none; }
  [data-fx="zoom"] > img { animation: none; }
}
