/*
 * Modern UI base shell: typography, sidebar, content, topbar, hamburger.
 * Loaded after Bootstrap, tbate.css and the theme stylesheet, so these
 * layout rules replace the copies that used to live in BlueWhite/DarkDark.
 */

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--tb-bg);
  color: var(--tb-text);
  font-size: 0.95rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--tb-heading);
  font-weight: 600;
  letter-spacing: -0.015em;
}

p {
  color: inherit;
}

a {
  color: var(--tb-link);
}

a:hover,
a:focus {
  color: var(--tb-link);
}

::selection {
  background: var(--tb-selection-bg);
}

:focus-visible {
  outline: 2px solid var(--tb-focus);
  outline-offset: 2px;
}

.wrapper {
  display: flex;
  width: 100%;
  align-items: stretch;
}

#sidebar {
  width: 180px;
  min-width: 180px;
  max-width: 180px;
  flex: 0 0 180px;
  align-self: flex-start;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--tb-sidebar-bg);
  color: var(--tb-sidebar-fg);
  transition: margin-left var(--tb-transition), transform var(--tb-transition);
  z-index: 1030;
}

#sidebar.active {
  margin-left: -180px;
}

#sidebar .sidebar-header {
  padding: 12px;
  background: var(--tb-sidebar-bg);
}

#sidebar .sidebar-header a,
#sidebar .sidebar-header h3,
#sidebar .sidebar-header h4,
#sidebar .sidebar-header h5 {
  color: var(--tb-sidebar-fg);
}

#sidebar hr {
  border-color: var(--tb-sidebar-muted);
  opacity: 0.35;
}

#sidebar ul {
  margin-bottom: 0;
}

#sidebar ul li a,
#sidebar ul li a.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--tb-radius-sm);
  color: inherit;
  font-size: 1rem;
  line-height: 1.3;
  transition: background-color var(--tb-transition), color var(--tb-transition), transform var(--tb-transition);
}

#sidebar ul li a:hover,
#sidebar ul li a:focus {
  background: var(--tb-sidebar-hover-bg);
  color: var(--tb-sidebar-hover-fg);
}

@media (hover: hover) {
  #sidebar ul li a:hover {
    transform: translateX(4px);
  }
}

#sidebar ul li.active > a,
#sidebar ul li a[aria-expanded="true"] {
  background: var(--tb-sidebar-active-bg);
  color: var(--tb-sidebar-active-fg);
  box-shadow: var(--tb-shadow-sm);
}

#sidebar ul ul {
  padding-left: 4px;
}

#sidebar ul ul a {
  min-height: 40px;
  padding-left: 24px;
  background: var(--tb-sidebar-submenu-bg);
  font-size: 0.9rem;
}

#sidebar ul ul a:hover,
#sidebar ul ul a:focus {
  background: var(--tb-sidebar-hover-bg);
  color: var(--tb-sidebar-hover-fg);
}

#sidebar a[data-toggle="collapse"] {
  position: relative;
}

#sidebar .dropdown-toggle::after {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  transition: transform var(--tb-transition);
}

#sidebar .dropdown-toggle[aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(180deg);
}

#sidebar .nav-chevron {
  margin-left: auto;
  flex: 0 0 auto;
  transition: transform var(--tb-transition);
}

#sidebar [data-toggle="collapse"][aria-expanded="true"] .nav-chevron {
  transform: rotate(180deg);
}

#sidebar ul li a > i {
  flex: 0 0 auto;
}

#sidebar .nav-class-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#sidebar .nav-class-static {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 12px 6px 24px;
  font-size: 0.9rem;
  color: var(--tb-sidebar-muted);
  opacity: 0.6;
  cursor: default;
}

#sidebar ul li a.nav-class-link:hover {
  transform: none;
}

#sidebar .tb-nav-group {
  margin: 14px 12px 4px;
  color: var(--tb-sidebar-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

#content {
  width: 100%;
  min-width: 0;
  padding: 1rem;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--tb-bg);
  transition: margin-left var(--tb-transition);
}

.navbar > .container-fluid {
  flex-wrap: nowrap;
}

.navbar .navbar-nav {
  flex-direction: row;
  flex-wrap: nowrap;
  flex-shrink: 0;
  align-items: center;
}

.navbar #topnavtitle {
  min-width: 0;
}

.navbar {
  flex-flow: row nowrap;
  margin-bottom: 1rem;
  padding: 8px 16px;
  background: var(--tb-navbar-bg);
  color: var(--tb-navbar-fg);
  border: 0 !important;
  border-bottom: 1px solid var(--tb-navbar-border) !important;
  border-radius: 0;
  box-shadow: none !important;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Stage build marker: a 3px rule on the top edge of the sticky navbar wrapper.
   The element is emitted by the faculty portal's topnav.php only when the
   active tree is Stage, so Prod renders nothing and the layout is unchanged. */
.tb-stage-bar {
  height: 3px;
  background: var(--tb-stage);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .navbar {
    background: var(--tb-navbar-solid);
  }
}

.navbar .nav-link,
.navbar .navbar-btn,
.navbar #topnavtitle {
  color: var(--tb-navbar-fg);
}

#topnavtitle {
  max-width: 55vw;
  overflow: hidden;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sidebarCollapse {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--tb-navbar-fg);
  cursor: pointer;
  box-shadow: none;
  outline: none !important;
}

#sidebarCollapse:hover,
#sidebarCollapse:focus-visible {
  background: rgba(127, 127, 127, 0.12);
  border-color: var(--tb-border);
}

#sidebarCollapse:focus-visible {
  outline: 2px solid var(--tb-focus);
  outline-offset: 2px;
}

#sidebarCollapse span {
  position: absolute;
  left: 50%;
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 0 0 -9px;
  background: currentColor;
  transition: top 0.4s ease, transform 0.4s ease, opacity 0.4s ease;
}

/* Desktop default: the sidebar is open, so the button is an X. */
#sidebarCollapse span:first-of-type {
  top: 50%;
  transform: rotate(45deg);
}

#sidebarCollapse span:nth-of-type(2) {
  top: 50%;
  opacity: 0;
}

#sidebarCollapse span:last-of-type {
  top: 50%;
  transform: rotate(-45deg);
}

/* Desktop collapsed: three evenly spaced bars (4px gaps). */
#sidebarCollapse.active span:first-of-type {
  top: calc(50% - 6px);
  transform: none;
}

#sidebarCollapse.active span:nth-of-type(2) {
  top: 50%;
  opacity: 1;
}

#sidebarCollapse.active span:last-of-type {
  top: calc(50% + 6px);
  transform: none;
}

@media (max-width: 768px) {
  /* Mobile default: closed drawer, so the button is a hamburger. */
  #sidebarCollapse span:first-of-type {
    top: calc(50% - 6px);
    transform: none;
  }

  #sidebarCollapse span:nth-of-type(2) {
    top: 50%;
    opacity: 1;
  }

  #sidebarCollapse span:last-of-type {
    top: calc(50% + 6px);
    transform: none;
  }

  /* Mobile open: X. */
  #sidebarCollapse.active span:first-of-type {
    top: 50%;
    transform: rotate(45deg);
  }

  #sidebarCollapse.active span:nth-of-type(2) {
    top: 50%;
    opacity: 0;
  }

  #sidebarCollapse.active span:last-of-type {
    top: 50%;
    transform: rotate(-45deg);
  }
}

@media (max-width: 991px) {
  #topnavtitle {
    max-width: 42vw;
  }
}
