/* Self-hosted fonts (Latin subset, SIL OFL: see wwwroot/fonts/*-OFL.txt). Archivo is --font-display, Atkinson Hyperlegible is --font-sans. */
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: Archivo; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/archivo-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: Archivo; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/archivo-latin-800-normal.woff2") format("woff2"); }

/* App shell: skip link, header menu, phone header. Tokens only, no new colours. */

body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); }
/* Blazor's FocusOnNavigate sets tabindex="-1" and focuses h1/main; beat .m-root :focus-visible specificity so no focus box appears on navigation or keyboard refresh. */
h1:focus, h1:focus-visible, main:focus, main:focus-visible,
.m-root h1:focus, .m-root h1:focus-visible, .m-root main:focus, .m-root main:focus-visible { outline: none; }

.m-shell { min-height: 100vh; display: flex; flex-direction: column; }
.m-shell > main { flex: 1; }

/* Skip link: off-screen until focused */
.m-skip { position: absolute; left: var(--space-3); top: -100px; z-index: 100; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface); color: var(--link); font-weight: 700; }
.m-skip:focus { top: var(--space-3); }

/* Theme menu (<details>) in the header, in place of the avatar */
.m-menu { position: relative; margin-left: auto; }
.m-menu__button { display: inline-flex; align-items: center; justify-content: center; list-style: none; padding: 0; }
.m-menu__button::-webkit-details-marker { display: none; }
.m-menu__panel { position: absolute; right: 0; top: calc(100% + var(--space-2)); z-index: 50; padding: var(--space-3); background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
.m-menu :focus-visible { outline: 2px solid var(--on-brand); outline-offset: 2px; }
.m-menu__panel :focus-visible { outline-color: var(--focus); }

/* Phones (J1): the menu button opens the drawer (NavDrawer) in place of the header nav and theme menu. The header is
   sticky (that is all it does without JS); js/phone-nav.js sets data-header-hidden while the page scrolls down, and
   clears it as soon as the page scrolls back up. */
@media (max-width: 599.98px) {
  .m-shell .m-header .m-nav, .m-shell .m-header .m-menu, .m-shell .m-header .m-brand__sub { display: none; }
  .m-shell .m-header { position: sticky; top: 0; z-index: 30; transition: transform 160ms ease; }
  .m-shell .m-header[data-header-hidden] { transform: translateY(-100%); }
  .m-shell .m-header__inner { flex-wrap: nowrap; gap: var(--space-2); padding: 10px var(--space-4) 10px var(--space-2); }
  .m-shell .m-navbtn { display: inline-flex; }
  /* Keyboard focus and #anchors land below the sticky header (64px) rather than under it. */
  html { scroll-padding-top: 72px; }
}
@media (prefers-reduced-motion: reduce) { .m-shell .m-header { transition: none; } }

/* Blazor's unhandled-error bar */
#blazor-error-ui { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; padding: var(--space-3) var(--space-5); background: var(--surface); color: var(--ink); border-top: 2px solid var(--note-ornament); }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: var(--space-3); top: var(--space-2); }
#blazor-error-ui a { color: var(--link); }

/* Library page (/tunes): filters beside the list; table on desktop, TuneCards on phones */
.m-library__recent { margin-bottom: var(--space-6); }
.m-library__body { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: flex-start; }
.m-library__filters { flex: 1 1 220px; max-width: 100%; display: flex; flex-direction: column; gap: var(--space-5); }
.m-library__filters form { display: flex; flex-direction: column; gap: var(--space-5); }
.m-library__filters p.m-meta { margin: 0; }
/* Filters: a <details> that is always open from 600px up (no summary), and folded on phones by library-filter.js. */
.m-library__more { min-width: 0; }
.m-library__more-body { display: flex; flex-direction: column; gap: var(--space-5); }
.m-library__more-state { display: inline-flex; align-items: center; gap: var(--space-2); }
.m-library__more-state .m-icon { width: 18px; height: 18px; color: var(--ink-muted); transform: rotate(-90deg); }
.m-library__more[open] .m-library__more-state .m-icon { transform: rotate(90deg); }
@media (min-width: 600px) { .m-library__more > summary { display: none; } }
.m-library__group { min-width: 0; }
.m-library__chips { display: flex; flex-direction: column; gap: var(--space-5); }
/* Admin: the category rows on the tune editor (static tag, then Up / Down / Remove) */
.m-category-list li { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.m-library__results { flex: 999 1 560px; min-width: 0; }
.m-library__count { margin: 0 0 var(--space-3); font-size: 14px; color: var(--ink-muted); }
.m-library__empty p { margin: 0 0 var(--space-4); color: var(--ink-muted); }
.m-library__empty-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* The catalog button carries the search words, which can be long: it wraps rather than widening a phone page. */
.m-library__empty-actions .m-btn { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: center; line-height: 1.25; padding-block: var(--space-2); }
.m-library__more-tunes { margin: var(--space-4) 0 0; }
/* While the search box has words in it, the recent tunes step aside so the results come right under it. */
.m-library:has(.m-search__input:not(:placeholder-shown)) .m-library__recent { display: none; }
.m-library-phone { display: none; grid-template-columns: 1fr; gap: var(--space-3); }
@media (max-width: 639.98px) {
  .m-library-table { display: none; }
  .m-library-phone { display: grid; }
}

/* Phones: a tighter vertical rhythm. Desktop spacing suits a page you read at arm's length; on a phone the same gaps
   push the tunes and the sheet a screen down. Content is padded --space-4 at the sides and --space-3/--space-4 between blocks. */
@media (max-width: 599.98px) {
  .m-page { padding: var(--space-4) var(--space-4) var(--space-6); }
  .m-page__head { gap: var(--space-3); margin-bottom: var(--space-4); }
  .m-page__title { margin-bottom: var(--space-1); }
  .m-panel { padding: var(--space-4); }
  .m-cards { gap: var(--space-2); }
  .m-tune-card { padding: var(--space-3) 14px; }

  /* Library and catalog: search, a folded Filters row, then the tunes. */
  .m-library__recent { margin-bottom: var(--space-4); }
  .m-library__recent .m-label { margin-bottom: var(--space-2); }
  .m-library__recent .m-cards { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: minmax(200px, 72%); overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: var(--space-4); margin-inline: calc(-1 * var(--space-4)); padding: 0 var(--space-4) var(--space-1); scrollbar-width: none; }
  .m-library__recent .m-cards > * { scroll-snap-align: start; }
  .m-library__body { gap: var(--space-4); }
  .m-library__filters, .m-library__filters form { gap: var(--space-3); }
  .m-library__more-body { gap: var(--space-4); padding: var(--space-3) 0 var(--space-2); }
  .m-library__count { margin-bottom: var(--space-2); }

  /* J2: nothing between the search and the tunes but the Filters row. */
  .m-library .m-page__lede { display: none; }
  .m-library__more-summary { min-height: var(--touch-min); }
}

/* Help: How to read the letters (/help/letters) */
.m-help { display: grid; gap: var(--space-5); max-width: 760px; }
.m-help p { margin: 0 0 var(--space-3); }
.m-help__sample { margin: 0; }
.m-help__sample img { display: block; width: 100%; height: auto; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.m-help__sample figcaption { margin-top: var(--space-2); font-size: 14px; color: var(--ink-muted); }

/* The hidden attribute always wins over component display rules (e.g. .m-btn { display:flex }). */
[hidden] { display: none !important; }

/* 44px touch targets on phones and touch screens (chips, brand, breadcrumb and small text links) */
@media (pointer: coarse), (max-width: 599.98px) {
  .m-chip, .m-brand { min-height: var(--touch-min); }
  .m-crumb a, .m-meta a, .m-setlist-nav__name { display: inline-flex; align-items: center; min-height: var(--touch-min); }
}
.m-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-5); }
.m-pager__status { margin: 0; }
.m-nav-progress { position: fixed; z-index: 1000; inset: 0 auto auto 0; width: 35%; height: 3px; background: var(--brass); pointer-events: none; animation: m-nav-progress 1.2s ease-in-out infinite; }
.m-nav-progress[hidden] { display: none; }
@keyframes m-nav-progress { from { transform: translateX(-110%); } to { transform: translateX(310%); } }
@media (prefers-reduced-motion: reduce) { .m-nav-progress { animation-duration: 2.4s; } }
