/* Header chrome: a translucent, blurred surface with a shared subtle frame. */
/* --header-total-h is .site-header-group's own real total rendered height (padding-top +
   .header-inner's height + the mobile TOC bar's height when it's showing (single.html's
   "mobileToc" block, baseof.html) + padding-bottom) - things outside the group (currently
   just body's own padding-top, base/reset.css) that need to sit flush under it read THIS
   instead of duplicating that math themselves. Written by nav.js's ResizeObserver against
   .site-header-group's real rendered height, not a hand-tracked number per breakpoint - the
   static value here is only a same-paint-frame fallback for the instant before that script
   runs. Hand-tracking this per breakpoint (and, before that, per breakpoint AND separately
   per .container's own padding, before the mobile TOC bar moved into .site-header-group -
   see that comment) is what left a gap between the header and the TOC bar twice before;
   measuring the real DOM instead of guessing at it removes the whole bug class. */
 :root{
     --header-total-h:64px; /* 0.5rem (8px) padding-top + .header-inner's 56px + 0 padding-bottom */
     --header-frame-inset:1.5rem;
     --header-content-inset:12px;
}
/* The one fixed, hide-on-scroll box - .site-header and the mobile TOC bar (single.html's
   "mobileToc" block) are plain in-flow siblings inside it (baseof.html), so they're always
   flush against each other and always move/hide together, by construction, with no offset
   math needed anywhere. Padding lives here (not on .site-header) so it wraps whichever of
   the two children currently renders last - just .site-header on any non-post page or a
   post above 1300px, .site-header then the TOC bar below that - instead of only ever
   trailing .header-inner specifically. */
 .site-header-group{
     position:fixed;
     top:0;
     left:0;
     right:0;
     z-index:50;
     max-width:var(--max);
     margin:0 auto;
     width:100%;
     padding-inline:var(--header-frame-inset);
     padding-top:0.5rem;
     transition:top 0.2s ease, transform 0.28s ease-in-out;
     will-change:transform, top;
}
 .site-header-group.hide{
     transform:translateY(-100%);
     top:0;
}
 .site-header-group.show{
     transform:translateY(0);
     top:0;
}
/* position:relative + z-index (any explicit value) makes .site-header a positioned element
   with its own stacking order at the .site-header-group level, instead of a plain in-flow
   box - without this, .header-inner's own backdrop-filter (below) traps .nav's dropdown
   (z-index:49, responsive.css) inside .header-inner's stacking context, and since
   .mobile-toc-container is a later DOM sibling of .site-header, it paints on top of the
   whole trapped context regardless of that z-index - the dropdown opens hidden behind the
   TOC bar. Explicit z-index here lets .site-header's entire box (dropdown included) outrank
   .mobile-toc-container's, which only needs to be positioned lower (see that rule). */
 .site-header{
     --link-hover:var(--foreground); /* Navbar links stay neutral in both themes. */
     display:block;
     position:relative;
     z-index:2;
     background:transparent;
     border:none;
}
 .header-inner{
     max-width:100%;
     margin:0 auto;
     padding:2px var(--header-content-inset);
     height:auto;
     min-height:40px;
     display:flex;
     align-items:center;
     justify-content:space-between;
     gap:12px;
     /* background:transparent + backdrop-filter:blur() alone has nothing to tint - blur()
        only smears what's already behind it, so the bar would read washed-out/colorless
        without some color mixed in here. */
     background:color-mix(in oklab, var(--background) 90%, transparent);
     backdrop-filter:blur(10px);
     -webkit-backdrop-filter:blur(10px);
     border:0;
     border-radius:0;
}
/* Dark theme's navbar read slightly heavier/more opaque than light's at the same 90% mix -
   10 points less here so it sits lighter against the WebGL background. */
 :is([data-theme="mono"],[data-color-scheme="dark"]) .header-inner{
     background:color-mix(in oklab, var(--background) 80%, transparent);
}
 @media (min-width:1024px){
     .header-inner{
         display:flex;
         align-items:center;
         justify-content:space-between;
         gap:8px;
    }
     .header-inner .brand{
         flex-shrink:0;
    }
     .header-inner .nav{
         flex-grow:1;
         justify-content:flex-end;
         margin-left:auto;
         margin-right:4px;
         max-width:900px;
    }
     .header-inner .header-actions{
         flex-shrink:0;
    }
}
 .brand{
     display:flex;
     align-items:center;
     gap:10px;
     text-decoration:none;
}
 .brand-mark{
     width:32px;
     height:28px;
     display:grid;
     place-items:center;
     font-size:16px;
     line-height:1;
     border-radius:0;
}
/* Caps the rendered size regardless of the mark's own source aspect ratio - without this, an
   SVG here with only a viewBox (no width/height) scales to fit .brand-mark's 32x28 box via
   default "meet" behavior, so a wide/thin shape (the original mark, ~2:1) renders small while
   a roughly-square one (the dragon0N.png tests, ~1:1) renders close to the full box - nearly
   double the visual size for the same navbar slot, since each is constrained by whichever
   dimension is tighter for its own proportions. Fixed height keeps every mark a consistent,
   modest size no matter what gets swapped in next. */
 .brand-mark svg{
     height:28px;
     width:auto;
     max-width:100%;
}
 .brand-text{
     font-family:var(--display);
     font-size:13px;
     letter-spacing:.14em;
     text-transform:uppercase;
     color:var(--foreground);
     font-weight:400;
}
@media (min-width:769px){
  .brand-text{
    letter-spacing:.11em;
    -webkit-text-stroke:.02em currentColor;
  }
}
 .nav{
     display:flex;
     gap:18px;
     align-items:center;
     margin-left:auto;
     flex-grow:1;
     justify-content:flex-end;
     max-width:900px;
}
 .nav a{
     font-size:calc(13px * var(--type-scale));
     font-weight:500;
     font-family:var(--font);
     color:var(--muted-foreground);
     padding:5px 0;
     border-bottom:2px solid transparent;
     position:relative;
}
 .nav a:hover{
     color:var(--link-hover);
}
 .nav a.active{
     color:var(--foreground);
     border-bottom-color:var(--foreground);
}
 .nav-dropdown{
     position:relative;
}
 .nav-dropdown::after{
     content:"";
     position:absolute;
     top:100%;
     left:0;
     right:0;
     height:8px;
     display:none;
}
 .nav-dropdown:hover::after{
     display:block;
}
 .nav-dropdown-toggle{
     display:inline-flex;
     align-items:center;
     gap:4px;
}
 /* Scoped to .nav specifically (not the bare class) - the footer's language-switch button
    also carries .nav-dropdown-toggle for its open/close JS, but has its own distinct look
    (small round icon button, footer.css's .lang-switch-toggle) that these must not touch. */
 .nav .nav-dropdown-toggle{
     /* Real <button> now (was an <a href="#">), so it needs .nav a's styling repeated here
        directly instead of inherited via the "a" tag selector, plus a button-chrome reset. */
     border:none;
     background:none;
     cursor:pointer;
     font-family:var(--font);
     font-size:calc(13px * var(--type-scale));
     font-weight:500;
     color:var(--muted-foreground);
     padding:5px 0;
     border-bottom:2px solid transparent;
     position:relative;
}
 .nav .nav-dropdown-toggle:hover{
     color:var(--link-hover);
}
 .nav-dropdown-menu{
     display:none;
     position:absolute;
     top:100%;
     left:0;
     background:var(--bg-elev);
     border:1px solid var(--border-soft);
     min-width:160px;
     z-index:60;
     flex-direction:column;
     padding:4px 0;
     margin-top:8px;
}
/* An @keyframes animation restarts automatically the moment an element goes from
   display:none to displayed (unlike a transition, which needs the element already rendered
   at its start value), so this is a CSS-only addition - no JS change needed for either the
   hover/focus-within path or the .open class nav.js toggles for click/keyboard use. */
 .nav-dropdown:hover .nav-dropdown-menu, .nav-dropdown:focus-within .nav-dropdown-menu, .nav-dropdown.open .nav-dropdown-menu{
     display:flex;
     animation:navDropdownIn .18s ease;
}
 @keyframes navDropdownIn{
     from{ opacity:0; transform:translateY(-4px); }
     to{ opacity:1; transform:translateY(0); }
}
 .nav-dropdown-menu a{
     padding:8px 14px;
     font-size:13px;
     font-weight:500;
     color:var(--muted-foreground);
     border-bottom:1px solid transparent;
}
 .nav-dropdown-menu a:hover{
     background:var(--foreground);
     color:var(--background);
}
 .nav-dropdown-menu a.active{
     color:var(--foreground);
}
[data-theme="mono"] .nav-dropdown-menu a:hover{ background:var(--code-bg); color:var(--link-hover); }
 .header-actions{
     display:flex;
     gap:8px;
     align-items:center;
}
/* .header-actions prefix (not bare .nav-toggle) so this reliably beats .icon-btn's own
   display:grid (below, same 0,1,0 specificity, declared later in this file) without
   !important - .icon-btn{display:grid} would otherwise win by source order alone. */
 .header-actions .nav-toggle{
     display:none;
}
 .search-backdrop{
     display:none;
     position:fixed;
     inset:0;
     background:rgba(0,0,0,.6);
     backdrop-filter:blur(4px);
     -webkit-backdrop-filter:blur(4px);
     z-index:97;
}
 .search-backdrop.open{
     display:block;
}
 .mobile-search{
     display:none;
     z-index:98;
}
 .mobile-search.open{
     display:block;
}
 .mobile-search-close{
     display:none;
}
/* A small centered popup window (modal + dimmed backdrop), styled after hugo-theme-reimu's
   search popup, instead of the mobile full-width bar below. Below 768px, responsive.css's
   media query overrides position back to that original bar (no
   backdrop dimming, no close button - the outside-tap-to-close behavior already covers
   it there).

   Opens and closes via opacity/transform transitions rather than display or a one-way
   @keyframes animation, so closing fades/slides back out symmetrically instead of
   vanishing instantly - display:none can't be transitioned, so this stays permanently
   display:block at this width and uses visibility (delayed on the way out, immediate on
   the way in) to drop it from hit-testing and the accessibility tree once fully hidden. */
 @media (min-width:769px){
     .search-backdrop{
         display:block;
         opacity:0;
         pointer-events:none;
         transition:opacity .2s ease;
    }
     .search-backdrop.open{
         opacity:1;
         pointer-events:auto;
    }
     .mobile-search{
         display:block;
         position:fixed;
         top:14%;
         left:50%;
         width:480px;
         max-width:calc(100% - 32px);
         background:var(--bg-elev);
         border:1px solid var(--border-soft);
         box-shadow:var(--shadow);
         padding:40px 16px 16px;
         opacity:0;
         visibility:hidden;
         pointer-events:none;
         transform:translate(-50%, -8px);
         transition:opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
    }
     .mobile-search.open{
         opacity:1;
         visibility:visible;
         pointer-events:auto;
         transform:translate(-50%, 0);
         transition:opacity .2s ease, transform .2s ease, visibility 0s linear 0s;
    }
     .mobile-search .search-box input{
         padding-right:36px;
    }
     .mobile-search-close{
         display:grid;
         place-items:center;
         position:absolute;
         top:10px;
         right:10px;
         width:26px;
         height:26px;
         border:none;
         background:transparent;
         color:var(--muted-foreground);
         cursor:pointer;
         z-index:1;
    }
     .mobile-search-close:hover{
         color:var(--foreground);
    }
}
 .icon-btn{
     width:32px;
     height:32px;
     border-radius:999px;
     border:1px solid var(--border);
     background:var(--card);
     color:var(--muted-foreground);
     display:grid;
     place-items:center;
     cursor:pointer;
     font-size:13px;
}
 #themeToggle, .mobile-search-toggle{
     border:none;
     background:transparent;
}
 #themeToggle:hover{
     background:transparent;
     border:none;
     color:var(--foreground);
}
 .icon-btn:hover{
     background:var(--foreground);
     color:var(--background);
     border-color:var(--foreground);
}
/* Search uses a plain color change instead of the generic filled-circle hover. */
 .mobile-search-toggle:hover{
     background:transparent;
     border-color:transparent;
     color:var(--foreground);
}
/* Sun/moon crossfade - both icons always rendered, stacked in the same grid cell
   (#themeToggle/.icon-btn is already display:grid; place-items:center, so pinning both to
   grid-area 1/1 overlaps them instead of the default one-per-row auto-placement), and
   switched with opacity + a quarter-turn rotation instead of a display:none/block snap. */
 .icon-sun, .icon-moon{
     grid-area:1 / 1;
     transition:opacity .35s ease, transform .4s ease;
}
 .icon-sun{
     opacity:1;
     transform:rotate(0deg) scale(1);
}
 .icon-moon{
     opacity:0;
     transform:rotate(-90deg) scale(.5);
}
 :is([data-theme="mono"],[data-color-scheme="dark"]) .icon-sun{
     opacity:0;
     transform:rotate(90deg) scale(.5);
}
 :is([data-theme="mono"],[data-color-scheme="dark"]) .icon-moon{
     opacity:1;
     transform:rotate(0deg) scale(1);
}
 
.lang-switch{ position:relative; display:flex; align-items:center; gap:2px; font-family:inherit; font-size:10px; font-weight:600; letter-spacing:.04em; }
.lang-switch-current{ padding:4px 6px; color:var(--foreground); }
.lang-switch-link{ padding:4px 6px; color:var(--muted-foreground); border-radius:0; }
.lang-switch-link:hover{ color:var(--link-hover); background:var(--bg-elev); }


.nav .nav-dropdown-toggle > svg {width:10.5px;height:10.5px;}

/* Desktop navbar: 10% larger, with its width still aligned to the page. */
@media (min-width:1025px){
  :root{--header-content-inset:13.2px;}
  .header-inner{min-height:44px;padding-block:2.2px;gap:8.8px;}
  .header-inner .brand{gap:10.45px;}
  .header-inner .brand-mark{width:33.44px;height:29.26px;}
  .header-inner .brand-mark svg{height:29.26px;}
  .header-inner .brand-text{font-size:13.585px;}
  .header-inner .nav{gap:19.8px;}
  .header-inner .nav a,.header-inner .nav .nav-dropdown-toggle{font-size:calc(14.3px * var(--type-scale));}
  .header-inner .nav .nav-dropdown-toggle > svg{width:11.55px;height:11.55px;}
  .header-inner .icon-btn{width:35.2px;height:35.2px;}
  .header-inner .icon-btn svg{width:15.4px;height:15.4px;}
}
