.header {
  position: fixed;
  top: 0.875rem;
  left: 5%;
  right: 5%;
  margin: 0 auto;
  max-width: 1600px;
  border: 1px var(--border-color) solid;
  border-radius: 1.5rem;
  padding: 0.5rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  background-color: var(--header-background-color);
  transition: max-width 0.5s cubic-bezier(0.34, 1.45, 0.64, 1);
  user-select: none;
}

.header::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border-radius: inherit; 
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  z-index: -1;
}

.header::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--header-hover-gradient); 
  border-radius: inherit; 
  opacity: 0; 
  transition: opacity 0.5s ease; 
  z-index: -2; 
}

.logo {
  width: 2.65rem;
  height: auto;
}

.logo-container {
  display: flex;
  align-items: center;
  border-radius: 0.625rem;
  transition: transform 0.7s cubic-bezier(0.3, 1.5, 0.7, 1);
}

.left-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.center-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex: 1;
}

.right-section {
  display: flex;
  align-items: center;
}

.menu-button {
  border: none;
  cursor: pointer;
  display: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 0;
}

.menu-button:hover .menu-icon:active {
  color: var(--title-color);
  transform: scale(0.85);
}

.dropdown-content {
  background-color: transparent;
  transition: all 0.3s;
  display: flex;
  gap: 0.375rem;
}

.dropdown-content a {
  border-radius: 1rem;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  color: var(--button-text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.375rem 0.75rem;
  position: relative;
  overflow: hidden;
  background: transparent;
  z-index: 0;
}

.theme-button {
  background: var(--button-background-color);
  border-radius: 1rem;
  border: 1px var(--border-color) solid;
  transition: background-color 0.3s, box-shadow 0.3s;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--button-box-shadow);}

.theme-icon {
  font-size: 0;
  color: var(--button-text-color);
  transition: color 0.3s, transform 0.15s;
}

.theme-button:active {
  background: var(--button-hover);
}

.theme-button:active .theme-icon {
  color: var(--title-color);
  transform: scale(0.85);
}

.dropdown-content span {
  transition: all 0.15s;
}

.dropdown-content a:active span {
  scale: 1;
  transform: translateY(0px);
}

@media (min-width: 769px) {
  .header:hover::after {
    opacity: 1; 
  }

  .theme-button:hover {
    background: var(--button-hover);
    box-shadow: var(--button-hover-box-shadow);
  }

  .theme-button:hover .theme-icon {
    color: var(--title-color);
  }

  .dropdown-content a.active {
    background: var(--button-hover);
    border: 1px var(--border-color) solid;
    box-shadow: var(--button-box-shadow);
    color: var(--title-color); 
    transition: box-shadow 0.3s ease-in-out;
    font-weight: 500;
  }

  .dropdown-content a:before {
    content: "";
    position: absolute;
    inset: 50%;
    width: 101%; 
    height: 101%;
    border-radius: inherit;
    background: var(--button-radial-hover-gradient); 
    transform: translate(-50%, -50%) scale(0); 
    z-index: -1; 
  }
  
  .dropdown-content a:hover:before {
    transform: translate(-50%, -50%) scale(1);
  }
  
  .dropdown-content a:hover {
    color: var(--title-color); 
    transform: scale(1.05); 
    border: 1px var(--border-color) solid; 
    transition: transform 0.4s cubic-bezier(0.4, 1.8, 0.5, 1);
    background: var(--button-background-color);
    box-shadow: var(--button-box-shadow);
  }

  .dropdown-content a:active {
    transform: translateY(0px);
  }

  .dropdown-content a:active span {
    scale: 0.85;
  }

  .logo-container:hover {
    transform: rotate(360deg);
  }
  .menu-button {
    display: none;
  }
}

@media (max-width: 768px) {
  .header {
    top: 0.5rem;
    left: 2%;
    right: 2%;
  }

  .menu-icon {
    font-size: 1.5rem;
    color: var(--button-text-color);
    transition: color 0.3s, transform 0.15s;
    user-select: none;
  }

  .menu-button {
    background-color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.375rem;
  }

  .left-section {
    gap: 0.5rem;
  }

  .right-section {
    background: var(--button-background-color);
    border: 1px var(--border-color) solid;
    border-radius: 1rem;
    box-shadow: var(--button-box-shadow);
  }

  .theme-button {
    border: none;
    background: transparent;
  }

  .dropdown-content {
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    position: absolute;
    background-color: var(--header-background-color);
    z-index: 1;
    right: 0;
    top: 4.5rem;
    border-radius: 1.25rem;
    border: 1px var(--border-color) solid;
    padding: 0.375rem;
    width: 148px;
    transition: transform 0.3s cubic-bezier(0.2, 2.0, 0.3, 1.8);
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    box-shadow: var(--card-box-shadow);
  }
  
  .dropdown-content::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    border-radius: inherit;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    z-index: -1;
  }

  .dropdown-content a {
    padding: 0.75rem;
    border-radius: 0.875rem;
    transition: background-color 0.3s, color 0.3s, transform 0.15s;
    color: var(--button-text-color);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.625rem;
  }

  .theme-button {
    box-shadow: none;
    background-color: var(--button-background-color);
  }

  .dropdown-content.active {
    visibility: visible;
    opacity: 1;
    transform: translateY(0px);
  }

  .right-section:focus-within .menu-icon {
    color: var(--title-color);
  }
}
