/* ========================================================================== 
 * 13.78.24 — Mobile platform chrome
 * Presentation only. Existing routes, mobile-menu/search/theme behaviors,
 * account authority and scroll-hide controller stay unchanged.
 * ========================================================================== */

/* Tablet and compact desktop deliberately stay on the icon-rail model from
 * 13.78.23. This guard prevents mobile chrome from leaking across the 768px
 * transition while touch targets remain available in the left rail. */
@media (min-width: 768px) and (max-width: 1299px) {
  .dhvx-mobile-topbar,
  .dhvx-bottom-nav { display: none !important; }
}

@media (max-width: 767px) {
  :root {
    --dhvx-mobile-top: calc(54px + env(safe-area-inset-top, 0px));
    --dhvx-mobile-bottom: 60px;
  }

  /* Top bar: compact identity + utilities, not a miniature desktop header. */
  .dhvx-mobile-topbar,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-mobile-topbar,
  .dhvx-site-app.is-reader .dhvx-mobile-topbar,
  .dhvx-site-app.is-listing .dhvx-mobile-topbar,
  .dhvx-site-app.is-entity .dhvx-mobile-topbar,
  .dhvx-site-app.is-system.is-system-document .dhvx-mobile-topbar,
  body.error404 .dhvx-site-app.is-system .dhvx-mobile-topbar {
    position: fixed;
    z-index: 100;
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    box-sizing: border-box;
    min-height: var(--dhvx-mobile-top);
    height: var(--dhvx-mobile-top);
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(6px, env(safe-area-inset-left, 0px));
    padding-right: max(6px, env(safe-area-inset-right, 0px));
    gap: 1px;
    border-bottom: 1px solid color-mix(in srgb, var(--dhvx-border) 58%, transparent);
    background: color-mix(in srgb, var(--dhvx-surface) 94%, transparent);
    box-shadow: 0 5px 18px rgba(44, 37, 29, .035);
    -webkit-backdrop-filter: blur(14px) saturate(1.08);
    backdrop-filter: blur(14px) saturate(1.08);
  }
  /* WordPress uses a 46px admin bar on phone widths. Keep DHV chrome below
   * it instead of allowing the two fixed layers to occupy the same pixels. */
  body.admin-bar .dhvx-mobile-topbar,
  body.admin-bar .dhvx-app[data-dhv-experience="feed"] .dhvx-mobile-topbar,
  body.admin-bar .dhvx-site-app.is-reader .dhvx-mobile-topbar,
  body.admin-bar .dhvx-site-app.is-listing .dhvx-mobile-topbar,
  body.admin-bar .dhvx-site-app.is-entity .dhvx-mobile-topbar {
    top: 46px;
  }

  .dhvx-mobile-topbar .dhvx-mobile-brand {
    min-width: 38px;
    height: 48px;
    padding-inline: 2px;
    margin-right: auto;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
  }
  .dhvx-mobile-topbar .dhvx-mobile-brand svg,
  .dhvx-mobile-topbar .dhvx-mobile-brand img {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }
  .dhvx-mobile-topbar .dhvx-mobile-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-basis: 44px;
    border-radius: 12px;
    color: color-mix(in srgb, var(--dhvx-text-secondary) 90%, var(--dhvx-text));
    transition: background-color .14s ease, color .14s ease, transform .14s ease;
  }
  .dhvx-mobile-topbar .dhvx-mobile-icon .dhvx-icon,
  .dhvx-mobile-topbar .dhvx-mobile-icon > svg { width: 22px; height: 22px; }
  .dhvx-mobile-topbar .dhvx-mobile-theme-trigger {
    color: var(--dhvx-text-muted);
  }
  .dhvx-mobile-topbar .dhvx-mobile-menu-trigger[aria-expanded="true"],
  .dhvx-mobile-topbar .dhvx-mobile-theme-trigger[aria-pressed="true"],
  .dhvx-mobile-topbar .dhvx-mobile-search-trigger[aria-current="page"] {
    color: var(--dhvx-brand-strong);
    background: color-mix(in srgb, var(--dhvx-brand) 8%, var(--dhvx-surface));
  }
  .dhvx-mobile-topbar .dhvx-mobile-icon:focus-visible,
  .dhvx-mobile-topbar .dhvx-mobile-brand:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--dhvx-brand) 74%, transparent);
    outline-offset: -2px;
  }

  /* Bottom navigation: four persistent destinations. Active state is expressed
   * around the icon, not as another full-width tab or ranking marker. */
  .dhvx-bottom-nav,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav,
  .dhvx-site-app.is-reader .dhvx-bottom-nav,
  .dhvx-site-app.is-listing .dhvx-bottom-nav,
  .dhvx-site-app.is-entity .dhvx-bottom-nav {
    box-sizing: border-box;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-flow: row;
    min-height: calc(var(--dhvx-mobile-bottom) + env(safe-area-inset-bottom, 0px));
    padding: 2px max(5px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(5px, env(safe-area-inset-left, 0px));
    border-top: 1px solid color-mix(in srgb, var(--dhvx-border) 60%, transparent);
    background: var(--dhvx-surface);
    box-shadow: 0 -8px 24px rgba(44, 37, 29, .045);
    -webkit-backdrop-filter: blur(16px) saturate(1.08);
    backdrop-filter: blur(16px) saturate(1.08);
  }
  .dhvx-bottom-nav a,
  .dhvx-bottom-nav button,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a {
    position: relative;
    isolation: isolate;
    min-width: 0;
    min-height: 56px;
    padding: 4px 2px 3px;
    gap: 2px;
    border-radius: 10px;
    color: var(--dhvx-text-muted);
    -webkit-tap-highlight-color: transparent;
  }
  .dhvx-bottom-nav a::before,
  .dhvx-bottom-nav button::before,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 4px;
    left: 50%;
    width: 38px;
    height: 30px;
    border-radius: 999px;
    background: transparent;
    transform: translateX(-50%);
    transition: background-color .14s ease, transform .14s ease;
  }
  .dhvx-bottom-nav a.is-active::before,
  .dhvx-bottom-nav a[aria-current="page"]::before,
  .dhvx-bottom-nav button[aria-expanded="true"]::before,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a.is-active::before {
    background: color-mix(in srgb, var(--dhvx-brand) 10%, var(--dhvx-surface));
  }
  .dhvx-bottom-nav a > .dhvx-icon,
  .dhvx-bottom-nav button > .dhvx-icon,
  .dhvx-bottom-nav__icon,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a .dhvx-icon {
    position: relative;
    z-index: 1;
    width: 22px;
    height: 22px;
  }
  .dhvx-bottom-nav__icon { display: grid; place-items: center; }
  .dhvx-bottom-nav a.is-active,
  .dhvx-bottom-nav a[aria-current="page"],
  .dhvx-bottom-nav button[aria-expanded="true"],
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a.is-active {
    color: var(--dhvx-text);
  }
  .dhvx-bottom-nav a.is-active > .dhvx-icon,
  .dhvx-bottom-nav a[aria-current="page"] > .dhvx-icon,
  .dhvx-bottom-nav a.is-active .dhvx-bottom-nav__icon,
  .dhvx-bottom-nav a[aria-current="page"] .dhvx-bottom-nav__icon,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a.is-active .dhvx-icon {
    color: var(--dhvx-brand-strong);
  }
  .dhvx-bottom-nav small,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav small {
    position: relative;
    z-index: 1;
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.25px;
    line-height: 1.15;
    font-weight: 590;
    letter-spacing: .005em;
  }
  .dhvx-bottom-nav a.is-active small,
  .dhvx-bottom-nav a[aria-current="page"] small,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a.is-active small {
    font-weight: 720;
  }
  .dhvx-bottom-nav__avatar,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav__avatar {
    width: 23px;
    height: 23px;
    border-radius: 50%;
  }

  @media (hover: none) and (pointer: coarse) {
    .dhvx-mobile-topbar .dhvx-mobile-icon:active,
    .dhvx-mobile-topbar .dhvx-mobile-brand:active,
    .dhvx-bottom-nav a:active,
    .dhvx-bottom-nav button:active {
      background: color-mix(in srgb, var(--dhvx-surface-soft) 78%, transparent);
      transform: scale(.98);
    }
  }
}

/* Narrow phones retain labels; hierarchy compresses without falling back to
 * icon-only navigation. */
@media (max-width: 359px) {
  :root { --dhvx-mobile-bottom: 58px; }
  .dhvx-mobile-topbar .dhvx-mobile-brand { min-width: 34px; }
  .dhvx-mobile-topbar .dhvx-mobile-brand svg,
  .dhvx-mobile-topbar .dhvx-mobile-brand img { width: 32px; height: 32px; flex-basis: 32px; }
  .dhvx-mobile-topbar .dhvx-mobile-icon { width: 42px; min-width: 42px; flex-basis: 42px; }
  .dhvx-bottom-nav a,
  .dhvx-bottom-nav button,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a { min-height: 54px; }
  .dhvx-bottom-nav small,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav small { font-size: 9.75px; max-width: 70px; }
}

/* Short touch landscape: preserve reading height while retaining all four
 * destinations and 44px minimum touchability. */
@media (max-width: 767px) and (max-height: 500px) {
  :root {
    --dhvx-mobile-top: calc(48px + env(safe-area-inset-top, 0px));
    --dhvx-mobile-bottom: 54px;
  }
  .dhvx-mobile-topbar .dhvx-mobile-brand { height: 44px; }
  .dhvx-mobile-topbar .dhvx-mobile-brand svg,
  .dhvx-mobile-topbar .dhvx-mobile-brand img { width: 30px; height: 30px; flex-basis: 30px; }
  .dhvx-bottom-nav a,
  .dhvx-bottom-nav button,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav a { min-height: 50px; }
  .dhvx-bottom-nav small,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-bottom-nav small { font-size: 9.5px; }
}

html[data-theme="dark"] .dhvx-mobile-topbar,
html[data-theme="dark"] .dhvx-bottom-nav {
  border-color: color-mix(in srgb, var(--dhvx-border) 72%, transparent);
  box-shadow: none;
}

@media (forced-colors: active) {
  .dhvx-mobile-topbar,
  .dhvx-bottom-nav { border-color: CanvasText; background: Canvas; box-shadow: none; }
  .dhvx-bottom-nav a.is-active::before,
  .dhvx-bottom-nav a[aria-current="page"]::before,
  .dhvx-bottom-nav button[aria-expanded="true"]::before { outline: 1px solid Highlight; background: Canvas; }
}

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