/* City Line Operations navigation uses the existing rail, tablet and phone layouts. */
@media screen {
  body:not(.login-mode) #primarySidebar {
    --ops-nav-bg: #111c29;
    --ops-nav-line: #304051;
    --ops-nav-text: #f3f6fb;
    --ops-nav-muted: #b9c5d3;
    --ops-nav-hover: #233345;
    --ops-nav-gold: #ffcb16;
    --ops-nav-on-gold: #201b0a;
    --line: var(--ops-nav-line);
    --line-strong: #415163;
    scrollbar-color: #536476 var(--ops-nav-bg);
    color: var(--ops-nav-text);
    border-color: var(--ops-nav-line);
    background-color: var(--ops-nav-bg);
    box-shadow: 1px 0 0 var(--ops-nav-line);
  }

  body:not(.login-mode) #primarySidebar {
    .brand,
    .sidebar-footer {
      border-color: var(--ops-nav-line);
      background-color: var(--ops-nav-bg);
    }

    .nav-list { scrollbar-color: #536476 var(--ops-nav-bg); }

    .sidebar-section-title {
      color: #ecf1f7;
      font-weight: 700;
    }

    .nav-item[data-view] {
      --ops-nav-icon: #94b5f2;
      color: var(--ops-nav-text);
      background-color: transparent;
      border-color: transparent;
      border-radius: 9px;
      font-weight: 600;
      box-shadow: none;
    }

    .nav-item[data-nav-tone="cyan"],
    .nav-item[data-nav-tone="teal"] { --ops-nav-icon: #82d7cd; }
    .nav-item[data-nav-tone="indigo"],
    .nav-item[data-nav-tone="violet"] { --ops-nav-icon: #b5a4ee; }
    .nav-item[data-nav-tone="amber"],
    .nav-item[data-nav-tone="orange"] { --ops-nav-icon: #eac078; }
    .nav-item[data-nav-tone="emerald"] { --ops-nav-icon: #8bd6ad; }
    .nav-item[data-nav-tone="rose"] { --ops-nav-icon: #ed9eb9; }
    .nav-item[data-nav-tone="slate"] { --ops-nav-icon: #b2c4d7; }

    .nav-item[data-view] > .icon {
      color: var(--ops-nav-icon);
      background: color-mix(in srgb, var(--ops-nav-icon) 13%, var(--ops-nav-bg));
      border: 1px solid color-mix(in srgb, var(--ops-nav-icon) 22%, var(--ops-nav-bg));
      border-radius: 7px;
      box-shadow: none;
      font-variation-settings: "FILL" 0, "wght" 520, "GRAD" 25, "opsz" 24;
    }

    .nav-item[data-view]:hover,
    .sidebar-collapse-control:is(:hover, :focus-visible),
    .sidebar-submenu [data-sidebar-shortcut]:hover {
      color: #fff;
      background-color: var(--ops-nav-hover);
    }

    .nav-item[data-view]:is(.active, [aria-current="page"]),
    [data-sidebar-page]:has([data-sidebar-shortcut][aria-current="page"]) > .nav-item[data-view] {
      color: var(--ops-nav-on-gold);
      background-color: var(--ops-nav-gold);
      border-color: transparent;
      box-shadow: none;
      font-weight: 750;
    }

    .nav-item[data-view].active::before { content: none; }
    .nav-item[data-view]:is(.active, [aria-current="page"]) > .icon,
    [data-sidebar-page]:has([data-sidebar-shortcut][aria-current="page"]) > .nav-item > .icon {
      color: var(--ops-nav-on-gold);
      background: rgb(43 34 8 / 9%);
      border-color: transparent;
      box-shadow: none;
    }
    .nav-item[data-view]::after { color: inherit; }

    .sidebar-submenu [data-sidebar-shortcut],
    .sidebar-create:not([hidden]),
    .sidebar-collapse-control {
      color: var(--ops-nav-muted);
      background-color: transparent;
    }

    .sidebar-submenu [data-sidebar-shortcut]:is(.active, [aria-current="page"], [aria-current="true"]) {
      color: #fff3b8;
      background-color: #38404a;
      box-shadow: inset 3px 0 var(--ops-nav-gold);
      font-weight: 700;
    }

    .sidebar-create:is(:hover, :focus-visible, :active) > .material-symbols-rounded {
      background: var(--ops-nav-hover);
      color: #fff;
    }

    :is(.nav-item[data-view], .sidebar-create, .sidebar-collapse-control, [data-sidebar-shortcut]):focus-visible {
      outline: 2px solid #fce183;
      outline-offset: -3px;
      box-shadow: inset 0 0 0 4px #34475a;
    }
  }
}

@media screen and (min-width: 1025px) {
  body:not(.login-mode):not(.sidebar-collapsed) #primarySidebar {
    --ops-rail-inset: 12px;
    padding: 0 var(--ops-rail-inset);
    .brand { height: 66px; margin-bottom: 4px; }
    .brand .brand-wordmark {
      content: url("/assets/operations-wordmark.webp");
      width: min(94%, 196px);
      height: auto;
    }

    .nav-list {
      grid-auto-rows: max-content;
      gap: 4px;
      padding: 0 1px 4px;
      scrollbar-width: thin;
    }
    .sidebar-group-items { gap: 2px; }
    .nav-item[data-view] {
      grid-template-columns: 28px minmax(0, 1fr) auto;
      gap: 9px;
      padding-inline: 10px;
    }
    .nav-item[data-view] > .icon { width: 28px; height: 28px; }

    /* The + is a separate target; its surface joins the active page row. */
    [data-sidebar-page]:has(> .nav-item.active, > .nav-item[aria-current="page"], [data-sidebar-shortcut][aria-current="page"]):has(> .sidebar-create:not([hidden])) {
      column-gap: 0;
      > .nav-item { border-start-end-radius: 0; border-end-end-radius: 0; }
      > .sidebar-create {
        align-self: stretch;
        height: auto;
        color: var(--ops-nav-on-gold);
        background-color: var(--ops-nav-gold);
        border-radius: 0 9px 9px 0;
      }
      > .sidebar-create:is(:hover, :focus-visible) .material-symbols-rounded {
        background: rgb(43 34 8 / 14%);
        color: var(--ops-nav-on-gold);
      }
    }
  }
}

@media screen and (min-width: 1025px) and (pointer: fine) {
  body:not(.login-mode):not(.sidebar-collapsed) #primarySidebar {
    --sidebar-shortcut-height: 25px;
    .sidebar-section-title { min-height: 27px; padding-block: 3px; }
    .sidebar-group-items { gap: 1px; }
    [data-sidebar-group] + [data-sidebar-group]:not([hidden]) { padding-top: 3px; }
    .sidebar-submenu { margin-block: 0; }
    .nav-item[data-view] {
      grid-template-columns: 24px minmax(0, 1fr) auto;
      min-height: 34px;
      height: 34px;
      padding-block: 3px;
    }
    .nav-item[data-view] > .icon { width: 24px; height: 24px; font-size: 17px; }
    .sidebar-create:not([hidden]) { min-height: 34px; height: 34px; }
  }
}

@media screen and (min-width: 761px) {
  body:not(.login-mode) #primarySidebar {
    --ops-road-height: clamp(152px, 18vh, 198px);
    /* Anchor the artwork to the rail so the menu and footer share one continuous surface. */
    background-image:
      linear-gradient(to bottom, var(--ops-nav-bg), rgb(17 28 41 / 96%) 18%, rgb(17 28 41 / 68%) 48%, rgb(17 28 41 / 18%) 80%, transparent),
      linear-gradient(to right, rgb(17 28 41 / 76%), rgb(17 28 41 / 48%) 40%, transparent 88%),
      url("/assets/calendar-asphalt.webp");
    background-size: 100% var(--ops-road-height), 100% var(--ops-road-height), auto var(--ops-road-height);
    background-position: center bottom;
    background-repeat: no-repeat;

    .sidebar-footer { background-color: transparent; border: 0; }
    .sidebar-collapse-control {
      color: var(--ops-nav-text);
      background-color: rgb(17 28 41 / 70%);
    }
    .sidebar-collapse-control:hover { background-color: var(--ops-nav-hover); }
  }
}

@media screen and (min-width: 1025px) and (min-height: 760px) {
  body:not(.login-mode):not(.sidebar-collapsed) #primarySidebar .sidebar-footer {
    justify-content: end;
    flex: none;
    min-height: clamp(48px, 6.8vh, 78px);
    padding: 0 0 3px;
    .sidebar-collapse-control { width: fit-content; min-height: 38px; }
    @media screen and (pointer: coarse) {
      .sidebar-collapse-control { min-height: 44px; }
    }
  }
}

@media screen {
  body:not(.login-mode) #mainContent > .topbar {
    color: var(--text);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }

  body:not(.login-mode) #mainContent .route-toolbar-title-only .route-toolbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: none;
    color: var(--text);
    font-size: clamp(1.125rem, 1.35vw, 1.5rem);
    font-weight: 780;
    letter-spacing: -.025em;
    line-height: 1.2;
  }

  body:not(.login-mode) #mainContent .route-toolbar-icon {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 31px;
    height: 31px;
    border-radius: 9px;
    background: #ffcf25;
    color: #4d3900;
    font-size: 21px;
    font-variation-settings: "FILL" 0, "wght" 550, "GRAD" 0, "opsz" 24;
  }

  body:not(.login-mode) #mainContent .topbar-shared {
    .profile-switcher-button,
    .search input,
    .topbar-notifications { border-radius: 9px; }
  }
}

@media screen and (min-width: 761px) and (max-width: 1180px) {
  body:not(.login-mode, [data-view="calendar"]) #mainContent > .topbar:has(.route-toolbar-title-only) {
    grid-template-columns: minmax(max-content, 1fr) minmax(0, var(--global-topbar-shared-width));
    .topbar-shared { width: 100%; }
  }
  body[data-view="calendar"] #mainContent > .topbar {
    #pageToolbar:has(.route-toolbar-title) { flex: 1 0 max-content; }
    .topbar-shared > .search { flex: 0 1 160px; width: 160px; min-width: 96px; }
  }
}

@media screen and (min-width: 761px) and (max-width: 1024px) {
  body:not(.login-mode) .app-shell:has(> #primarySidebar) {
    grid-template-columns: 76px minmax(0, 1fr);
  }
  body:not(.login-mode) #primarySidebar {
    width: 76px;
    min-width: 76px;
    padding: 9px 8px 10px;
    .brand { width: 100%; height: 44px; padding: 0; margin: 0; }
    .brand .brand-icon {
      width: 42px;
      height: 42px;
      opacity: 1;
      transform: translate(-50%, -50%);
    }
  }
}

@media screen and (max-width: 760px) {
  body:not(.login-mode) #primarySidebar {
    box-shadow: 0 -1px 0 var(--ops-nav-line);
    .nav-list { flex: 0 0 100%; width: 100%; min-width: 0; gap: 3px; }
    /* Five destinations fit the visible rail; additional pages scroll with it. */
    [data-sidebar-page] { flex: 0 0 calc((100% - 12px) / 5); min-width: 0; }
    [data-sidebar-page] > .nav-item[data-view]:not([hidden]) {
      flex: 1 1 100%;
      width: 100%;
      min-width: 0;
      max-width: none;
      padding-inline: 2px;
    }
    [data-sidebar-page] > .nav-item[data-mobile-label]::after {
      max-width: 100%;
      white-space: normal;
      overflow-wrap: anywhere;
      line-height: 1.1;
    }
  }

  body:not(.login-mode) #primarySidebar .nav-item[data-view] > .icon {
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
  }
}
