:root {
  --hdr-top-h: 36px;
  --hdr-brand-h: 88px;
  --hdr-nav-h: 52px;
  --hdr-total: calc(var(--hdr-top-h) + var(--hdr-brand-h) + var(--hdr-nav-h));
}

#site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  width: 100%;
  will-change: transform;
}

#hdr-top {
  height: var(--hdr-top-h);
  background: var(--color-secondary);
  transition: height .3s ease, opacity .3s ease;
  overflow: hidden;
}

#hdr-brand {
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
  transition: padding .3s ease, height .3s ease;
  height: var(--hdr-brand-h);
  display: flex;
  align-items: center;
}

#hdr-nav {
  background: var(--color-secondary);
  height: var(--hdr-nav-h);
  transition: background .3s ease;
  position: relative;
}

#hdr-nav::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary) 0%, transparent 100%);
  opacity: 0;
  transition: opacity .3s ease;
}

#site-header.scrolled #hdr-top {
  height: 0;
  opacity: 0;
}

#site-header.scrolled #hdr-brand {
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

#site-header.scrolled #hdr-nav {
  background: rgba(30, 58, 138, .97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
}

#site-header.scrolled #hdr-nav::after {
  opacity: 1;
}

#site-header.scrolled #nav-inline-brand {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  max-width: 260px;
}

#nav-inline-brand {
  opacity: 0;
  transform: translateX(-12px);
  pointer-events: none;
  max-width: 0;
  overflow: hidden;
  transition: opacity .3s ease, transform .3s ease, max-width .3s ease;
  white-space: nowrap;
}

.lang-seg {
  display: inline-flex;
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: 9999px;
  overflow: hidden;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
}
.lang-seg span {
  padding: 4px 13px;
  color: rgba(255,255,255,.65);
  transition: background .2s, color .2s;
  user-select: none;
}
.lang-seg span.lang-active {
  background: rgba(255,255,255,.22);
  color: #fff;
}

/* Correct navbar active and hover underline effect */
#hdr-nav .menu > ul > li {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
}

#hdr-nav .menu > ul > li > .menu-item > a {
  position: relative;
}

#hdr-nav .menu > ul > li > .menu-item > a::after {
  content: '';
  position: absolute;
  bottom: -6px; left: 0; right: 0;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s ease;
}

#hdr-nav .menu > ul > li:hover > .menu-item > a::after,
#hdr-nav .menu > ul > li.active > .menu-item > a::after {
  transform: scaleX(1);
}

.mobile-drawer {
  max-height: 0;
  overflow-y: hidden;
  transition: max-height .4s cubic-bezier(.4, 0, .2, 1);
  background: var(--color-secondary);
}
.mobile-drawer.open {
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Scrollbar styles for the mobile drawer */
.mobile-drawer::-webkit-scrollbar {
  width: 5px;
}
.mobile-drawer::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}
.mobile-drawer::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

#hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  border: 1.5px solid rgba(30, 58, 138, 0.15);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: all 0.25s ease;
  padding: 0;
}
#hamburger-btn:hover {
  border-color: var(--color-primary);
  background: rgba(30, 58, 138, 0.04);
}
#hamburger-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
#hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-secondary);
  border-radius: 2px;
  transition: transform .3s ease, opacity .3s ease;
}
#hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#hamburger-btn.open span:nth-child(2) { opacity: 0; }
#hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile Drawer Menu Accordion styles */
.mob-menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.mob-menu-item-group {
  display: flex;
  flex-direction: column;
  width: 100%;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.mob-menu-item-group:last-child {
  border-bottom: none;
}

.mob-menu-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  transition: background-color 0.2s ease;
}

.mob-menu-item-row:hover,
.mob-menu-item-row:focus-within {
  background-color: rgba(255, 255, 255, 0.04);
}

.mob-menu-link {
  flex: 1;
  display: block;
  padding: 12px 14px;
  color: rgba(255, 255, 255, 0.95);
  font-family: var(--font-poppins, 'Poppins', sans-serif);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease, padding-left 0.2s ease;
  position: relative;
}

/* Hover effect on links */
.mob-menu-link:hover,
.mob-menu-link:focus {
  color: #ffffff;
  padding-left: 18px;
}

/* Flat link takes full row padding */
.mob-menu-link-flat {
  padding-right: 14px;
}

/* Accordion expand button */
.mob-accordion-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
  user-select: none;
}

.mob-accordion-btn:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.08);
}

/* Accordion chevron */
.mob-chevron {
  font-size: 0.85rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Submenu container indentation & left line */
.mob-submenu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 16px;
  margin-left: 8px;
  border-left: 1.5px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 8px;
}

.mob-submenu-link {
  font-size: 0.88rem;
  font-weight: 450;
  color: rgba(255, 255, 255, 0.85);
  padding: 10px 12px;
}

.mob-submenu-link:hover {
  color: #ffffff;
  padding-left: 16px;
}

/* Accordion toggle behavior */
.mob-accordion-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

/* Checked state expansion & rotation */
.mob-accordion-toggle:checked ~ .mob-accordion-content {
  max-height: 1200px;
  opacity: 1;
}

.mob-accordion-toggle:checked ~ .mob-menu-item-row .mob-chevron {
  transform: rotate(180deg);
}

.mob-accordion-toggle:checked ~ .mob-menu-item-row .mob-accordion-btn {
  color: var(--color-primary);
}

#hdr-date-en, #hdr-date-ne {
  font-variant-numeric: tabular-nums;
  font-size: .72rem;
  letter-spacing: .03em;
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
#site-header { animation: fadeSlideDown .4s ease both; }

@media print {
  #site-header { position: static; box-shadow: none; }
  #hdr-top, #hdr-nav { display: none; }
}
