/* Site header: brand, nav, theme toggle, App Store button */
/* Sticky at every width. The header controller publishes --header-height so anchors land below it. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--glass-line);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  padding-block: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  text-decoration: none;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 22px;
  margin-left: auto;
  font-size: 15px;
  font-weight: 600;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-2);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
}

/* In the single-row layout the toggle sits at the far right, after the App Store button. */
.theme-toggle {
  order: 1;
}

/* Below ~720px the header becomes rows: brand and toggle, then the nav, with the button beside the toggle while it fits. */
@media (max-width: 720px) {
  .site-header__inner {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px 14px;
  }

  .brand {
    grid-row: 1;
    grid-column: 1;
  }

  .theme-toggle {
    grid-row: 1;
    grid-column: 2;
    order: 0;
  }

  .header-cta {
    grid-row: 1;
    grid-column: 3;
  }

  /* The five links stay on one row: no wrapping, spread across the width, text scaling with the viewport. */
  .site-nav {
    grid-row: 2;
    grid-column: 1 / -1;
    flex-wrap: nowrap;
    justify-content: space-between;
    margin-left: 0;
    gap: 0 8px;
    font-size: clamp(12px, 3.6vw, 15px);
  }

  .site-nav a {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .site-header__inner {
    grid-template-columns: 1fr auto;
  }

  .header-cta {
    grid-row: 3;
    grid-column: 1 / -1;
    justify-self: center;
  }
}
