header {
  position: sticky;
  top: 0;
  grid-template-columns: subgrid;
  height: var(--header-height);
  background-color: var(--bg);
  z-index: 20;
  padding: 0;
  margin-top: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgb(from var(--ib) r g b / 0.5);
  transition: background-color 0.3s ease, border-bottom-color 0.3s ease, height 0.3s ease;
}

.site-header.transparent {
  background-color: transparent;
  border-bottom-color: transparent;
}

.header-contents-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* Only stretch header contents on dashboard */
.site-header.dashboard .header-contents-container {
  height: 100%;
}

@media only screen and (min-width: 640px) {
  .header-contents-container.dashboard {
    grid-template-columns: 240px 1fr auto;
  }
}

.header-logo-container {
  grid-area: left;
  margin: 0 0 0 24px;
  padding: 0;
  border-radius: var(--quaver);
  width: clamp(9.375em, 4.9528em + 11.7925vw, 12.5em);
  display: flex;
  align-items: center;

  &:has(>.logo-link:hover) {
    background-color: rgb(from var(--mb) r g b / 0.2);
  }

  &:has(>.logo-link:active) {
    background-color: rgb(from var(--mb) r g b / 0.4);
  }
}

.logo-link {
  display: flex;
  justify-content: center;
  background: none;

  &:hover {
    background: none;
  }
}

.logo {
  object-fit: contain;
  height: 35px;
  transition: height 0.3s ease;
}

@media only screen and (max-width: 640px) {
  .logo {
    height: 24px;
  }

  header {
    height: var(--header-height);
  }
}

/* breadcrumb links */
.header-middle-breadcrumb-container {
  overflow-x: scroll;
  padding: var(--crotchet) 0;
}

.header-middle-breadcrumb-ul {
  display: none;
  align-items: center;
  gap: var(--crotchet);
  list-style: none;
  margin: auto 0;
}

@media (min-width: 640px) {
  .header-middle-breadcrumb-ul {
    display: flex;
  }
}

.header-breadcrumb-divider {
  color: var(--shw);
}

.header-breadcrumb-icon {
  flex-shrink: 0;
  color: var(--bg);
  height: 20px;
  width: 20px;
}

/* right nav */
.header-right-nav {
  grid-area: right;
  display: flex;
  flex-direction: row;
  justify-content: end;
  align-items: center;
  margin-right: 24px;
  height: auto;
}

/* Dashboard: make right nav fill full header height */
.site-header.dashboard .header-right-nav {
  height: var(--header-height);
  align-self: stretch;
}

.header-right-nav-ul {
  display: flex;
  flex-direction: row;
  justify-content: end;
  align-items: center;
  padding: 0;
  list-style: none;
  gap: 16px;
  height: auto;
}

.site-header.dashboard .header-right-nav-ul {
  height: 100%;
}

/* Individual list items alignment */
.header-right-nav-ul li {
  display: flex;
  align-items: center;
  height: auto;
}

.site-header.dashboard .header-right-nav-ul li {
  height: 100%;
}

/* Specific alignment for search and hamburger list items */
.header-right-nav-ul .search-li,
.header-right-nav-ul .hamburger-li {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ensure icon buttons within list items are centered */
.header-right-nav-ul .search-li .icon-btn,
.header-right-nav-ul .hamburger-li .icon-btn,
.header-right-nav-ul .search-li .hamburger-btn,
.header-right-nav-ul .hamburger-li .hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fix vertical centering of icons in header links */
.header-right-nav a.search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto;
}

.site-header.dashboard .header-right-nav a.search-icon {
  height: 100% !important;
}

.header-right-nav .notifications-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto;
}

.site-header.dashboard .header-right-nav .notifications-btn {
  height: 100% !important;
}

/* Ensure header action buttons expand to full header height even if other CSS sets fixed size */
.site-header.dashboard .header-right-nav .icon-btn,
.site-header.dashboard .header-right-nav .hamburger-btn {
  height: 100% !important;
  min-height: 0;
}

/* Keep inner icons at 24px while container fills height */
.header-right-nav .search-icon>svg,
.header-right-nav .icon-btn>svg,
.header-right-nav .hamburger-btn>svg {
  width: 24px;
  height: 24px;
}

/* Nudge icons to perfect visual center */
.header-right-nav .search-icon,
.header-right-nav .icon-btn,
.header-right-nav .hamburger-btn {
  position: relative;
  top: -1px;
}

.header-text-link,
.header-breadcrumb-link {
  color: var(--shw);
  text-decoration: none;
  padding: var(--semiquaver) var(--quaver);
  border-radius: var(--quaver);
  white-space: nowrap;

  &:hover {
    background-color: rgb(from var(--mb) r g b / 0.2);
  }

  &:active {
    background-color: rgb(from var(--mb) r g b / 0.4);
    color: var(--shw);
  }
}

.account-button,
.home-button {
  background: none;
  height: 100%;
  width: 32px;
  border: none;
  border-radius: var(--quaver);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-sans);
  letter-spacing: 0.08em;

  &:hover {
    background-color: rgb(from var(--mb) r g b / 0.2);
  }

  &:active {
    background-color: rgb(from var(--mb) r g b / 0.4);
  }

  &>svg {
    color: var(--shw);
  }
}

/* Sign up button styling */
.sign-up-button {
  color: var(--mb);
  text-decoration: none;
  padding: var(--semiquaver) var(--quaver);
  border-radius: var(--quaver);
  white-space: nowrap;
  font-family: var(--font-sans);
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 540;
  margin-right: 16px;

  &:active {
    background-color: rgb(from var(--mb) r g b / 0.4);
  }
}

/* Auth buttons container styling */
.auth-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.auth-buttons .sign-up-button {
  margin-right: 0;
}

/* hide hamburger */
@media (min-width: 640px) {
  .hamburger-wrapper {
    display: none;
  }
}

/* show hamburger */
@media (max-width: 640px) {
  .header-right-nav-ul {
    display: none;
  }
}


.notification-avatar-wrapper {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.notification-avatar {
  border-radius: 50%;
  width: 60px;
  height: 60px;
  object-fit: cover;
}

.notification-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}


.notifications-dropdown {
  position: relative;
}

.notifications-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  letter-spacing: 0.08em;
}

.notifications-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: auto;
  max-height: 80vh;
  display: block;
  overflow-y: auto;
  background: #F5F5F5;
  border: none;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  padding: 0;
}

.notifications-dropdown-menu.hidden {
  display: none;
}

.notifications-dropdown-menu::before {
  content: "NOTIFICATIONS";
  display: block;
  color: var(--mb);
  font-family: "Bodoni Moda";
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 16px 10px 16px;
  background: #F5F5F5;
  border-bottom: 1px solid #E0E0E0;
  margin: 0;
}

.notifications-dropdown-header {
  display: none;
}

.notifications-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #fff;
}

.notifications-list li {
  padding: 20px 24px;
  display: flex;
  gap: 16px;
  border-bottom: 1px solid #F0F0F0;
  background: #fff;
  position: relative;
  align-items: flex-start;
}

.notifications-list li:hover {
  background: #FAFAFA;
}

.notifications-list li.unread {
  background-color: #fff;
}

.notification-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.empty-msg {
  padding: 1em;
  text-align: center;
  color: #777;
}

.notification-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.notification-message {
  color: #000;
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.02em;
  display: block;
}

.notification-message:hover {
  color: #333;
}

.notification-content .notification-time {
  color: #999;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.notification-content .notification-time time {
  color: #999;
}

/* Time ago indicator on right side */
.notifications-list li>.notification-time {
  color: #000;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.notifications-list li>.notification-time a {
  color: #000;
  text-decoration: none;
}

/* Mobile adjustments */
@media only screen and (max-width: 640px) {
  .dropdown-menu {
    width: 90vw;
    right: 5vw;
  }

  .notifications-dropdown-menu {
    width: 90vw;
    right: 5vw;
    left: auto;
  }

  .notifications-dropdown-menu::before {
    font-size: 18px;
    padding: 20px 16px 16px 16px;
  }

  .notifications-list li {
    padding: 16px;
    gap: 12px;
  }

  .notification-avatar {
    width: 48px;
    height: 48px;
  }

  .notification-badge {
    width: 20px;
    height: 20px;
  }

  .notification-message {
    font-size: 14px;
  }

  .notification-content .notification-time {
    font-size: 12px;
  }

  .notifications-list li>.notification-time {
    font-size: 14px;
  }
}



.menu-section {
  min-width: 250px;
  /* keep all sections same width */
  margin-bottom: 38px;
}

.menu-section h3 {
  color: var(--black);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 540;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 18px 0;
  /* 5px space below, reset top margin */
}

.menu-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-section ul li a {
  color: var(--mb);
  /* Hamburger Menu - Secondary/DT */
  font-family: var(--font-sans);
  font-size: 14px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  text-transform: capitalize;
  margin-bottom: 10px;
  letter-spacing: 0.08em;
  text-decoration: none;
}

/* Search overlay styles */
.search-overlay {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 475px;
  background: var(--shw);
  /* box-shadow: 0 4px 8px rgba(0,0,0,0.1); */
  display: flex;
  flex-direction: column;
  padding: 0 48px 0;
  /* removed bottom padding */
  gap: 16px;
  z-index: 90;
  border-top: rgb(from var(--ib) r g b / 0.5) 1px solid;
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  transform-origin: top;
  backdrop-filter: blur(10px);
  /* remove border-bottom */
}

/* Search overlay transitions - opening animation */
.search-overlay:not(.hidden) {
  animation: searchSlideDown 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

.search-overlay.hidden {
  animation: searchSlideUp 0.3s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

@keyframes searchSlideDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
    backdrop-filter: blur(0px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
    backdrop-filter: blur(10px);
  }
}

@keyframes searchSlideUp {
  0% {
    opacity: 1;
    transform: translateY(0);
    backdrop-filter: blur(10px);
  }

  100% {
    opacity: 0;
    transform: translateY(-20px);
    backdrop-filter: blur(0px);
  }
}

/* Overlay form */
.search-overlay-form {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

/* Menu footer styles */
.menu-footer {
  display: flex;
  justify-content: flex-end;
}

.menu-footer ul {
  list-style: none;
  display: flex;
  gap: 1.5em;
  padding: 10px 0px;
  margin: 0;
}

.menu-footer ul li a {
  color: var(--mb);
  /* Hamburger Menu - Secondary/DT */
  font-family: var(--font-sans);
  font-size: 14px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  text-transform: capitalize;
  letter-spacing: 0.08em;
  text-decoration: none;

}

.nav-user-icon {
  --size: 32px;
  height: var(--size) !important;
  width: var(--size) !important;
  border-radius: 50% !important;
  object-fit: cover;
}

.profile-link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}



@media (max-width: 640px) {
  .menu-sections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    /* space between columns on desktop */
    max-width: 1000px;
    /* optional: limit total width */
    margin: 50px auto 0;
    padding: 0;
  }

  .menu-sections {
    grid-template-columns: 1fr;
    /* single column */
    gap: 20px;
    /* smaller gap between each section */
  }

  .menu-section h3 {
    margin-top: 30px;
    /* spacing above each header */
  }

  .menu-sections {
    grid-template-columns: 1fr;
    /* stack vertically */
    gap: 20px;
  }

  #menu-overlay.search-overlay {
    position: fixed !important;
    top: calc(var(--header-height, 60px)) !important;
    /* sits below header */
    left: 0 !important;
    right: 0 !important;
    max-height: calc(100vh - (var(--header-height, 60px))) !important;
    height: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    /* smooth iOS scroll */
    z-index: 99999 !important;
    /* above everything */
    background: var(--shw) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
    padding: 20px 20px 40px !important;
    /* keep inner spacing */
    transition: opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), backdrop-filter 0.3s cubic-bezier(0.4, 0.0, 0.2, 1) !important;
    transform: none !important;
  }

  .menu-sections {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    margin: 20px !important;
    width: auto !important;
    transform: none !important;
    transition: opacity 0.3s ease-out 0.1s !important;
  }

  #menu-overlay.hidden .menu-sections {
    opacity: 0 !important;
    transform: none !important;
  }

  #menu-overlay .menu-footer {
    transform: none !important;
    transition: opacity 0.3s ease-out 0.15s !important;
  }

  #menu-overlay.hidden .menu-footer {
    opacity: 0 !important;
    transform: none !important;
  }

  .header-right-nav .header-right-nav-ul {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* hide all li by default */
  .header-right-nav .header-right-nav-ul li {
    display: none !important;
  }

  /* show only the hamburger and the search icon */
  .header-right-nav .header-right-nav-ul li.hamburger-li,
  .header-right-nav .header-right-nav-ul li.search-li {
    display: block !important;
  }

  /* ensure the buttons inside are visible and clickable */
  .header-right-nav .header-right-nav-ul li .icon-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
  }

  .site-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 9999 !important;
  }

  /* Ensure homepage (non-dashboard) header vertically centers icons on mobile */
  .site-header:not(.dashboard) .header-contents-container {
    height: var(--header-height);
  }

  .site-header:not(.dashboard) .header-right-nav {
    height: var(--header-height);
    align-self: stretch;
  }

  .site-header:not(.dashboard) .header-right-nav-ul {
    height: 100%;
  }

  .site-header:not(.dashboard) .header-right-nav-ul li {
    height: 100%;
    display: flex;
    align-items: center;
  }

  .site-header:not(.dashboard) .header-right-nav a.search-icon,
  .site-header:not(.dashboard) .header-right-nav .icon-btn,
  .site-header:not(.dashboard) .header-right-nav .hamburger-btn,
  .site-header:not(.dashboard) .header-right-nav .notifications-btn {
    height: 100% !important;
    display: inline-flex;
    align-items: center;
  }
}

/* Homepage specific header styles */
body.pages.index .site-header {
  position: fixed;
  width: 100%;
  height: 56px;
}

body.pages.index .site-header.transparent {
  height: var(--header-height);
}

/* Logo scaling on scroll for homepage */
body.pages.index .site-header .logo {
  height: 28px;
}

body.pages.index .site-header.transparent .logo {
  height: 35px;
}

@media only screen and (max-width: 640px) {
  body.pages.index .site-header {
    height: 48px;
  }

  body.pages.index .site-header.transparent {
    height: var(--header-height);
  }

  body.pages.index .site-header .logo {
    height: 19px;
  }

  body.pages.index .site-header.transparent .logo {
    height: 24px;
  }
}