/* Concept 1: preserve the resting surfaces; respond at first contact. */
.swipe-action {
  isolation: isolate;
  overflow: hidden;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.meal-reveal > .swipe-action { position: relative; }
.swipe-action::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 90ms;
  z-index: 0;
}
.swipe-action__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform-origin: center;
  transition: transform 95ms cubic-bezier(.2,.8,.2,1);
}
.swipe-action__content svg { width: 20px; height: 20px; flex: none; }
.swipe-action.is-pressed::before { opacity: .2; transition: none; }
.swipe-action.is-pressed .swipe-action__content { transform: scale(.92); transition: none; }
.swipe-action.is-released::before { opacity: .12; }
.swipe-action:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -4px; }

/* Automatic dialog/return focus must not leave a keyboard ring after touch.
   Keep native focus and field styling; keyboard input restores the ring. */
:root[data-input-modality="pointer"] .swipe-action:focus,
:root[data-input-modality="pointer"] dialog.sheet button:focus,
:root[data-input-modality="pointer"] :is([data-entry-menu], [data-meal-menu], [data-ingredient-menu]):focus {
  outline: none;
}

/* Retain the original 180ms settling; input never waits for this animation. */
.app-main .editor-ingredient.is-swiping .ingredient-delete { visibility: visible; }
.app-main .ingredient-delete {
  z-index: 2;
  clip-path: inset(0 0 0 100%);
  transition: clip-path 180ms var(--ease);
}
.app-main .editor-ingredient.is-open .ingredient-delete { clip-path: inset(0); }
.app-main .editor-ingredient.is-swiping .ingredient-delete {
  clip-path: inset(0 0 0 max(0px, calc(82px + var(--ingredient-swipe-x, 0px))));
  transition: none;
}
/* Once released open, the moving front must no longer cover the buttons. */
.app-main .meal.is-meal-open:not(.is-meal-swiping) .meal-reveal,
.app-main .entry.is-open:not(.is-dragging) > .entry-reveal { z-index: 2; }
/* Keep the action behind the returning surface until it covers it fully. */
.app-main .meal.is-swipe-closing .meal-reveal,
.app-main .entry.is-swipe-closing > .entry-reveal,
.app-main .editor-ingredient.is-swipe-closing .ingredient-delete {
  visibility: visible;
  pointer-events: none;
}
.app-main .meal.is-swipe-closing .meal-reveal,
.app-main .entry.is-swipe-closing > .entry-reveal { z-index: 0; }

/* Explicit variants: other sheets retain their existing placement/layout. */
dialog.sheet.sheet--bottom {
  position: fixed;
  inset: auto 9px max(9px, env(safe-area-inset-bottom, 0px));
  width: calc(100% - 18px);
  max-width: 440px;
  max-height: calc(100dvh - 24px - env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  border-radius: 23px;
  box-shadow: 0 -10px 50px #20273925;
}
.sheet__handle { width: 35px; height: 4px; border-radius: 10px; background: var(--line); margin: 9px auto 0; }
.sheet--paired .sheet__actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sheet--paired .sheet__actions > .btn { min-width: 0; width: 100%; }
.sheet--swipe-delete .sheet__content { gap: 7px; padding-top: 8px; padding-bottom: 0; }
.sheet--swipe-delete .sheet__object { font-size: var(--text-md); font-weight: 750; overflow-wrap: anywhere; margin: 0; }
.sheet--swipe-delete .sheet__actions { padding: 21px 20px 24px; }
.sheet--bottom[open] { animation: swipe-sheet-in 140ms ease-out; }
@keyframes swipe-sheet-in {
  from { transform: translateY(18px); opacity: .75; }
  to { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .swipe-action::before, .swipe-action__content { transition: none; }
  .swipe-action.is-pressed .swipe-action__content { transform: none; }
  .sheet--bottom[open] { animation: none; }
}
