/* The one-row header (11-28), the same on every Minnesinger page: index.html (the Scriptorium), dacapo.html,
   home.html, and the Learn page. Load it after styles.css. header.js does the steps for narrower windows.

   Markup (one pattern, so a new page or tab only adds a line):
     <header class="topbar">
       <a class="brand" href="home.html" …><img class="mark" …><img class="word" …></a>   (the logo: goes Home)
       <nav class="pages" aria-label="Minnesinger pages"> <a href="index.html">Scriptorium</a> <a href="dacapo.html">Da Capo</a> … </nav>
       <nav class="actions menubar" id="actions">…</nav>     (Scriptorium only: File Edit View … Help)
       <div class="songname" id="songName">…</div>           (Scriptorium only; app.js puts the file chip after it)
       <span class="hdr-spacer"></span>                       (other pages: pushes what follows to the right)
       … page-specific chips and buttons …
       <button id="btnMenu" class="menubtn">☰ Menu</button>   (phones; Scriptorium only)
     </header>
   The current page's tab has aria-current="page". Home has no tab: the logo is its way in.

   Narrow windows (header.js adds these to .topbar, one at a time, until the row fits with room for the title):
     hdr-tight   smaller gaps and menu padding, the file chip shortened
     hdr-tabs    the page tabs fold into one "Scriptorium ▾" button
     hdr-noword  the logo without the word "minnesinger"
   Phones (≤ 820 px) keep the ☰ Menu: the menus open as a panel under the header. */

@media (min-width: 821px) {
  .topbar { flex-wrap: nowrap; gap: 10px; padding: 0 12px 0 10px; height: 46px; min-height: 46px; position: relative; z-index: 2; }
  .topbar > * { flex: none; }
  .topbar .brand { display: flex; align-items: center; gap: 7px; padding: 4px 8px 4px 4px; margin-right: 2px; border-radius: 10px; text-decoration: none; }
  .topbar .brand:hover { background: var(--panel2); }
  .topbar .brand .mark { height: 26px; width: 26px; }
  .topbar .brand .word { height: 17px; width: auto; }
  .topbar .pages { gap: 2px; }
  .topbar .pages a { font-size: 13.5px; line-height: 1.2; padding: 6px 11px; border-radius: 8px; }
  /* The menus, on the same row: a thin rule between the page tabs and File. */
  .topbar .menubar { display: flex; flex-wrap: nowrap; gap: 0; padding: 0 0 0 8px; margin-left: 2px; background: none; border: 0;
    border-left: 1px solid var(--line); border-radius: 0; height: 26px; align-items: center; }
  .topbar .menubar .mtop { padding: 5px 9px; font-size: 14px; line-height: 1.2; }
  .topbar .menubar .mpanel { top: calc(100% + 11px); }
  /* The song's name: takes the room that's left, and is the first thing to give way. */
  .topbar .songname { flex: 1 1 auto; min-width: 0; font-size: 14.5px; font-weight: 800; padding-left: 12px; border-left: 1px solid var(--line);
    line-height: 26px; height: 26px; }
  .topbar .syncchip { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
  .topbar .hdr-spacer { flex: 1 1 auto; min-width: 0; }

  /* Step 1: tighter */
  .topbar.hdr-tight { gap: 6px; }
  .topbar.hdr-tight .menubar .mtop { padding: 5px 6px; }
  .topbar.hdr-tight .pages a { padding: 6px 8px; }
  .topbar.hdr-tight .syncchip { max-width: 150px; }
  /* Step 2: the page tabs fold into one button with a small list */
  .topbar .pagesbtn { display: none; }
  .topbar.hdr-tabs .pagesbtn { display: inline-flex; align-items: center; gap: 6px; font: 800 13.5px/1.2 var(--ui); padding: 6px 10px; border-radius: 8px;
    background: var(--text); border-color: var(--text); color: #fff; }
  .topbar.hdr-tabs .pagesbtn:hover { background: #2c3170; }
  .topbar.hdr-tabs .pages { display: none; position: absolute; top: calc(100% + 4px); z-index: 70; flex-direction: column; gap: 2px; min-width: 190px;
    padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px #1f235040; }
  .topbar.hdr-tabs.pages-open .pages { display: flex; }
  .topbar.hdr-tabs .pages a { padding: 8px 12px; }
  /* Step 3: the logo's mark only */
  .topbar.hdr-noword .brand .word { display: none; }
}

/* Phones and narrow windows: the existing ☰ Menu layout (styles.css), with the menu bar now inside the header. */
@media (max-width: 820px) {
  .topbar .brand { display: flex; align-items: center; text-decoration: none; border-radius: 10px; }
  .topbar .brand .mark { height: 32px; width: 32px; }
  .topbar .pagesbtn, .topbar .hdr-spacer { display: none; }
  /* five page tabs (Scriptorium, Bandstand, Da Capo, Worksheets, Learn) share one row on a 360 px phone */
  .topbar .pages { gap: 2px; }
  .topbar .pages a { padding: 7px 3px; font-size: 13px; min-width: 0; }
  .topbar > .actions { display: none; }
  .topbar.open > .actions { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 4px; position: absolute; top: calc(100% + 4px); left: 8px; right: 8px;
    z-index: 45; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 50px #1f235040;
    max-height: calc(100dvh - 150px); overflow-y: auto; }
}
