/* site chrome: header, drawer, theme toggle
   one navigation, shared byte-identical across every page */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--header-bg);
  border-bottom: var(--line) solid var(--header-border);
}

/* focus rings use the header text color, not the accent */
.site-header :focus-visible,
.site-drawer :focus-visible {
  outline-color: var(--header-text);
}

.site-header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.site-brand,
.site-brand:hover {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: transparent;
  color: var(--header-text);
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.site-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

/* centered on the bar, not between the brand and the buttons */
.site-nav {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.site-nav a,
.icon-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 14px;
  border: var(--line-thin) solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--header-text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  /* every control in the bar shares this line box, sized for the 26px marks */
  line-height: 1.8;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.site-nav a:hover,
.icon-button:hover {
  color: var(--header-text);
  border-color: var(--header-border);
  background: var(--header-hover-bg);
  box-shadow: var(--shadow-ink);
  transform: translate(-1px, -1px);
}

.site-nav a:active,
.icon-button:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.site-nav a[aria-current='page'] {
  color: var(--header-text);
  border-color: var(--header-border);
  background: var(--accent-fill-alt);
  box-shadow: var(--shadow-ink);
}

.site-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.github-link {
  padding: 4px 12px;
}

.github-link svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  flex-shrink: 0;
}

.icon-button svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  flex-shrink: 0;
}

.theme-toggle {
  justify-content: center;
  width: 112px;
}

.theme-toggle .theme-icon-light {
  display: none;
}

[data-theme='light'] .theme-toggle .theme-icon-light {
  display: block;
}

[data-theme='light'] .theme-toggle .theme-icon-dark {
  display: none;
}

/* the bars fold into a cross when open */
.drawer-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  width: 42px;
  margin-left: var(--space-1);
  padding: 9px 9px;
  border: var(--line-thin) solid var(--header-border);
  border-radius: var(--radius);
  background: var(--header-hover-bg);
  box-shadow: var(--shadow-ink);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.drawer-toggle:active,
.drawer-toggle[aria-expanded='true'] {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.drawer-toggle span {
  display: block;
  width: 20px;
  height: 3px;
  background: var(--header-text);
  transition: transform 0.3s, opacity 0.3s;
}

.drawer-toggle[aria-expanded='true'] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.drawer-toggle[aria-expanded='true'] span:nth-child(2) {
  opacity: 0;
}

.drawer-toggle[aria-expanded='true'] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* drawer */

.site-drawer {
  position: fixed;
  inset: var(--header-height) 0 auto 0;
  z-index: 19;
  padding: var(--space-3) var(--space-4) var(--space-5);
  background: var(--bg-raised);
  border-bottom: var(--line) solid var(--border);
  transform: translateY(-100%);
  visibility: hidden;
  transition: transform 0.3s ease-in-out, visibility 0.3s;
}

.site-drawer[data-open='true'] {
  transform: translateY(0);
  visibility: visible;
}

.site-drawer a {
  display: block;
  padding: var(--space-3) var(--space-2);
  border-bottom: var(--line-thin) solid var(--border);
  color: var(--text);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.site-drawer a:hover {
  color: var(--accent-contrast);
  background: var(--accent-fill);
}

.site-drawer a:last-child {
  border-bottom: 0;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.drawer-overlay[data-open='true'] {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 801px) {
  .site-drawer,
  .drawer-overlay {
    display: none;
  }
}

@media (max-width: 800px) {
  .site-brand,
  .site-brand:hover {
    font-size: 1.6rem;
  }

  .site-brand img {
    width: 32px;
    height: 32px;
  }

  .site-nav,
  .github-link span,
  #themeLabel {
    display: none;
  }

  .theme-toggle {
    width: 44px;
    padding: 4px;
  }

  .drawer-toggle {
    display: flex;
  }
}
