/*
 * Mashin Irani — Header Mini-Cart (hover preview).
 *
 * Enqueued at priority 102, i.e. AFTER mirani-header-spacing.css (101), because the <=640px block at the
 * bottom of this file repairs the ONE child combinator that file relies on. Verified by grepping every
 * stylesheet on the site: `.site-header .hdr .utils > a.icon-btn` in mirani-header-spacing.css is the
 * only child-combinator rule targeting a .utils child anywhere. Every other .utils rule (mi.css,
 * home.css, product.css, mirani-finder.css, and the rest of header-spacing.css) uses descendant
 * combinators and keeps matching through the wrapper.
 *
 * Every custom property has a hex/px fallback verified against mi.css :root. The design system has NO
 * --space-7 and it is never referenced here. Note the unprefixed tokens live in mi.css / home.css /
 * product.css, not in tokens.css, so on some pages the fallbacks are what actually apply — they are set
 * to the exact token values.
 */

/* Wrapper injected around the frozen cart anchor. A <div>, not a <span>: it must legally contain the
   popup's flow content. It becomes the flex item of .utils where the bare anchor used to sit. */
.mi-mc{
  position: relative;
  display: inline-flex;
  align-items: center;
}

/*
 * Popup shell — transparent, and its padding-block-start doubles as the hover bridge so the pointer can
 * travel from the button into the card without crossing a dead gap. The visible surface is .mi-mc__card.
 *
 * Anchoring: inset-inline-end:0 resolves to left:0 in RTL, so the panel's inline-end edge sits on the
 * button's inline-end edge and the panel extends toward the page centre. That is the safe direction —
 * .utils is pushed to the inline-end (left) of the header by margin-inline-start:auto, so a panel that
 * grew further outward would run off the viewport. Width is viewport-clamped as a second guard, so it
 * can never trip body{overflow-x:clip}.
 *
 * Nothing clips it: neither .site-header, .hdr, .container nor .utils sets overflow (verified).
 */
.mi-mc__pop{
  position: absolute;
  inset-inline-end: 0;
  top: 100%;
  z-index: 70; /* above mirani-desktop-mega.css's panel (60), inside .site-header's own z-index:1100 context */
  width: min(360px, calc(100vw - 32px));
  padding-block-start: 8px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 200ms cubic-bezier(.2,0,0,1), transform 200ms cubic-bezier(.2,0,0,1);
}
.mi-mc__pop[hidden]{ display: none; }
.mi-mc.is-open .mi-mc__pop{
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.mi-mc__card{
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border, #D9CBC2);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-e4, 0 16px 40px rgba(16,33,52,.14));
  overflow: hidden;
  text-align: start;
}

/* ---- list -------------------------------------------------------------- */

.mi-mc__body{
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.mi-mc__row{
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px;
  border-radius: var(--radius-md, 8px);
  color: inherit;
  text-decoration: none;
  transition: background 120ms cubic-bezier(.2,0,0,1);
}
.mi-mc__row:hover{ background: var(--n-100, #ECE4DA); }
.mi-mc__row + .mi-mc__row{ border-block-start: 1px solid var(--border, #D9CBC2); }

.mi-mc__thumb{
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  background: var(--n-100, #ECE4DA);
  border: 1px solid var(--border, #D9CBC2);
}
.mi-mc__thumb img{ width: 100%; height: 100%; object-fit: cover; display: block; }

.mi-mc__meta{ min-width: 0; flex: 1 1 auto; }

.mi-mc__name{
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--navy-900, #102134);
}
.mi-mc__qty{
  display: block;
  margin-block-start: 4px;
  font-size: .8125rem;
  color: var(--text-secondary, #404751);
}

.mi-mc__more{
  padding: 8px;
  font-size: .8125rem;
  color: var(--text-tertiary, #6E6A66);
  text-align: center;
}

/* ---- empty / error state ------------------------------------------------ */

.mi-mc__empty{
  padding: 24px 16px;
  text-align: center;
  color: var(--text-secondary, #404751);
}
.mi-mc__empty svg{
  display: block;
  flex: none;              /* an svg inside a flex parent collapses to ~2px without this */
  width: 32px;
  height: 32px;
  margin: 0 auto 8px;
  fill: none;
  stroke: var(--n-300, #C0B2A6);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mi-mc__empty b{
  display: block;
  font-size: .9375rem;
  font-weight: 700;
  color: var(--navy-900, #102134);
}
.mi-mc__empty span{
  display: block;
  margin-block-start: 4px;
  font-size: .8125rem;
}
.mi-mc__empty a{ color: var(--link, #3C507D); text-decoration: underline; }

/* ---- skeleton ----------------------------------------------------------- */

.mi-mc__skel{ padding: 8px; display: grid; gap: 12px; }
.mi-mc__skel span{
  display: block;
  height: 52px;
  border-radius: var(--radius-md, 8px);
  background: linear-gradient(90deg, #ECE4DA, #F5F0E9, #ECE4DA);
  background-size: 200% 100%;
  animation: mi-mc-shimmer 1.1s linear infinite;
}
@keyframes mi-mc-shimmer{
  from{ background-position: 200% 0; }
  to  { background-position: -200% 0; }
}

/* ---- footer: subtotal + actions ----------------------------------------- */

.mi-mc__foot{
  border-block-start: 1px solid var(--border, #D9CBC2);
  padding: 12px;
  background: #FBF8F3;
}
.mi-mc__foot[hidden]{ display: none; }

.mi-mc__sub{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 12px;
  font-size: .875rem;
  color: var(--text-secondary, #404751);
}
.mi-mc__sub b{ font-size: 1rem; color: var(--navy-900, #102134); }

.mi-mc__acts{ display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/*
 * Both actions are <a>, never <button>/[type=submit] — so hello-elementor reset.css's
 * background-color:transparent rule cannot strip their fill, and they need no (0,2,0) counter-rule.
 * Scoped classes (not .btn) keep them clear of the site-wide .btn.btn-cta/.btn-buy fixes.
 */
.mi-mc__btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding-inline: 12px;
  border-radius: var(--radius-md, 8px);
  border: 1.5px solid var(--navy-800, #112250);
  background: transparent;
  color: var(--navy-800, #112250);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background 120ms cubic-bezier(.2,0,0,1), color 120ms cubic-bezier(.2,0,0,1);
}
.mi-mc__btn:hover{ background: rgba(17,34,80,.08); }
.mi-mc__btn:focus-visible{ outline: 2px solid var(--link, #3C507D); outline-offset: 2px; }
.mi-mc__btn--buy{
  background: var(--navy-800, #112250);
  color: var(--ivory-50, #F5F0E9);
}
.mi-mc__btn--buy:hover{ background: var(--navy-900, #102134); color: var(--ivory-50, #F5F0E9); }

/* ---- gating: desktop + fine pointer only -------------------------------- */

/*
 * Touch and small screens never see the popup — the cart button stays a plain link to /cart/.
 * The JS applies the same test per interaction, and never calls preventDefault, so a tap is never
 * trapped.
 */
@media (max-width: 1080px), (hover: none), (pointer: coarse){
  .mi-mc__pop{ display: none !important; }
}

@media (prefers-reduced-motion: reduce){
  .mi-mc__pop{ transition: none; }
  .mi-mc__skel span{ animation: none; }
  .mi-mc__row{ transition: none; }
}

/* ---- header-spacing.css repair (REQUIRED — do not delete) ---------------- */

/*
 * mirani-header-spacing.css flattens .utils at <=640px with display:contents and then orders the
 * flattened children. Its cart rule uses a CHILD combinator:
 *     .site-header .hdr .utils > a.icon-btn{ order: 4; }
 * The .mi-mc wrapper breaks that match. Re-flatten the wrapper too and restore the order, so the mobile
 * sequence stays  logo(1) → hamburger(2) → gift(3) → cart(4).
 *
 * Same specificity (0,4,1) as the original, and this file loads later, so it wins either way.
 * display:contents on .mi-mc also removes its containing block, but the popup is display:none at these
 * widths so nothing depends on .mi-mc's position:relative here.
 */
@media (max-width: 640px){
  .site-header .hdr .utils .mi-mc{ display: contents; }
  .site-header .hdr .mi-mc > a.icon-btn{ order: 4; }
}
