/* ============================================================
   Cart timer chip -- when active, replaces the standalone cart icon
   in the navbar and itself becomes the link to /cart. Single pill
   carries: cart icon + item count + separator + "Complete in MM:SS".

   When inactive (cart empty, no timer): chip is hidden (display:none),
   the standalone .tx-cart-standalone anchor shows as before.

   When active: chip renders as inline-flex AND the standalone cart
   anchor is hidden via .tx-cart-standalone.is-hidden (set by JS).

   Three-state color scheme:
     default  (>60s): amber  -- "you have time, but the clock is on"
     warning  (<=60s): urgent -- "hurry up"
     critical (<=15s): urgent + pulse -- "act NOW"

   THEMING: colors come from --tx-timer* variables defined per theme in
   tixhub-listing.css. They are tuned against --tx-nav-bg (the chip lives
   on the navbar), NOT the page background. Do not substitute --tx-coral
   here: in the Cool theme the page accent is slate-blue on a slate-blue
   bar (1.34:1) and the chip would be invisible exactly when it matters.
   ============================================================ */
.tx-cart-timer {
  display: none;                 /* JS flips to inline-flex on activate */
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 36px;
  border-radius: 999px;
  /* !important on all three: this chip is an <a> inside the navbar, and
     navbar.css sets background/color on navbar anchors at higher specificity.
     The old hardcoded rule got away without it because losing the cascade
     still left amber literals in place; with var() the chip silently rendered
     navbar-grey with blue-grey text while the (uncontested) border stayed
     amber. The .is-warning/.is-critical states below already use !important
     for the same reason. */
  background: var(--tx-timer-bg, rgba(245, 158, 11, 0.12)) !important;
  border: 1.5px solid var(--tx-timer, #F59E0B) !important;
  color: var(--tx-timer, #F59E0B) !important;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  user-select: none;
  flex-shrink: 0;
  text-decoration: none;          /* it's an <a> now */
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}
.tx-cart-timer:hover {
  text-decoration: none;
  filter: brightness(1.08);
}
.tx-cart-timer.is-active {
  display: inline-flex;
}

/* Cart icon at the start of the pill */
.tx-cart-timer__icon {
  font-size: 14px;
  line-height: 1;
  color: inherit !important;
}

/* Item count -- inline number next to the cart icon. No background pill;
   it would add visual noise (3-color clash with chip border + text).
   Just a bold colored number. */
.tx-cart-timer__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  color: inherit;
  padding: 0 2px;
}

/* Separator dot between count and label */
.tx-cart-timer__sep {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: currentColor;
  opacity: 0.4;
  margin: 0 2px;
}

.tx-cart-timer__label {
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: inherit !important;
}
.tx-cart-timer .tx-cart-timer__time {
  min-width: 42px;       /* keeps "9:59" -> "10:00" from jittering width */
  text-align: right;
  font-weight: 700;
  color: inherit !important;
}

/* When timer is active, hide the standalone cart icon to avoid duplication */
.tx-cart-standalone.is-hidden {
  display: none !important;
}

/* Warning state -- last 60 seconds. Urgent fill, dark text on the chip
   itself (icon, label, time, separator).
   --tx-timer-on-urgent is dark in EVERY theme: white text on these warm
   fills measures ~2:1 and fails, whereas dark measures 6.2-8.5:1. This is
   why it is a dedicated variable and not --tx-on-accent (which is #FFFFFF
   in Classic and Cool). */
.tx-cart-timer.is-warning {
  background: var(--tx-timer-urgent, #FF6B54) !important;
  color: var(--tx-timer-on-urgent, #1a1a1a) !important;
  border-color: var(--tx-timer-urgent, #FF6B54) !important;
}
.tx-cart-timer.is-warning .tx-cart-timer__icon,
.tx-cart-timer.is-warning .tx-cart-timer__label,
.tx-cart-timer.is-warning .tx-cart-timer__time {
  color: var(--tx-timer-on-urgent, #1a1a1a) !important;
}

/* Critical state -- last 15 seconds. Urgent fill + pulse animation. */
.tx-cart-timer.is-critical {
  background: var(--tx-timer-urgent, #FF6B54) !important;
  color: var(--tx-timer-on-urgent, #1a1a1a) !important;
  border-color: var(--tx-timer-urgent, #FF6B54) !important;
  animation: tx-cart-timer-pulse 1s ease-in-out infinite;
}
.tx-cart-timer.is-critical .tx-cart-timer__icon,
.tx-cart-timer.is-critical .tx-cart-timer__label,
.tx-cart-timer.is-critical .tx-cart-timer__time {
  color: var(--tx-timer-on-urgent, #1a1a1a) !important;
}

/* Pulse halo uses currentColor so it follows the per-theme urgent color
   instead of the old hardcoded coral rgba(). */
@keyframes tx-cart-timer-pulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 currentColor; }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 6px transparent; }
}

/* Respect reduced-motion: keep the color change, drop the scaling pulse. */
@media (prefers-reduced-motion: reduce) {
  .tx-cart-timer.is-critical {
    animation: none;
  }
  .tx-cart-timer {
    transition: none;
  }
}

/* Mobile: smaller chip, drop the "Complete in" label and the separator
   so the pill stays compact: [cart] [2] 9:59 */
@media (max-width: 880px) {
  .tx-cart-timer {
    height: 30px;
    padding: 0 12px;
    font-size: 13px;
    gap: 6px;
  }
  .tx-cart-timer__label,
  .tx-cart-timer__sep { display: none; }
  .tx-cart-timer__icon { font-size: 13px; }
  .tx-cart-timer__count { font-size: 13px; }
}

/* ============================================================
   Expiry-prompt SweetAlert customizations.
   ============================================================ */

/* z-index -- online-modal.js uses z-index: 2147483647 (max int) on its
   container. SweetAlert2 v9 defaults to 1060 which renders BEHIND the
   modal. Force SweetAlert to the same max-int level -- being painted
   later in the DOM, it'll stack on top. cart-timer.js also closes any
   open online-modal before this fires, but this is the safety net. */
.swal2-container {
  z-index: 2147483647 !important;
}
.swal2-container .swal2-popup {
  z-index: 2147483647 !important;
}

.swal2-popup.tx-swal-popup {
  background-color: var(--tx-card-bg) !important;
  color: var(--tx-text) !important;
  border: 1px solid var(--tx-border) !important;
  border-radius: var(--tx-radius-card, 12px) !important;
  padding: 28px 28px 22px !important;
  font-family: inherit !important;
}

.swal2-popup.tx-swal-popup .swal2-title {
  color: var(--tx-text) !important;
  font-size: 22px !important;
  font-weight: 600 !important;
  margin: 0 0 10px !important;
  padding: 0 !important;
}

.swal2-popup.tx-swal-popup .tx-swal-html,
.swal2-popup.tx-swal-popup .swal2-html-container {
  color: var(--tx-muted) !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  margin: 0 0 8px !important;
  padding: 0 !important;
}

.swal2-popup.tx-swal-popup .swal2-actions {
  margin-top: 20px !important;
  gap: 10px;
}
.swal2-popup.tx-swal-popup .tx-swal-confirm,
.swal2-popup.tx-swal-popup .tx-swal-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px !important;
  border-radius: 999px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  font-family: inherit !important;
  cursor: pointer;
  border: 1px solid transparent !important;
  line-height: 1 !important;
  margin: 0 !important;
}

/* The modal sits on --tx-card-bg (the PAGE surface, not the navbar), so
   here --tx-coral IS the right variable -- each theme's accent is designed
   to read against its own card background. */
.swal2-popup.tx-swal-popup .tx-swal-confirm {
  background: var(--tx-coral) !important;
  color: var(--tx-on-accent, #1a1a1a) !important;
}
.swal2-popup.tx-swal-popup .tx-swal-confirm:hover {
  filter: brightness(0.95);
}

/* Classic only: its accent (#D85A30) with white text measures 3.87:1 on the
   card -- under AA. Deepen the fill to clear it (5.72:1). The other three
   themes already pass (Dark 5.22, Cool 7.06, Plum 7.18) and are left alone.
   NOTE: this replaces an older `body:not(.theme-dark)` rule which broke when
   dark became the default theme -- `:not(.theme-dark)` began matching every
   theme, including dark, since dark no longer carries a body class. */
body.theme-classic .swal2-popup.tx-swal-popup .tx-swal-confirm {
  background: var(--tx-coral-deep, #B83A28) !important;
  color: #fff !important;
}
.swal2-popup.tx-swal-popup .tx-swal-cancel {
  background: transparent !important;
  color: var(--tx-text) !important;
  border-color: var(--tx-border-mid, var(--tx-border)) !important;
}
.swal2-popup.tx-swal-popup .tx-swal-cancel:hover {
  background: var(--tx-dropdown-hover) !important;
  border-color: var(--tx-text) !important;
}

/* Grace bar inside modal */
.tx-cart-grace-bar {
  height: 4px;
  background: var(--tx-search-bg);
  border-radius: 999px;
  overflow: hidden;
  margin: 18px 0 8px;
}
.tx-cart-grace-bar__fill {
  height: 100%;
  background: var(--tx-coral);
  width: 100%;
  transition: width 0.25s linear;
}
.tx-cart-grace-text {
  font-size: 13px;
  color: var(--tx-muted);
  margin-top: 6px;
  text-align: center;
}

/* Backdrop dim */
.swal2-container.swal2-backdrop-show {
  background-color: rgba(0, 0, 0, 0.55) !important;
}
