/* V4.3.2 — polished bottom navigation + smoother mobile scrolling */

@media (max-width: 900px) {
  :root {
    --mobile-nav-bar-height: 70px;
    --mobile-nav-outer-gap: 10px;
  }

  html {
    scroll-behavior: auto !important;
  }

  body {
    overscroll-behavior-y: auto !important;
  }

  .main-content {
    touch-action: pan-y;
    padding-bottom: calc(
      var(--mobile-nav-bar-height) +
      (var(--mobile-nav-outer-gap) * 2) +
      env(safe-area-inset-bottom)
    ) !important;
  }

  /* Floating, consistent navigation bar. Avoid expensive blur on Android. */
  .mobile-bottom-nav.mobile-only {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    position: fixed;
    z-index: 90;
    left: max(var(--mobile-nav-outer-gap), env(safe-area-inset-left));
    right: max(var(--mobile-nav-outer-gap), env(safe-area-inset-right));
    bottom: calc(var(--mobile-nav-outer-gap) + env(safe-area-inset-bottom));
    width: auto;
    height: var(--mobile-nav-bar-height);
    min-height: var(--mobile-nav-bar-height);
    padding: 6px;
    border: 1px solid rgba(205, 216, 231, 0.92);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 28px rgba(14, 38, 72, 0.16), 0 2px 7px rgba(14, 38, 72, 0.07);
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    transform: none !important;
    will-change: auto !important;
    contain: layout paint;
  }

  .mobile-bottom-nav > a,
  .mobile-bottom-nav > button {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    min-width: 0;
    min-height: 56px;
    margin: 0;
    padding: 4px 1px 3px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: #728096;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font: inherit;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    transition: color 120ms ease, background-color 120ms ease, transform 80ms ease;
  }

  .mobile-bottom-nav > a::before,
  .mobile-bottom-nav > button::before,
  .mobile-bottom-nav > a.active::before,
  .mobile-bottom-nav > button.active::before {
    content: none !important;
  }

  .mobile-bottom-nav > a:active,
  .mobile-bottom-nav > button:active {
    transform: scale(0.96);
  }

  .mobile-bottom-nav > a.active,
  .mobile-bottom-nav > button.active {
    color: #0f63e8;
    background: #edf4ff;
    font-weight: 800;
  }

  .mobile-bottom-nav > a.active::after,
  .mobile-bottom-nav > button.active::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 50%;
    width: 18px;
    height: 3px;
    border-radius: 999px;
    background: currentColor;
    transform: translateX(-50%);
  }

  .mobile-bottom-nav .mobile-nav-icon {
    width: 31px;
    height: 29px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 0 !important;
    line-height: 1;
  }

  .mobile-bottom-nav .mobile-nav-icon svg {
    width: 23px;
    height: 23px;
    display: block;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-bottom-nav [data-view="home"] .mobile-nav-icon svg path:first-child {
    fill: currentColor;
    stroke: currentColor;
  }

  .mobile-bottom-nav [data-view="home"]:not(.active) .mobile-nav-icon svg path:first-child {
    fill: none;
  }

  .mobile-bottom-nav #mobileMoreButton .mobile-nav-icon svg circle {
    fill: currentColor;
    stroke: none;
  }

  .mobile-bottom-nav small {
    display: block;
    max-width: 100%;
    margin: 0;
    color: inherit;
    font-size: 10px !important;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Expensive visual effects create noticeable hitching on mid-range phones. */
  .quick-tags button,
  .quick-tags a,
  .modal-backdrop,
  .modal-header,
  .sidebar-overlay {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  .topbar,
  .mobile-bottom-nav,
  .hero-card,
  .panel {
    will-change: auto !important;
  }

  .topbar {
    transform: none !important;
  }

  /* content-visibility can pause briefly when cards enter the viewport. */
  .recent-card,
  .hsk-panel,
  .study-grid,
  .leaderboard-panel,
  .seo-content-section,
  .content-pair,
  .right-column,
  .cms-contact-section,
  .seo-popular-grid a {
    content-visibility: visible !important;
    contain-intrinsic-size: none !important;
  }

  .hero-card,
  .panel,
  .progress-panel,
  .word-card,
  .recent-card,
  .hsk-panel,
  .leaderboard-panel {
    box-shadow: 0 4px 14px rgba(24, 54, 94, 0.06) !important;
  }

  .modal-dialog,
  .modal-body,
  .sidebar {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 390px) {
  :root {
    --mobile-nav-outer-gap: 7px;
  }

  .mobile-bottom-nav.mobile-only {
    border-radius: 19px;
    padding-left: 4px;
    padding-right: 4px;
  }

  .mobile-bottom-nav > a,
  .mobile-bottom-nav > button {
    border-radius: 14px;
  }

  .mobile-bottom-nav small {
    font-size: 9.5px !important;
  }
}

@media (hover: none) and (pointer: coarse) {
  .mobile-bottom-nav > a:hover,
  .mobile-bottom-nav > button:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-bottom-nav > a,
  .mobile-bottom-nav > button {
    transition: none !important;
  }
}

/* V4.4.0 — crawlable dictionary hub navigation on the home page. */
.seo-dictionary-hub-nav{display:flex;flex-wrap:wrap;gap:9px;margin:18px 0 22px}
.seo-dictionary-hub-nav a{display:inline-flex;align-items:center;min-height:42px;padding:8px 13px;border:1px solid rgba(12,28,54,.12);border-radius:999px;background:#fff;color:#143d72;font-weight:800;text-decoration:none}
.seo-dictionary-hub-nav a:hover{border-color:#2f6fc4;background:#f4f8ff}
@media(max-width:700px){.seo-dictionary-hub-nav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.seo-dictionary-hub-nav a{justify-content:center;text-align:center;font-size:13px;padding-inline:8px}}
