/* Tunelight's tool page: the canvas on top, the controls under it on a phone and
   beside it on a wide screen. Colours shared with Tailwave and the website. */

:root {
  color-scheme: light dark;
  --bg: #eef0f6;
  --surface: #ffffff;
  --surface-2: #f5f6fa;
  --surface-3: #e5e8f0;
  --border: rgba(15, 23, 42, 0.09);
  --text: #0f172a;
  --text-2: #4f5a70;
  --text-3: #5f6677;
  --accent-a: #059669;
  --accent-b: #0891b2;
  --good: #047b56;
  --on-accent: #ffffff;
  --focus: rgba(124, 58, 237, 0.5);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0c11;
    --surface: #12151c;
    --surface-2: #171b24;
    --surface-3: #242a37;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e9ecf3;
    --text-2: #a8b0c2;
    --text-3: #8b92a3;
    --accent-a: #34d399;
    --accent-b: #22d3ee;
    --good: #34d399;
    --on-accent: #0a0c11;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0c11;
  --surface: #12151c;
  --surface-2: #171b24;
  --surface-3: #242a37;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e9ecf3;
  --text-2: #a8b0c2;
  --text-3: #8b92a3;
  --accent-a: #34d399;
  --accent-b: #22d3ee;
  --good: #34d399;
  --on-accent: #0a0c11;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

:focus-visible { outline: 2px solid var(--accent-b); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- The bar (development page; the website has its own header) ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; text-decoration: none; }
.tools-nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tools-nav a {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.tools-nav a[aria-current] { background: var(--surface-3); color: var(--text); }

/* ---- The tool ------------------------------------------------------------- */

.tool {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 1120px;
  margin: 0 auto;
}

.stage {
  position: relative;
  height: min(56vh, 520px);
  min-height: 300px;
}
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.notice {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 12px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 14px;
}

.panel { padding: 8px 16px 24px; }
.readout {
  min-height: 1.5em;
  margin: 0 0 12px;
  color: var(--text-2);
  font: 14px/1.5 var(--mono);
  text-align: center;
}

.controls { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }

button, select, input, summary { font: inherit; color: inherit; }

button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
button:hover { border-color: color-mix(in srgb, var(--accent-b) 40%, var(--border)); }
button[aria-pressed="true"], .seg button[aria-checked="true"] {
  background: color-mix(in srgb, var(--accent-b) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--accent-b) 55%, var(--border));
}

.start {
  min-width: 140px;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: var(--on-accent);
  font-weight: 700;
  font-size: 17px;
}
.start[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.tap { min-width: 96px; min-height: 52px; border-radius: 999px; font-weight: 600; }

.icon-btn { min-width: 44px; padding: 0; border-radius: 999px; font-size: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { color: var(--text-2); font-size: 14px; }
.field .unit { color: var(--text-3); font-size: 13px; }
.field output { color: var(--text-2); font: 13px var(--mono); }

select, input[type="number"] {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}
input[type="range"] { width: 100%; accent-color: var(--accent-b); min-height: 32px; }

.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { min-width: 44px; padding: 0 12px; border-radius: 10px; }

.strings, .accents { display: flex; flex-wrap: wrap; gap: 8px; }
.strings button { min-width: 52px; border-radius: 999px; }
.accents .beat { width: 48px; padding: 0; border-radius: 12px; font-weight: 700; }
.accents .beat.l3 { background: color-mix(in srgb, var(--accent-b) 30%, var(--surface)); }
.accents .beat.l2 { background: color-mix(in srgb, var(--accent-a) 18%, var(--surface)); }
.accents .beat.l1 { background: var(--surface-2); color: var(--text-2); }
.accents .beat.l0 { background: transparent; color: var(--text-3); border-style: dashed; }

.custom { display: flex; flex-direction: column; gap: 8px; }
.custom input { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font: 15px var(--mono); }
.custom button { align-self: flex-start; }

.presets { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.presets input[type="text"] { flex: 1; min-width: 160px; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.preset-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.preset-list li { display: flex; gap: 6px; align-items: center; }
.preset-list li.empty { color: var(--text-3); font-size: 14px; }
.preset-list .load { flex: 1; display: flex; justify-content: space-between; gap: 10px; text-align: left; }
.preset-list .load span { color: var(--text-3); font-size: 14px; }
.preset-list li.current .load { border-color: color-mix(in srgb, var(--accent-b) 55%, var(--border)); }

.tempo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tempo input { width: 96px; font-size: 24px; font-weight: 700; text-align: center; }
.marking { color: var(--text-3); font-size: 14px; }

.more { border-top: 1px solid var(--border); padding-top: 10px; }
.more summary { cursor: pointer; color: var(--text-2); min-height: 32px; }
.more .grid { margin-top: 12px; }
.hint { margin: 0; color: var(--text-3); font-size: 13px; }

@media (min-width: 900px) {
  .tool { grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); align-items: start; padding: 16px; gap: 16px; }
  .stage { height: min(70vh, 620px); border-radius: 18px; overflow: hidden; border: 1px solid var(--border); }
  .panel { padding: 8px 0; }
  .readout { text-align: left; }
}

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