/* mmmt-tools shared UI kit
   Design tokens + base components, extracted from tuner.html so every tool
   speaks the same visual language. Import this first, then add tool-specific
   styles in the page. */

:root {
  --ink:   #0a0e0d;
  --paper: #f2ede2;
  --dim:   #6b6358;
  /* Accent colours are darkened to meet WCAG 2.1 AA text contrast (≥4.5:1) on the
     paper background: flat 5.5:1, sharp 5.2:1, lock 5.1:1. They also read fine as
     fills/graphics (where only 3:1 applies). */
  --flat:  #0b57d0;   /* cool = flat / low  */
  --sharp: #a8420a;   /* warm = sharp / hot */
  --lock:  #2f7130;   /* good / in tune     */
  --line:  rgba(10, 14, 13, 0.20);
  --panel: rgba(10, 14, 13, 0.03);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono:  ui-monospace, "SF Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

/* --- accessibility: visible focus + screen-reader-only headings --- */
/* A high-contrast focus ring for keyboard users on every focusable element
   (WCAG 2.4.7). :focus-visible keeps it off mouse clicks. */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* Visually hidden but available to assistive tech — used for page <h1>s on the
   minimal "app" tools that have no visible title. */
.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;
}
/* The page title divs become <h1>s for document structure; keep their weight
   (a UA <h1> would otherwise render bold). */
h1.lede, h1.synth-lede { font-weight: 400; }

/* --- top bar / wordmark / privacy tag --- */
.topbar {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; flex-wrap: wrap;
  padding: clamp(1.2rem, 4vw, 2.4rem);
}
.wordmark { font-weight: 600; letter-spacing: -0.02em; font-size: 1.05rem; }
.wordmark a { color: inherit; text-decoration: none; }
.wordmark a:hover { text-decoration: underline; }
.wordmark span { color: var(--dim); font-weight: 400; }
.privacy {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--dim);
}

/* --- buttons --- */
.btn {
  font-family: var(--serif); font-size: 1rem; font-weight: 600;
  background: var(--ink); color: var(--paper); border: none;
  padding: 0.85rem 2.2rem; border-radius: 100px; cursor: pointer;
  letter-spacing: -0.01em; transition: transform 0.15s ease, opacity 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

/* --- small mono labels & status line --- */
.mono { font-family: var(--mono); }
.dim  { color: var(--dim); }
.msg {
  font-family: var(--mono); font-size: 0.74rem; color: var(--sharp);
  letter-spacing: 0.04em; min-height: 1.2em; text-align: center;
}

/* --- cards / metric grid (used by Inspector and later meters) --- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 1.1rem 1.3rem;
}
.metric-grid {
  display: grid; gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.metric { display: flex; flex-direction: column; gap: 0.2rem; }
.metric .label {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--dim);
}
.metric .value {
  font-family: var(--mono); font-size: 1.35rem; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.metric .value.good { color: var(--lock); }
.metric .value.warn { color: var(--sharp); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

/* ---------------- synthesis pages (shared) ---------------- */
.synth-wrap { max-width: 54rem; margin: 0 auto; padding: 0 clamp(1.2rem, 4vw, 2.4rem) 4rem; }
.synth-lede { font-size: clamp(1.5rem, 4vw, 2.2rem); letter-spacing: -0.02em; margin-top: 0.5rem; }
.synth-note { color: var(--dim); font-size: 0.88rem; line-height: 1.5; margin-top: 0.6rem; max-width: 62ch; }
.synth-note code { font-family: var(--mono); font-size: 0.9em; }
.synth-note a { color: var(--ink); }

.viz { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 1.3rem 0; }
@media (max-width: 34rem) { .viz { grid-template-columns: 1fr; } }
.viz figure { margin: 0; }
.viz figcaption { font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--dim); margin-bottom: 0.3rem; }
.viz canvas { width: 100%; height: 120px; display: block; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; }

.panels { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.panel { border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; }
.panel h3 { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--dim); margin: 0 0 0.7rem; }

.ctl { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem;
  font-family: var(--mono); font-size: 0.66rem; color: var(--dim); }
.ctl > label { flex: 0 0 5rem; }
.ctl input[type="range"] { flex: 1; min-width: 0; accent-color: var(--ink); }
.ctl .val { flex: 0 0 3.4rem; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.ctl select, .ctl input[type="file"] { flex: 1; min-width: 0; font-family: var(--mono); font-size: 0.68rem;
  color: var(--ink); background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 0.3rem 0.4rem; }

/* one-octave-per-row playable strip; black notes read darker + shorter */
.keys { display: flex; gap: 2px; margin-top: 1.5rem; height: 7.5rem; align-items: flex-start;
  touch-action: none; user-select: none; }
.key { flex: 1; height: 100%; border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 7px 7px; background: #fff; cursor: pointer; position: relative;
  transition: background 0.05s; }
.key.black { height: 62%; background: var(--ink); border-color: var(--ink); }
.key.on { background: var(--lock); border-color: var(--lock); }
.key span { position: absolute; bottom: 0.35rem; left: 0; right: 0; text-align: center;
  font-family: var(--mono); font-size: 0.56rem; color: var(--dim); pointer-events: none; }
.key.black span { color: var(--paper); }
.key.on span { color: var(--paper); }

.hint { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--dim); margin-top: 0.8rem; text-align: center; }
.synth-bar { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin: 1.1rem 0; }
.synth-bar .btn.live { background: transparent; color: var(--ink); border: 1px solid var(--line); }

/* --- record widget (js/record-ui.js): record button, level meter, take counter --- */
.recorder { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.recorder .rmeter { width: 6.5rem; height: 0.5rem; border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden; }
.recorder .rmeter i { display: block; height: 100%; width: 0; background: var(--ink); }
.recorder .rmeter i.hot { background: var(--sharp); }
.recorder label { display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.78rem; color: var(--dim); cursor: pointer; white-space: nowrap; }
.recorder .rhint { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.04em; color: var(--dim); }

/* --- catalog: the landing page and the category hub pages --- */
.wrap { max-width: 60rem; margin: 0 auto; padding: 0 clamp(1.2rem, 4vw, 2.4rem) 4rem; }
.lede { font-size: clamp(1.6rem, 5vw, 2.6rem); line-height: 1.1;
        letter-spacing: -0.03em; max-width: 22ch; margin-top: 1rem; }
.lede span { color: var(--dim); }
.sub { color: var(--dim); margin-top: 1rem; max-width: 52ch; font-size: 1.05rem; }
.wrap h2 { font-size: 0.72rem; font-family: var(--mono); letter-spacing: 0.12em;
     text-transform: uppercase; color: var(--dim); margin: 2.6rem 0 0.5rem;
     border-bottom: 1px solid var(--line); padding-bottom: 0.5rem; }
.section-intro { color: var(--dim); font-size: 0.92rem; line-height: 1.4;
                 max-width: 58ch; margin: 0 0 1rem; }
.grid { display: grid; gap: 0.9rem;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
a.tool { display: block; text-decoration: none; color: inherit; }
.tool .card { height: 100%; transition: transform 0.15s ease, border-color 0.2s; }
a.tool:hover .card { transform: translateY(-2px); border-color: var(--ink); }
.tool h3 { font-size: 1.15rem; letter-spacing: -0.01em; }
.tool p { color: var(--dim); font-size: 0.9rem; margin-top: 0.35rem; line-height: 1.35; }
.tag { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.08em;
       text-transform: uppercase; padding: 0.15rem 0.5rem; border-radius: 100px;
       border: 1px solid var(--line); color: var(--dim); }
.tag.live { color: var(--lock); border-color: var(--lock); }
.tag.count { color: var(--dim); }
.tool .top { display: flex; justify-content: space-between; align-items: center;
             margin-bottom: 0.2rem; }
.catalog-foot { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1.2rem;
                font-family: var(--mono); font-size: 0.74rem; color: var(--dim); }
.catalog-foot a { color: var(--ink); }
