/* The shared top bar (Gus, 11/11/2026). Loaded last in every page's <head>, so it wins over each page's own .bar rules.
   Built by tools/sitio/barra.py. Five things live here:
   1. Lab is a button, last, after CV. On /lab/ it is the current page.
   2. Phones and tablets (<= 1080px): the section links fold into a menu behind a round button (the CV viewer's "more" pattern).
      Under 600px Lab moves into that menu, first, so the bar keeps the logo, ES, the theme and CV in place.
   3. A light hover on the round buttons and the outlined ones: same family, transform and colour only.
   4. Smart sticky: hides going down, comes back going up (nav.js), with a solid background once the page has moved.
   5. Two dropdowns (13/11/2026): "About" (the five home sections) and "Life" (Flying, Off the clock, Desk), then Notes. */

header.bar { position: sticky; top: 0; z-index: 40; gap: 12px; transition: transform .2s var(--ease); }
header.bar::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: var(--bg);
  box-shadow: 0 0 0 100vmax var(--bg), 0 1px 0 100vmax var(--line); clip-path: inset(0 -100vmax -1px -100vmax); opacity: 0; transition: opacity .2s var(--ease); }
header.bar.bar-solid::before { opacity: 1; }
header.bar.bar-off { transform: translateY(calc(-100% - 2px)); }
main [id] { scroll-margin-top: 64px; }

/* Spacing: the same rhythm as before (links … ES ◐ … CV Lab), now with a single gap. */
header.bar > ul { margin-left: auto; margin-right: 16px; }
header.bar .lang, header.bar .theme { margin-left: 0; }
header.bar .cv-btn { margin-left: 16px; }
/* The outlined button, for pages that don't carry it (the CV viewer, the 404). Same values as the home page's .btn. */
header.bar .btn { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--ink); background: none;
  color: var(--ink); font: 500 .9375rem/1 var(--sans); text-decoration: none; white-space: nowrap; }

/* Round controls: ES, theme and the menu button share one shape. */
header.bar .menu-btn { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border-radius: 999px; border: 1px solid var(--ctl-line, var(--line)); background: none; color: var(--ink); cursor: pointer; }
header.bar .menu-btn svg { width: 18px; height: 18px; fill: currentColor; }
header.bar .menu-btn[aria-expanded="true"] { border-color: var(--ink); background: var(--line-hover); }

/* "View " + "CV" are two flex items: no flex gap between them, a word space instead. */
header.bar .cv-btn { gap: 0; }
header.bar .cv-v { margin-right: .28em; }

/* Lab: an outlined button like CV. On the Lab page it is filled, the way a current page reads. */
header.bar .lab-btn[aria-current="page"] { background: var(--ink); color: var(--solid-ink); border-color: var(--ink); }

/* Hover and keyboard focus: the border and the fill move toward the ink, the button lifts 1px, the theme half-turns. */
header.bar :is(.lang, .theme, .menu-btn, .btn) { transition: transform .18s var(--ease), border-color .18s var(--ease), background-color .18s var(--ease), color .18s var(--ease); }
header.bar .theme svg { transition: transform .32s var(--ease); }
header.bar :is(.lang, .theme, .menu-btn, .btn):focus-visible { border-color: var(--ink); background-color: var(--line-hover); transform: translateY(-1px); }
header.bar .theme:focus-visible svg { transform: rotate(180deg); }
@media (hover: hover) {
  header.bar :is(.lang, .theme, .menu-btn, .btn):hover { border-color: var(--ink); background-color: var(--line-hover); transform: translateY(-1px); }
  header.bar .theme:hover svg { transform: rotate(180deg); }
}
header.bar .lab-btn[aria-current="page"]:is(:hover, :focus-visible) { background: var(--ink); }
header.bar :is(.lang, .theme, .menu-btn, .btn):active { transform: translateY(0) scale(.96); }

/* The menu. Hidden on desktop, where the links are in the bar. With two groups it is tall: on a phone turned sideways it
   scrolls inside instead of running off the screen (13/11/2026). */
header.bar .menu-wrap { position: relative; display: none; }
header.bar .menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 232px; max-height: calc(100svh - 76px); overflow-y: auto; overscroll-behavior: contain; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 18px 40px -18px rgba(0, 0, 0, .35);
  visibility: hidden; opacity: 0; transform: translateY(-4px); transition: opacity .16s var(--ease), transform .16s var(--ease), visibility 0s linear .16s; }
header.bar .menu.open { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
header.bar .menu ul { display: block; list-style: none; margin: 0; padding: 0; gap: 0; }
header.bar .menu a { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px; color: var(--ink); font-size: 1rem; text-decoration: none; transition: background-color .16s var(--ease); }
header.bar .menu a:is(:hover, :focus-visible) { background: var(--line-hover); outline-offset: -2px; }
header.bar .menu .m-lab { display: none; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
header.bar .menu .m-lab a { justify-content: space-between; border: 1px solid var(--ink); border-radius: 999px; font-weight: 500; }
header.bar .menu .m-lab a::after { content: "→"; font-family: var(--mono); font-size: .875rem; color: var(--muted); }
header.bar .menu .m-lab a[aria-current="page"] { background: var(--ink); color: var(--solid-ink); }
header.bar .menu .m-lab a[aria-current="page"]::after { content: "●"; color: inherit; font-size: .5rem; }

/* The dropdowns, "About" / "Sobre mí" and "Life" / "Vida" (Gus, 13/11/2026). On desktop each one is a button that opens a
   small panel of the same family as the phone menu (one open at a time); on phones and tablets each is a titled group in that menu (nav.js). */
header.bar > ul > .desp { position: relative; display: flex; }
header.bar .desp-btn { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: .9375rem; line-height: inherit;
  cursor: pointer; transition: color .16s var(--ease); }
header.bar .desp-btn svg { width: 12px; height: 12px; transition: transform .18s var(--ease); }
header.bar .desp-btn:is(:hover, :focus-visible, [aria-expanded="true"]) { color: var(--ink); }
header.bar .desp-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
header.bar .desp-btn[aria-current] { color: var(--ink); }
header.bar .desp-btn[aria-current] .desp-t { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .45em; }
header.bar .desp-panel { display: block; position: absolute; top: calc(100% + 20px); left: 50%; min-width: 200px; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 18px 40px -18px rgba(0, 0, 0, .35);
  visibility: hidden; opacity: 0; transform: translate(-50%, -4px); transition: opacity .16s var(--ease), transform .16s var(--ease), visibility 0s linear .16s; }
header.bar .desp-panel.desp-abierto { visibility: visible; opacity: 1; transform: translate(-50%, 0); transition-delay: 0s; }
header.bar .desp-panel a { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 0 14px; border-radius: 10px; color: var(--ink);
  font-size: 1rem; text-decoration: none; white-space: nowrap; transition: background-color .16s var(--ease); }
header.bar .desp-panel a:is(:hover, :focus-visible) { background: var(--line-hover); color: var(--ink); outline-offset: -2px; }
/* The current section, in the panel and in the phone menu: filled lightly, with the dot the Lab uses for "you are here". */
header.bar :is(.desp-panel, .menu .m-grupo) a[aria-current="page"] { background: var(--line-hover); text-decoration: none; }
header.bar :is(.desp-panel, .menu .m-grupo) a[aria-current="page"]::after { content: "●"; margin-left: auto; padding-left: 16px; font-size: .5rem; color: var(--ink); }
/* The phone menu: each group is a small title over its links; a hairline between the groups and before Notes. */
header.bar .menu :is(.m-grupo + .m-grupo, .m-sep) { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
header.bar .menu .m-tit { display: flex; align-items: center; min-height: 30px; padding: 0 14px; font: 500 .75rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
header.bar .menu .m-tit[aria-current] { color: var(--ink); }

@media (max-width: 1080px) {
  header.bar > ul { display: none; }
  header.bar .mark { margin-right: auto; }
  header.bar .menu-wrap { display: block; }
  header.bar .cv-btn { margin-left: 0; }
}
@media (max-width: 599px) {
  header.bar .lab-btn { display: none; }
  header.bar .menu .m-lab { display: block; }
}
/* Narrow phones: CV keeps its place as "CV". */
@media (max-width: 420px) {
  header.bar .cv-v { display: none; }
  header.bar .btn { padding: 0 14px; }
}
/* 360px and less: the mark keeps the logo; the name stays for screen readers. */
@media (max-width: 360px) {
  header.bar { gap: 8px; }
  header.bar .mark { font-size: 0; gap: 0; }
  header.bar :is(.lang, .theme, .menu-btn) { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  header.bar, header.bar::before, header.bar .menu, header.bar :is(.lang, .theme, .menu-btn, .btn), header.bar .theme svg,
  header.bar .desp-panel, header.bar .desp-btn, header.bar .desp-btn svg { transition: none; }
  header.bar :is(.lang, .theme, .menu-btn, .btn):is(:hover, :focus-visible, :active), header.bar .theme:is(:hover, :focus-visible) svg { transform: none; }
  header.bar .menu { transform: none; }
  header.bar .desp-panel, header.bar .desp-panel.desp-abierto { transform: translateX(-50%); }
}
