/* Cart-fill Shop button (slice D PR2, issue #96).

   The Shop button lives in the recipe-detail ingredients-section-head
   row, replacing the .recipe-detail__soon "Shop the ingredients"
   placeholder when ShopEnabled is true at boot.

   Treatment: outlined-tomato pill — transparent background, --md-primary
   border + text. Calibrated AT MOST EQUAL to the labelled
   recipe_save_button (Save is the single sanctioned filled-tomato page
   CTA per the bible's brand-voice rule; Shop is a contextual secondary
   action adjacent to the ingredients it acts on). See spec v3.1
   amendments + ~/Developer/recipe-masonry/cart-fill/critique.md for the
   bakeoff converge rationale.

   State-layer hover/active uses the .state-layer utility (globals.css)
   per bible 7.4.3. --md-primary-hover is NOT used (reserved to
   save-heart.css:50).

   Cascade-layer note: lives in `components`. */

@layer components {
  .shop-button {
    /* layout */
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: 1.5px solid var(--md-primary);
    border-radius: var(--radius-pill);
    background: transparent;
    /* type */
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--md-primary);
    /* affordance */
    cursor: pointer;
    transition: transform var(--motion-spring-fast-effects-duration) var(--motion-spring-fast-effects);
  }

  .shop-button:is(:active, [data-force~="active"]) {
    transform: scale(0.97);
  }

  .shop-button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
  }

  /* Icon-tile and handoff arrow track currentColor so the outlined
     tomato treatment carries through both. Width matches the
     section-head's other inline icons (16px). */
  .shop-button .icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
  }

  .shop-button__label {
    /* Hold the label tight to the icon and arrow; no expansion. */
  }

  .shop-button__handoff {
    /* The ↗ glyph signals cross-domain handoff per D-AC3. Slightly
       larger than the body weight so it reads as a discrete affordance
       rather than punctuation. Inherits the parent button's gap; no
       extra inline margin is needed (was 1px optical offset; dropped
       per css-spacing-guard, design-bible 4.8). */
    font-size: 1em;
    line-height: 1;
  }

  /* htmx in-flight: hint progress while the request is outstanding.
     htmx adds .htmx-request to the button automatically. */
  .shop-button.htmx-request {
    cursor: progress;
    opacity: 0.7;
  }

  /* Error fragment slot — sibling under the section-head, lives in the
     same column as the ingredient rails. Empty by default; htmx fills
     it via hx-swap=innerHTML. aria-live=polite on the placeholder
     surfaces the error to screen readers without stealing focus. */
  .recipe-detail__shop-error {
    margin-block-start: var(--space-2);
    min-height: 0;
  }

  .recipe-detail__shop-error:empty {
    /* Collapse cleanly when no error is set. */
    display: none;
  }

  .shop-error__copy {
    display: inline-block;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--md-surface-container-low);
    border: 1px solid var(--md-border-muted);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--md-on-surface);
  }

  /* On mobile the section-head is tighter; the button stays
     compact (does not stretch — only Save stretches in its actions
     row, per recipe-save-button.css:77). */
  @media (max-width: 640px) {
    .shop-button {
      font-size: 0.8125rem;
      padding: var(--space-2) var(--space-3);
    }
  }
}
