/* Staff! Music Ninja chrome. The Level Lab design tokens, themes, page base and button shapes come from
   studio/base.css, loaded first, and the page frame, tray, corner tools, Menu and cards from the
   other studio/ styles; this file adds Staff! Music Ninja's own. The stage keeps its own sheet color in
   both themes (PAPER in src/game/config.js), as Clatter Lab's board keeps its sky. */

/* The music font (SIL OFL 1.1, license in assets/fonts). Roboto is studio/base.css's. */
@font-face { font-family: 'Petaluma'; src: url('../assets/fonts/Petaluma.woff2') format('woff2'); font-display: block; }

/* Small notes under labels (song tiles, Beats a Minute): 14 px, the game's smallest text for K-8
   readers (TEXT_MIN.note in src/game/ui.js), not Studio's 10 px tag size. The How Hard cards keep
   Studio's size: 14 px doesn't fit their 90 x 90 (studio/tray.css). */
:root { --staff-note-size: 14px; }

html, body {
  touch-action: pinch-zoom; /* pinch zoom stays (Menu, picker, cards); no double-tap zoom or scrolling */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { touch-action: manipulation; }
svg[data-icon] { flex: 0 0 auto; }

/* ---- The stage ---- */
#stage { background: #ecdcb8; } /* PAPER, shown before the first frame is drawn */
#stage { touch-action: none; } /* the play area: every touch is a tap */
#game { position: absolute; left: 0; top: 0; display: block; touch-action: none; }

/* While the game starts up (body.loading, removed by lab.js once the stage has drawn), the
   controls hide and a spinner turns on the sheet: the shared studio/shell.css. */

/* The big button while a song plays: Pause (lab.js sets .pausing; studio/tools.css has Play and Stop) */
.studio-play .icon-pause, .studio-play.pausing .icon-play { display: none; }
.studio-play.pausing .icon-pause { display: block; }

/* ---- The top bar: the song on the left (and the picker), Share ---- */
.song-info { display: flex; align-items: center; gap: var(--content-gap); min-width: 0; flex: 1 1 auto; }
.song-title { font-weight: var(--font-weight-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-share[hidden] { display: none; }
#btn-share { flex: none; margin-left: 0; }
.studio-topbar .studio-menu-button { margin-left: 0; }

/* ---- What shows when ----
   mode-play / mode-write: which of the two places the player is in.
   playing: a song is running (or paused, or just ended): nothing to choose, so the tray and the
   bar's buttons rest. page: a page drawn on the stage (the Timing Check) has it all. */
body.mode-play #btn-undo,
body.mode-play #btn-redo { display: none; }
body.playing #tray { opacity: 0.5; pointer-events: none; }
body.playing #btn-hint { visibility: hidden; } /* the score has its corner */
body.page #view-tools, body.page #run-tools, body.page #tray { visibility: hidden; }
/* A short screen (a phone on its side): the tray makes way for the staff while a song plays. */
@media (max-height: 500px) {
  body.playing #tray { display: none; }
}

/* ---- The tray ---- */
.tray-row {
  display: flex;
  gap: var(--content-gap);
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: safe center;
  touch-action: pan-x;
  /* A card's height even while empty: the How Hard cards are made by lab.js, so while the
     game loads the tray would be short and the stage would jump when they arrive. */
  min-height: var(--studio-card-size, 90px);
}
.tray-row::-webkit-scrollbar { display: none; }
.tray-row[hidden] { display: none; }
.group { display: flex; gap: var(--space-1); flex: none; }
#note-tray { overflow: visible; justify-content: flex-start; gap: var(--space-1); touch-action: none; }

/* Play: How Hard, chosen with a tap */
.studio-card-choice { gap: var(--space-1); line-height: 1; } /* 90 x 90, as every card (studio/tray.css) */
.studio-card-choice svg { width: 35px; height: 35px; color: var(--color-text-dark); }
.studio-card-choice.active svg { color: var(--color-accent); }
.studio-card-choice .name { margin-top: 0; }
.studio-card-choice .sub { font-size: var(--font-size-sm); line-height: 15px; color: var(--color-text-dark); white-space: nowrap; }

/* Write, Tap It: Record, Groove (Play or Stop on it), New Tune */
#tap-record svg { color: var(--color-error); }
#tap-band .icon-stop, #tap-band.active .icon-play { display: none; }
#tap-band.active .icon-stop { display: block; }
.studio-card-choice:disabled { opacity: 0.4; cursor: not-allowed; }

/* Write: a note or a mark on each card, in the music font */
.note-card .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  color: var(--color-text);
}
.note-card .icon svg { width: 100%; height: 100%; display: block; overflow: visible; }
.note-card .icon text { font-family: 'Petaluma'; fill: currentColor; }
.note-card .name.tight { letter-spacing: -0.03em; }
.note-card.kb { border-color: var(--color-accent); } /* the keyboard's note length (1-7) */

/* ---- Cards over the stage: Paused, and the end of a song ---- */
.lab-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100% - 2 * var(--content-gap)));
  max-height: calc(100% - 2 * var(--content-gap));
  overflow-y: auto;
  padding: var(--content-gap);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--content-gap);
  z-index: 5;
  animation: pop-in 0.3s ease-out;
}
.lab-card[hidden] { display: none; }
.lab-card .studio-pop-text { white-space: pre-line; }
.lab-card-buttons { display: flex; flex-wrap: wrap; gap: var(--content-gap); justify-content: center; }
.lab-card-buttons .button { gap: var(--space-1); }
.lab-card-buttons .button[hidden] { display: none; }
/* Paused: Stop, Start Over and Continue are all one size (three equal columns) */
#pause-card { width: min(400px, calc(100% - 2 * var(--content-gap))); }
#pause-card .lab-card-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
#pause-card .lab-card-buttons .button { justify-content: center; padding-inline: var(--space-1); white-space: nowrap; }
@keyframes pop-in { from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; } }
/* The grade: a big letter in the accent, where Clatter Lab's card has its star */
.end-grade { font-size: 50px; line-height: 55px; font-weight: var(--font-weight-bold); color: var(--color-accent); }
.end-grade:empty { display: none; }
.end-fix { display: flex; align-items: center; justify-content: center; gap: var(--content-gap); }
.end-fix[hidden] { display: none; }

/* The cards that ask or tell (studio/dialog.css) sit over the Paused and end cards */
#card { z-index: 46; }

/* ---- Song picker: the shared one (studio/picker.css); these are a song's tile ---- */
.song-tile {
  aspect-ratio: auto;
  min-height: 132px; /* the fullest tile: grade, a 2-line name, the time and a best score */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* the grade (or ♪) at the top, the name right under it... */
  gap: var(--space-1);
}
.song-tile .time { margin-top: auto; } /* ...and the time, then the best score (or Not Played Yet), at the bottom, so each sits in the same place on every tile */
.song-tile .best { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-tile .best.none { color: var(--color-text); opacity: 0.7; font-style: italic; } /* Not Played Yet: there, but quiet (still 4.5:1) */
.song-tile.current { box-shadow: inset 0 0 0 1px var(--color-accent); }
.song-tile .grade { font-size: var(--font-size-lg); font-weight: var(--font-weight-bold); line-height: 25px; color: var(--color-border-light); }
.song-tile.done .grade { color: var(--color-accent); }
.song-tile .name { font-weight: var(--font-weight-bold); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.song-tile .sub { color: var(--color-text-dark); font-size: var(--staff-note-size); line-height: 18px; }

/* ---- The picker's Write pages (lab.js writePicker): My Songs, From Friends and Examples: cards from studio/picker.css, with
   Edit, share and delete. These are a song's: its first bars on the paper, and its name on one line. ---- */
.studio-picker-pic { aspect-ratio: 24 / 11; background: #ecdcb8; /* the paper (PAPER), while it draws */ }
.studio-picker-pic.plus { background: transparent; }
.studio-picker-name { display: block; font-weight: var(--font-weight-bold); white-space: nowrap; text-overflow: ellipsis; }

/* ---- The Menu ---- */
/* Levels / Sandbox and Tap It / Write It: studio/panel.css (.studio-panel-choice) */
#btn-code[hidden] { display: none; }

/* The Menu's pages: the root and Song Settings, stacked in one spot (so the sheet keeps the
   size of the taller), sliding sideways between them (menuPage in lab.js). */
/* It is what scrolls (overflow-x hidden makes y auto), so it reaches up to the head's line and
   down to the sheet's bottom edge and pads back in by as much: the scrollbar runs the full height. */
.menu-pages {
  display: grid;
  overflow-x: hidden;
  margin: calc(-1 * var(--content-gap)) calc(-1 * var(--content-gap)) calc(-1 * (var(--content-gap) + env(safe-area-inset-bottom)));
  padding: var(--content-gap) 0 calc(var(--content-gap) + env(safe-area-inset-bottom));
}
.menu-page {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: calc(var(--content-gap) * 2); /* as the sheet: two spaces between sections (studio/panel.css) */
  padding: 0 var(--content-gap);
  transition: transform 0.25s ease, visibility 0s 0.25s;
  visibility: hidden;
}
.menu-page.on { visibility: visible; transition: transform 0.25s ease; }
#menu-root:not(.on) { transform: translateX(-100%); }
#menu-song-page:not(.on) { transform: translateX(100%); }
.no-slide .menu-page { transition: none; }
@media (prefers-reduced-motion: reduce) { .menu-page { transition: none; } .lab-card { animation: none; } }
/* ‹ in the head, on Song Settings: the title sits beside it */
.studio-panel-head #menu-back[hidden] { display: none; }
.studio-panel-head #menu-back + .studio-panel-title { margin-right: auto; margin-left: var(--space-1); }
/* On Song Settings the title goes back too (lab.js): ‹ and the words are one target */
.studio-panel-title.back { cursor: pointer; }
@media (hover: hover) {
  :where(html:not([data-pointer='touch'])) .studio-panel-head:has(.studio-panel-title.back:hover) #menu-back,
  :where(html:not([data-pointer='touch'])) .studio-panel-title.back:hover { color: var(--color-text); }
}
/* A row that opens a page: its name, and › at the right */
.menu-next svg { color: var(--color-text-dark); }
.studio-panel-section[hidden], .studio-panel-section > .studio-panel-row[hidden] { display: none; }
.studio-panel-section > .button[hidden] { display: none; }
.studio-panel-section > .button { gap: var(--space-1); }

/* A setting with a value: the name, then − value + */
.lab-rows { display: flex; flex-direction: column; gap: var(--space-1); }
.lab-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 45px;
  padding: 0 var(--space-1) 0 var(--space-2);
  background: var(--color-background);
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-lg);
}
.lab-row .label { flex: 1 1 auto; min-width: 0; }
/* Song Settings: two spaces between its three kinds of controls (the Tap It / Write It switch,
   the rows, the buttons), as between the root page's sections. */
.studio-panel-section > #song-rows, .studio-panel-section > #btn-clear { margin-top: calc(var(--content-gap) * 2); }
.lab-row .value { flex: 0 0 80px; text-align: center; font-weight: var(--font-weight-bold); line-height: 15px; }
.lab-row .value small { display: block; font-size: var(--staff-note-size); font-weight: var(--font-weight); color: var(--color-text-dark); }
.lab-row .button-icon { flex: none; }
.lab-row[hidden] { display: none; }
/* A volume: ten small bars */
.lab-bar { display: flex; gap: 2px; justify-content: center; }
.lab-bar i { width: 5px; height: 15px; border-radius: 2px; background: var(--color-border-light); }
.lab-bar i.on { background: var(--color-accent); }
.studio-panel-section > .studio-panel-row { width: 100%; }
