/* FAN-1311: one responsive navigation contract for the shared base template. */

.fc-mobile-menu-toggle {
  display: none;
}

/* The logo is a sibling of the rail, so a drawer can never hide it. */
.fc-mhome > .fc-rail__brand {
  z-index: 35;
}

/* News previously owned a desktop-only drawer; the shared rail stays exposed here. */
.fc-mhome--news {
  grid-template-columns: 112px 1fr;
}

.fc-mhome--news .fc-rail--news-drawer {
  position: static;
  width: auto;
  min-height: 0;
  padding: 68px 0 120px;
  overflow: visible;
  background: #fff;
  box-shadow: none;
  transform: none;
  transition: none;
}

@media (max-width: 900px) {
  /* At iPad widths the logo remains exposed and the nav is a horizontal rail. */
  .fc-mhome--news {
    grid-template-columns: 1fr;
  }

  .fc-mhome > .fc-rail__brand {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    width: 140px;
    height: 56px;
    padding: 12px 14px;
  }

  .fc-rail {
    padding-inline-start: 140px;
  }

  .fc-mhome--news .fc-rail--news-drawer {
    position: static;
    width: auto;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    padding-inline-start: 140px;
    overflow-x: auto;
    overflow-y: visible;
    transform: none;
  }

  [dir="rtl"] .fc-mhome--news .fc-rail--news-drawer {
    transform: none;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  /* Override the legacy news drawer's phone-sized child rules on iPad. */
  .fc-mhome--news .fc-rail--news-drawer .fc-rail__btn {
    width: auto;
    min-width: 76px;
    flex-direction: row;
  }

  .fc-mhome--news .fc-rail--news-drawer .fc-rail__premium-wrap {
    width: 54px;
    min-width: 54px;
  }

  .fc-mhome--news .fc-rail--news-drawer .fc-rail__guest-actions {
    width: auto;
    flex-direction: row;
  }
}

@media (max-width: 640px) {
  /* Phones get the only collapsed navigation. */
  .fc-mhome,
  .fc-mhome--news {
    grid-template-columns: 1fr;
  }

  .fc-mhome > .fc-rail__brand {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    width: 140px;
    height: 56px;
    padding: 12px 14px;
    background: #fff;
  }

  .fc-mobile-menu-toggle {
    position: static;
    margin-inline-start: auto;
    top: 8px;
    inset-inline-end: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 84px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--fc-rule-strong);
    border-radius: 8px;
    background: var(--fc-surface);
    color: var(--fc-ink);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
  }

  .fc-mobile-menu-toggle:focus-visible {
    outline: 2.5px solid var(--fc-electric);
    outline-offset: 2px;
  }

  .fc-mobile-menu-toggle__icon {
    display: grid;
    gap: 4px;
    width: 20px;
  }

  .fc-mobile-menu-toggle__icon span {
    display: block;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
  }

  .fc-mobile-menu-toggle__label {
    line-height: 1;
  }

  .fc-rail {
    position: fixed;
    z-index: 80;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: min(19rem, calc(100vw - 3rem));
    padding: 68px 14px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--fc-surface);
    box-shadow: 18px 0 40px -28px var(--fc-black);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform var(--fc-t-base) var(--fc-ease-sharp), visibility 0s linear var(--fc-t-base);
  }

  .fc-rail.is-mobile-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform var(--fc-t-base) var(--fc-ease-sharp), visibility 0s;
  }

  .fc-mhome--news .fc-rail--news-drawer {
    position: fixed;
    z-index: 80;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: min(19rem, calc(100vw - 3rem));
    min-height: 0;
    padding: 68px 14px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--fc-surface);
    box-shadow: 18px 0 40px -28px var(--fc-black);
    transform: translateX(-105%);
    visibility: hidden;
  }

  .fc-mhome--news .fc-rail--news-drawer.is-mobile-open {
    transform: translateX(0);
    visibility: visible;
  }

  .fc-rail .fc-rail__btn {
    width: 100%;
    min-height: 44px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-align: start;
  }

  .fc-rail .fc-rail__btn > span:not(.ico):not(.badge),
  .fc-rail .fc-rail__premium-label {
    display: inline-flex;
    width: auto;
    text-align: start;
  }

  .fc-rail .fc-rail__premium-wrap,
  .fc-rail .fc-rail__guest-actions {
    width: 100%;
    align-items: stretch;
  }

  .fc-rail .fc-rail__premium-wrap {
    flex-direction: row;
    margin: 8px 0;
  }

  .fc-rail .fc-rail__join,
  .fc-rail .fc-rail__login {
    width: 100%;
  }

  /* The secondary menu is moved here by nav.js only while this media query matches. */
  .fc-rail .fc-topbar__menu {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-top: 10px;
    overflow: visible;
  }

  .fc-rail .fc-nd {
    width: 100%;
    height: auto;
    flex-direction: column;
    align-items: stretch;
  }

  .fc-rail .fc-nd__trigger {
    width: 100%;
    min-height: 44px;
    height: 44px;
    justify-content: space-between;
    padding: 0 12px;
    border-radius: 8px;
  }

  .fc-rail .fc-nd__panel {
    position: static;
    display: none;
    width: 100% !important;
    padding-top: 4px;
  }

  .fc-rail .fc-nd.is-open .fc-nd__panel {
    display: block;
  }

  .fc-rail .fc-nd__panel-inner {
    border-radius: 8px;
    box-shadow: none;
    background: var(--fc-surface-2);
  }

  .fc-topbar {
    min-height: 58px;
    height: auto;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 14px;
    padding-inline-start: 140px;
  }

  .fc-mhome--news .fc-topbar {
    min-height: 58px;
    height: auto;
    padding: 8px 14px;
    padding-inline-start: 140px;
  }

  .fc-topbar > .fc-topbar__menu {
    display: none;
  }

  .fc-topbar > .fc-search {
    display: flex !important;
    order: 3;
    flex-basis: 100%;
    max-width: none;
    height: 44px;
  }

  .fc-topbar > .fc-topbar__cta {
    order: 2;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .fc-mobile-nav-backdrop,
  .fc-news-drawer-backdrop {
    position: fixed;
    z-index: 70;
    inset: 0;
    border: 0;
    background: color-mix(in srgb, var(--fc-black) 48%, transparent);
    cursor: pointer;
  }

  .fc-mobile-nav-backdrop[hidden],
  .fc-news-drawer-backdrop[hidden] {
    display: none;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  [dir="rtl"] .fc-rail,
  [dir="rtl"] .fc-mhome--news .fc-rail--news-drawer {
    inset-inline-start: auto;
    inset-inline-end: 0;
    transform: translateX(105%);
    box-shadow: -18px 0 40px -28px var(--fc-black);
  }

  [dir="rtl"] .fc-rail.is-mobile-open,
  [dir="rtl"] .fc-mhome--news .fc-rail--news-drawer.is-mobile-open {
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fc-rail,
  .fc-mhome--news .fc-rail--news-drawer {
    transition: none;
  }
}
