/* Site header sticky behavior */
.site-header {
  position: fixed;
  top: var(--drupal-displace-offset-top, 0px);
  left: var(--drupal-displace-offset-left, 0px);
  right: var(--drupal-displace-offset-right, 0px);
  width: calc(100% - var(--drupal-displace-offset-left, 0px) - var(--drupal-displace-offset-right, 0px));
  z-index: 50;
  transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), backdrop-filter 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Solid bg by default for pages without hero */
.site-header:not(.is-scrolled):not(.is-menu-open) {
  background-color: rgb(13, 21, 50);
}

/* Transparent when page has a hero (gradient handles readability) */
body:has([data-video-hero], [data-image-hero], .study-program-hero) .site-header:not(.is-scrolled):not(.is-menu-open) {
  background-color: transparent;
}

.site-header.is-scrolled {
  background-color: rgba(13, 21, 50, 0.95);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 4px rgba(13, 21, 50, 0.6);
}

/* Mobile sticky header - taller */
@media (max-width: 1023px) {
  .site-header.is-scrolled {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
}

/* Solid background when mobile menu is open */
.site-header.is-menu-open {
  background-color: rgb(13, 21, 50);
}

.site-header.is-menu-open .header-gradient {
  opacity: 0;
}

.site-header.is-scrolled .header-gradient {
  opacity: 0;
}

.header-top-row > div {
  padding-bottom: 0.5rem;
}

/* Header top gradient — hidden by default (not needed over solid bg) */
.header-gradient {
  background: linear-gradient(
    180deg,
    rgba(13, 21, 50, 0.8) 0%,
    rgba(13, 21, 50, 0.8) 35%,
    rgba(13, 21, 50, 0.6) 55%,
    rgba(13, 21, 50, 0.35) 75%,
    rgba(13, 21, 50, 0.12) 90%,
    rgba(13, 21, 50, 0) 100%
  );
  transition: opacity 0.3s ease;
  opacity: 0;
}

/* Show gradient only when hero exists */
body:has([data-video-hero], [data-image-hero], .study-program-hero) .header-gradient {
  opacity: 1;
}

/* Desktop header layout - align items stretch so both sides same height */
.header-desktop {
  align-items: stretch;
}

/* Logo - smooth scale on scroll, vertically centered */
.header-logo {
  transform-origin: left center;
  will-change: transform;
  display: flex;
  align-items: center;
}

.header-logo img {
  display: block;
}

/* Language area width - used for alignment */
:root {
  --header-lang-width: 3.5rem;
  --header-gap: 0.5rem;
}

/* Right side container - flex column, same height as logo */
/* padding-top reserves space for the absolutely positioned top row */
.header-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  position: relative;
  padding-top: 2.5rem;
  min-width: 0;
}

/* Top row - absolutely positioned at top, full width of parent */
.header-top-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transform-origin: top right;
  will-change: opacity;
  z-index: 10;
}

/* Top row content - right-aligned, baseline aligned for underlines */
.header-top-content {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: var(--header-gap);
}

/* Search area - width set by JS to fill available space */
.header-search-area {
  flex: 1;
  min-width: 200px;
}

/* Language area - fixed width for alignment */
.header-lang-area {
  flex-shrink: 0;
  min-width: var(--header-lang-width);
  display: flex;
  justify-content: flex-end;
}

/* Nav row content - right-aligned */
.header-nav-content {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--header-gap);
}

/* Nav area - natural width, right-aligned */
.header-nav-area {
  min-width: 0;
}

/* Spacer to match language area width */
.header-lang-spacer {
  flex-shrink: 0;
  width: var(--header-lang-width);
  display: flex;
  justify-content: flex-end;
}

/* Nav row - at bottom in default, centered when scrolled */
.header-nav-row {
  margin-top: auto;
  width: 100%;
  min-width: 0;
  transition: margin-top 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* When scrolled, center nav vertically */
.site-header.is-scrolled .header-right {
  justify-content: center;
}

.site-header.is-scrolled .header-nav-row {
  margin-top: 0;
}

/* Mobile menu */
.mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: rgb(13, 21, 50);
}

.mobile-menu.is-open {
  max-height: 80vh;
}

/* Mobile navigation link hover */
.mobile-nav__link {
  transition: text-decoration 0.2s ease;
}

.mobile-nav__link:hover,
.mobile-nav__link.is-active {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Mobile CTA - filled (default) */
.mobile-nav__cta {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.25rem 1.5rem;
  background-color: var(--color-light);
  color: var(--color-primary);
  border-radius: 9999px;
  transition: opacity 0.2s ease;
  margin-right: 0.75rem;
}

.mobile-nav__cta:hover {
  opacity: 0.9;
}

/* Mobile CTA - outlined variant */
.mobile-nav__cta--outline {
  background-color: transparent;
  color: white;
  border: 1px solid white;
}

.mobile-nav__cta--outline:hover {
  opacity: 0.8;
}

/* Hamburger icon animation */
.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: white;
  margin: 5px 0;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.hamburger.is-active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.is-active span:nth-child(2) {
  opacity: 0;
}

.hamburger.is-active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Narrow desktop: shrink logo & header gap to free nav space */
@media (max-width: 1220px) {
  .header-desktop {
    gap: 2rem; /* 32px, down from 56px */
  }

  .header-logo img {
    height: 42px; /* down from 56px (h-14) */
  }
}
