/* =========================================================
   MOBILE BOTTOM NAVIGATION
   ========================================================= */
.cg-mobile-nav {
  display: none;
}
.cg-mobile-menu, .cg-mobile-menu-shade { display: none; }

/* Phone portrait only. Landscape intentionally returns to the normal site
   layout so the fixed bar does not consume scarce vertical space. */
@media (max-width: 900px) and (orientation: portrait) {
  :root {
    --cg-mobile-nav-height: 68px;
    --cg-mobile-nav-red: #ed1c24;
    --cg-mobile-nav-ink: #171a1d;
    --cg-mobile-nav-bg: #f8f5ee;
  }

  /* The footer needs a real scrollable tail equal to the fixed bar height.
     This lets every legal line remain visible after the user releases the
     scroll instead of snapping back underneath the navigation. */
  body {
    padding-bottom: 0;
  }

  .cg-site-footer {
    margin-bottom: calc(var(--cg-mobile-nav-height) + 8px + env(safe-area-inset-bottom, 0px));
  }

  .cg-mobile-nav {
    position: fixed;
    z-index: 9998;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: var(--cg-mobile-nav-height);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom, 0px));
    background: var(--cg-mobile-nav-bg);
    border-top: 1px solid rgba(23, 26, 29, .10);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, .045);
  }

  .cg-mobile-nav__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 58px;
    padding: 0 1px;
    color: var(--cg-mobile-nav-ink);
    font-family: "Open Sans", Arial, sans-serif;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.02;
    text-align: center;
    text-decoration: none !important;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s ease;
  }

  button.cg-mobile-nav__item { appearance: none; border: 0; border-radius: 0; background: transparent; margin: 0; cursor: pointer; box-shadow: none; }
  .cg-mobile-nav__item:focus-visible { outline: 2px solid #ed1c24; outline-offset: -3px; }
  .cg-mobile-menu-shade { display: block; position: fixed; inset: 0; z-index: 9996; background: rgba(0,0,0,.24); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s ease, visibility .2s; touch-action: none; }
  .cg-mobile-menu { display: block; position: fixed; left: 0; right: 0; bottom: var(--cg-mobile-bar-offset, 68px); z-index: 9997; padding: 8px 20px 18px; max-height: calc(100dvh - var(--cg-mobile-bar-offset, 68px) - 90px); overflow-y: auto; overscroll-behavior: contain; border-radius: 18px 18px 0 0; background: #fff; color: #171a1d; box-shadow: 0 -8px 32px #0002; transform: translateY(28px); opacity: 0; visibility: hidden; pointer-events: none; transition: transform .22s ease, opacity .2s ease, visibility .22s; }
  .cg-mobile-menu.is-open, .cg-mobile-menu-shade.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
  .cg-mobile-menu.is-open { transform: translateY(0); }
  .cg-mobile-menu__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 0 10px; }
  .cg-mobile-menu .cg-mobile-menu__head h2 { margin: 0; color: #171a1d; font: 700 19px/1.3 "Open Sans", Arial, sans-serif; }
  .cg-mobile-menu__close { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; margin: 0 -8px 0 0; background: transparent; border: 0; border-radius: 50%; color: #555; font: 30px/1 Arial, sans-serif; cursor: pointer; }
  .cg-mobile-menu__links[hidden] { display: none; }
  .cg-mobile-menu__links a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 51px; padding: 12px 4px; border-top: 1px solid #eee; color: #222; font: 600 16px/1.4 "Open Sans", Arial, sans-serif; text-decoration: none; }
  .cg-mobile-menu__links a:after { content: '›'; color: #b91e2d; font-size: 25px; line-height: 1; }
  .cg-mobile-menu__links a:hover, .cg-mobile-menu__links a:focus-visible { color: #b91e2d; background: #faf8f4; }
  @media (prefers-reduced-motion: reduce) { .cg-mobile-menu, .cg-mobile-menu-shade { transition: none; } }

  .cg-mobile-nav__label {
    display: block;
    white-space: nowrap;
  }

  .cg-mobile-nav__label--stacked {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    line-height: .95;
  }

  .cg-mobile-nav__item:hover,
  .cg-mobile-nav__item:focus-visible,
  .cg-mobile-nav__item.is-active {
    color: var(--cg-mobile-nav-red);
    text-decoration: none !important;
  }

  .cg-mobile-nav__item.is-active::after {
    content: "";
    position: absolute;
    left: 22%;
    right: 22%;
    bottom: -1px;
    height: 3px;
    border-radius: 999px;
    background: var(--cg-mobile-nav-red);
  }

  .cg-mobile-nav__icon {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .cg-mobile-nav__item--text .cg-mobile-nav__icon {
    width: 36px;
    height: 36px;
  }
}

/* Home-search sheets must clear the fixed portrait navigation, including
   its safe-area padding. The bar script measures its actual rendered height. */
@media (max-width: 640px) and (orientation: portrait) {
  body .cg-findbar .cg-pop {
    bottom: calc(var(--cg-mobile-bar-offset, calc(68px + env(safe-area-inset-bottom, 0px))) + 12px);
    box-sizing: border-box;
    max-height: min(75vh, calc(100dvh - var(--cg-mobile-bar-offset, calc(68px + env(safe-area-inset-bottom, 0px))) - 100px));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* Explicitly undo the portrait footer clearance when a phone is rotated. */
@media (max-width: 900px) and (orientation: landscape) {
  .cg-mobile-nav {
    display: none !important;
  }

  .cg-site-footer {
    margin-bottom: 0 !important;
  }
}

