/*
  Styles for the shared site header ("header.php"): a full-width bar pinned to the top,
  with numbered navigation links and a thin progress line that fills while scrolling.
  Mobile layout first, desktop from 900px.
*/

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--header-border);
  background: var(--header-background);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* Reading progress line, sized by header.js through "--scroll-progress". */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 2px;
  background: var(--header-progress);
  transform: scaleX(var(--scroll-progress, 0));
  transform-origin: left;
}

.header-bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100% - 32px, var(--content-width));
  min-height: 68px;
  margin-inline: auto;
  padding-block: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--heading-text);
  text-decoration: none;
}

/* Logo with a dashed "orbit" ring that turns slowly on hover. */
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1.5px dashed var(--brand-orbit);
  border-radius: 50%;
  opacity: 0.45;
}

.brand-mark img {
  width: 34px;
  height: 34px;
}

@media (prefers-reduced-motion: no-preference) {
  .brand:hover .brand-mark::before {
    animation: brand-orbit-spin 6s linear infinite;
    opacity: 1;
  }

  .brand:hover .brand-mark img {
    animation: brand-orbit-spin 12s linear infinite reverse;
  }
}

@keyframes brand-orbit-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Mobile menu button: shows a menu icon when closed and a cross when open. */
.menu-button {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1.5px solid var(--menu-button-border);
  border-radius: var(--radius-small);
  background: var(--menu-button-background);
  color: var(--menu-button-icon);
  box-shadow: 3px 3px 0 var(--menu-panel-shadow);
  cursor: pointer;
}

.menu-button .icon {
  width: 22px;
  height: 22px;
}

.menu-button-close,
.menu-button[aria-expanded="true"] .menu-button-open {
  display: none;
}

.menu-button[aria-expanded="true"] .menu-button-close {
  display: block;
}

/* Without JavaScript the navigation simply stays visible inside the bar. */
.site-nav {
  width: 100%;
  padding: 4px 0 8px;
}

.js .site-nav {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  right: 0;
  padding: 12px;
  border: 1.5px solid var(--menu-panel-border);
  border-radius: var(--radius-medium);
  background: var(--menu-panel-background);
  box-shadow: 6px 6px 0 var(--menu-panel-shadow);
}

.js .menu-button[aria-expanded="true"] + .site-nav {
  display: block;
}

.nav-list {
  display: grid;
  list-style: none;
  margin-bottom: 12px;
  counter-reset: nav-number;
}

/* Each link carries a small index number, like entries in a table of contents. */
.nav-link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--header-border);
  font-weight: 600;
  color: var(--nav-link-text);
  text-decoration: none;
  counter-increment: nav-number;
  transition: color 0.2s ease;
}

.nav-link::before {
  content: counter(nav-number, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--nav-link-number);
}

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

.nav-cta {
  width: 100%;
}

@media (min-width: 900px) {
  .header-bar {
    flex-wrap: nowrap;
    min-height: var(--header-height);
  }

  .menu-button {
    display: none;
  }

  .site-nav,
  .js .site-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    position: static;
    width: auto;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .nav-list {
    display: flex;
    gap: 4px;
    margin: 0;
  }

  .nav-link {
    position: relative;
    padding: 10px 14px;
    border-bottom: 0;
  }

  /* Small accent bar under the current page's link. */
  .nav-link[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 2px;
    height: 2px;
    background: var(--nav-link-active-marker);
  }

  .nav-cta {
    width: auto;
    min-height: 46px;
    padding: 8px 20px;
  }
}
