/*
 * Nion mobile dock
 * One authoritative component. Keep dock visuals out of styles.css/brand.css
 * so the glass surface and active indicator never compete in the cascade.
 */
.nion-dock {
  display: none;
}

@property --nion-dock-glow-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@media (max-width: 640px) {
  :root {
    --nion-mobile-dock-safe-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    --nion-mobile-dock-height: 56px;
    --nion-mobile-dock-action-gap: 10px;
    --nion-mobile-dock-action-bottom: calc(
      var(--nion-mobile-dock-safe-bottom) +
      var(--nion-mobile-dock-height) +
      var(--nion-mobile-dock-action-gap)
    );
  }

  .nion-dock {
    --dock-safe-bottom: var(--nion-mobile-dock-safe-bottom);
    --dock-height: var(--nion-mobile-dock-height);
    position: fixed;
    left: 50%;
    bottom: var(--dock-safe-bottom);
    z-index: 120;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    direction: rtl;
    width: min(370px, calc(100vw - 20px));
    height: var(--dock-height);
    padding: 4px;
    margin: 0;
    overflow: visible;
    isolation: isolate;
    border: 0;
    border-radius: 21px;
    background: transparent;
    box-shadow: none;
    transform: translate3d(-50%, 0, 0);
    backface-visibility: hidden;
    contain: layout style paint;
  }

  body[data-route="product"] .detail-cart,
  body[data-route="product"] .detail-sticky-cart,
  body[data-route="cart"] .cart-sticky-checkout {
    bottom: var(--nion-mobile-dock-action-bottom) !important;
  }

  html[dir="ltr"] .nion-dock {
    direction: ltr;
  }

  .nion-dock::before {
    content: none;
  }

  .nion-dock::after {
    content: "";
    position: absolute;
    z-index: 4;
    inset: 0;
    padding: 1px;
    pointer-events: none;
    border-radius: inherit;
    background: conic-gradient(
      from var(--nion-dock-glow-angle),
      transparent 0 66%,
      rgba(80, 225, 207, 0.3) 71%,
      rgba(176, 77, 196, 0.52) 82%,
      rgba(121, 71, 207, 0.46) 94%,
      transparent 100%
    );
    -webkit-mask:
      linear-gradient(#000 0 0) content-box,
      linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.72;
    filter: none;
    animation: nion-dock-glow-orbit 9s linear infinite;
  }

  @keyframes nion-dock-glow-orbit {
    to {
      --nion-dock-glow-angle: 360deg;
    }
  }

  .nion-dock-surface {
    position: absolute;
    z-index: 0;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow:
      0 5px 16px rgba(31, 27, 43, 0.075),
      inset 0 1px 0 rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: blur(14px) saturate(138%);
    backdrop-filter: blur(14px) saturate(138%);
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
  }

  .nion-dock-indicator {
    position: absolute;
    z-index: 2;
    top: 5px;
    bottom: 5px;
    left: 0;
    display: block;
    width: calc((100% - 8px) / 5 - 12px);
    pointer-events: none;
    border-radius: 16px;
    background: transparent;
    box-shadow: none;
    filter: none;
    opacity: 0;
    transform: translate3d(0, 0, 0);
    transition: transform 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
    will-change: transform;
    backface-visibility: hidden;
  }

  .nion-dock-indicator-core {
    position: absolute;
    inset: 0;
    display: block;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.76);
    border-radius: inherit;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(245, 240, 255, 0.42));
    box-shadow:
      0 2px 7px rgba(77, 54, 118, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.72);
    filter: none;
    transform: scale(1);
    transform-origin: 50% 50%;
    will-change: transform;
    backface-visibility: hidden;
  }

  .nion-dock-item {
    position: relative;
    z-index: 3;
    display: flex;
    min-width: 0;
    height: 48px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1px;
    padding: 2px;
    color: #62626b;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: none;
  }

  .nion-dock-item .nion-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    stroke-width: 1.98;
    transform: translate3d(0, 0, 0);
  }

  .nion-dock-item > span {
    position: relative;
    z-index: 1;
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: currentColor;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nion-dock-item.active {
    color: #7947cf;
  }

  .nion-dock-item.active .nion-icon {
    stroke-width: 2.2;
  }

  .nion-dock-cart-count,
  .nion-dock em[data-dock-cart-count] {
    position: absolute;
    top: 1px;
    inset-inline-end: 7px;
    z-index: 3;
    display: grid;
    min-width: 15px;
    height: 15px;
    place-items: center;
    padding: 0 4px;
    border: 1.5px solid rgba(255, 255, 255, 0.96);
    border-radius: 999px;
    background: #b04dc4;
    box-shadow: 0 3px 8px rgba(176, 77, 196, 0.26);
    color: #fff;
    font-size: 8px;
    font-style: normal;
    font-weight: 800;
    line-height: 1;
  }

  .nion-dock-cart-count[hidden],
  .nion-dock em[data-dock-cart-count][hidden] {
    display: none;
  }

  html[data-theme="dark"] .nion-dock-surface {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(20, 20, 25, 0.72);
    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.24),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }

  html[data-theme="dark"] .nion-dock-item {
    color: #aaa8b2;
  }

  html[data-theme="dark"] .nion-dock-item.active {
    color: #d7b7ff;
  }

  html[data-theme="dark"] .nion-dock-indicator-core {
    border-color: rgba(255, 255, 255, 0.15);
    background: linear-gradient(145deg, rgba(92, 84, 108, 0.68), rgba(48, 43, 58, 0.54));
    box-shadow:
      0 2px 7px rgba(0, 0, 0, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.13);
  }

  /* Keep the liquid-glass look on Android while avoiding the expensive
     blur + multi-shadow + SVG-filter combination that causes frame drops on
     mid-range devices. */
  html[data-platform="android"] .nion-dock,
  html[data-platform="android"] .nion-dock-surface,
  html[data-platform="android"] .nion-dock-item,
  html[data-platform="android"] .nion-dock-item .nion-icon {
    backface-visibility: hidden;
    transform-style: preserve-3d;
  }

  html[data-platform="android"] .nion-dock-surface {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 18px rgba(31, 27, 43, 0.1);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  html[data-platform="android"] .nion-dock-item .nion-icon {
    stroke-width: 2.14;
  }

  html[data-platform="android"] .nion-dock-item.active .nion-icon {
    filter: none;
  }

  html[data-platform="android"][data-theme="dark"] .nion-dock-surface {
    background: rgba(20, 20, 25, 0.92);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  }
}

@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .nion-dock::after {
    animation: none;
  }

  .nion-dock-indicator,
  .nion-dock-item,
  .nion-dock-item .nion-icon {
    transition-duration: 1ms;
  }
}

/* The Android dock background is already nearly opaque and layered. Avoid
   recomputing a live backdrop texture on every scroll frame; its transform
   animations and liquid gradients remain compositor-driven. */
@media (max-width: 640px) {
  html[data-platform="android"] .nion-dock-surface {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
