.lantivo-bottom-nav,
.lantivo-bottom-nav__space {
  display: none;
}

/* Device geometry is CSS-native from the first paint, with no JS sizing handoff. */
/* The 390px designer preview has a 35px content row and a 20px blue extension. */
/* Wide primary-touch devices retain mobile navigation in landscape.
   Fine-pointer desktop layouts remain hidden at the existing breakpoint. */
@media (max-width: 1023px), (max-width: 1199px) and (pointer: coarse), (pointer: coarse) and (hover: none) {
  .lantivo-bottom-nav,
  .lantivo-bottom-nav__space {
    --lantivo-nav-build: 20261009-device2;
    --lantivo-safe-inline: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    --lantivo-nav-unit: clamp(0.82px, calc(100vw / 390), 1.5px);
    --lantivo-core-height: calc(var(--lantivo-bottom-nav-height-units, 35) * var(--lantivo-nav-unit));
    --lantivo-tail-height: max(
      calc(20 * var(--lantivo-nav-unit)),
      calc(44px - var(--lantivo-core-height))
    );
    --lantivo-main-height: calc(var(--lantivo-core-height) + var(--lantivo-tail-height));
  }

  .lantivo-bottom-nav__space {
    display: block;
    height: calc(var(--lantivo-main-height) + env(safe-area-inset-bottom, 0px));
  }

  .lantivo-bottom-nav {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: var(--lantivo-core-height) var(--lantivo-tail-height) env(safe-area-inset-bottom, 0px);
    width: 100%;
    height: calc(var(--lantivo-main-height) + env(safe-area-inset-bottom, 0px));
    /* Symmetric notch avoidance preserves Contact at the viewport center. */
    padding-inline: max(3.846153846%, var(--lantivo-safe-inline));
    overflow: visible;
    border: 0;
    border-radius: calc(12 * var(--lantivo-nav-unit)) calc(12 * var(--lantivo-nav-unit)) 0 0;
    background: var(--lantivo-bottom-nav-background, #d2e5f6);
    box-shadow: none;
    isolation: isolate;
    font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
  }

  .lantivo-bottom-nav__highlight {
    position: absolute;
    z-index: 0;
    top: calc(var(--lantivo-main-height) / 2);
    left: 0;
    width: calc(85 * var(--lantivo-nav-unit));
    height: calc(45 * var(--lantivo-nav-unit));
    transform: translate3d(0, -50%, 0) translateX(-50%);
    border-radius: calc(10 * var(--lantivo-nav-unit));
    background: #e4f2ff;
    opacity: 1;
    pointer-events: none;
    transition: transform 0.8s ease;
  }

  .lantivo-bottom-nav__highlight[hidden] {
    display: none;
  }

  /* Paint inside the selected item's actual grid area before deferred JS.
     Grid positioning handles RTL and scrollbar widths without duplicate math. */
  .lantivo-bottom-nav[data-nav-initial-key="home"] { --lantivo-initial-column: 1; }
  .lantivo-bottom-nav[data-nav-initial-key="categories"] { --lantivo-initial-column: 2; }
  .lantivo-bottom-nav[data-nav-initial-key="about"] { --lantivo-initial-column: 4; }
  .lantivo-bottom-nav[data-nav-initial-key="search"] { --lantivo-initial-column: 5; }

  .lantivo-bottom-nav:not([data-nav-ready]) .lantivo-bottom-nav__highlight {
    grid-column: var(--lantivo-initial-column, 1) / span 1;
    grid-row: 1 / span 2;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
    transition: none;
  }

  .lantivo-bottom-nav__item {
    position: relative;
    z-index: 1;
    display: flex;
    /* Span the blue content row and extension so the tap target stays usable
       while the icon/label group remains at the same visual center. */
    grid-row: 1 / span 2;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: var(--lantivo-main-height);
    padding: 0 calc(2 * var(--lantivo-nav-unit));
    color: #243447 !important;
    text-align: center;
    text-decoration: none;
    transform: none;
    -webkit-tap-highlight-color: transparent;
  }

  .lantivo-bottom-nav__item[data-key="home"] { grid-column: 1; }
  .lantivo-bottom-nav__item[data-key="categories"] { grid-column: 2; }
  .lantivo-bottom-nav__item[data-key="about"] { grid-column: 4; }
  .lantivo-bottom-nav__item[data-key="search"] { grid-column: 5; }

  .lantivo-bottom-nav__item.is-active {
    color: #002d71 !important;
  }

  .lantivo-bottom-nav__content {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    max-width: 100%;
  }

  .lantivo-bottom-nav__icon {
    display: block;
    flex: 0 0 auto;
    width: calc(24 * var(--lantivo-nav-unit));
    height: calc(24 * var(--lantivo-nav-unit));
    transform: scale(var(--lantivo-optical-x, 1), var(--lantivo-optical-y, var(--lantivo-optical-x, 1)));
  }

  .lantivo-bottom-nav__icon--home {
    --lantivo-optical-x: 1.10855;
    --lantivo-optical-y: 1.042;
  }

  .lantivo-bottom-nav__icon--categories {
    --lantivo-optical-x: 1.03406;
    --lantivo-optical-y: 1.05928;
  }

  .lantivo-bottom-nav__icon--contact {
    --lantivo-optical-x: 0.99152;
    color: #fff;
  }

  .lantivo-bottom-nav__icon--about {
    --lantivo-optical-x: 0.96536;
  }

  .lantivo-bottom-nav__icon--search {
    --lantivo-optical-x: 1.01009;
  }

  .lantivo-bottom-nav__label {
    display: none;
    max-width: 100%;
    color: inherit;
    font-size: max(10px, calc(10 * var(--lantivo-nav-unit)));
    font-weight: 600;
    line-height: 1.1;
    overflow-wrap: anywhere;
  }

  .lantivo-bottom-nav__item.is-active .lantivo-bottom-nav__label {
    display: block;
  }

  /* Match the designer's optical gap correction for its 24px icon frames. */
  .lantivo-bottom-nav__item[data-key="home"] .lantivo-bottom-nav__label { margin-top: calc(-0.538 * var(--lantivo-nav-unit)); }
  .lantivo-bottom-nav__item[data-key="categories"] .lantivo-bottom-nav__label { margin-top: calc(-0.3479 * var(--lantivo-nav-unit)); }
  .lantivo-bottom-nav__item[data-key="about"] .lantivo-bottom-nav__label { margin-top: calc(1.3114 * var(--lantivo-nav-unit)); }
  .lantivo-bottom-nav__item[data-key="search"] .lantivo-bottom-nav__label { margin-top: calc(0.124 * var(--lantivo-nav-unit)); }

  .lantivo-bottom-nav__item--contact {
    position: absolute;
    z-index: 2;
    top: calc(var(--lantivo-main-height) / 2 - 21.5 * var(--lantivo-nav-unit));
    left: 50%;
    grid-column: auto;
    width: calc(72 * var(--lantivo-nav-unit));
    height: calc(58 * var(--lantivo-nav-unit));
    padding: 0;
    color: #002d71 !important;
    transform: translateX(-50%);
  }

  .lantivo-bottom-nav__item--contact .lantivo-bottom-nav__content {
    overflow: visible;
  }

  .lantivo-bottom-nav__contact-orb {
    display: grid;
    flex: 0 0 calc(55 * var(--lantivo-nav-unit));
    place-items: center;
    box-sizing: border-box;
    width: calc(55 * var(--lantivo-nav-unit));
    height: calc(55 * var(--lantivo-nav-unit));
    transform: translateY(calc(-15 * var(--lantivo-nav-unit)));
    border: calc(5 * var(--lantivo-nav-unit)) solid var(--lantivo-bottom-nav-background, #d2e5f6);
    border-radius: 50%;
    background: #002d71;
    box-shadow: none;
  }

  .lantivo-bottom-nav__item--contact .lantivo-bottom-nav__label {
    display: block;
    flex: 0 0 auto;
    max-width: none;
    margin-top: calc(-2.65 * var(--lantivo-nav-unit));
    color: #002d71;
    white-space: nowrap;
    transform: translateY(calc(-15 * var(--lantivo-nav-unit)));
  }

  .lantivo-bottom-nav__item:focus-visible {
    outline: 2px solid #002d71;
    outline-offset: -3px;
  }
}

/* Reserve a gesture-safe strip and scale to the short viewport in phone landscape. */
@media (orientation: landscape) and (max-height: 600px) {
  .lantivo-bottom-nav,
  .lantivo-bottom-nav__space {
    --lantivo-nav-unit: clamp(0.82px, calc(100vh / 844), 1px);
    --lantivo-safe-bottom: max(env(safe-area-inset-bottom, 0px), 24px);
    --lantivo-core-height: calc(var(--lantivo-bottom-nav-height-units, 35) * var(--lantivo-nav-unit));
    --lantivo-tail-height: max(
      calc(20 * var(--lantivo-nav-unit)),
      calc(44px - var(--lantivo-core-height))
    );
    --lantivo-main-height: calc(var(--lantivo-core-height) + var(--lantivo-tail-height));
  }

  .lantivo-bottom-nav__space {
    height: calc(var(--lantivo-main-height) + var(--lantivo-safe-bottom));
  }

  .lantivo-bottom-nav {
    grid-template-rows: var(--lantivo-core-height) var(--lantivo-tail-height) var(--lantivo-safe-bottom);
    height: calc(var(--lantivo-main-height) + var(--lantivo-safe-bottom));
  }
}

@supports (height: 100svh) {
  @media (orientation: landscape) and (max-height: 600px) {
    .lantivo-bottom-nav,
    .lantivo-bottom-nav__space {
      --lantivo-nav-unit: clamp(0.82px, calc(100svh / 844), 1px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .lantivo-bottom-nav__highlight {
    transition: none;
  }
}
