/* ==========================================================================
   Helpers — small patterns that need a bit more than one property:
   stacks, stretched link, focus ring, hover lift, icon link, fixed / sticky bars.
   (Text truncation and visually-hidden live with the utilities.)
   ========================================================================== */

/* Stacks -----------------------------------------------------------------------
   .stack    a column with even space between      .hstack   a row, centered vertically
   .cluster  a row that wraps (tags, buttons)       .spacer   takes the free space (pushes the rest away)
   The space is --mo-stack-gap (1rem; .75rem in a row) — or any gap-* utility. */
.stack { --mo-stack-gap: 1rem; display: flex; flex-direction: column; gap: var(--mo-stack-gap); min-width: 0; }
.hstack { --mo-stack-gap: .75rem; display: flex; flex-direction: row; align-items: center; gap: var(--mo-stack-gap); min-width: 0; }
.cluster { --mo-stack-gap: .5rem; display: flex; flex-wrap: wrap; align-items: center; gap: var(--mo-stack-gap); min-width: 0; }
.spacer { flex: 1 1 auto; }

/* Stretched link ------------------------------------------------------------------
   <div class="card"> … <a class="stretched-link" href="/orders/10421">Order #10421</a> … </div>
   The link's click area covers its nearest positioned parent (cards and list rows already are;
   add .relative to anything else). Other links and buttons inside stay clickable on top. */
.stretched-link::after { position: absolute; inset: 0; z-index: 1; content: ""; }
.stretched-link:focus-visible { outline: 0; }
:has(> .stretched-link:focus-visible, > * .stretched-link:focus-visible):where(.relative, .card, .list-group-item, .media, [class*="position-"]),
.relative:has(.stretched-link:focus-visible) { outline: var(--mo-focus-ring-width) solid var(--mo-default-focus-ring); outline-offset: 2px; }

/* Focus ring --------------------------------------------------------------------
   Every focusable Moey component already shows a ring for the keyboard. These are for your own:
   .focus-ring          a ring when it has keyboard focus (theme-<color> picks the color)
   .focus-ring-inset    drawn inside the edge (for things in a scrolling or clipped box)
   .focus-within-ring   a ring around the whole box when anything inside has keyboard focus */
.focus-ring:focus-visible { outline: 0; box-shadow: 0 0 0 var(--mo-focus-ring-width) var(--mo-theme-focus-ring); }
.focus-ring-inset:focus-visible { outline: 0; box-shadow: inset 0 0 0 var(--mo-focus-ring-width) var(--mo-theme-focus-ring); }
.focus-within-ring:has(:focus-visible) { box-shadow: 0 0 0 var(--mo-focus-ring-width) var(--mo-theme-focus-ring); }
.focus-within-ring :focus-visible { outline: 0; }

/* Hover lift ------------------------------------------------------------------------
   .hover-lift   rises a little with a soft shadow     .hover-grow   grows a touch
   .hover-dim    fades a little (image tiles)
   Only for a mouse (phones have no hover), and still for people who ask for less motion. */
@media (hover: hover) {
  .hover-lift:hover { translate: 0 -.1875rem; box-shadow: var(--mo-shadow-lg); }
  .hover-grow:hover { scale: 1.025; }
  .hover-dim:hover { opacity: .8; }
}
@media (prefers-reduced-motion: no-preference) {
  :is(.hover-lift, .hover-grow, .hover-dim) { transition: translate .2s var(--mo-ease), scale .2s var(--mo-ease), box-shadow .2s var(--mo-ease), opacity .2s var(--mo-ease); }
}
@media (prefers-reduced-motion: reduce) {
  .hover-lift:hover { translate: none; }
  .hover-grow:hover { scale: none; }
}

/* Icon link ---------------------------------------------------------------------------
   <a class="icon-link" href="…">Read the docs <i class="mi mi-arrow-right"></i></a>
   .icon-link-hover  the trailing icon nudges forward on hover */
.icon-link { display: inline-flex; gap: .375rem; align-items: center; text-underline-offset: .25em; }
.icon-link > .mi { flex-shrink: 0; font-size: 1.1em; }
@media (prefers-reduced-motion: no-preference) { .icon-link-hover > .mi:last-child { transition: translate .2s var(--mo-ease); } }
.icon-link-hover:is(:hover, :focus-visible) > .mi:last-child { translate: .1875em 0; }
.icon-link-hover:is(:hover, :focus-visible):dir(rtl) > .mi:last-child { translate: -.1875em 0; }

/* Fixed & sticky bars -------------------------------------------------------------------
   .fixed-top / .fixed-bottom   stay on screen while the page scrolls (app bars, a phone tab bar)
   .sticky-top / .sticky-bottom stick once they reach the edge (table headers, section titles, save bars)
   Fixed bottom bars keep clear of the phone's home bar. */
.fixed-top { position: fixed; inset: 0 0 auto; z-index: var(--mo-z-fixed); }
.fixed-bottom { position: fixed; inset: auto 0 0; z-index: var(--mo-z-fixed); padding-bottom: env(safe-area-inset-bottom); }
.sticky-top { position: sticky; top: 0; z-index: var(--mo-z-sticky); }
.sticky-bottom { position: sticky; bottom: 0; z-index: var(--mo-z-sticky); }

/* Mirror a directional icon (an arrow) in right-to-left pages only */
.rtl-flip:dir(rtl) { scale: -1 1; }
