:root {
  --color-glass-bg: rgba(255, 255, 255, 0.2);
  --color-glass-border: rgba(255, 255, 255, 0.3);
  --color-link-highlight: rgba(255, 255, 255, 0.25);

  --color-text: #ffffff;
  --color-focus-outline: #5ab1ff;

  --font-family-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-weight-bold: 600;

  --blur-value: 10px;
  --border-radius-soft: 8px;
  --navbar-height: 70px;
  --navbar-padding: 1.5rem;
  --container-width: 1140px;
  --transition-speed: 0.3s;
}

*, *::before, *::after {
  box-sizing: border-box;
}

header:first-of-type {
  position: fixed;
  inset: 0 auto auto 0;
  width: 100%;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  z-index: 1000;

  background: var(--color-glass-bg);
  border-bottom: 1px solid var(--color-glass-border);
  box-shadow: 0 4px 30px rgba(0,0,0,0.1);
  backdrop-filter: blur(var(--blur-value));
  -webkit-backdrop-filter: blur(var(--blur-value));
}

header:first-of-type > nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--container-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--navbar-padding);
  position: relative;
}

/* Brand (first link inside nav) */
header:first-of-type > nav > a:first-of-type {
  font-size: 1.5rem;
  font-weight: var(--font-weight-bold);
}

/* Text shadow for brand + nav links */
header:first-of-type > nav > a:first-of-type,
header:first-of-type nav ul a {
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Mobile toggle button */
header:first-of-type > nav > button {
  display: block;
  padding: .5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 1001;
}

header:first-of-type > nav > button span {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px auto;
  background-color: var(--color-text);
  border-radius: 2px;
  transition: all var(--transition-speed) ease-in-out;
}

/* Animate bars into "X" based on aria-expanded */
header:first-of-type > nav > button[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
header:first-of-type > nav > button[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
header:first-of-type > nav > button[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Mobile menu */
header:first-of-type nav ul {
  display: none;
  flex-direction: column;
  width: 100%;
  position: absolute;
  top: var(--navbar-height);
  left: 0;
  z-index: -1;
  padding-bottom: 1rem;

  background: var(--color-glass-bg);
  backdrop-filter: blur(var(--blur-value));
  -webkit-backdrop-filter: blur(var(--blur-value));
  border-top: 1px solid var(--color-glass-border);
}

/* Reveal menu when toggle is expanded (no classes needed!) */
header:first-of-type nav:has(> button[aria-expanded="true"]) ul {
  display: flex;
  background-image: linear-gradient(45deg, #ff005c, #5200ff);
}

header:first-of-type nav li { text-align: center; }

header:first-of-type nav ul a {
  display: block;
  padding: 1.25rem;
  font-weight: var(--font-weight-bold);
  transition: background var(--transition-speed) ease;
}

header:first-of-type nav ul a:hover,
header:first-of-type nav ul a:focus {
  background-color: var(--color-link-highlight);
}

/* Accessible focus */
:is(header:first-of-type > nav > button, header:first-of-type nav ul a):focus-visible {
  outline: 2px solid var(--color-focus-outline);
  outline-offset: 2px;
  border-radius: var(--border-radius-soft);
}

/* Desktop */
@media (min-width: 768px) {
  header:first-of-type > nav > button {
    display: none;
  }

  header:first-of-type nav ul {
    display: flex;
    flex-direction: row;
    align-items: center;
    position: static;
    width: auto;
    padding: 0;
    gap: .5rem;
    background: none !important;
    backdrop-filter: none;
    border: none;
    z-index: 1;
  }

  header:first-of-type nav ul a {
    padding: .6rem 1.1rem;
    border-radius: var(--border-radius-soft);
  }

  header:first-of-type nav ul a:hover,
  header:first-of-type nav ul a:focus,
  header:first-of-type nav ul a[aria-current="page"] {
    background-color: var(--color-link-highlight);
  }
}
