/* Sticky navigation inspired by Ricoui's brand / menu / theme arrangement.
   Layers: page art 1–3, grain 8, navigation 12, skip link 20. */
:root {
  --nav-surface: rgb(244 245 238 / .75);
  --nav-surface-solid: #f4f5ee;
  --nav-border: rgb(88 108 92 / .18);
  --nav-hover: rgb(88 108 92 / .08);
  --nav-active: rgb(88 108 92 / .11);
  --nav-shadow: none;
  --nav-scroll-shadow: 0 8px 28px rgb(39 63 53 / .1);
}

html[data-theme="dark"] {
  --nav-surface: rgb(18 24 21 / .8);
  --nav-surface-solid: #121815;
  --nav-border: rgb(210 225 212 / .14);
  --nav-hover: rgb(218 230 217 / .08);
  --nav-active: rgb(218 230 217 / .11);
  --nav-shadow: none;
  --nav-scroll-shadow: 0 10px 32px rgb(4 9 7 / .35);
}

html { scroll-padding-top: 112px; }
.nav-scroll-marker { position: absolute; top: 1px; left: 0; width: 1px; height: 1px; pointer-events: none; }
.site-header {
  position: sticky;
  top: 0;
  z-index: 12;
  display: block;
  width: 100%;
  min-height: 68px;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: var(--nav-surface);
  color: var(--ink);
  box-shadow: var(--nav-shadow);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-family: var(--sans);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.site-header[data-scrolled="true"] { border-bottom-color: var(--nav-border); box-shadow: var(--nav-scroll-shadow); }
.nav-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  width: min(var(--page-width), 90%);
  min-height: 68px;
  margin-inline: auto;
}
.site-header .wordmark {
  justify-self: start;
  padding-block: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: .065em;
  white-space: nowrap;
}
.site-header .wordmark:hover { color: var(--accent); }
.site-header .site-nav { display: flex; align-items: center; gap: 26px; margin-left: auto; }
.site-header .site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 2px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: .035em;
  white-space: nowrap;
  transition: color .18s ease, background-color .18s ease;
}
.site-header .site-nav a::after { content: none; }
.site-header .site-nav a:hover { color: var(--ink); }
.site-header .site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.nav-actions { display: flex; align-items: center; gap: 4px; justify-self: end; }
.nav-icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .18s ease, transform .18s ease;
}
.nav-icon-button:hover { background: var(--nav-hover); }
.nav-icon-button:active { transform: scale(.95); }
.nav-icon-button svg { grid-area: 1 / 1; width: 21px; height: 21px; stroke-width: 1.7; }
#theme-toggle { position: relative; grid-template-columns: 1fr 1fr; width: 62px; flex-basis: 62px; background: transparent; }
#theme-toggle::before { content: ""; position: absolute; inset: 6px 0; border: 1px solid var(--nav-border); border-radius: 999px; background: var(--nav-hover); }
#theme-toggle::after { content: ""; position: absolute; top: 10px; left: 5px; width: 24px; height: 24px; border-radius: 50%; background: var(--nav-surface-solid); box-shadow: 0 1px 3px rgb(30 47 37 / .12); transition: transform .2s ease; }
#theme-toggle svg { position: relative; z-index: 1; grid-area: auto; width: 16px; height: 16px; }
#theme-toggle .theme-icon-moon { color: var(--muted); }
html[data-theme="dark"] #theme-toggle::after { transform: translateX(28px); }
html[data-theme="dark"] #theme-toggle .theme-icon-sun { color: var(--muted); }
html[data-theme="dark"] #theme-toggle .theme-icon-moon { color: var(--ink); }
.nav-icon-close { visibility: hidden; }
.nav-menu-toggle { display: none; }
.site-header a:focus-visible, .site-header button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 999px; }

@media (max-width: 1280px) { .nav-inner { width: min(1024px, calc(100% - 48px)); } }
@media (max-width: 1023px) { .nav-inner { width: min(960px, calc(100% - 48px)); } }
@media (max-width: 811px) { .nav-inner { width: calc(100% - 32px); } }
@media (max-width: 767px) {
  html { scroll-padding-top: 96px; }
  .site-header {
    top: 0;
    min-height: 64px;
  }
  .nav-inner { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 0; min-height: 64px; }
  .site-header .wordmark { font-size: 19px; }
  .nav-actions { grid-column: 2; grid-row: 1; }
  .site-header .site-nav {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    gap: 22px;
    margin-left: 0;
    padding: 2px 0 8px;
  }
  .site-header.nav-ready .nav-menu-toggle { display: inline-grid; }
  .site-header.nav-ready .site-nav {
    position: absolute;
    top: calc(100% + 7px);
    left: 0;
    right: 0;
    display: grid;
    gap: 4px;
    justify-content: stretch;
    padding: 10px;
    border: 1px solid var(--nav-border);
    border-radius: 22px;
    background: var(--nav-surface-solid);
    box-shadow: var(--nav-scroll-shadow);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
  }
  .site-header .site-nav a { min-height: 46px; padding-inline: 18px; border-radius: 13px; font-size: 15px; }
  .site-header .site-nav a:hover, .site-header .site-nav a[aria-current="page"] { background: var(--nav-active); }
  .site-header[data-menu-open="true"] .site-nav { visibility: visible; opacity: 1; transform: none; pointer-events: auto; }
  .site-header[data-menu-open="true"] .nav-icon-menu { visibility: hidden; }
  .site-header[data-menu-open="true"] .nav-icon-close { visibility: visible; }
}

@media (prefers-reduced-transparency: reduce) {
  .site-header { background: var(--nav-surface-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .site-header, .site-header .site-nav, .site-header .site-nav a, .nav-icon-button { transition: none; }
}
@media (forced-colors: active) {
  .site-header, .site-header.nav-ready .site-nav { background: Canvas; border-color: ButtonText; }
  .site-header .site-nav a[aria-current="page"] { outline: 1px solid ButtonText; }
  .nav-icon-button { color: ButtonText; }
}
