/* Press feedback is shared by native links, buttons, and the story disclosure. */
@property --control-wash {
  syntax: '<color>';
  inherits: false;
  initial-value: transparent;
}

:where(button, a[href], summary) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  --hover-wash: rgb(110 74 32 / 7%);
  --pressed-wash: rgb(110 74 32 / 16%);
  --pressed-scale: .98;
}

:where(.primary, .bag-primary, .bag-note-save, .floating-order, .schedule-day[aria-pressed=true]) {
  --hover-wash: rgb(255 240 204 / 10%);
  --pressed-wash: rgb(255 240 204 / 22%);
}

:where(.product, .method-grid button, .choice-row, .location-strip, .bag-preference,
  .schedule-slot, .bag-note, #menu-dialog nav a, .schedule-secondary, .signoff, summary) {
  --pressed-scale: .995;
}

:where(.controls button, .stepper button, .bag-stepper button, .schedule-month-arrows button,
  .bag-close, #close-box, .schedule-day, .shopping-bag) {
  --pressed-scale: .93;
}

:where(.wordmark, .signoff, #menu-dialog nav a, .scroll) {
  --hover-wash: transparent;
}

/* Plain text links can wrap across several lines. Tint each text fragment. */
:where(a[href]:not([class], nav a, .site-header a)) {
  background-image: linear-gradient(var(--control-wash, transparent), var(--control-wash, transparent));
  box-decoration-break: clone;
}

/* The face sits above opaque icons and thumbnails. A press anywhere tints
   the full padded surface, with the same rounded corners as the control. */
:where(button, summary, nav a, .site-header a, a[class]) {
  position: relative;
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
}
:where(button:enabled, summary, nav a[href], .site-header a[href], a[href][class]):not([aria-disabled=true])::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  --control-wash: inherit;
  background-color: var(--control-wash, transparent);
}

@media (max-width: 760px) {
  .hero-order {
    --hover-wash: rgb(255 240 204 / 10%);
    --pressed-wash: rgb(255 240 204 / 22%);
  }
}

@media (hover: hover) and (pointer: fine) {
  :where(button:enabled, a[href], summary):not([aria-disabled=true]):hover {
    --control-wash: var(--hover-wash);
  }
}

:where(button:enabled, a[href], summary):not([aria-disabled=true]):is(:active, [data-control-pressed]) {
  --control-wash: var(--pressed-wash);
}

@media (prefers-reduced-motion: no-preference) {
  :where(button:enabled, a[href], summary):not([aria-disabled=true]) {
    transition: scale 175ms cubic-bezier(.22,1,.36,1), translate 175ms ease-out,
      --control-wash 150ms ease-out, box-shadow 150ms ease-out, opacity 150ms ease-out;
  }

  :where(.product .chevron, .method-arrow, .bag-preference > svg) {
    transition: translate 160ms cubic-bezier(.2,.8,.3,1);
  }

  @media (hover: hover) and (pointer: fine) {
    :is(a.pill, button.pill:enabled):hover {
      translate: 0 -1px;
      box-shadow: 3px 5px var(--ink);
    }
    :is(.product, .method-grid button, .bag-preference):enabled:hover
      :is(.chevron, .method-arrow, svg:last-child) { translate: 2px 0; }
  }

  :where(button:enabled, a[href], summary):not([aria-disabled=true]):is(:active, [data-control-pressed]) {
    scale: var(--pressed-scale);
    transition-duration: 40ms;
    transition-timing-function: ease-out;
  }

  :is(a.pill, button.pill:enabled):is(:active, [data-control-pressed]) {
    scale: 1;
    translate: 2px 2px;
    box-shadow: 1px 1px var(--ink);
  }

  @media (max-width: 760px) {
    .pill.hero-order:is(:hover, :active, [data-control-pressed]) { box-shadow: none; }
    .pill.hero-order:is(:active, [data-control-pressed]) { translate: 0 1px; scale: .98; }
  }
}
