/*
 * Exo Vault TCG — reversible staging enhancements
 * Mobile stability foundation. Loaded after the parent theme.
 */

/* Structural safety: prevent media and intrinsic-width children from widening the page. */
html,
body,
.wp-site-blocks {
  max-width: 100%;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

.ev-ticker,
.ev-ticker__viewport,
.ev-header,
.ev-header__inner,
.ev-header__actions {
  min-width: 0;
  max-width: 100%;
}

.ev-ticker {
  contain: inline-size;
}

.ev-ticker__viewport {
  overflow: hidden;
  overflow: clip;
}

/* Last-resort page guard. The layout rules below remove the root cause. */
@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

@media (max-width: 480px) {
  /* Three deliberate zones: menu / flexible brand / compact utilities. */
  .ev-header__inner {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.3rem;
    box-sizing: border-box;
    width: 100%;
    padding-inline: 0.55rem;
  }

  .ev-menu-toggle {
    grid-column: 1;
  }

  .ev-header__brand {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    margin-inline: 0;
    overflow: hidden;
    font-size: clamp(0.72rem, 3.2vw, 0.86rem);
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ev-header__actions {
    grid-column: 3;
    justify-self: end;
    gap: 0.15rem;
    min-width: 0;
  }

  /* One language action is clearer on mobile: show the language the user can switch to. */
  .ev-lang__btn.is-current,
  .ev-lang__btn[aria-current="true"] {
    display: none;
  }

  .ev-lang {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    padding: 1px;
  }

  .ev-lang__btn {
    min-width: 32px;
    width: 32px;
    height: 36px;
    padding: 0;
  }

  /* Theme follows the saved/system preference on small screens; this avoids a crowded toolbar. */
  .ev-theme-toggle {
    display: none;
  }

  .ev-icon-btn {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 0;
  }

  .ev-cart-count {
    inset-inline-end: -1px;
  }

  .woocommerce ul.products,
  .wc-block-product-template,
  .wp-block-query .wp-block-post-template {
    max-width: 100%;
  }

  .woocommerce ul.products li.product,
  .wc-block-product,
  .wp-block-post {
    min-width: 0;
  }

  input,
  select,
  textarea,
  button {
    max-width: 100%;
  }
}

@media (max-width: 350px) {
  /* Account remains available in the mobile drawer (added by the companion script). */
  .ev-header__account {
    display: none;
  }

  .ev-header__brand {
    font-size: 0.72rem;
    letter-spacing: 0.02em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ev-ticker__track {
    animation-play-state: paused !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Sold-out treatment: muted collectible card + sharp editorial status flag.
 * Inspired by premium automotive geometry and Linear-style dark surfaces. */
.products .product.outofstock {
  position: relative;
}

.products .product.outofstock::before {
  content: "SOLD OUT";
  position: absolute;
  z-index: 6;
  top: 0.72rem;
  inset-inline-end: 0.72rem;
  min-width: 6.4rem;
  padding: 0.48rem 0.78rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.18rem;
  background: #d84a4a;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.13em;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 0.45rem 1.35rem rgba(0, 0, 0, 0.34);
  pointer-events: none;
}

/* The parent theme stamps a second diagonal SOLD OUT label on ::after.
 * Keep one deliberate status marker only. */
.products .product.outofstock::after {
  display: none !important;
  content: none !important;
}

/* The theme's Sealed chip occupies the same corner; the archive panel below
 * preserves that information without colliding with the SOLD OUT flag. */
.products .product.outofstock .ev-chip {
  display: none !important;
}

html[lang^="ar"] .products .product.outofstock::before,
html[dir="rtl"] .products .product.outofstock::before {
  content: "نفد المخزون";
  letter-spacing: 0;
}

.products .product.outofstock img {
  filter: grayscale(0.64) saturate(0.48) contrast(0.94);
  opacity: 0.68;
}

.ev-stock-archive {
  display: grid;
  width: min(100%, 19rem);
  box-sizing: border-box;
  gap: 0.28rem;
  padding: 0.74rem 0.86rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-inline-start: 3px solid #d84a4a;
  border-radius: 0.32rem;
  background:
    linear-gradient(110deg, rgba(216, 74, 74, 0.08), transparent 44%),
    rgba(255, 255, 255, 0.045);
  color: #d0d3d8;
  line-height: 1.12;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 0.4rem 1.2rem rgba(0, 0, 0, 0.14);
}

.ev-stock-archive__status {
  color: #ff7373;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.105em;
  text-transform: uppercase;
}

html[lang^="ar"] .ev-stock-archive__status,
html[dir="rtl"] .ev-stock-archive__status,
html[lang^="ar"] .ev-stock-archive__seal,
html[dir="rtl"] .ev-stock-archive__seal {
  letter-spacing: 0;
}

.ev-stock-archive__seal {
  color: #858a93;
  font-size: 0.59rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.ev-stock-filter {
  display: flex;
  margin-block: 0 1rem;
}

.ev-stock-filter__control {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 0.68rem;
  padding: 0.62rem 0.88rem;
  border: 1px solid rgba(201, 162, 39, 0.36);
  border-radius: 0.72rem;
  background: rgba(13, 8, 24, 0.55);
  color: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.ev-stock-filter__box {
  position: relative;
  width: 1.08rem;
  height: 1.08rem;
  flex: 0 0 1.08rem;
  border: 1px solid rgba(240, 214, 122, 0.75);
  border-radius: 0.24rem;
  background: rgba(201, 162, 39, 0.06);
}

.ev-stock-filter__control.is-active {
  border-color: rgba(240, 214, 122, 0.82);
  background: rgba(201, 162, 39, 0.13);
  box-shadow: 0 0 1.25rem rgba(201, 162, 39, 0.14);
}

.ev-stock-filter__control.is-active .ev-stock-filter__box::after {
  content: "";
  position: absolute;
  inset: 0.19rem;
  border-radius: 0.12rem;
  background: var(--ev-gold-hi, #f0d67a);
  box-shadow: 0 0 0.75rem rgba(240, 214, 122, 0.75);
}

.ev-stock-filter__control:focus-visible {
  outline: 2px solid var(--ev-gold-hi, #f0d67a);
  outline-offset: 3px;
}
