/*
 * 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;
}

@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: "";
    position: absolute;
    z-index: 1;
    inset: 1px 14% auto;
    height: 38%;
    pointer-events: none;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0));
    opacity: 0.86;
  }

  .nion-dock-surface {
    position: absolute;
    z-index: 0;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    border-radius: inherit;
    background:
      linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(248, 247, 252, 0.68)),
      radial-gradient(circle at 14% 115%, rgba(103, 238, 219, 0.1), transparent 35%),
      radial-gradient(circle at 86% -12%, rgba(204, 128, 246, 0.11), transparent 38%),
      rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(255, 255, 255, 0.74);
    box-shadow:
      0 5px 14px rgba(20, 22, 32, 0.08),
      0 1px 3px rgba(20, 22, 32, 0.045),
      inset 0 1px 0 rgba(255, 255, 255, 0.98),
      inset 0 -1px 0 rgba(137, 113, 181, 0.08);
    -webkit-backdrop-filter: blur(12px) saturate(138%);
    backdrop-filter: blur(12px) saturate(138%);
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
  }

  .nion-dock-active-glass {
    position: absolute;
    z-index: 2;
    top: 4px;
    bottom: 4px;
    left: 0;
    width: min(62.4px, calc(20vw - 15.6px));
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 17px;
    background:
      radial-gradient(circle at 18% 88%, rgba(91, 238, 215, 0.28), transparent 47%),
      radial-gradient(circle at 85% 13%, rgba(193, 111, 240, 0.25), transparent 48%),
      linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(251, 247, 255, 0.68));
    box-shadow:
      0 5px 14px rgba(123, 74, 176, 0.1),
      0 1px 5px rgba(41, 192, 179, 0.07),
      inset 0 1px 0 rgba(255, 255, 255, 1),
      inset 0 -1px 0 rgba(114, 82, 173, 0.09);
    --dock-active-x: 9px;
    --dock-active-stretch: 1;
    transform: translate3d(var(--dock-active-x), -1px, 0) scaleX(var(--dock-active-stretch));
    transform-origin: center;
    transition:
      transform 480ms cubic-bezier(0.16, 1, 0.3, 1),
      opacity 120ms ease;
    will-change: transform;
    backface-visibility: hidden;
  }

  .nion-dock-active-glass.is-gliding {
    --dock-active-stretch: 1.045;
  }

  .nion-dock-active-glass::before {
    content: "";
    position: absolute;
    inset: 1px 7px auto;
    height: 45%;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent);
    transform: translate3d(-14%, 0, 0);
    opacity: 0.82;
    transition:
      transform 520ms cubic-bezier(0.16, 1, 0.3, 1),
      opacity 240ms ease;
  }

  .nion-dock-active-glass.is-gliding::before {
    transform: translate3d(14%, 0, 0);
    opacity: 1;
  }

  .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;
    transform: translate3d(0, 0, 0);
    transition:
      color 120ms ease,
      transform 150ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .nion-dock-item::before {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 15px;
    pointer-events: none;
    background: transparent;
  }

  .nion-dock-item .nion-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    stroke-width: 1.85;
    transform: translate3d(0, 0, 0);
    transition:
      transform 340ms cubic-bezier(0.16, 1, 0.3, 1),
      filter 240ms ease;
  }

  .nion-dock-item > span {
    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 {
    filter: drop-shadow(0 3px 5px rgba(121, 71, 207, 0.2));
    transform: translate3d(0, -1px, 0) scale(1.09);
  }

  .nion-dock-item.is-selecting .nion-icon {
    will-change: transform;
  }

  .nion-dock-item[data-dock-tab="home"].is-selecting .nion-icon {
    animation: nionDockHomeSelect 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item[data-dock-tab="sections"].is-selecting .nion-icon {
    animation: nionDockGridSettle 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item[data-dock-tab="sections"].is-selecting .nion-icon rect {
    transform-box: fill-box;
    transform-origin: center;
  }

  .nion-dock-item[data-dock-tab="sections"].is-selecting .nion-icon rect:nth-of-type(1) {
    animation: nionDockGridTopStart 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item[data-dock-tab="sections"].is-selecting .nion-icon rect:nth-of-type(2) {
    animation: nionDockGridTopEnd 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item[data-dock-tab="sections"].is-selecting .nion-icon rect:nth-of-type(3) {
    animation: nionDockGridBottomStart 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item[data-dock-tab="sections"].is-selecting .nion-icon rect:nth-of-type(4) {
    animation: nionDockGridBottomEnd 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item[data-dock-tab="offers"].is-selecting .nion-icon {
    animation: nionDockOfferSelect 540ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item[data-dock-tab="cart"].is-selecting .nion-icon {
    animation: nionDockCartSelect 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item[data-dock-tab="account"].is-selecting .nion-icon {
    animation: nionDockAccountSelect 500ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item.is-selecting > span {
    animation: nionDockLabelSelect 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .nion-dock-item.is-tapped {
    transform: scale(0.97);
  }

  .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.13);
    background:
      linear-gradient(145deg, rgba(25, 25, 31, 0.92), rgba(13, 14, 18, 0.84)),
      radial-gradient(circle at 13% 112%, rgba(83, 230, 210, 0.11), transparent 36%),
      radial-gradient(circle at 86% -10%, rgba(187, 105, 239, 0.14), transparent 40%),
      rgba(13, 14, 18, 0.88);
    box-shadow:
      0 6px 18px rgba(0, 0, 0, 0.3),
      0 1px 5px rgba(0, 0, 0, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  }

  html[data-theme="dark"] .nion-dock::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), transparent);
  }

  html[data-theme="dark"] .nion-dock-active-glass {
    border-color: rgba(255, 255, 255, 0.18);
    background:
      radial-gradient(circle at 18% 88%, rgba(74, 225, 205, 0.2), transparent 48%),
      radial-gradient(circle at 85% 13%, rgba(181, 97, 237, 0.24), transparent 49%),
      linear-gradient(145deg, rgba(68, 65, 79, 0.82), rgba(31, 31, 39, 0.76));
    box-shadow:
      0 10px 24px rgba(0, 0, 0, 0.24),
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  }

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

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

@keyframes nionDockHomeSelect {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  38% {
    transform: translate3d(0, -3px, 0) scale(1.17);
  }
  68% {
    transform: translate3d(0, 0, 0) scale(1.02);
  }
  100% {
    transform: translate3d(0, -1px, 0) scale(1.09);
  }
}

@keyframes nionDockGridSettle {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  45% { transform: translate3d(0, -1px, 0) scale(1.13); }
  100% { transform: translate3d(0, -1px, 0) scale(1.09); }
}

@keyframes nionDockGridTopStart {
  0%, 100% { transform: translate3d(0, 0, 0); }
  38% { transform: translate3d(-1.8px, -1.8px, 0); }
}

@keyframes nionDockGridTopEnd {
  0%, 100% { transform: translate3d(0, 0, 0); }
  38% { transform: translate3d(1.8px, -1.8px, 0); }
}

@keyframes nionDockGridBottomStart {
  0%, 100% { transform: translate3d(0, 0, 0); }
  38% { transform: translate3d(-1.8px, 1.8px, 0); }
}

@keyframes nionDockGridBottomEnd {
  0%, 100% { transform: translate3d(0, 0, 0); }
  38% { transform: translate3d(1.8px, 1.8px, 0); }
}

@keyframes nionDockOfferSelect {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  42% { transform: translate3d(0, -2px, 0) rotate(-7deg) scale(1.15); }
  72% { transform: translate3d(0, -1px, 0) rotate(2deg) scale(1.08); }
  100% { transform: translate3d(0, -1px, 0) rotate(0deg) scale(1.09); }
}

@keyframes nionDockCartSelect {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  34% { transform: translate3d(2px, -2px, 0) rotate(5deg) scale(1.13); }
  62% { transform: translate3d(-1px, 0, 0) rotate(-2deg) scale(1.07); }
  100% { transform: translate3d(0, -1px, 0) rotate(0deg) scale(1.09); }
}

@keyframes nionDockAccountSelect {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  40% { transform: translate3d(0, -1px, 0) scale(1.18); }
  70% { transform: translate3d(0, -1px, 0) scale(1.06); }
  100% { transform: translate3d(0, -1px, 0) scale(1.09); }
}

@keyframes nionDockLabelSelect {
  0% {
    opacity: 0.72;
    transform: translate3d(0, 1px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .nion-dock-active-glass,
  .nion-dock-item,
  .nion-dock-item .nion-icon {
    transition-duration: 1ms;
  }

  .nion-dock-item.is-selecting .nion-icon,
  .nion-dock-item.is-selecting > span {
    animation: none;
  }
}
