/* Tokens and header rules follow the live site's theme (site.css), so the
   metronome looks like part of oscarlopezdrums.com. */
@font-face { font-family: Jost; src: url('fonts/jost-700.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #17191c;
  --surface: #202327;
  --raised: #292c31;
  --text: #f3f2f0;
  --muted: #b5b5b7;
  --line: #404348;
  --line-strong: #686a6e;
  --orange: #ff9a47;
  --orange-hover: #ffb06e;
  --on-orange: #14110f;
  --max: 1280px;
  --app: 720px;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font-family: Arial, Helvetica, sans-serif; font-size: 17px; line-height: 1.65; }
a { color: inherit; text-underline-offset: .25em; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 4px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 40; background: var(--orange); color: var(--on-orange); padding: 10px 14px; border-radius: 4px; font-weight: 700; }
.skip:focus { top: 12px; }

/* ---- Site header (mirrors the theme) ---- */
.wrap { width: min(var(--max), calc(100% - 96px)); margin: auto; }
.site-header { position: sticky; top: 0; z-index: 30; background: #17191cf2; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid #40434888; }
.header-inner { height: 96px; display: flex; align-items: center; gap: 36px; }
.brand { font-family: Jost, Arial, sans-serif; font-weight: 700; text-decoration: none; line-height: .95; font-size: 1.65rem; letter-spacing: -.065em; flex-shrink: 0; }
.brand span { display: block; color: var(--orange); font-family: Arial, sans-serif; font-size: .66rem; letter-spacing: .4em; margin-top: 9px; font-weight: 700; }
.desktop-nav { display: flex; gap: 27px; align-items: center; margin-left: auto; }
.desktop-nav a { font-size: .9rem; text-decoration: none; white-space: nowrap; }
/* Metronome link (added to the live site header 20 Nov 2026): on small phones it
   lives only in the Menu, so the header bar still fits. */
@media (max-width: 420px) { .site-header .metronome-shortcut { display: none !important; } }
.groove-shortcut { display: inline-flex; align-items: center; min-height: 44px; font-size: .9rem; font-weight: 700; white-space: nowrap; text-decoration: none; color: var(--orange); }
.utility-top { font-size: .8rem; text-decoration: none; color: var(--muted); white-space: nowrap; }
.button { display: inline-flex; justify-content: center; align-items: center; padding: 15px 24px; border-radius: 4px; background: var(--orange); color: var(--on-orange); border: 1px solid var(--orange); font-weight: 700; font-size: .94rem; line-height: 1.4; text-decoration: none; min-height: 48px; white-space: nowrap; transition: background .18s; }
.button:hover { background: var(--orange-hover); border-color: var(--orange-hover); }
.header-cta { padding: 12px 18px; font-size: .87rem; }
.menu-toggle { display: none; background: transparent; border: 1px solid var(--line); color: var(--text); padding: 9px 14px; border-radius: 4px; }
.mobile-nav { padding: 20px 24px 28px; border-top: 1px solid var(--line); }
.mobile-nav a { display: block; padding: 10px 0; text-decoration: none; }
.mobile-nav .mobile-utilities { display: flex; gap: 24px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }

@media (max-width: 1200px) {
  .wrap { width: calc(100% - 64px); }
  .header-inner { gap: 22px; }
  .desktop-nav { gap: 19px; }
  .utility-top { display: none; }
}
@media (max-width: 1100px) {
  .desktop-nav, .header-cta, .utility-top { display: none !important; }
  .menu-toggle { display: block; min-height: 44px; }
  .groove-shortcut { margin-left: auto; }
  .header-inner { height: 80px; }
}
@media (max-width: 700px) {
  body { font-size: 16px; }
  .wrap { width: calc(100% - 40px); }
  .site-header .wrap { width: calc(100% - 32px); }
  .header-inner { gap: 10px; height: 76px; }
  .site-header .brand { font-size: 1.3rem; }
  .site-header .brand span { font-size: .6rem; }
  .groove-shortcut { font-size: .875rem; }
  .menu-toggle { font-size: .875rem; padding: 9px 10px; }
}
@media (max-width: 360px) {
  .site-header .brand { font-size: 1.2rem; }
  .header-inner { gap: 8px; }
}

/* ---- Metronome ---- */
.app { width: min(var(--app), calc(100% - 32px)); margin: 0 auto; padding: 28px 0 40px; }
.eyebrow { font-size: .76rem; line-height: 1.5; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--orange); margin: 0 0 4px; }
.title { font-family: Jost, Arial, sans-serif; font-weight: 700; letter-spacing: -.035em; line-height: 1.08; font-size: clamp(1.8rem, 5vw, 2.4rem); margin: 0 0 22px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 4px; padding: 4px; gap: 4px; background: var(--surface); }
.tab { min-height: 44px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-weight: 700; font-size: .95rem; }
.tab:hover { color: var(--text); background: var(--raised); }
.tab[aria-selected="true"] { background: var(--orange); color: var(--on-orange); }

.tempo { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 28px; }
.step { flex: none; width: 52px; height: 52px; border-radius: 4px; border: 1px solid var(--line-strong); background: transparent; font-size: 1.7rem; line-height: 1; }
.step:hover { border-color: var(--orange); color: var(--orange); }
.tempo-number {
  width: 3.3ch; min-width: 0; padding: 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; text-align: center;
  font-family: Jost, Arial, sans-serif; font-weight: 700; font-size: clamp(4.2rem, 21vw, 6.5rem); line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.tempo-number:focus { outline: none; border-bottom-color: var(--orange); }
/* Drag up/down to change the tempo (see ui.js). Typing works once tapped. */
.tempo-number { cursor: ns-resize; touch-action: none; -webkit-user-select: none; user-select: none; }
.tempo-number:focus { cursor: text; -webkit-user-select: text; user-select: text; }
.tempo-number.dragging { color: var(--orange); }
.tempo-number:focus-visible { outline: none; }
.bpm-label { text-align: center; color: var(--muted); font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; margin: 6px 0 12px; }
.bpm-label .unit { letter-spacing: normal; text-transform: none; font-weight: 400; }
.tap-row { display: flex; justify-content: center; }
.ghost { min-height: 44px; padding: 8px 18px; border-radius: 4px; border: 1px solid var(--line-strong); background: transparent; font-size: .87rem; font-weight: 700; }
.ghost:hover { border-color: var(--orange); }

.play { width: 100%; margin-top: 22px; min-height: 60px; font-size: 1.1rem; gap: 10px; }
.play svg { width: 18px; height: 18px; fill: currentColor; }
.play[aria-pressed="true"] { background: var(--text); border-color: var(--text); }
.play:disabled { opacity: .45; cursor: not-allowed; }
.status { text-align: center; color: var(--muted); font-size: .85rem; min-height: 1.65em; margin: 10px 0 0; }

.settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 22px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .78rem; font-weight: 700; color: var(--muted); }
.meter { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 700; }
select { min-height: 44px; min-width: 72px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 4px; }
.sub-select { min-width: 140px; }

.pattern-title { font-size: 1rem; margin: 24px 0 2px; }
.help { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }
.grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 16px 10px; }
.beat { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 100%; }
.beat-label { font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
/* --cols is set by ui.js so long beats wrap into even rows (12 → 6 + 6). */
.beat-notes { display: grid; grid-template-columns: repeat(var(--cols, 4), 44px); justify-content: center; gap: 2px; }

/* Each click: a 44px touch target with a shape that encodes the sound,
   so states never depend on colour alone. */
.note { position: relative; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; touch-action: manipulation; }
.note::before { content: ''; position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; border-radius: 50%; box-sizing: border-box; transition: transform .06s ease; }
.note[data-sound="0"]::before { width: 28px; height: 28px; background: var(--orange); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--orange); }
.note[data-sound="1"]::before { background: var(--orange); }
.note[data-sound="2"]::before { border: 2px solid var(--orange); background: radial-gradient(circle, var(--orange) 0 4px, transparent 4.5px); }
.note[data-sound="3"]::before { border: 2px dashed var(--line-strong); }
.note[data-sound="3"]::after { content: ''; position: absolute; inset: 0; margin: auto; width: 10px; height: 2px; background: var(--muted); }
.note:hover::before { filter: brightness(1.15); }
.note.now { background: var(--raised); }
.note.now::before { transform: scale(1.2); }
.note.now[data-sound="3"]::before { border-color: var(--text); }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; list-style: none; padding: 0; margin: 12px 0 0; color: var(--muted); font-size: .8rem; }
.legend li { display: inline-flex; align-items: center; gap: 4px; }
.legend .note { width: 40px; height: 40px; pointer-events: none; }

@media (max-width: 440px) {
  .legend { display: grid; grid-template-columns: repeat(2, auto); justify-content: center; column-gap: 28px; }
}

/* ---- Sequence (Metronome tab) ---- */
/* Small on/off switch (Sequence). 44px tall touch target, compact look. */
/* Tucked into the top-right of the settings block, label beside the switch,
   so it never pushes Time signature / Subdivision around. */
.toggle-field { order: -1; flex: 1 1 100%; flex-direction: row; justify-content: flex-end; align-items: center; gap: 8px; margin: -12px 0 -10px; }
.toggle-field .field-label { font-weight: 400; cursor: pointer; }
.toggle { display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; border: 0; background: transparent; }
.toggle-track { position: relative; width: 46px; height: 26px; border-radius: 13px; border: 1px solid var(--line-strong); background: var(--surface); transition: background .15s, border-color .15s; }
.toggle-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.toggle[aria-checked="true"] .toggle-track { background: var(--orange); border-color: var(--orange); }
.toggle[aria-checked="true"] .toggle-knob { transform: translateX(20px); background: var(--on-orange); }
.toggle:focus-visible { outline: none; }
.toggle:focus-visible .toggle-track { outline: 3px solid var(--orange); outline-offset: 3px; }
.seq-editor { margin-top: 16px; }
.seq-editor .help { text-align: center; }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.card { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.card.playing { border-color: var(--orange); box-shadow: inset 0 0 0 1px var(--orange); }
.card-num { position: absolute; top: -9px; left: 8px; padding: 0 5px; background: var(--bg); color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .06em; }
.frac { display: flex; flex-direction: column; align-items: center; }
.frac select { min-width: 64px; text-align: center; }
.frac-line { width: 100%; height: 2px; background: var(--text); margin: 4px 0; border-radius: 1px; }
/* Polyrhythm cards: N : M side by side. */
.ratio { display: flex; align-items: center; gap: 4px; }
.ratio select { min-width: 58px; text-align: center; }
.ratio-sep { font-family: Jost, Arial, sans-serif; font-weight: 700; font-size: 1.3rem; padding: 0 2px; }
#pcards .card-add { min-height: 64px; }
.card-side { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 6px; }
.card .times { min-width: 70px; }
.card-side .card-remove { width: auto; }
.card-remove { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-size: 1.3rem; line-height: 1; }
.card-remove:hover { border-color: var(--orange); color: var(--orange); }
.card-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 96px; min-height: 120px; border: 1px dashed var(--line-strong); border-radius: 4px; background: transparent; color: var(--orange); font-weight: 700; font-size: .85rem; }
.card-add .plus { font-size: 2rem; line-height: 1; }
.card-add:hover { border-color: var(--orange); }
.card-add:disabled { color: var(--muted); border-color: var(--line); cursor: not-allowed; }
.warn { margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--orange); background: #ff9a4712; font-size: .85rem; }

/* Circles for a sequence: one block per card. */
.grid.seq { display: block; }
.seq-block { padding: 6px 0 14px; }
.seq-block + .seq-block { border-top: 1px solid var(--line); padding-top: 14px; }
.seq-head { display: flex; justify-content: center; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.seq-title { font-family: Jost, Arial, sans-serif; font-weight: 700; font-size: 1.15rem; }
.seq-count { font-size: .78rem; color: var(--muted); }
.seq-block.playing .seq-count { color: var(--orange); font-weight: 700; }
.pseq-block .axis { margin-top: 4px; }
.seq-beats { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 18px; }

/* ---- Polyrhythm tab ---- */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.mode { min-height: 60px; text-align: left; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 4px; background: transparent; display: flex; flex-direction: column; justify-content: center; gap: 2px; line-height: 1.3; }
.mode strong { font-size: .95rem; }
.mode span { font-size: .76rem; color: var(--muted); }
.mode:hover { border-color: var(--orange); }
.mode[aria-pressed="true"] { border-color: var(--orange); background: #ff9a4714; box-shadow: inset 0 0 0 1px var(--orange); }
.mode[aria-pressed="true"] strong { color: var(--orange); }
.poly-desc { color: var(--muted); font-size: .9rem; margin: 18px 0 12px; }
.poly-desc strong { color: var(--text); }
.poly-scroll { overflow-x: auto; overscroll-behavior-x: contain; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 14px 12px 10px; scrollbar-color: var(--line-strong) transparent; }
@media (max-width: 440px) { .poly-scroll { padding: 12px 6px 8px; } }
.scroll-hint { font-size: .78rem; color: var(--muted); text-align: center; margin: 6px 0 0; }

/* Together: one shared time axis. Circle centres sit at
   22px + x * (width - 44px), so x = 0 is the left edge for both rows. */
.axis { position: relative; min-width: var(--min-width, 0); }
.row-label { position: relative; z-index: 1; font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-weight: 700; margin: 0 0 2px; }
.track { position: relative; height: 44px; margin-bottom: 12px; }
.track > .note, .track > .ghost-note { position: absolute; top: 0; left: calc(var(--x) * (100% - 44px)); z-index: 1; }
.ghost-note { width: 44px; height: 44px; }
.ghost-note::before { content: ''; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border-radius: 50%; border: 2px dashed var(--line-strong); box-sizing: border-box; }
.guides { position: absolute; left: 0; right: 0; top: 22px; bottom: 26px; pointer-events: none; }
.guide { position: absolute; top: 0; bottom: 0; width: 1px; left: calc(var(--x) * (100% - 44px) + 21.5px); background: var(--line); }
.guide.together { width: 2px; left: calc(var(--x) * (100% - 44px) + 21px); background: #ff9a4766; }
.scale { position: relative; margin: 0 22px; border-top: 1px solid var(--line-strong); height: 22px; font-size: .72rem; color: var(--muted); }
.scale::before, .scale::after { content: ''; position: absolute; top: -5px; width: 1px; height: 9px; background: var(--line-strong); }
.scale::before { left: 0; } .scale::after { right: 0; }
.scale span { position: absolute; top: 3px; white-space: nowrap; }
.scale .start { left: 0; transform: translateX(-50%); }
.scale .mid { left: 50%; transform: translateX(-50%); }
.scale .end { right: 0; transform: translateX(50%); }

/* Accent every N: one beat per line, accents above the click they land on. */
.acc-beat { margin-bottom: 12px; min-width: calc(var(--cols) * 46px); }
.acc-beat:last-child { margin-bottom: 2px; }
.acc-label { font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-weight: 700; margin-bottom: 2px; }
.acc-row { display: grid; grid-template-columns: repeat(var(--cols), 44px); gap: 2px; }
.acc-row .slot-empty { width: 44px; height: 44px; position: relative; }
.acc-row .slot-empty::before { content: ''; position: absolute; inset: 0; margin: auto; width: 4px; height: 4px; border-radius: 50%; background: var(--line); }
.acc-rows-key { display: flex; gap: 16px; font-size: .75rem; color: var(--muted); margin: 0 0 8px; }

/* ---- Random muting (expandable) ---- */
.practice { margin-top: 22px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.practice summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px; cursor: pointer; font-weight: 700; }
.practice summary::-webkit-details-marker { display: none; }
.practice summary::after { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: 0 4px 4px 0; flex: none; }
.practice[open] summary::after { transform: rotate(-135deg); margin-bottom: -4px; }
.summary-state { margin-left: auto; font-weight: 400; font-size: .85rem; color: var(--muted); }
.summary-state.on { color: var(--orange); font-weight: 700; }
.practice-body { padding: 0 16px 16px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; font-size: .95rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--orange); flex: none; }
.mute-fields { border: 0; margin: 4px 0 8px; padding: 12px 0 0; border-top: 1px solid var(--line); display: grid; gap: 14px; }
.mute-fields:disabled { opacity: .5; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border: 1px solid var(--line); border-radius: 4px; padding: 4px; }
.segmented label { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; border-radius: 3px; font-weight: 700; font-size: .9rem; cursor: pointer; }
.segmented input { accent-color: var(--orange); }
.segmented label:has(input:checked) { background: #ff9a4722; color: var(--orange); }
input[type="range"] { width: 100%; min-height: 32px; accent-color: var(--orange); }
.field output { color: var(--text); }
.help.small { font-size: .8rem; margin: 0; }
.mute-fields:disabled .segmented label, .mute-fields:disabled input { cursor: not-allowed; }

.sound-row { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 22px 0 0; }
.sound-row select { min-width: 170px; }
.sound-note { text-align: center; margin: 6px 0 0; font-size: .8rem; }
.legend-help { text-align: center; margin: 18px 0 0; }

.panel-note { color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 4px; padding: 28px 16px; margin-top: 20px; }

.foot { width: min(var(--app), calc(100% - 32px)); margin: 0 auto; padding: 0 0 40px; color: var(--muted); font-size: .8rem; text-align: center; }
.foot kbd { font-family: inherit; border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }

@media (prefers-reduced-motion: reduce) {
  .note::before, .button, .toggle-track, .toggle-knob { transition: none; }
  .note.now::before { transform: none; outline: 2px solid var(--text); outline-offset: 3px; }
}
