/* app.css — two-pane layout glue for the viewer app.
 * Look-bearing rules live in the packages (player.css, demo.css, the editor
 * bundle's injected theme); this file only arranges them and the few
 * app-owned bits (header toggles, resizer, status line). */

:root {
  --left-w: 420px;
  --resizer-w: 6px;
  /* demo.css positions the fixed video slot from these: */
  --sidebar-w: var(--left-w);
  --font-ui: 'Atkinson Hyperlegible', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: var(--font-ui); }

.layout {
  display: grid;
  grid-template-columns: var(--left-w) var(--resizer-w) 1fr;
  min-height: 100vh;
}

/* ── Left pane: editor ─────────────────────────────────────────────── */
.text-pane {
  display: flex; flex-direction: column;
  background: #fafaf8; border-right: 1px solid #e0ddd6;
  overflow: hidden;
  position: sticky; top: 0; align-self: start; height: 100vh;
}
.text-pane-header {
  flex-shrink: 0; padding: 8px 10px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  border-bottom: 1px solid #e0ddd6; background: #f4f3ef;
}
.text-pane-header select {
  flex: 1 1 100%; min-width: 160px;
  font: 13px/1.3 var(--font-ui);
  padding: 5px 8px; border-radius: 6px;
  border: 1px solid #bbb; background: #fff;
}
/* The dialect select is a compact companion to #pieceSelect (not full-width). */
.text-pane-header #dialectSelect { flex: 0 0 auto; min-width: 90px; }
.seg-toggle {
  display: flex; gap: 1px; background: #ccc; border-radius: 5px; overflow: hidden;
}
.seg-toggle button {
  padding: 4px 10px; border: none; background: #eee;
  font: 500 11px/1.2 var(--font-ui);
  color: #555; cursor: pointer;
}
.seg-toggle button.active { background: #fff; color: #111; font-weight: 700; }
.seg-toggle button:hover:not(.active) { background: #e8e8e8; }
.seg-toggle button:disabled { opacity: 0.4; cursor: default; }

#editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#editor .cm-editor { flex: 1; min-height: 0; }
#status {
  flex-shrink: 0; font-size: 12px; color: #888; padding: 4px 12px;
  border-top: 1px solid #e0ddd6; min-height: 24px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#status.error { color: #cf222e; }

/* ── Stamp dials (Ibut3) ───────────────────────────────────────────────
 * Look ported verbatim from the retired VIEWER_HTML (json_score_viewer.py).
 * The warm dark-accent palette is scoped here so the dials read as one self-
 * contained control cluster in the otherwise-light header. Markup is built by
 * dials.js; #dials is the mount, .im-dials the cluster it inserts. */
.im-dials {
  --im-bg-chip: #3a2418;
  --im-bg-pop: #2a1810;
  --im-text: #f5ebe0;
  --im-muted: #a89888;
  --im-border: #5a4030;
  --im-accent: #ff6b35;
  --im-accent-soft: #e8a030;
  display: none; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 4px 8px; background: var(--im-bg-pop); border-radius: 8px;
  border: 1px solid var(--im-border);
}
.im-dials.on { display: flex; }
.im-dials .stamp-side { display: flex; gap: 10px; align-items: center; }
.im-dials .stamp-side label {
  font-size: 11px; color: var(--im-muted); display: flex;
  align-items: center; gap: 4px; cursor: pointer;
}
.im-dials .stamp-side input[type=number] {
  width: 56px; background: var(--im-bg-chip); color: var(--im-text);
  border: 1px solid var(--im-border); border-radius: 4px; padding: 2px 4px;
}
.im-dials .stamp-side input[type=checkbox] { accent-color: var(--im-accent); }

.im-dials .chip {
  position: relative; display: flex; align-items: baseline; gap: 6px;
  padding: 4px 10px; border-radius: 999px; background: var(--im-bg-chip);
  border: 1px solid var(--im-border); cursor: default; user-select: none;
  font-variant-numeric: tabular-nums;
}
.im-dials .chip:hover, .im-dials .chip.open { border-color: var(--im-accent-soft); }
.im-dials .chip.open { background: #4a2c1c; box-shadow: 0 0 0 1px var(--im-accent-soft); }
.im-dials .chip-name {
  font-size: 10px; color: var(--im-accent-soft); text-transform: uppercase;
  letter-spacing: .03em;
}
.im-dials .chip-val { font-size: 12px; color: var(--im-text); font-weight: 600; }
.im-dials .chip-pop {
  display: none; position: absolute; left: 50%; top: calc(100% + 6px);
  transform: translateX(-50%); z-index: 200; padding: 10px 12px 8px;
  background: var(--im-bg-pop); border: 1px solid var(--im-accent-soft);
  border-radius: 8px; box-shadow: 0 8px 24px #0008; min-width: 140px;
}
.im-dials .chip-pop::before {
  content: ''; position: absolute; left: 50%; top: -5px; width: 8px; height: 8px;
  background: var(--im-bg-pop); border-left: 1px solid var(--im-accent-soft);
  border-top: 1px solid var(--im-accent-soft); transform: translateX(-50%) rotate(45deg);
}
.im-dials .chip.open .chip-pop, .im-dials .chip.show-pop .chip-pop { display: block; }
.im-dials .chip-pop input[type=range] {
  width: 120px; margin: 0; accent-color: var(--im-accent); cursor: pointer;
}

/* ── Resizer ───────────────────────────────────────────────────────── */
.resizer {
  cursor: col-resize; background: transparent; position: relative;
  z-index: 10; touch-action: none;
}
.resizer:hover { background: rgba(0, 0, 0, 0.06); }
.resizer::after {
  content: ''; position: absolute; top: 0; bottom: 0;
  left: 2px; width: 1px; background: #d6cb00;
}

/* ── Right pane ────────────────────────────────────────────────────── */
/* Lights (typeset _applyLights): bright while studying/paused, dark in
 * cinema. demo.css reads --demo-panel-bg for the notation panel. */
.demo-main {
  --demo-panel-bg: rgb(248, 246, 244);
  background: var(--demo-panel-bg);
  transition: background 0.6s ease;
}
.demo-main.lights-off { --demo-panel-bg: rgb(65, 64, 63); }
.demo-main .notation-panel { background: var(--demo-panel-bg); }

/* The notation bar docks to the right pane's bottom in page mode. */
.notation-bar {
  position: fixed !important; bottom: 0 !important;
  left: calc(var(--left-w) + var(--resizer-w)) !important; right: 0 !important;
  z-index: 100 !important;
}
.notation-panel, .panel { position: static !important; }
.notation-content-area { overflow: visible !important; padding-bottom: 96px !important; }

/* Editor→notation pick outline (cursor-inside-token highlight). */
.editor-pick, .editor-pick * {
  fill: #0969da !important;
  stroke: #0969da !important;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .text-pane { position: static; height: auto; max-height: 34vh; }
  .resizer { display: none; }
  :root { --sidebar-w: 0px; }
  .notation-bar { left: 0 !important; }
}
