/* Shopping cart: header badge, slide-in drawer, full cart page, card add-to-cart, issue badges, toast.
   All scoped under .asg-store so it layers on the premium cyan-on-charcoal design system in site.css and
   inherits its tokens (--asg-surface, --asg-border, --asg-primary, --asg-radius…). Mobile-first. */

/* ---------- header cart button + badge ---------- */
.asg-store .asg-cart-nav { display: flex; align-items: center; }
.asg-store .asg-cart-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; color: var(--asg-muted);
  border: 1px solid var(--asg-border-strong); background: rgba(255, 255, 255, 0.02);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.asg-store .asg-cart-btn:hover { color: #fff; border-color: color-mix(in srgb, var(--asg-primary, #5bb8e8) 60%, transparent); background: color-mix(in srgb, var(--asg-primary, #5bb8e8) 12%, transparent); }
.asg-store .asg-cart-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700; line-height: 1; border-radius: 999px;
  background: var(--asg-primary, #5bb8e8); color: var(--asg-btn-ink, #04141c); box-shadow: 0 2px 8px -2px rgba(0,0,0,0.5);
}
@media (max-width: 767.98px) {
  .asg-store .asg-cart-nav { justify-content: flex-start; }
  .asg-store .asg-cart-btn { width: 100%; height: auto; padding: 0.6rem 0.8rem; gap: 0.5rem; }
  .asg-store .asg-cart-btn::after { content: 'Cart'; font-weight: 600; }
  .asg-store .asg-cart-badge { position: static; margin-left: auto; }
}

/* ---------- icon button (cart remove, drawer close/remove) ----------
   Shared chrome for the small square icon buttons in the cart line, drawer header and drawer lines. These
   were bare <button>s (browser default chrome, no guaranteed hit area), which read poorly and were fiddly to
   tap on a phone — give them a consistent themed box with a comfortable touch target. */
.asg-store .asg-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 40px; height: 40px; padding: 0; cursor: pointer;
  color: var(--asg-muted); border: 1px solid transparent; border-radius: 10px;
  background: transparent; transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.asg-store .asg-iconbtn:hover { color: #ff8a8a; background: color-mix(in srgb, #ff6b6b 12%, transparent); border-color: color-mix(in srgb, #ff6b6b 35%, transparent); }
.asg-store .asg-iconbtn:focus-visible { outline: none; box-shadow: var(--asg-ring); }
.asg-store .asg-iconbtn svg { flex: none; }
/* The drawer's close (X) is a neutral control, not destructive — give it the same subtle bordered chrome
   as the header cart button (resting border + faint fill) and a neutral brand-ish hover, never the red
   destructive treatment. Its inline SVG uses currentColor, so it inherits the muted icon colour. */
.asg-store .asg-drawer__close { border-color: var(--asg-border-strong); background: rgba(255, 255, 255, 0.02); }
.asg-store .asg-drawer__close:hover { color: #fff; background: color-mix(in srgb, var(--asg-primary, #5bb8e8) 12%, transparent); border-color: color-mix(in srgb, var(--asg-primary, #5bb8e8) 60%, transparent); }

/* ---------- slide-in drawer ---------- */
.asg-store .asg-drawer { position: fixed; inset: 0; z-index: 1060; visibility: hidden; }
.asg-store .asg-drawer.is-open { visibility: visible; }
.asg-store .asg-drawer__scrim {
  position: absolute; inset: 0; background: rgba(2, 6, 12, 0.6); opacity: 0;
  transition: opacity 0.25s ease; backdrop-filter: blur(2px);
}
.asg-store .asg-drawer.is-open .asg-drawer__scrim { opacity: 1; }
.asg-store .asg-drawer__panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(420px, 92vw);
  display: flex; flex-direction: column; background: var(--asg-surface, #131a22);
  border-left: 1px solid var(--asg-border-strong); box-shadow: -24px 0 60px -20px rgba(0,0,0,0.7);
  transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.2,0.7,0.2,1); outline: none;
}
.asg-store .asg-drawer.is-open .asg-drawer__panel { transform: translateX(0); }
.asg-store .asg-drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--asg-border);
}
.asg-store .asg-drawer__title { margin: 0; font-size: 1.1rem; }
.asg-store .asg-drawer__body { flex: 1 1 auto; overflow-y: auto; padding: 0.5rem 1.1rem; }
.asg-store .asg-drawer__loading, .asg-store .asg-drawer__empty { padding: 2rem 0; text-align: center; }
.asg-store .asg-drawer__empty { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }
.asg-store .asg-drawer__lines { list-style: none; margin: 0; padding: 0; }
.asg-store .asg-drawer__line { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.8rem 0; border-bottom: 1px solid var(--asg-border); }
.asg-store .asg-drawer__thumb, .asg-store .asg-cart__thumb {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 10px; overflow: hidden;
  background: var(--asg-surface-2); border: 1px solid var(--asg-border);
}
.asg-store .asg-drawer__thumb img, .asg-store .asg-cart__thumb img { width: 100%; height: 100%; object-fit: cover; }
.asg-store .asg-drawer__thumb-fallback, .asg-store .asg-cart__thumb-fallback { font-weight: 700; color: var(--asg-muted); }
.asg-store .asg-drawer__line-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.asg-store .asg-drawer__line-title { font-weight: 600; color: var(--asg-text, #fff); text-decoration: none; }
.asg-store .asg-drawer__line-title:hover { color: var(--asg-primary, #5bb8e8); }
.asg-store .asg-drawer__line-variant { font-size: 0.82rem; color: var(--asg-muted); }
.asg-store .asg-drawer__line-price { font-size: 0.9rem; color: var(--asg-text, #fff); }
.asg-store .asg-drawer__interval { color: var(--asg-muted); font-size: 0.8rem; }
/* Slightly smaller than the standalone cart-page remove so it sits neatly in the compact drawer line. */
.asg-store .asg-drawer__remove { width: 36px; height: 36px; }
.asg-store .asg-drawer__foot { padding: 1rem 1.1rem; border-top: 1px solid var(--asg-border); display: flex; flex-direction: column; gap: 0.6rem; }
.asg-store .asg-drawer__subtotal { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.05rem; }
.asg-store .asg-drawer__continue { margin-top: 0; }
.asg-store body.asg-no-scroll, body.asg-no-scroll { overflow: hidden; }

/* ---------- full cart page ---------- */
.asg-store .asg-cart__empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; padding: 2.5rem 1.5rem; }
.asg-store .asg-cart__empty-icon { color: var(--asg-muted); }
.asg-store .asg-cart__empty-title { margin: 0; }
.asg-store .asg-cart__lines { list-style: none; margin: 0 0 1.25rem; padding: 0.4rem 1.1rem; }
.asg-store .asg-cart__line { display: flex; gap: 1rem; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--asg-border); }
.asg-store .asg-cart__line:last-child { border-bottom: none; }
.asg-store .asg-cart__thumb { width: 72px; height: 72px; }
.asg-store .asg-cart__line-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.asg-store .asg-cart__line-title { font-weight: 700; color: var(--asg-text, #fff); text-decoration: none; }
.asg-store .asg-cart__line-title:hover { color: var(--asg-primary, #5bb8e8); }
.asg-store .asg-cart__line-variant { font-size: 0.85rem; color: var(--asg-muted); }
.asg-store .asg-cart__line-price { text-align: right; white-space: nowrap; }
.asg-store .asg-cart__amount { font-weight: 700; }
.asg-store .asg-cart__interval { color: var(--asg-muted); font-size: 0.85rem; }
.asg-store .asg-cart__line--blocked { opacity: 0.7; }
.asg-store .asg-cart__remove-form { flex: 0 0 auto; }
/* On a phone the 72px thumb + nowrap price + remove button leave almost no room for the title column, so the
   line cramps/overflows. Shrink the thumb and tighten the gap (matching the drawer) so the row stays readable
   and the remove control stays tappable. */
@media (max-width: 480px) {
  .asg-store .asg-cart__line { gap: 0.6rem; }
  .asg-store .asg-cart__thumb { width: 56px; height: 56px; }
  .asg-store .asg-cart__line-price { font-size: 0.9rem; }
}

.asg-store .asg-cart__grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .asg-store .asg-cart__grid { grid-template-columns: 1fr 1fr; align-items: start; } }
/* Subscription-only cart: no coupon panel, so the totals get the full width instead of a lone half-column. */
@media (min-width: 768px) { .asg-store .asg-cart__grid--no-coupon { grid-template-columns: 1fr; } }
.asg-store .asg-cart__section-title { font-size: 1rem; margin: 0 0 0.6rem; }
.asg-store .asg-cart__coupon-form { display: flex; gap: 0.5rem; }
.asg-store .asg-cart__coupon-form .form-control { flex: 1 1 auto; }
.asg-store .asg-cart__coupon-applied { display: flex; align-items: center; gap: 0.6rem; }
.asg-store .asg-cart__total-row { display: flex; justify-content: space-between; padding: 0.4rem 0; }
.asg-store .asg-cart__total-row--discount { color: var(--asg-primary, #5bb8e8); }
.asg-store .asg-cart__total-row--grand { border-top: 1px solid var(--asg-border); margin-top: 0.4rem; padding-top: 0.8rem; font-size: 1.15rem; font-weight: 800; }
.asg-store .asg-cart__renew-note, .asg-store .asg-cart__issue-note { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0.6rem 0; }
.asg-store .asg-cart__totals .btn-asg, .asg-store .asg-cart__totals .btn-asg-outline { margin-top: 0.6rem; }
.asg-store .asg-cart__continue { display: block; text-align: center; margin-top: 0.8rem; color: var(--asg-muted); text-decoration: none; }
.asg-store .asg-cart__continue:hover { color: var(--asg-primary, #5bb8e8); }
.asg-store .asg-cart__clear-form { text-align: center; margin-top: 0.6rem; }
.asg-store .asg-cart__link-btn { background: none; border: none; color: var(--asg-muted); cursor: pointer; padding: 0; font-size: 0.88rem; text-decoration: underline; }
.asg-store .asg-cart__link-btn:hover { color: #ff6b6b; }

/* ---------- issue badges ---------- */
.asg-store .cart-badge {
  display: inline-flex; align-items: center; gap: 0.3rem; width: fit-content;
  font-size: 0.72rem; font-weight: 700; padding: 0.18rem 0.5rem; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.asg-store .cart-badge--info { background: color-mix(in srgb, var(--asg-primary, #5bb8e8) 18%, transparent); color: var(--asg-primary, #5bb8e8); }
.asg-store .cart-badge--warn { background: color-mix(in srgb, #f5b454 20%, transparent); color: #f5b454; }
.asg-store .cart-badge--danger { background: color-mix(in srgb, #ff6b6b 18%, transparent); color: #ff8a8a; }

/* ---------- product card add-to-cart ---------- */
.asg-store .product-card__add { position: relative; z-index: 2; margin-top: 0.75rem; }
.asg-store .product-card__add-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; }
.asg-store .product-card__add-btn.is-loading { opacity: 0.7; cursor: progress; }
.asg-store .btn-asg.is-loading, .asg-store .btn-asg-outline.is-loading { opacity: 0.75; cursor: progress; }

/* ---------- toast (storefront) ---------- */
.asg-store .asg-cart-toasts, .asg-cart-toasts {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 0.5rem; z-index: 1080; pointer-events: none;
}
.asg-cart-toast {
  pointer-events: auto; padding: 0.7rem 1.1rem; border-radius: 10px; font-weight: 600; font-size: 0.92rem;
  background: var(--asg-surface-3, #1a222d); color: var(--asg-text, #fff);
  border: 1px solid var(--asg-border-strong); box-shadow: 0 14px 36px -12px rgba(0,0,0,0.6);
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s ease, transform 0.2s ease;
}
.asg-cart-toast.is-shown { opacity: 1; transform: translateY(0); }
.asg-cart-toast--success { border-left: 3px solid #4ade80; }
.asg-cart-toast--info { border-left: 3px solid var(--asg-primary, #5bb8e8); }
.asg-cart-toast--error { border-left: 3px solid #ff6b6b; }

/* ---------- centered modal (ownership gating: already-owned / subscribed / supersede warning) ----------
   A reusable dialog: dimmed backdrop, centered card, focus-trapped in cart.js, Esc/backdrop/close dismiss.
   Themed from the storefront tokens; readable and tappable down to a 375px viewport. Rendered on <body>
   with its own .asg-store scope so the tokens resolve even outside a store-scoped page region. */
.asg-store.asg-modal, .asg-modal.asg-store {
  position: fixed; inset: 0; z-index: 1090; display: flex; align-items: center; justify-content: center;
  padding: 1rem; visibility: hidden;
}
.asg-modal.is-open { visibility: visible; }
.asg-modal__scrim {
  position: absolute; inset: 0; background: rgba(2, 6, 12, 0.66); opacity: 0;
  transition: opacity 0.2s ease; backdrop-filter: blur(2px);
}
.asg-modal.is-open .asg-modal__scrim { opacity: 1; }
.asg-modal__dialog {
  position: relative; width: min(460px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto;
  background: var(--asg-surface, #131a22); border: 1px solid var(--asg-border-strong);
  border-radius: var(--asg-radius, 14px); box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.75);
  padding: 1.6rem 1.5rem 1.4rem; outline: none;
  transform: translateY(10px) scale(0.98); opacity: 0;
  transition: transform 0.2s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s ease;
}
.asg-modal.is-open .asg-modal__dialog { transform: translateY(0) scale(1); opacity: 1; }
.asg-modal__close { position: absolute; top: 0.55rem; right: 0.55rem; width: 36px; height: 36px; }
.asg-modal__close { border-color: var(--asg-border-strong); background: rgba(255, 255, 255, 0.02); }
.asg-modal__close:hover { color: #fff; background: color-mix(in srgb, var(--asg-primary, #5bb8e8) 12%, transparent); border-color: color-mix(in srgb, var(--asg-primary, #5bb8e8) 60%, transparent); }
.asg-modal__title { margin: 0 2rem 0.6rem 0; font-size: 1.2rem; color: var(--asg-text, #fff); }
.asg-modal__body { margin: 0 0 1.2rem; color: var(--asg-muted); line-height: 1.5; }
.asg-modal__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: flex-end; }
.asg-modal__btn { min-width: 8rem; }
/* On a narrow phone the two actions stack full-width so both stay easy to tap. */
@media (max-width: 420px) {
  .asg-modal__actions { flex-direction: column-reverse; }
  .asg-modal__actions .asg-modal__btn { width: 100%; min-width: 0; }
}

/* Danger tone: a rejection the buyer triggered (a repeat free trial, or subscribing while a trial runs). A
   red border + accent bar + red title makes the "no, wait until your trial is over" unmistakable. */
.asg-modal--danger .asg-modal__dialog {
  border-color: color-mix(in srgb, #ef4444 55%, transparent);
  border-top: 4px solid #ef4444;
}
.asg-modal--danger .asg-modal__title { color: #f87171; }

/* Supersede disclosure line on the checkout review page (persistent, alongside the auto-opened modal). */
.asg-store .asg-supersede-notice {
  display: flex; align-items: flex-start; gap: 0.5rem; margin: 0 0 1rem;
  padding: 0.7rem 0.9rem; border-radius: 10px; font-size: 0.9rem; line-height: 1.45;
  color: #f5b454; background: color-mix(in srgb, #f5b454 12%, transparent);
  border: 1px solid color-mix(in srgb, #f5b454 30%, transparent);
}
.asg-store .asg-supersede-notice svg { flex: 0 0 auto; margin-top: 0.15rem; }

@media (prefers-reduced-motion: reduce) {
  .asg-store .asg-drawer__panel, .asg-store .asg-drawer__scrim, .asg-cart-toast,
  .asg-modal__scrim, .asg-modal__dialog { transition: none; }
}
