/* ==============================================================
   File:    /css/header.css
   Purpose: The header on every public page (inc-site-nav.asp): Menu at
            the left, the logo in the middle, Index at the right, the hub
            row and its panels, and the two drawers.
   Version: 1.0.0
   Updated: 2026-10-28

   Changelog:
     1.0.0 (2026-10-28) Steve: "Let's just build that" (preview 5). Its
           own sheet so the header can change without a site.css bump on
           every page. Colours are site.css names only: the --menu-*
           names follow the page (dark on the home page and the dark
           pages, light when the reader chose light); --hd-* below point
           at site.css names by job, the same way, set on the header's
           own elements so no site.css selector is repeated here. The bar is fixed at
           --menu-bar-h at every width and both drawers open under it
           (classic-asp-mobile-menu rule 1); one button opens and closes
           each (rules 6, 7); a drawer scrolls inside itself and pins the
           page (rules 8 to 10). Steve's design departs from the skill in
           two places: a drawer at every width, not phones only, and the
           Index wide enough for its titles (CLAUDE.md, The header).
   ============================================================== */

.ox-mast,
.ox-hubrow,
.ox-drawer {
  --hd-dim: var(--ox-ink-dim);
  --hd-card: var(--ox-surface);
  --hd-gold-text: var(--ox-accent);
  --hd-mark: var(--ox-accent-bg);
  --hd-bar-bg: var(--ox-bg);
  --hd-shadow: var(--home-shade-28);
  --hd-drawer-w: 400px;
}
.ox-home .ox-mast,
.ox-home .ox-hubrow,
.ox-home .ox-drawer,
:root:not([data-theme="light"]) .ox-dark .ox-mast,
:root:not([data-theme="light"]) .ox-dark .ox-hubrow,
:root:not([data-theme="light"]) .ox-dark .ox-drawer {
  --hd-dim: var(--home-dim);
  --hd-card: var(--home-card);
  --hd-gold-text: var(--home-gold-bright);
  --hd-mark: var(--home-warm-bg);
  --hd-bar-bg: var(--home-bg);
  --hd-shadow: var(--home-shade-74);
}

/* The bar: fixed at every width, one height. */
.ox-mast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: var(--menu-bar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 max(16px, calc((100% - var(--home-wrap)) / 2));
  background: var(--hd-bar-bg);
  border-bottom: 1px solid var(--menu-line);
  color: var(--menu-ink);
}
.ox-mast-spacer { height: var(--menu-bar-h); }
.ox-mast__brand { justify-self: center; text-decoration: none; }
.ox-mast__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 12px;
  background: none;
  color: var(--menu-ink);
  border: 1px solid var(--menu-line);
  border-radius: 4px;
  font: 600 var(--fs-lg)/1 var(--home-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.ox-mast__btn:hover,
.ox-mast__btn[aria-expanded="true"] { border-color: var(--menu-accent); }
.ox-mast__btn:focus-visible { outline: 2px solid var(--menu-accent); outline-offset: 2px; }
.ox-mast__btn--menu { justify-self: start; }
.ox-mast__btn--index { justify-self: end; }
.ox-mast__btn[aria-expanded="true"] .menu-icon span:nth-child(1) { top: 6px; transform: rotate(45deg); }
.ox-mast__btn[aria-expanded="true"] .menu-icon span:nth-child(2) { opacity: 0; }
.ox-mast__btn[aria-expanded="true"] .menu-icon span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

/* Index: the book becomes an X while open. */
.ox-mast__x { display: none; position: relative; width: 20px; height: 14px; }
.ox-mast__x::before,
.ox-mast__x::after {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.ox-mast__x::before { transform: rotate(45deg); }
.ox-mast__x::after { transform: rotate(-45deg); }
.ox-mast__btn--index[aria-expanded="true"] .ox-mast__ico { display: none; }
.ox-mast__btn--index[aria-expanded="true"] .ox-mast__x { display: inline-block; }
.ox-mast__dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--hd-gold-text);
  box-shadow: 0 0 0 2px var(--hd-bar-bg);
}

/* The hub row under the bar, wider screens only. */
.ox-hubrow {
  position: relative;
  z-index: 50;
  border-bottom: 1px solid var(--menu-line);
  background: var(--hd-bar-bg);
}
.ox-hubrow__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 4px;
  list-style: none;
  margin: 0 auto;
  padding: 0 16px;
  max-width: var(--home-wrap);
}
.ox-hubrow__link {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 12px;
  border-bottom: 2px solid transparent;
  color: var(--hd-dim);
  font: var(--fs-xl)/1.2 var(--home-sans);
  letter-spacing: 0.03em;
  text-decoration: none;
}
.ox-hubrow__link:hover,
.ox-hubrow__link.is-open,
.ox-hubrow__link[aria-current="page"] { color: var(--menu-ink); border-bottom-color: var(--menu-accent); }

/* A hub's panel: the hub, its sub-topics, its stories. */
.ox-mega {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: var(--hd-card);
  border-bottom: 2px solid var(--menu-accent);
  box-shadow: 0 30px 60px var(--hd-shadow);
}
.ox-mega__panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr);
  align-items: start;
  gap: 32px;
  max-width: var(--home-wrap);
  margin: 0 auto;
  padding: 28px 16px 32px;
}
.ox-mega__panel[hidden] { display: none; }
.ox-mega__kicker,
.ox-mega__label {
  margin: 0 0 14px;
  font: 700 var(--fs-md)/1.2 var(--home-display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--hd-gold-text);
}
.ox-mega__label { color: var(--hd-dim); }
.ox-mega__intro { margin: 0 0 16px; font: var(--fs-4xl)/1.5 Georgia, "Times New Roman", serif; color: var(--menu-ink); }
.ox-mega__all { font: 600 var(--fs-lg)/1.3 var(--home-sans); color: var(--hd-gold-text); text-decoration: none; }
.ox-mega ul { list-style: none; margin: 0; padding: 0; }
.ox-mega__topics button {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: var(--tap-min);
  padding: 8px 12px;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  color: var(--menu-ink);
  font: var(--fs-2xl)/1.3 var(--home-sans);
  text-align: left;
  cursor: pointer;
}
.ox-mega__topics button:hover,
.ox-mega__topics button.is-on { background: var(--hd-mark); border-left-color: var(--menu-accent); color: var(--hd-gold-text); }
.ox-mega__topics button:disabled { color: var(--hd-dim); background: none; border-left-color: transparent; cursor: default; }
.ox-mega__n { color: var(--hd-dim); font-size: var(--fs-lg); }
.ox-mega__list li { border-bottom: 1px solid var(--menu-line); }
.ox-mega__list li[hidden] { display: none; }
.ox-mega__list a { display: block; padding: 10px 0; text-decoration: none; color: var(--menu-ink); }
.ox-mega__list b { display: block; font: 400 var(--fs-4xl)/1.3 Georgia, "Times New Roman", serif; }
.ox-mega__list span { display: block; margin-top: 3px; color: var(--hd-dim); font-size: var(--fs-xl); line-height: 1.45; }
.ox-mega__list a:hover b { color: var(--hd-gold-text); }

/* The drawers: under the bar, on their button's side, scrolling inside. */
.ox-drawer-scrim {
  position: fixed;
  top: var(--menu-bar-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  background: var(--menu-scrim);
  touch-action: none;
}
.ox-drawer-scrim[hidden] { display: none; }
.ox-drawer {
  position: fixed;
  top: var(--menu-bar-h);
  bottom: 0;
  z-index: 58;
  width: min(var(--hd-drawer-w), 100%);
  max-height: calc(100vh - var(--menu-bar-h));
  max-height: calc(100dvh - var(--menu-bar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px 32px;
  background: var(--menu-bg);
  color: var(--menu-ink);
  border-top: 2px solid var(--menu-accent);
  visibility: hidden;
  transition: transform 0.22s ease, visibility 0s linear 0.22s;
}
.ox-drawer--left { left: 0; border-right: 1px solid var(--menu-line); transform: translateX(-100%); }
.ox-drawer--right { right: 0; border-left: 1px solid var(--menu-line); transform: translateX(100%); }
.ox-drawer.is-open { transform: none; visibility: visible; transition: transform 0.22s ease; }
html.drawer-open { overflow: hidden; }

.ox-drawer__h {
  margin: 24px 0 6px;
  font: 700 var(--fs-md)/1.2 var(--home-display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--hd-dim);
}
.ox-drawer__links { list-style: none; margin: 0; padding: 0; }
.ox-drawer a { color: var(--menu-ink); text-decoration: none; }
.ox-drawer a:hover { color: var(--hd-gold-text); }
.ox-drawer__links a {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  border-bottom: 1px solid var(--menu-line);
  font-size: var(--fs-2xl);
}

/* Menu: hubs open to their sub-topics and newest stories. */
.ox-tree details { border-bottom: 1px solid var(--menu-line); }
.ox-tree summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  list-style: none;
  cursor: pointer;
  font: 700 var(--fs-xl)/1.25 var(--home-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.ox-tree summary::-webkit-details-marker { display: none; }
.ox-tree summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 1.5px solid var(--menu-accent);
  border-bottom: 1.5px solid var(--menu-accent);
  transform: rotate(45deg);
}
.ox-tree details[open] > summary::after { transform: rotate(-135deg); }
.ox-tree__topic,
.ox-tree__story,
.ox-tree__all { display: flex; align-items: center; min-height: var(--tap-min); margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--menu-line); }
.ox-tree__topic { justify-content: space-between; gap: 12px; font-size: var(--fs-2xl); }
.ox-tree__topic span { color: var(--hd-dim); font-size: var(--fs-lg); }
.ox-tree__story { font: var(--fs-2xl)/1.35 Georgia, "Times New Roman", serif; color: var(--hd-dim); }
.ox-drawer .ox-tree__all { margin-bottom: 8px; font: 600 var(--fs-lg)/1.3 var(--home-sans); color: var(--hd-gold-text); }

/* Index: search, the hub buttons, every article newest first. */
.ox-ix__search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 0 12px;
  border: 1px solid var(--menu-line);
  border-radius: 4px;
  color: var(--hd-dim);
  background: var(--hd-bar-bg);
}
.ox-ix__search:focus-within { border-color: var(--menu-accent); }
.ox-ix__search input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-min);
  border: 0;
  outline: 0;
  background: none;
  color: var(--menu-ink);
  font: var(--fs-2xl) var(--home-sans);
}
.ox-ix__hubs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.ox-ix__hubs button {
  min-height: 36px;
  padding: 0 12px;
  background: none;
  border: 1px solid var(--menu-line);
  border-radius: 999px;
  color: var(--hd-dim);
  font: var(--fs-md)/1.2 var(--home-sans);
  cursor: pointer;
}
.ox-ix__hubs button:hover { border-color: var(--menu-accent); }
.ox-ix__hubs button.is-on { background: var(--menu-accent); border-color: var(--menu-accent); color: var(--home-on-gold); font-weight: 600; }
.ox-ix { list-style: none; margin: 0; padding: 0; }
.ox-ix li { border-bottom: 1px solid var(--menu-line); }
.ox-ix li[hidden] { display: none; }
.ox-ix a { display: block; padding: 12px 0; }
.ox-ix__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 4px;
  font: 600 var(--fs-sm)/1.3 var(--home-sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hd-dim);
}
.ox-ix__meta span { color: var(--hd-gold-text); }
.ox-ix b { display: block; font: 400 var(--fs-3xl)/1.32 Georgia, "Times New Roman", serif; }
.ox-ix li.is-here a { padding-left: 12px; border-left: 2px solid var(--menu-accent); }
.ox-ix__none { color: var(--hd-dim); }

/* Tablets and phones: no hub row (the Menu drawer has every hub). */
@media (max-width: 1024px) {
  .ox-hubrow { display: none; }
}
/* Phones: the buttons show their icons only, the logo a little smaller, the drawers full width. */
@media screen and (max-width: 640px), screen and (max-width: 960px) and (max-height: 600px) {
  .ox-mast__lbl { display: none; }
  .ox-mast__btn { padding: 0; justify-content: center; }
  .ox-mast__brand .ox-brand__official { font-size: 20px; }
  .ox-mast__brand .ox-brand__x { font-size: 31px; }
  .ox-drawer { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ox-drawer,
  .ox-drawer.is-open { transition: none; }
}
