/* Study Quest — music-ui.css
 * The Music window (key J) and the now-playing chip (game/js/ui-music.js), in EMBER & IRON (docs/DESIGN.md is law):
 * a forged window with a smoked-steel body (parchment belongs to the Codex only), bone text, bronze hairlines between
 * the folder list and the page, the playing track lit by an ember edge. Composes theme.css components in markup; this
 * file only lays them out and adds .mus-* parts. Load order: base → theme → hud → panels → world-ui → music-ui → codex.
 */

/* ====================================================================================== window frame
 * SQ.UI.Windows builds a legacy .window.frame; ui-music.js adds the codex classes (codex-window, codex-banner,
 * codex-close, codex-window__body). These scoped resets remove what base.css still paints underneath. */
.window.mus-win {
  height: min(620px, calc(100vh - 40px));
  max-width: calc(100vw - 16px);
  max-height: none;
  min-width: 0;
}
.mus-win .win-header {
  height: auto;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  cursor: default;
}
.mus-win .win-title { cursor: move; letter-spacing: 0; }
.mus-win .win-close { box-shadow: none; display: block; color: transparent; }
.mus-win .win-close .icon, .mus-win .win-close svg { display: none; }
.mus-win .win-body {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.mus {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* ====================================================================================== now playing (a darker smoked strip) */
.mus-now {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--cx-sp-6);
  flex: none;
  padding: 12px 18px 13px 20px;
  border-bottom: 1px solid rgba(176, 122, 60, 0.5);
  background: linear-gradient(180deg, rgba(196, 204, 214, 0.07), rgba(196, 204, 214, 0) 2px), radial-gradient(ellipse 60% 120% at 0% 100%, rgba(255, 120, 40, 0.1), rgba(255, 120, 40, 0) 70%), linear-gradient(180deg, rgba(4, 5, 6, 0.42), rgba(4, 5, 6, 0.3)), var(--cx-bg-smoke);
  box-shadow: 0 1px 0 #000;
}
.mus-now__info { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-width: 0; }
.mus-now__where { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mus-now__title {
  font: 400 25px/1.12 var(--cx-font-head);
  color: var(--cx-gold-text);
  text-shadow: var(--cx-sh-text-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mus-now__by { font: italic 400 var(--cx-fs-small)/1.3 var(--cx-font-flavor); color: var(--cx-text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mus-now__prog { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.mus-now__bar { flex: 1 1 auto; min-width: 60px; }
.mus-now__time { flex: none; min-width: 76px; font-size: 12px; text-align: right; color: var(--cx-text-dim); }
.mus-now__ctl { display: flex; gap: 10px; flex: none; }
.mus-now .codex-action { --cx-action: 48px; }
.mus-now .codex-action:disabled { opacity: 0.55; }
.mus-now .codex-action__icon > svg { width: 100%; height: 100%; }

/* compact: the folder picker replaces the side list */
.mus-pickrow {
  display: none;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 6px 10px 7px;
  border-bottom: 1px solid rgba(176, 122, 60, 0.45);
  box-shadow: 0 1px 0 #000;
}
.mus-pick { flex: 1 1 auto; min-width: 0; min-height: 26px; padding-top: 3px; padding-bottom: 3px; }

/* ====================================================================================== folders + page (smoked steel) */
.mus-main {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  color: var(--cx-text);
}
.mus-nav {
  overflow: auto; padding: 2px 0 12px;
  border-right: 1px solid rgba(176, 122, 60, 0.4);
  box-shadow: 1px 0 0 #000;
  background: linear-gradient(90deg, rgba(5, 6, 7, 0.35), rgba(5, 6, 7, 0.15));
}
.mus-nav__group { padding: 12px 12px 4px; list-style: none; color: var(--cx-text-dim); border-bottom: 1px solid rgba(176, 122, 60, 0.22); }
.mus-nav__row { min-height: 40px; padding: 5px 10px 5px 13px; gap: 8px; }
.mus-nav__row .codex-row__title { font-size: 16px; }
.mus-nav__row.is-quiet .codex-row__title { color: var(--cx-text-dim); }
.mus-nav__row:focus { outline: none; }
.mus-nav__row:focus-visible { outline: 2px solid var(--cx-torch); outline-offset: -2px; }
.mus-nav__mark { display: grid; place-items: center; width: 15px; height: 15px; color: var(--cx-torch); }
.mus-nav__mark > svg { width: 100%; height: 100%; }
.mus-nav__here { font: 700 12px/1 var(--cx-font-label); letter-spacing: 0.05em; color: var(--cx-lapis-3); }

.mus-page { position: relative; overflow: auto; padding: 16px 22px 20px 26px; }
.mus-page__title { margin: 0 0 4px; }
.mus-page__where { margin: 0 0 10px; color: var(--cx-text-dim); }
.mus-page__count { display: block; margin: 8px 0 5px; }
.mus-page__note, .mus-page__help { margin: 8px 0 0; color: var(--cx-text-dim); }
.mus-page__empty { margin: 10px 0 4px; }
.mus-page__lead { margin: 2px 0 6px; }
.mus-page__lead::after { content: ''; display: block; clear: both; }
.mus-page__steps { margin-top: 6px; }
.mus-page .codex-divider { margin: 14px 0 10px; }
.mus-path {
  font: italic 400 1em/1.3 var(--cx-font-body);
  color: var(--cx-lapis-3);
  overflow-wrap: anywhere;
}

/* track rows */
.mus-tracks { border-top: 1px solid rgba(176, 122, 60, 0.25); }
.mus-track { min-height: 44px; gap: 11px; padding: 5px 6px 5px 12px; cursor: default; }
.mus-track .codex-row__title { font-size: 16px; }
.mus-track .codex-check { flex: none; }
.mus-track.is-off .codex-row__title, .mus-track.is-off .codex-row__meta { color: var(--cx-text-faint); }
.mus-track.is-selected .codex-row__meta { color: var(--cx-torch); }
.mus-track__play { flex: none; gap: 5px; }
.mus-track__playicon { display: inline-grid; width: 11px; height: 11px; margin-top: -1px; }
.mus-track__playicon > svg { width: 100%; height: 100%; }
.mus-track__now {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-right: 10px;
  font: 700 12px/1 var(--cx-font-label);
  letter-spacing: 0.05em;
  color: var(--cx-torch);
}
.mus-track__now > svg { width: 13px; height: 13px; }

/* ====================================================================================== credits */
.mus-credits__lead { margin: 2px 0 8px; }
.mus-credits__lead::after { content: ''; display: block; clear: both; }
.mus-credits__lead a { color: var(--cx-lapis-3); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.codex-vellum .mus-credits__lead a { color: var(--cx-ink-lapis); text-decoration-color: rgba(31, 58, 118, 0.45); }
.mus-credits__support { margin: 4px 0 6px; }
.mus-credits__links { margin: 0 0 2px; }
.mus-credits__folder { display: block; margin: 12px 0 2px; }
.mus-credits__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); column-gap: 26px; margin: 3px 0 6px; }
.mus-credits__title { font-weight: 500; }
.mus-credits__loading { color: var(--cx-text-dim); }
/* {ink: true}: the same inks as inside .codex-vellum, for a light page that is not a codex vellum (legacy parchment) */
.mus-credits--ink { color: var(--cx-ink-text); }
.mus-credits--ink .cx-h1 { color: var(--cx-ink-rubric-lg); text-shadow: none; }
.mus-credits--ink .cx-label { color: var(--cx-ink-text-dim); }
.mus-credits--ink .cx-flavor { color: var(--cx-ink-gold); }
.mus-credits--ink .mus-credits__lead a { color: var(--cx-ink-lapis); text-decoration-color: rgba(31, 58, 118, 0.45); }
.mus-credits--ink .codex-links > a { color: var(--cx-ink-text); text-shadow: none; }
.mus-credits--ink .codex-links > * + *::before { color: var(--cx-ink-rubric); }
.mus-credits--ink .codex-links > :nth-child(odd) + *::before { color: var(--cx-ink-lapis); }
.mus-credits--ink .codex-links > a:hover { color: var(--cx-ink-rubric); }
.mus-credits--ink .codex-paras > li::before { color: var(--cx-ink-rubric-lg); }
.mus-credits--ink .codex-paras > li:nth-child(even)::before { color: var(--cx-ink-lapis); }
.mus-credits--ink .codex-divider { --_c: rgba(122, 29, 16, 0.32); --_f: var(--cx-orn-filler); }

/* ====================================================================================== footer (on the forged band) */
.mus-foot {
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  padding: 8px 34px 0;      /* clear of the cornerpieces (DESIGN §7) */
}
.mus-foot__mode { display: flex; align-items: center; gap: 8px; }
.mus-foot__mode .cx-label { color: var(--cx-text-dim); text-shadow: 0 1px 0 #000; }
.mus-foot .codex-select { min-height: 26px; padding-top: 2px; padding-bottom: 2px; font-size: 14px; }
.mus-foot__toggles { display: flex; align-items: center; gap: 6px; flex: none; }
.mus-foot__toggles .codex-btn { padding-left: 10px; padding-right: 10px; white-space: nowrap; }
.mus-foot { gap: 8px; }   /* V7.2.3: Study Radio and Sound are buttons now (no Shift keys) */
.mus-foot__btns { display: flex; align-items: center; gap: 8px; flex: none; }

/* opened from the login / character screens (Credits): above them, modal, a click outside closes it */
.mus-glue-layer {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 3000;
  background: rgba(6, 4, 3, 0.5);
  animation: cx-fade var(--cx-dur-calm) var(--cx-ease);
}
.mus-glue-layer:empty { display: none; }
.mus-glue-layer > .window { pointer-events: auto; }

/* ====================================================================================== compact (480×360) */
body.sq-compact .window.mus-win { height: calc(100vh - 42px); }
body.sq-compact .mus-now { gap: 10px; padding: 7px 10px 8px 12px; }
body.sq-compact .mus-now__title { font-size: 18px; }
body.sq-compact .mus-now__prog { display: none; }
body.sq-compact .mus-now__time { min-width: 0; }
body.sq-compact .mus-now .codex-action { --cx-action: 36px; }
body.sq-compact .mus-pickrow { display: flex; }
body.sq-compact .mus-main { grid-template-columns: minmax(0, 1fr); }
body.sq-compact .mus-nav { display: none; }
body.sq-compact .mus-page { padding: 10px 12px 12px 16px; }
body.sq-compact .mus-track { min-height: 34px; padding: 3px 4px 3px 8px; gap: 8px; }
body.sq-compact .mus-track .codex-row__title, body.sq-compact .mus-nav__row .codex-row__title { font-size: 15px; }
body.sq-compact .mus-foot { padding: 5px 20px 0; }
body.sq-compact .mus-foot { flex-wrap: wrap; row-gap: 4px; }
@media (max-width: 560px), (max-height: 420px) {
  .window.mus-win { height: calc(100vh - 42px); }
  .mus-now { gap: 10px; padding: 7px 10px 8px 12px; }
  .mus-now__title { font-size: 18px; }
  .mus-now__where { font-size: var(--cx-fs-sc-min); }
  .mus-now__prog { display: none; }
  .mus-now__time { min-width: 0; }
  .mus-now .codex-action { --cx-action: 36px; }
  .mus-pickrow { display: flex; }
  .mus-main { grid-template-columns: minmax(0, 1fr); }
  .mus-nav { display: none; }
  .mus-page { padding: 10px 12px 12px 16px; }
  .mus-page .codex-divider { margin: 10px 0 8px; }
  .mus-track { min-height: 34px; padding: 3px 4px 3px 8px; gap: 8px; }
  .mus-track .codex-row__title { font-size: 15px; }
  .mus-foot { padding: 5px 20px 0; }
  .mus-foot { flex-wrap: wrap; row-gap: 4px; }
}

/* ====================================================================================== now-playing chip (HUD) */
.mus-chip {
  -webkit-appearance: none;
  appearance: none;
  position: fixed;
  top: 40px;
  left: 50%;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-sizing: border-box;
  max-width: min(440px, calc(100vw - 16px));
  height: 27px;
  margin: 0;
  padding: 0 13px 0 10px;
  font: 400 12px/1 var(--cx-font-body);
  color: var(--cx-text-dim);
  white-space: nowrap;
  background: var(--cx-caps), var(--cx-bg-ink);
  border: 1px solid rgba(176, 122, 60, 0.5);
  border-radius: var(--cx-r-1);
  box-shadow: var(--cx-sh-1), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  pointer-events: auto;
  opacity: 1;
  transition: opacity var(--cx-dur-calm) var(--cx-ease);
}
.mus-chip.is-idle { opacity: 0; transition-duration: var(--cx-dur-slow); }
.mus-chip.is-idle:hover, .mus-chip:focus-visible { opacity: 1; transition-duration: var(--cx-dur-quick); }
.mus-chip.is-gone { visibility: hidden; pointer-events: none; }
.mus-chip:hover .mus-chip__title { color: var(--cx-gold-leaf); }
.mus-chip:focus { outline: none; }
.mus-chip:focus-visible { outline: 2px solid var(--cx-torch); outline-offset: 2px; }
.mus-chip__note { display: grid; place-items: center; flex: none; width: 13px; height: 13px; color: var(--cx-gold-3); }
.mus-chip__note > svg { width: 100%; height: 100%; filter: drop-shadow(0 1px 0 #000); }
.mus-chip__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font: italic 400 14px/1.1 var(--cx-font-flavor);
  color: var(--cx-gold-3);
  text-shadow: 0 1px 0 #000;
  transition: color var(--cx-dur-quick) var(--cx-ease);
}
.mus-chip__by { flex: none; text-shadow: 0 1px 0 #000; }
html[data-sq-screen]:not([data-sq-screen="game"]) .mus-chip { display: none; }
body.sq-compact .mus-chip { height: 23px; padding: 0 10px 0 8px; gap: 6px; }
body.sq-compact .mus-chip__title { font-size: 13px; }

/* compact credits: "support the artist" and the links come right under the title, the long notice follows */
@media (max-width: 560px), (max-height: 420px) {
  .mus-credits { display: flex; flex-direction: column; }
  .mus-credits__support { order: 1; margin: 0 0 2px; }
  .mus-credits__links { order: 2; margin: 0 0 8px; }
  .mus-credits__lead { order: 3; }
  .mus-credits > .codex-divider { order: 4; }
  .mus-credits__tracks { order: 5; }
}
body.sq-compact .mus-credits { display: flex; flex-direction: column; }
body.sq-compact .mus-credits__support { order: 1; margin: 0 0 2px; }
body.sq-compact .mus-credits__links { order: 2; margin: 0 0 8px; }
body.sq-compact .mus-credits__lead { order: 3; }
body.sq-compact .mus-credits > .codex-divider { order: 4; }
body.sq-compact .mus-credits__tracks { order: 5; }

/* a credit line that opens the Credits page (any element with data-music-credits, e.g. the glue screens' footer) */
[data-music-credits] { cursor: pointer; transition: color var(--cx-dur-quick) var(--cx-ease); }
[data-music-credits]:hover { color: var(--cx-gold-text); text-decoration: underline; text-decoration-color: rgba(176, 122, 60, 0.5); text-underline-offset: 3px; }
[data-music-credits]:focus { outline: none; }
[data-music-credits]:focus-visible { outline: 2px solid var(--cx-torch); outline-offset: 3px; }
