/* The Scriptorium on a PHONE (phone-scriptorium.js puts body.phone on it: a touch screen whose short side is 500 px or
   less, held either way). A phone sees the music and one slim bar of menus; picking a menu opens it over the bottom
   (or the right side when held sideways). Tablets and iPads never get body.phone, so none of this touches them.
   Everything here sits behind body.phone. */

#phBar, #phSheet { display: none; }

body.phone { height: 100dvh; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }

/* ---- the screen is the music: no header, toolbar rows, palettes, chart, piano, or status line ---- */
body.phone #toolbar { display: contents; }
body.phone #toolbar > header,
body.phone #toolbar > #quickbar,
body.phone #toolbar > #dockTop { display: none !important; }
body.phone .workspace { order: 1; flex: 1 1 0; min-height: 0; min-width: 0; display: grid;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
body.phone .workspace > .scorepane { grid-column: 1; grid-row: 1; }
body.phone .workspace > .chartside { display: none !important; }
body.phone .pdock { display: none !important; }
body.phone #status, body.phone #piano, body.phone #pianoTab, body.phone .scorepane > .tkeys { display: none !important; }
body.phone .score { padding: 6px; }

/* the finger's long press must never start the browser's own text selection or callout on the music */
body.phone #score, body.phone #score svg, body.phone #score svg * {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
body.phone #score input { -webkit-user-select: text; user-select: text; }

/* ---- the slim bar of menus ---- */
body.phone #phBar { display: flex; order: 3; flex: none; background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 35; }
body.phone #phBar button { flex: 1 1 0; min-width: 0; min-height: 52px; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 2px;
  font: 700 12px/1.1 var(--ui); color: var(--text); }
body.phone #phBar button .ph-i { font-size: 20px; line-height: 1; }
body.phone #phBar button.on { background: var(--text); color: #fff; }
body.phone #phBar button#phPlay { color: var(--accent); }
body.phone #phBar button#phPlay.on { background: var(--accent); color: #fff; }

/* ---- the one open menu ---- */
body.phone #phSheet:not([hidden]) { display: flex; flex-direction: column; order: 2; flex: none; max-height: 46dvh;
  background: var(--panel); border-top: 2px solid var(--line); box-shadow: 0 -8px 24px #1f23501f; z-index: 34; min-height: 0; }
.ph-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 14px; border-bottom: 1px solid var(--line); flex: none; }
.ph-head b { flex: 1; font: 800 16px/1.2 var(--ui); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-head button { min-width: 44px; min-height: 44px; padding: 6px 10px; font-size: 16px; }
.ph-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; padding: 8px 12px 14px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.ph-hint { margin: 0 0 10px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.ph-sec { margin: 0 0 14px; }
.ph-sec > h3 { margin: 0 0 6px; font: 800 12px/1.2 var(--ui); letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 8px; }
.ph-grid button { min-height: 48px; padding: 8px 6px; font-size: 15px; white-space: normal; }
.ph-grid.ph-tight { gap: 6px; margin-bottom: 6px; }
.ph-grid.ph-tight button { min-height: 50px; padding: 6px 2px; font-size: 15px; min-width: 0; }
.ph-grid button.dyn { font: italic 700 19px 'EB Garamond', Georgia, serif; }
.ph-grid button.wide { grid-column: 1 / -1; }
.ph-grid button.danger { color: var(--accent); }
.ph-grid button.on { background: var(--text); color: #fff; border-color: var(--text); }
.ph-big { width: 100%; min-height: 56px; font-size: 17px; font-weight: 800; margin-bottom: 8px; }

/* real controls moved in from the toolbar and palettes (the same elements, so they work as they always did) */
.ph-body kbd { display: none; }
.ph-body .tg { display: block; border: 0; padding: 0; margin: 0; background: transparent; box-shadow: none; }
.ph-body .tg > .tg-label { display: none; }
.ph-body .tg-body { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ph-body .tg-body .seg { display: inline-flex; }
.ph-body .tg-body .barnav { display: inline-flex; align-items: center; gap: 6px; }
.ph-body .palette { display: flex !important; flex-wrap: wrap; align-items: center; gap: 8px; width: auto; padding: 0; background: transparent; border: 0; box-shadow: none; }
.ph-body .palette .pal-grip { display: none !important; }
.ph-body .palette #durGroup { display: flex; flex-wrap: wrap; gap: 8px; grid-column: auto; }
.ph-body .palette button { min-width: 48px; min-height: 48px; flex: 0 0 auto; font-size: 17px; }
.ph-body .palette small { display: none; }
.ph-body .palette .group { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-body .palette select, .ph-body .tg select { min-height: 48px; font-size: 16px; }
/* Notes menu: the everyday buttons only (lengths from a sixteenth up, dot, rest, signs, tie); the rest stays on the computer */
.ph-body #palNotes #durShort, .ph-body #palNotes [data-dur="64th"], .ph-body #palNotes [data-dur="32nd"], .ph-body #palNotes #btnEnharm,
.ph-body #palNotes [data-act="chord"], .ph-body #palNotes #btnChordBuild, .ph-body #palNotes #btnTriplet, .ph-body #palNotes #btnTuplet,
.ph-body #palNotes #repGroup, .ph-body .tkeys [data-key="Escape"], .ph-body .tkeys [data-key="Tab"], .ph-body .tkeys [data-key="Enter"],
.ph-body .tkeys [data-mods="ctrl"] { display: none !important; }
.ph-body .singgrp { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.ph-body #qsRec { min-height: 64px; font-size: 19px; font-weight: 800; flex: 1 1 100%; }
.ph-body #qsNotes, .ph-body #qsLyrics { flex: 1 1 40%; min-height: 52px; font-size: 16px; }
.ph-body .qsmsg { flex: 1 1 100%; }
.ph-body .tkeys { display: flex !important; flex-wrap: wrap; overflow: visible; padding: 8px 0 0; border: 0; background: transparent; }
.ph-body .tkeys > [data-mod] { display: none; }
.ph-body .tkeys > .sep { display: none; }
.ph-body .tkeys button { min-width: 48px; min-height: 48px; }
.ph-body .mpanel { display: flex !important; flex-direction: column; position: static; min-width: 0; width: auto; max-height: none; box-shadow: none;
  border: 0; padding: 0; background: transparent; }
.ph-body .mpanel > button, .ph-body .mpanel .msub > button, .ph-body .msubpanel > button, .ph-body .mpanel .group > button { min-height: 48px; font-size: 16px; }
.ph-body .mpanel .mrow { min-height: 48px; font-size: 16px; }
.ph-body .mpanel .msubpanel { margin-left: 8px; }

/* typing a lyric or a chord: the menu steps aside so the keyboard and the music get the room */
body.phone.ph-typing #phSheet, body.phone.ph-typing #phBar { display: none !important; }

/* a message sits above the bar, not on it */
body.phone .toast { bottom: 76px; max-width: 92vw; }

/* held sideways: the bar runs down the right edge, the open menu is a panel beside the music */
@media (orientation: landscape) {
  body.phone { flex-direction: row; }
  body.phone #phBar { order: 3; flex-direction: column; width: 62px; border-top: 0; border-left: 1px solid var(--line); padding-bottom: 0; }
  body.phone #phBar button { min-height: 0; flex: 1 1 0; }
  body.phone #phSheet:not([hidden]) { order: 2; width: min(50vw, 440px); max-height: none; height: 100dvh; border-top: 0; border-left: 2px solid var(--line);
    box-shadow: -8px 0 24px #1f23501f; }
  body.phone .toast { bottom: 16px; }
}
