/* stylelint-disable selector-class-pattern -- same BEM naming as layout.css. */

/* Liquid glass bottom bar shared by the independent sites and the z3house aggregate.
   A clear lens travels with the finger and settles into the highlight; the glass reads what is
   behind it (data-tone) so light sections get light glass with dark icons. */

.platform-bottom-nav {
  display: none;
}

[data-glass-nav] .glass-filter {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

[data-glass-nav] .glass-lens {
  display: none;
}

@media (width <= 767px) {
  body:has([data-glass-nav]) {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }

  /* stylelint-disable property-no-vendor-prefix -- iOS 17 and earlier only read the prefixed backdrop filter. */
  .mobile-bottom-nav[data-glass-nav],
  .platform-bottom-nav[data-glass-nav] {
    position: fixed;
    z-index: var(--z-nav, 30);
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    display: flex;
    min-height: 64px;
    gap: 0;
    padding: 6px;
    border: 1px solid rgb(255 255 255 / 34%);
    border-radius: 999px;
    background: linear-gradient(180deg, rgb(255 255 255 / 12%), rgb(255 255 255 / 0%) 55%), rgb(20 20 22 / 20%);
    box-shadow: 0 0 0 .5px rgb(0 0 0 / 22%), 0 12px 32px rgb(0 0 0 / 26%), inset 0 1px 0 rgb(255 255 255 / 45%), inset 0 -1px 0 rgb(255 255 255 / 12%);
    -webkit-backdrop-filter: blur(2px) brightness(.82) saturate(180%);
    backdrop-filter: blur(2px) brightness(.82) saturate(180%);
    transform-origin: 50% 100%;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition-property: transform, background, border-color, box-shadow;
    transition-duration: .32s;
    transition-timing-function: cubic-bezier(.25, 1.25, .4, 1);
  }

  [data-glass-nav]::before {
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 6px;
    width: calc((100% - 12px) / var(--tab-count));
    content: "";
    border-radius: 999px;
    background: rgb(255 255 255 / 28%);
    box-shadow: 0 0 0 .5px rgb(0 0 0 / 12%), inset 0 1px 0 rgb(255 255 255 / 50%);
    transform: translateX(calc(var(--active-index) * 100%));
    transition: transform .5s cubic-bezier(.3, 1.35, .5, 1), opacity .2s;
  }

  [data-glass-nav][data-active="false"]::before,
  [data-glass-nav].is-lensing::before {
    opacity: 0;
  }

  [data-glass-nav] a {
    position: relative;
    z-index: 3;
    display: grid;
    flex: 1;
    min-width: 0;
    min-height: 52px;
    gap: .2rem;
    place-content: center;
    place-items: center;
    padding: 0;
    color: #fff;
    font-size: .68rem;
    line-height: 1.1;
    text-decoration: none;
    text-shadow: 0 1px 3px rgb(0 0 0 / 65%);
    transition-property: transform, color;
    transition-duration: .25s, .32s;
  }

  [data-glass-nav] a[aria-current="page"] {
    color: #fff;
    font-weight: 700;
  }

  [data-glass-nav] .mobile-bottom-nav__icon,
  [data-glass-nav] .platform-bottom-nav__icon {
    width: auto;
    height: auto;
    background: none;
    transform: none;
    filter: drop-shadow(0 1px 2px rgb(0 0 0 / 60%));
  }

  [data-glass-nav][data-tone="light"] .mobile-bottom-nav__icon,
  [data-glass-nav][data-tone="light"] .platform-bottom-nav__icon {
    filter: none;
  }

  [data-glass-nav] a[aria-current="page"] .mobile-bottom-nav__icon {
    background: none;
    transform: none;
  }

  [data-glass-nav] i,
  [data-glass-nav] a[aria-current="page"] i,
  [data-glass-nav] a:active i {
    font-size: 1.05rem;
    transform: none;
  }

  [data-glass-nav] svg {
    width: 22px;
    height: 22px;
  }

  [data-glass-nav] a.is-under-lens {
    transform: scale(1.3);
  }

  [data-glass-nav] a.is-settling {
    animation: glass-settle .36s ease-out;
  }

  [data-glass-nav].is-pressing {
    transform: scale(1.06);
  }

  [data-glass-nav] .glass-lens {
    position: absolute;
    z-index: 2;
    top: -9px;
    bottom: -9px;
    left: -4px;
    display: block;
    width: calc((100% - 12px) / var(--tab-count) + 20px);
    border: 1.5px solid rgb(255 255 255 / 92%);
    border-radius: 999px;
    background: linear-gradient(180deg, rgb(255 255 255 / 16%), rgb(255 255 255 / 2%) 45%, rgb(255 255 255 / 10%));
    box-shadow: 0 0 0 1px rgb(0 0 0 / 14%), 0 12px 28px rgb(0 0 0 / 28%), inset 0 2px 6px rgb(255 255 255 / 45%), inset 0 -4px 10px rgb(255 255 255 / 22%);
    opacity: 0;
    pointer-events: none;
    -webkit-backdrop-filter: blur(.5px) brightness(1.6) saturate(160%);
    backdrop-filter: blur(.5px) brightness(1.6) saturate(160%);
    transition: opacity .14s;
  }

  [data-glass-nav].is-lensing .glass-lens {
    opacity: 1;
  }

  /* Over light sections the glass turns light with dark icons, like the native adaptive tab bar. */
  .mobile-bottom-nav[data-glass-nav][data-tone="light"],
  .platform-bottom-nav[data-glass-nav][data-tone="light"] {
    border-color: rgb(255 255 255 / 75%);
    background: linear-gradient(180deg, rgb(255 255 255 / 40%), rgb(255 255 255 / 10%) 60%), rgb(255 255 255 / 16%);
    box-shadow: 0 0 0 .5px rgb(0 0 0 / 12%), 0 10px 28px rgb(0 0 0 / 14%), inset 0 1px 0 rgb(255 255 255 / 90%), inset 0 -1px 0 rgb(255 255 255 / 40%);
    -webkit-backdrop-filter: blur(2px) saturate(180%) brightness(1.06);
    backdrop-filter: blur(2px) saturate(180%) brightness(1.06);
  }
  /* stylelint-enable property-no-vendor-prefix */

  [data-glass-nav][data-tone="light"] a,
  [data-glass-nav][data-tone="light"] a[aria-current="page"] {
    color: #1d2420;
    text-shadow: 0 1px 1px rgb(255 255 255 / 55%);
  }

  [data-glass-nav][data-tone="light"]::before {
    background: rgb(0 0 0 / 8%);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 70%);
  }

  /* Refraction only where glass-nav.js confirmed a Chromium engine: WebKit accepts url() in
     backdrop-filter but then drops the whole filter. */
  .mobile-bottom-nav[data-glass-nav][data-refract],
  .platform-bottom-nav[data-glass-nav][data-refract] {
    backdrop-filter: url("#z3house-glass-distort") blur(2px) brightness(.82) saturate(180%);
  }

  .mobile-bottom-nav[data-glass-nav][data-tone="light"][data-refract],
  .platform-bottom-nav[data-glass-nav][data-tone="light"][data-refract] {
    backdrop-filter: url("#z3house-glass-distort") blur(2px) saturate(180%) brightness(1.06);
  }
}

/* The newly selected icon refracts briefly as the lens dissolves, then settles. */
@keyframes glass-settle {
  0% {
    filter: blur(1.4px) drop-shadow(-2px 0 0 rgb(255 80 120 / 45%)) drop-shadow(2px 0 0 rgb(80 180 255 / 45%));
    transform: scale(1.18);
  }

  60% {
    filter: blur(.3px);
    transform: scale(.97);
  }

  100% {
    filter: none;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-glass-nav],
  [data-glass-nav]::before,
  [data-glass-nav] a {
    transition: none;
  }

  [data-glass-nav].is-pressing {
    transform: none;
  }
}
