/* ===== Header (home link) + centered primary menu =====
   Site only ever renders in the vertical layout (see index.html body class),
   so these rules are written directly instead of duplicated per-layout. */

.site-header {
  position: fixed;
  top: 24px;
  left: 0;
  width: 100%;
  padding: 0 48px;
  z-index: 11;
  pointer-events: none; /* only the link itself should be clickable */
}
.site-header-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  pointer-events: auto;
  font-size: 1.5rem;
  letter-spacing: 0.15em;
}
.site-header-divider { color: var(--color-text); }

.site-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 10;
  transition: opacity var(--transition-medium) ease;
}
/* Faded out (but still occupying no layout space issues, pointer-events off) while a section is open */
.site-menu.is-hidden { opacity: 0; pointer-events: none; }

.nav-item { position: relative; display: block; cursor: pointer; line-height: 1; }

.nav-link {
  position: relative;
  display: inline-block;
  padding: 7px 0;
  margin: 0;
  color: var(--color-text);
  font-size: 1.5rem;
  font-weight: normal;
  line-height: inherit;
  text-align: center;
  overflow: visible;
}
.nav-link::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 0; height: 3px;
  background-color: var(--color-text);
  transition: all var(--transition-medium) ease;
}
.nav-link:hover::after,
.nav-link:focus-visible::after { width: 100%; }
/* Keyboard focus indicator matches the hover underline for consistent affordance */
.nav-link:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; }

/* Active state: underline expands into a full background fill */
.nav-item.active .nav-link { color: var(--color-background); }
.nav-item.active .nav-link::after { left: 0; width: 100%; height: 100%; bottom: 0; background-color: var(--color-text); z-index: -1; }

/* Detail state: fill morphs into a thin stroke to the right of the text.
   Matches regardless of whether .active is also present. */
.nav-item.detail .nav-link { color: var(--color-text); }
.nav-item.detail .nav-link::after {
  left: calc(100% + 6px); /* small gap to the right of text */
  width: 2px;             /* thin stroke */
  height: 100%;           /* full height of text box */
  bottom: 0;
  border-radius: 0;       /* no rounding for a crisp line */
}

/* Exiting state: fill collapses back into a plain underline before disappearing */
.nav-item.exiting .nav-link { color: var(--color-text); }
.nav-item.exiting .nav-link::after { width: 100%; height: 3px; bottom: 0; background-color: var(--color-text); }

/* Responsive tweaks: shrink the header/menu text on smaller screens so they
   never overflow or crowd the viewport. */
@media (max-width: 768px) {
  .site-header { top: 20px; padding: 0 24px; }
  .site-header-link { font-size: 1.2rem; }
  .site-menu { gap: 8px; }
  .nav-link { padding: 5px 0; font-size: 1.2rem; font-weight: normal; color: var(--color-text); }
}
@media (max-width: 480px) {
  .site-header { top: 16px; padding: 0 16px; }
  .site-header-link { font-size: 1rem; }
  .site-menu { gap: 6px; }
  .nav-link { padding: 4px 0; font-size: 1rem; }
}
