/* OS 9 menu bar (replaces the old taskbar). Semantic --os-* tokens only.
   <header class="os-menubar-wrap">              ← unpositioned wrapper, so the two fixed bars below
     <nav class="os-menubar" aria-label="Main">     stack independently around the CRT overlay
       <a class="os-menubar__logo" href="/"><img src="Assets/web/icons/star-logo.png" alt="Nick Desro home"></a>
       <ul class="os-menubar__menu"><li><a class="os-menu__item" href="/work/">work</a></li>…</ul>
       <span class="os-menubar__clock" data-os-clock></span>
     </nav>
     <div class="os-tray">                          ← above the CRT overlay, never distorted
       show desktop (components/show-desktop.*), then three pixel-art icon buttons (src/shell.html):
       theme (sun | moon pair, "Switch to dark mode" / "Switch to light mode"), CRT ("CRT effect", aria-pressed),
       headings ("Aa" in the current heading font, "Fun headings", aria-pressed); a pixel checkbox mirrors
       aria-pressed on show desktop, CRT and headings; tooltips: components/tray-tip.*
     </div>
   </header>
   components/os-menubar.js runs the clock and measures the tray. */

.os-menubar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--z-os-menubar);
  display: flex;
  align-items: stretch;
  height: var(--menubar-h);
  padding: 0 var(--os-tray-w, 15rem) 0 var(--space-2);
  background: var(--os-face);
  color: var(--os-text);
  border-bottom: 1px solid var(--os-outline);
  box-shadow: inset 0 1px 0 var(--os-hi);
  font-family: var(--font-chrome);
  font-size: var(--os-size);
}

.os-menubar__logo {
  display: grid;
  place-items: center;
  padding: 0 var(--space-3);
}

.os-menubar__logo img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

/* House logo (Assets/menu-house-sm.png, 3x art): 16px tall, keeps its own aspect. The house is wider and
   heavier than the old 18px smiley, so it sits 2px shorter to look balanced next to the menu items. */
.os-menubar__logo--house img {
  width: auto;
  height: 16px;
}

/* Keep the old smiley's box width (70:67 art at 18px tall) so the menu items don't move */
.os-menubar__logo--house { min-width: calc(18px * 70 / 67 + 2 * var(--space-3)); }

/* Dark: the fuzzy black outline melts into the graphite bar, so add a faint light edge */
:root[data-theme="dark"] .os-menubar__logo--house img {
  filter: drop-shadow(0 0 0.6px var(--os-hi)) drop-shadow(0 0 0.6px var(--os-hi));
}

.os-menubar__menu {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.os-menu__item,
.os-menubar__logo {
  color: var(--os-text);
  text-decoration: none;
  line-height: calc(var(--menubar-h) - 1px);
}

.os-menu__item {
  display: block;
  padding: 0 var(--space-3);
}

.os-menu__item:hover,
.os-menu__item:focus-visible,
.os-menubar__logo:hover,
.os-menubar__logo:focus-visible {
  background: var(--os-select-bg);
  color: var(--os-select-text);
  outline: none;
}

.os-menubar__clock {
  margin-left: auto;
  padding: 0 var(--space-3);
  line-height: calc(var(--menubar-h) - 1px);
  white-space: nowrap;
}

/* ---- Toggle tray: right end of the menu bar, above the CRT overlay ---- */
.os-tray {
  position: fixed;
  top: 0;
  right: 0;
  z-index: var(--z-taskbar-btn);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--menubar-h);
  padding: 0 var(--space-2);
  background: var(--os-face);
  border-bottom: 1px solid var(--os-outline);
  border-left: 1px solid var(--os-lo);
  box-shadow: inset 1px 1px 0 var(--os-hi);
}

.os-tray__btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 3px;
  height: 20px; /* fits the 22px bar (21px inside its bottom border); the 16px faces get 1px above and below */
  padding: 0 3px;
  background: var(--os-btn-face);
  color: var(--os-text);
  border: 1px solid var(--os-outline);
  border-radius: 3px;
  box-shadow: inset 1px 1px 0 var(--os-hi), inset -1px -1px 0 var(--os-lo);
  font-family: var(--font-chrome);
  font-size: calc(11px * var(--chrome-scale));
  letter-spacing: var(--chrome-tracking);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.os-tray__btn:active {
  background: var(--os-face-pressed);
  box-shadow: inset 1px 1px 0 var(--os-lo), inset -1px -1px 0 var(--os-hi);
}

.os-tray__btn:focus-visible { outline: 2px solid var(--os-focus); outline-offset: 1px; }

/* Icon faces: every icon is a 16 x 16 pixel grid (square viewBox, width = height = 16, crisp edges, currentColor),
   rendered at exactly 16px (1 grid pixel = 1 CSS pixel; 20px would need a taller bar). flex: none so the bar never
   squeezes them.
   - Theme: a sun | moon PAIR in one button; the active mode is pressed in (inverted fill on a small inset box), the
     other dimmed. Keyed on html[data-theme], so it's right from first paint with no JavaScript. Under ~1100px: only
     the active icon. A tiny swap animation plays on toggle (theme.js sets data-anim; none under reduced motion).
   - CRT: a little monitor, dimmed with no scanlines when the effect is off. Headings: "Aa" in the heading font. */
.os-tray__icon { display: block; flex: none; width: 16px; height: 16px; fill: currentColor; }
.os-tray__btn--theme { gap: 1px; padding: 0; }
.os-tray__mode {
  display: grid;
  flex: none;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 2px;
  opacity: 0.45;
}
html[data-theme="light"] .os-tray__mode--light,
html[data-theme="dark"] .os-tray__mode--dark {
  opacity: 1;
  background: var(--os-text);
  color: var(--os-btn-face);
}
html[data-theme="light"] [data-anim] .os-tray__mode--light .os-tray__icon,
html[data-theme="dark"] [data-anim] .os-tray__mode--dark .os-tray__icon { animation: os-tray-swap 0.15s ease-out; }
@keyframes os-tray-swap {
  from { opacity: 0; transform: scale(0.5) rotate(-60deg); }
  to   { opacity: 1; transform: none; }
}
@media (max-width: 1099.98px) {
  .os-tray__btn--theme { padding: 0 1px; }
  html[data-theme="light"] .os-tray__mode--dark,
  html[data-theme="dark"] .os-tray__mode--light { display: none; }
  html[data-theme] .os-tray__mode { background: none; color: inherit; }
}
body:not(.crt-on) .os-tray__icon--crt { opacity: 0.45; }
body:not(.crt-on) .os-tray__scan { display: none; }
.os-tray__aa { /* previews the heading mode: drawn in the current heading font, in a 16 x 16 box */
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: 12px;
  letter-spacing: var(--heading-tracking);
  line-height: 1;
  overflow: visible;
}

/* Hit areas: an invisible pseudo-element, so the bar never gets taller or wider. Mouse / trackpad: at least 24 x 24
   (WCAG 2.2). Touch (pointer: coarse): 44 x 44; the buttons get 36px wide there so the areas meet without overlapping
   (36 + the 8px gap = 44; 40 + 4 on phones). */
.os-tray__btn { position: relative; }
.os-tray__btn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100%, 24px);
  height: 24px;
  transform: translate(-50%, -50%);
}
@media (pointer: coarse) {
  .os-tray__btn { min-width: 36px; }
  .os-tray__btn::before { top: -3px; width: max(100%, 44px); height: 44px; transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  [data-theme-toggle][data-anim] .os-tray__icon { animation: none !important; }
}

/* State box: a 10px pixel OS 9 checkbox left of the icon on Show desktop, CRT and headings; the X shows when the
   button's aria-pressed is "true" (CSS only, no extra JavaScript state). */
.os-tray__check { display: block; flex: none; width: 10px; height: 10px; }
.os-tray__check-ring { fill: var(--os-outline); }
.os-tray__check-fill { fill: var(--os-content); }
.os-tray__check-x { fill: var(--os-text); display: none; }
.os-tray__btn[aria-pressed="true"] .os-tray__check-x { display: inline; }

/* Narrow (< 700px): still ONE row. Page names hide (the dock handles navigation), the logo and clock stay,
   and the icon toggles keep their faces (Show desktop isn't rendered on phones). */
@media (max-width: 43.75rem) {
  .os-menubar__menu { display: none; }
  .os-menubar__clock { padding: 0 var(--space-2); }
  .os-tray { gap: 4px; padding: 0 5px; }
}
@media (max-width: 43.75rem) and (pointer: coarse) {
  .os-tray__btn { min-width: 40px; }
}

/* ---- Now-playing indicator (components/player.js): "♪ title" + play/pause, only off the home page.
   Sits between the menu and the clock; the bar stays one row (title hides under 700px). ---- */
.os-np {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  margin-left: auto;
  padding: 0 var(--space-2);
}

.os-np[hidden] { display: none; }
.os-np:not([hidden]) + .os-menubar__clock { margin-left: 0; }

.os-np__btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 16px;
  padding: 0;
  color: var(--os-text);
  background: var(--os-btn-face);
  border: 1px solid var(--os-outline);
  border-radius: 3px;
  box-shadow: inset 1px 1px 0 var(--os-hi), inset -1px -1px 0 var(--os-lo);
  cursor: pointer;
}

.os-np__btn:active { background: var(--os-face-pressed); }
.os-np__btn:focus-visible { outline: 2px solid var(--os-focus); outline-offset: 1px; }
.os-np__icon { width: 8px; height: 8px; fill: currentColor; }
.os-np__icon--pause { display: none; }
.os-np__btn[data-playing="true"] .os-np__icon--play { display: none; }
.os-np__btn[data-playing="true"] .os-np__icon--pause { display: block; }

.os-np__note { flex: none; }

.os-np__title {
  max-width: 16ch;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (max-width: 43.75rem) {
  .os-np__title { display: none; }
  .os-np { padding: 0 var(--space-1); }
}
