
/* Harmony Lab: shared tokens, base and experiment scaffolding (web spec 2, 3, 4.4).
   Fonts and the 'Acc' face for the accidentals live in fonts.css (linked first). Viewport
   units are written as var(--hl-vw, 100vw) / var(--hl-vh, 100vh): unset (direct, embed, hub)
   they are the window, on a native page shell.js sets them to the frame. Width queries come
   in twins: @media scoped to html:not([data-hl-frame="native"]) plus @container hl-frame. */
:root {
  --ink:       #050510;
  --ink-soft:  #0C0C1A;
  --ink-rule:  #1A1A2A;
  --paper:     #F4EFE6;
  --paper-mute:rgba(244,239,230,0.62);
  --paper-dim: rgba(244,239,230,0.35);
  --h1: #FF4E26;
  --h2: #FFB84A;
  --h3: #4DD7FF;
  --h4: #B488FF;
  --display: 'Acc', 'Fraunces', 'Georgia', serif;
  --sans:    'Acc', 'Bricolage Grotesque', system-ui, -apple-system, sans-serif;
  --mono:    'Acc', 'JetBrains Mono', ui-monospace, monospace;
  --brand:   'Acc', 'Bagel Fat One', 'Titan One', system-ui, sans-serif;
  --gutter: clamp(16px, calc(var(--hl-vw, 100vw) * 0.05), 64px);
  --max:    1440px;
  --ease:   cubic-bezier(0.16, 1, 0.3, 1);
}
/* V nativním rámu se --gutter počítá z šířky rámu (vlastnost z :root by zůstala podle okna). */
.hl-frame[data-hl-native] { --gutter: clamp(16px, calc(var(--hl-vw, 100vw) * 0.05), 64px); }

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  line-height: 1.55;
  letter-spacing: -0.005em;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--h1); color: var(--paper); }
:focus-visible { outline: 2px solid var(--h2); outline-offset: 3px; border-radius: 6px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* ── EXPERIMENTS ───────────────────────────────────────────── */
.exp {
  position: relative;
  padding: clamp(20px, calc(var(--hl-vh, 100vh) * 0.03), 32px) 0;
  border-top: 1px solid var(--ink-rule);
  --accent: var(--h2);
}
.exp-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, calc(var(--hl-vw, 100vw) * 0.05), 88px);
  align-items: start;
}
.exp.flip .exp-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.exp.flip .exp-copy { order: 2; }
.exp.flip .exp-stage { order: 1; }
.exp-copy { position: sticky; top: calc(var(--hl-bar-h, 48px) + 24px); }
.exp-num {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
  display: inline-flex; align-items: center; gap: 10px;
}
.exp-num::before { content: ""; width: 28px; height: 1px; background: currentColor; }
.exp h2 {
  margin-top: 18px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, calc(var(--hl-vw, 100vw) * 0.042), 62px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.exp h2 em { font-style: italic; color: var(--accent); }
.exp-lede {
  margin-top: 22px;
  font-size: clamp(16px, calc(var(--hl-vw, 100vw) * 0.013), 18px);
  color: var(--paper-mute);
  max-width: 520px;
}
.exp-lede + .exp-lede { margin-top: 14px; }
.exp-lede em { color: var(--paper); font-style: italic; }

.controls { margin-top: 30px; display: flex; flex-direction: column; gap: 18px; }
.ctl-label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--paper-dim);
  margin-bottom: 8px;
}
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  border-radius: 100px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 500;
  background: var(--paper); color: var(--ink);
  transition: background 0.3s, color 0.3s, transform 0.3s var(--ease), box-shadow 0.3s;
  white-space: nowrap;
}
/* Hover looks only where there is a real pointer: touch browsers keep :hover on the
   last thing tapped, which would hide a toggle's pressed state until you tap elsewhere */
@media (hover: hover) {
  .btn:hover { background: var(--accent); color: var(--ink); transform: translateY(-2px); }
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn.ghost { background: transparent; color: var(--paper); border: 1px solid var(--paper-dim); }
@media (hover: hover) {
  .btn.ghost:hover { border-color: var(--paper); background: rgba(244,239,230,0.06); color: var(--paper); }
}
/* Pressed wins over hover (same weight as .btn.ghost:hover, and later) */
.btn[aria-pressed="true"], .btn[aria-pressed="true"]:hover { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.btn .ico { width: 10px; height: 10px; display: inline-block; }
.btn .ico.play { width: 0; height: 0; border-left: 9px solid currentColor; border-top: 5.5px solid transparent; border-bottom: 5.5px solid transparent; }
.btn .ico.stop { background: currentColor; border-radius: 2px; }
.btn .ico.rec  { background: var(--h1); border-radius: 50%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px;
  padding: 4px;
  border: 1px solid rgba(244,239,230,0.14);
  border-radius: 24px;
  background: rgba(244,239,230,0.03);
}
.seg button {
  padding: 9px 14px;
  border-radius: 100px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--paper-mute);
  transition: background 0.25s, color 0.25s;
}
@media (hover: hover) { .seg button:hover { color: var(--paper); } }
.seg button.on { background: var(--paper); color: var(--ink); }
.seg select {
  font: inherit; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.1em; text-transform: uppercase;
  background: transparent; color: var(--paper);
  border: 0; padding: 8px 10px; border-radius: 100px;
  cursor: pointer;
}
.seg select option { background: var(--ink); color: var(--paper); }

/* Stage = the instrument panel */
.stage {
  position: relative;
  border-radius: 22px;
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(244,239,230,0.05), transparent 70%),
    var(--ink-soft);
  border: 1px solid rgba(244,239,230,0.09);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  overflow: hidden;
}
.stage-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
  gap: 12px 24px;
  padding: 18px 22px;
  border-top: 1px solid rgba(244,239,230,0.08);
}
.readout-label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--paper-dim);
}
.readout-chord {
  font-family: var(--display);
  font-size: clamp(30px, calc(var(--hl-vw, 100vw) * 0.034), 46px);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--paper);
  min-height: 1em;
  font-variant-numeric: tabular-nums;
}
.readout-colour { font-family: var(--sans); font-size: 14px; color: var(--paper-mute); font-style: italic; }
.mono-note {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--paper-mute);
  font-variant-numeric: tabular-nums;
}
.inline-msg {
  display: none;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  border: 1px solid rgba(255,78,38,0.35);
  background: rgba(255,78,38,0.08);
  color: var(--paper);
}
.inline-msg.on { display: block; }
.inline-msg.soft { border-color: rgba(244,239,230,0.14); background: rgba(244,239,230,0.04); color: var(--paper-mute); }
/* A game's status line lives in its stage, next to what you just did (05-07) */
.stage > .inline-msg { margin: 0 18px 14px; scroll-margin: calc(var(--hl-bar-h, 48px) + 20px) 0 16px; }
/* Copy-link fallback: the address to copy by hand */
/* The label's words come from CSS (LabUI.share), so the games' textContent checks never see them */
.inline-msg .share-label { display: block; color: var(--paper); }
.inline-msg .share-label::before { content: attr(data-text); }
.inline-msg .share-url {
  display: block; width: 100%; margin-top: 8px;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid rgba(244,239,230,0.2); background: rgba(5,5,16,0.5);
  font-family: var(--mono); font-size: 11px; color: var(--paper);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 960px) {
  /* One column: heading and intro, then the instrument, then its controls,
     so a phone sees what it's playing without scrolling past every button */
  html:not([data-hl-frame="native"]) .exp-grid, html:not([data-hl-frame="native"]) .exp.flip .exp-grid { grid-template-columns: 1fr; gap: 0; }
  html:not([data-hl-frame="native"]) .exp-copy { display: contents; }
  html:not([data-hl-frame="native"]) .exp .exp-stage, html:not([data-hl-frame="native"]) .exp.flip .exp-stage { order: 1; margin-top: 28px; }
  html:not([data-hl-frame="native"]) .exp .exp-copy > .controls { order: 2; }
}
/* The same one-column rule for a native page, sized by its frame (web spec 4.4) */
@container hl-frame (max-width: 960px) {
  .exp-grid, .exp.flip .exp-grid { grid-template-columns: 1fr; gap: 0; }
  .exp-copy { display: contents; }
  .exp .exp-stage, .exp.flip .exp-stage { order: 1; margin-top: 28px; }
  .exp .exp-copy > .controls { order: 2; }
}
@media (prefers-reduced-motion: reduce) {
  /* 'auto' scrolls (fragment links, the games' scrollIntoView) jump instead of gliding */
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── HARMONY LAB PAGES (web spec 3.1, 3.3; i18n spec 2.1, 6, 7.4, 7.5) ── */
/* No flash of English for a Czech visitor: locale.js sets html.i18n-wait, HLi18n.apply() drops it */
.i18n-wait body { visibility: hidden; }
/* The note-name legend is for Czech readers only (i18n spec 7.4 point 2); never uppercase it */
.note-hint { display: none; }
:lang(cs) .note-hint { display: block; }
/* Czech runs 15-30 % longer: hyphenate running text only, never buttons or headings;
   a heading breaks inside a long word rather than overflowing a 320 px screen */
:lang(cs) p { -webkit-hyphens: auto; hyphens: auto; }
:lang(cs) h1, :lang(cs) h2 { overflow-wrap: break-word; }

/* Tool first (web spec 3.3): the page's only h1 replaces span.exp-num and keeps its look */
h1.exp-num { font-weight: 400; }

/* The toy's story: <details> under the section, as wide as the section's content.
   Open or closed is shell.js's call (collapsed on a phone, open on tablet and desktop). */
.hl-story {
  max-width: var(--max); margin: 0 auto;
  padding: 0 var(--gutter) clamp(20px, calc(var(--hl-vh, 100vh) * 0.03), 32px);
}
.hl-story > summary {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 0;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--paper-mute);
  cursor: pointer; list-style: none;
}
.hl-story > summary::-webkit-details-marker { display: none; }
.hl-story > summary::before { content: "+"; width: 12px; text-align: center; color: var(--h2); }
.hl-story[open] > summary::before { content: "-"; }
@media (hover: hover) { .hl-story > summary:hover { color: var(--paper); } }
.hl-story > .exp-lede { margin-top: 8px; max-width: 760px; }
.hl-story > .exp-lede + .exp-lede { margin-top: 14px; }

/* Page footer: credit, the official site, the Czech note legend */
.hl-foot {
  max-width: var(--max); margin: 0 auto;
  padding: 20px var(--gutter) 28px;
  border-top: 1px solid var(--ink-rule);
  font-family: var(--mono); font-size: 11px; line-height: 1.6; letter-spacing: 0.04em;
  color: var(--paper-mute);
}
.hl-foot a { color: var(--paper-mute); text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) { .hl-foot a:hover { color: var(--paper); } }
.hl-foot .note-hint { margin-top: 6px; }
/* Inside the device frame the toy stands alone: no story, no footer (web spec 1.1, 3.3) */
html[data-hl-view="embed"] .hl-story, html[data-hl-view="embed"] .hl-foot { display: none; }

/* hl:own */
/* Doplňky po vytažení (pod značkou je tests/css.test.js nekontroluje). */
kbd { font: inherit; letter-spacing: inherit; white-space: nowrap; -webkit-hyphens: none; hyphens: none; }
.inline-msg a { color: var(--paper); text-decoration: underline; text-underline-offset: 3px; }
.exp h2 { text-wrap: balance; }
:lang(cs) .mono-note { -webkit-hyphens: manual; hyphens: manual; }
.seg button[translate="no"] { text-transform: none; }
