/**
 * @file
 * Header component styles for Barrio Red Aprende theme.
 */

/* Header Container */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--ra-shadow-md);
}

.header__container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Top Bar - GOV.CO */
.header__top-bar {
  background-color: var(--ra-header-top-bg);
  padding: 0.75rem 0;
}

.header__top-bar .header__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* GOV.CO Logo */
.header__gov-logo {
  flex-shrink: 0;
}

.header__gov-link {
  display: inline-block;
  line-height: 0;
}

.header__gov-link:focus {
  outline: 2px solid var(--ra-color-white);
  outline-offset: 2px;
}

.header__gov-icon {
  width: 100px;
  height: auto;
}

/* Top header region - normalize image height for block-provided GOV logo */
.header__top-region .logo-govco img,
.header__top-region img {
  height: 1.6rem;
  max-height: 1.6rem;
  width: auto;
  display: inline-block;
}

/* Search Form */
.header__search {
  flex: 1;
  max-width: 600px;
  margin: 0 auto;
}

/* User Menu */
.header__user-menu {
  position: relative;
  flex-shrink: 0;
}

.header__login-button {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.5rem;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--ra-color-white);
  background-color: transparent;
  border: 2px solid var(--ra-color-white);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.header__login-button:hover {
  background-color: var(--ra-color-white);
  color: var(--ra-color-cobalt);
  text-decoration: none;
}

.header__login-button:focus {
  outline: 2px solid var(--ra-color-white);
  outline-offset: 2px;
}

.header__user-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--ra-color-white);
  background-color: transparent;
  border: 2px solid var(--ra-color-white);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header__user-button:hover {
  background-color: var(--ra-color-white);
  color: var(--ra-color-cobalt);
}

.header__user-button:focus {
  outline: 2px solid var(--ra-color-white);
  outline-offset: 2px;
}

.header__user-button[aria-expanded="true"] .header__user-arrow {
  transform: rotate(180deg);
}

.header__user-icon {
  display: inline-flex;
}

.header__user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header__user-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.header__user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 200px;
  background-color: var(--ra-color-white);
  border-radius: 4px;
  box-shadow: var(--ra-shadow-lg);
  padding: 0.5rem 0;
}

.header__user-dropdown[hidden] {
  display: none;
}

.header__user-dropdown-link {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--color-matterhorn);
  font-size: var(--font-size-sm);
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.header__user-dropdown-link:hover {
  background-color: var(--ra-color-white-smoke);
  text-decoration: none;
}

/* Mobile Menu Toggle */
.header__mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 2rem;
  height: 2rem;
  background-color: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 10;
}

.header__mobile-toggle:focus {
  outline: 2px solid var(--ra-color-white);
  outline-offset: 2px;
}

.header__mobile-toggle-bar {
  width: 2rem;
  height: 0.25rem;
  background-color: var(--ra-color-white);
  border-radius: 10px;
  transition: all 0.3s ease;
  transform-origin: 1px;
}

.header__mobile-toggle[aria-expanded="true"] .header__mobile-toggle-bar:nth-child(1) {
  transform: rotate(45deg);
}

.header__mobile-toggle[aria-expanded="true"] .header__mobile-toggle-bar:nth-child(2) {
  opacity: 0;
}

.header__mobile-toggle[aria-expanded="true"] .header__mobile-toggle-bar:nth-child(3) {
  transform: rotate(-45deg);
}

/* Bottom Bar - Navigation */
.header__bottom-bar {
  background-color: var(--ra-header-bottom-bg);
  border-bottom: 1px solid var(--ra-header-border);
  padding: 1rem 0;
}

.header__bottom-bar .header__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

/* Brand Logo */
.header__brand {
  flex-shrink: 0;
}

.header__brand-link {
  display: inline-block;
  line-height: 0;
}

.header__brand-link:focus {
  outline: 2px solid var(--ra-color-focus);
  outline-offset: 2px;
}

.header__brand-logo {
  max-width: 200px;
  height: auto;
}

/* Backdrop */
.header__backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  transition: opacity 0.3s ease;
}

.header__backdrop[hidden] {
  display: none;
}

/* Responsive Styles */
@media (max-width: 991px) {
  .header__top-bar .header__container {
    flex-wrap: wrap;
  }

  .header__search {
    order: 3;
    flex-basis: 100%;
    max-width: 100%;
  }

  .header__mobile-toggle {
    display: flex;
  }

  .header__bottom-bar .header__container {
    flex-wrap: wrap;
  }
}

@media (max-width: 767px) {
  .header__container {
    padding: 0 0.75rem;
  }

  .header__top-bar {
    padding: 0.5rem 0;
  }

  .header__bottom-bar {
    padding: 0.75rem 0;
  }

  .header__gov-icon {
    width: 80px;
  }

  .header__brand-logo {
    max-width: 150px;
  }

  .header__login-button,
  .header__user-button {
    padding: 0.375rem 1rem;
    font-size: var(--font-size-xs);
  }

  .header__user-name {
    display: none;
  }
}

