/* ==========================================================================
   Paddy Prompt Studio — Online music sequencer
   Layers on /blog/style.css (same dark indigo/cyan palette and type scale).
   The transport, grid and prose-table rules mirror the drum machine so the
   two tools feel like one instrument; sequencer-only pieces are at the end.
   ==========================================================================

:root {
  --good: #34d399;
}

/* ----------------------------------------------------------- Machine shell */
.machine {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: 22px;
  padding: 1.15rem; margin: 0.5rem 0 1rem;
  box-shadow: 0 30px 70px -40px rgba(99, 102, 241, 0.6);
}

/* Transport row */
.transport {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--border-soft);
}
.play-btn {
  display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer;
  padding: 0.65rem 1.3rem; border: 0; border-radius: 12px;
  font: inherit; font-size: 0.98rem; font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #22d3ee); color: #0b0620;
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn .ico { width: 0.8rem; height: 0.8rem; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.play-btn[data-state="playing"] {
  background: rgba(52, 211, 153, 0.16); color: #6ee7b7;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.45);
}
.play-btn[data-state="playing"] .ico { clip-path: none; border-radius: 2px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.control {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.35rem 0.6rem;
}
.control > .lbl {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.62rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); font-weight: 700;
}
.control select {
  font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--text);
  background: #07080d; border: 1px solid var(--border); border-radius: 9px;
  padding: 0.4rem 0.5rem; max-width: 14.5rem;
}
.control input[type="number"] {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.95rem; font-weight: 700;
  width: 3.6rem; color: #c7d2fe; background: #07080d;
  border: 1px solid var(--border); border-radius: 9px; padding: 0.35rem 0.4rem; text-align: center;
}
.control .val {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700;
  font-size: 0.85rem; min-width: 2.6rem; text-align: right; color: #a5f3fc;
}

/* Range inputs (tempo, swing, volume) */
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 1.5rem;
  background: transparent; cursor: pointer; width: 7rem; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.12);
}
input[type="range"]::-moz-range-track {
  height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.12);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -6px;
  width: 17px; height: 17px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, #a5b4fc, #67e8f9);
}
input[type="range"]::-moz-range-thumb {
  width: 17px; height: 17px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, #a5b4fc, #67e8f9);
}
input[type="range"]:focus-visible { outline: 2px solid var(--indigo-strong); outline-offset: 3px; border-radius: 99px; }

.mini {
  appearance: none; cursor: pointer; font: inherit; font-size: 0.82rem; font-weight: 700;
  padding: 0.5rem 0.8rem; border-radius: 11px; color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
}
.mini:hover { background: rgba(129, 140, 248, 0.18); color: #fff; }
.mini.wide { margin-left: auto; }

/* ------------------------------------------------------------- Step ruler */
.grid-scroll { overflow-x: auto; padding: 1rem 0 0.25rem; -webkit-overflow-scrolling: touch; }
.grid-inner { min-width: 34rem; }

.ruler {
  display: grid; grid-template-columns: repeat(16, 1fr); gap: 0.28rem;
  margin: 0 0 0.45rem 9.5rem;
}
.ruler-cell {
  text-align: center; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.66rem; font-weight: 700; color: var(--text-dim);
  padding: 0.1rem 0; border-radius: 6px; transition: color 0.08s linear, background 0.08s linear;
}
.ruler-cell[data-beat="true"] { color: #c7d2fe; }
.ruler-cell[data-now="true"] { color: #07080d; background: #a5f3fc; }

/* -------------------------------------------------------------- Sequencer */
.seq-row {
  display: grid; grid-template-columns: 9.5rem 1fr;
  align-items: center; gap: 0.28rem; margin-bottom: 0.28rem;
}
.row-head { display: flex; align-items: center; gap: 0.3rem; padding-right: 0.45rem; }
.row-name {
  flex: 1; display: flex; align-items: center; gap: 0.45rem; cursor: pointer;
  font: inherit; font-size: 0.8rem; font-weight: 700; text-align: left;
  color: var(--text); background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border); border-radius: 9px; padding: 0.42rem 0.5rem;
  white-space: nowrap; overflow: hidden;
}
.row-name:hover { background: rgba(255, 255, 255, 0.07); }
.row-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.seq-row[data-hit="true"] .row-name { background: color-mix(in srgb, var(--c) 22%, transparent); border-color: var(--c); }
.seq-row[data-hit="true"] .row-dot { box-shadow: 0 0 10px 2px var(--c); }

.row-mute {
  cursor: pointer; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.6rem; font-weight: 700; line-height: 1;
  width: 1.55rem; height: 1.55rem; flex: 0 0 auto; border-radius: 7px;
  color: var(--text-dim); background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}
.row-mute:hover { color: #fff; }
.row-mute[aria-pressed="true"] { background: rgba(251, 113, 133, 0.18); border-color: rgba(251, 113, 133, 0.5); color: #fda4af; }

.row-steps { display: grid; grid-template-columns: repeat(16, 1fr); gap: 0.28rem; }

.cell {
  appearance: none; cursor: pointer; padding: 0; aspect-ratio: 1 / 1;
  min-height: 1.6rem; border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.06s ease-out, background 0.08s linear, box-shadow 0.08s linear;
}
.cell[data-beat="true"] { background: rgba(255, 255, 255, 0.075); }
.cell:hover { border-color: var(--c); }
.cell[data-v="1"] {
  background: color-mix(in srgb, var(--c) 55%, transparent);
  border-color: color-mix(in srgb, var(--c) 70%, transparent);
}
.cell[data-v="2"] {
  background: var(--c);
  border-color: #fff;
  box-shadow: 0 0 12px -1px var(--c);
}
.cell[data-now="true"] { transform: scale(1.14); }
.cell[data-now="true"][data-v="0"] { background: rgba(255, 255, 255, 0.16); }
.cell:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* Fallback for browsers without color-mix() support */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .cell[data-v="1"] { background: var(--c); opacity: 0.6; }
  .cell[data-v="2"] { background: var(--c); }
}

/* --------------------------------------------------------------- Readouts */
.seq-status {
  margin: 0.9rem 0 0; font-size: 0.88rem; color: var(--text-muted); min-height: 1.3em;
}
.seq-status[data-error="true"] { color: #fda4af; }

.groove {
  margin: 0.85rem 0 0; padding: 0.8rem 0.95rem;
  background: rgba(8, 145, 178, 0.07); border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 13px;
}
.groove .lbl {
  display: block; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700; margin-bottom: 0.3rem;
}
.groove p {
  margin: 0; font-size: 0.9rem; line-height: 1.55; color: #dfe4f1;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.85rem; }

.legend {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; align-items: center;
  margin: 0.85rem 0 0; font-size: 0.78rem; color: var(--text-dim);
}
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i {
  width: 0.85rem; height: 0.85rem; border-radius: 4px; display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.05);
}
.legend i.on { background: rgba(129, 140, 248, 0.6); border-color: rgba(129, 140, 248, 0.8); }
.legend i.acc { background: #818cf8; border-color: #fff; box-shadow: 0 0 8px -1px #818cf8; }

.seq-hint {
  margin: 0.5rem 0 0; font-size: 0.78rem; color: var(--text-dim);
}
.seq-hint kbd {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--border);
  border-radius: 5px; padding: 0.05rem 0.32rem; color: #c7d2fe;
}

/* ------------------------------------------------------------ Prose extras */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data caption { text-align: left; padding: 0.85rem 1rem 0.2rem; color: var(--text-dim); font-size: 0.82rem; }
table.data th, table.data td { padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid var(--border-soft); }
table.data thead th {
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); background: rgba(255, 255, 255, 0.03); font-weight: 700;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.mono, table.data th.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.85rem; color: #a5f3fc; }
table.data tbody tr:hover { background: rgba(129, 140, 248, 0.05); }

/* Inline pattern notation used in the prose, e.g. X - - x - - X - */
.notation {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.82rem;
  letter-spacing: 0.14em; color: #c7d2fe; white-space: nowrap;
}

/* --------------------------------------------------------------- Responsive */
@media (max-width: 640px) {
  .grid-inner { min-width: 30rem; }
  .ruler { margin-left: 6.6rem; }
  .seq-row { grid-template-columns: 6.6rem 1fr; }
  .row-name { font-size: 0.7rem; padding: 0.38rem 0.4rem; }
  .row-mute { width: 1.35rem; height: 1.35rem; }
  .cell { border-radius: 5px; min-height: 1.35rem; }
  .mini.wide { margin-left: 0; }
  input[type="range"] { width: 5.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cell, .ruler-cell { transition: none; }
  .cell[data-now="true"] { transform: none; box-shadow: 0 0 0 2px #fff inset; }
  .play-btn[data-state="playing"] .ico { animation: none; }
}

/* Caption under the beat-anatomy diagram */
.hero-figure figcaption {
  margin-top: 0.7rem; color: var(--text-dim); font-size: 0.85rem; line-height: 1.55;
}

/* ===================================================== Sequencer-only parts */

/* Second transport row: key, scale and loop length */
.transport + .transport { padding-top: 0.85rem; }

/* Part tabs: Drums / Bass / Chords / Lead */
.part-tabs {
  display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 1rem 0 0;
}
.part-tab {
  --c: #818cf8;
  display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer;
  font: inherit; font-size: 0.92rem; font-weight: 700; min-height: 44px;
  padding: 0.5rem 0.95rem; border-radius: 12px;
  color: var(--text-muted); background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}
.part-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.part-tab[aria-selected="true"] {
  color: #fff; border-color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  box-shadow: 0 0 0 1px var(--c) inset;
}
.part-tab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.part-tab .tab-key {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.62rem;
  color: var(--text-dim); border: 1px solid var(--border); border-radius: 5px; padding: 0 0.3rem;
}
.tab-dot {
  width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--c); opacity: 0.35;
  transition: opacity 0.08s linear, box-shadow 0.08s linear;
}
.tab-dot[data-hit="true"] { opacity: 1; box-shadow: 0 0 10px 2px var(--c); }

/* Per-part controls (sound, note length, level, mute, clear) */
.part-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.75rem;
}
.part-bar .mini[aria-pressed="true"] {
  background: rgba(251, 113, 133, 0.18); border-color: rgba(251, 113, 133, 0.5); color: #fda4af;
}
.part-hint { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--text-dim); }

/* Bar pager for 2- and 4-bar loops */
.bar-nav { display: flex; align-items: center; gap: 0.35rem; margin: 0.9rem 0 0; }
.bar-nav .lbl {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.62rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; margin-right: 0.2rem;
}
.bar-nav button {
  cursor: pointer; font: inherit; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.82rem; font-weight: 700; min-width: 2.6rem; min-height: 36px;
  border-radius: 9px; color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
}
.bar-nav button[aria-pressed="true"] { color: #07080d; background: #c7d2fe; border-color: #c7d2fe; }
.bar-nav button[data-now="true"] { box-shadow: 0 0 0 2px #a5f3fc; }

/* Wider name column: chord rows read like "vi · Am" */
.ruler { margin-left: 7.5rem; }
.seq-row { grid-template-columns: 7.5rem 1fr; }
.row-name .row-txt { overflow: hidden; text-overflow: ellipsis; }

/* Root-note rows in the bass and lead grids get a faint band, so you can
   always find "home" without reading the labels. */
.seq-row[data-root="true"] .row-steps .cell[data-v="0"] { background: rgba(255, 255, 255, 0.06); }
.seq-row[data-root="true"] .row-name { border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }

/* Melodic notes: on is solid, and a held note shows a faint tail */
#seq:not([data-part="drums"]) .cell[data-v="1"] {
  background: var(--c); border-color: #fff; box-shadow: 0 0 10px -2px var(--c);
}
.cell[data-tail="true"] {
  background: color-mix(in srgb, var(--c) 22%, transparent);
  border-color: color-mix(in srgb, var(--c) 35%, transparent);
}

/* Readouts for the key and progression */
.readouts { display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; margin: 0.85rem 0 0; font-size: 0.88rem; color: var(--text-muted); }
.readouts b {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.6rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); margin-right: 0.35rem;
}
.readouts span span { color: #a5f3fc; font-weight: 700; }

/* Suno bridge */
.bridge {
  margin-top: 1rem; padding: 0.9rem; border-radius: 14px;
  background: rgba(34, 211, 238, 0.05); border: 1px solid rgba(103, 232, 249, 0.25);
}
.bridge h3 { margin: 0 0 0.25rem; font-size: 1.02rem; }
.bridge p.sub { margin: 0 0 0.65rem; font-size: 0.85rem; color: var(--text-dim); }
.bridge-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.snippet {
  width: 100%; box-sizing: border-box; resize: vertical; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.84rem; line-height: 1.5; color: #e0f2fe; background: #07080d;
  border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.7rem;
}
.bridge-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.6rem; align-items: center; }
.studio-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0.55rem 1.1rem; border-radius: 12px;
  font-weight: 800; text-decoration: none; color: #0b0620; background: linear-gradient(135deg, #818cf8, #22d3ee);
}
.studio-link:hover { filter: brightness(1.08); }
.bridge .mini { min-height: 44px; }

@media (max-width: 640px) {
  .ruler { margin-left: 5.6rem; }
  .seq-row { grid-template-columns: 5.6rem 1fr; }
  .part-tab { padding: 0.45rem 0.7rem; font-size: 0.85rem; }
  .part-tab .tab-key { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tab-dot { transition: none; }
}

/* .control and .bar-nav set display, which would otherwise beat [hidden] */
.machine [hidden] { display: none !important; }
