/* ==========================================================================
   Paddy Prompt Studio — Free online metronome
   Layers on /blog/style.css (same dark indigo/cyan palette and type scale).
   Only the interactive widget and tables live here; prose is inherited.
   ========================================================================== */

:root {
  --good: #34d399;
  --down: #22d3ee;      /* bar downbeat */
  --accent: #818cf8;    /* other accents */
  --mute: #4b5263;
}

/* ------------------------------------------------------------ Shell */
.metro {
  position: relative;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: 22px;
  padding: 1.25rem; margin: 0.5rem 0 1rem;
  box-shadow: 0 30px 70px -40px rgba(99, 102, 241, 0.6);
  transition: box-shadow 0.4s ease, border-color 0.4s ease;
}
.metro[data-celebrate="true"] {
  border-color: rgba(52, 211, 153, 0.7);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35), 0 30px 90px -30px rgba(52, 211, 153, 0.8);
}

.metro-grid {
  display: grid; gap: 1.1rem; align-items: center;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

/* ------------------------------------------------------------ BPM block */
.bpm-block { display: flex; align-items: center; justify-content: center; gap: 0.6rem; }
.bpm-step {
  appearance: none; -webkit-appearance: none; cursor: pointer; flex: none;
  width: 3.2rem; height: 3.2rem; border-radius: 50%;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
  color: var(--text); font: inherit; font-size: 1.6rem; font-weight: 700; line-height: 1;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.bpm-step:hover { background: rgba(129, 140, 248, 0.22); }
.bpm-step:active { transform: translateY(1px); }

.bpm-read { text-align: center; min-width: 0; }
.bpm-read .bpm-line { display: flex; align-items: baseline; justify-content: center; gap: 0.3rem; }
#bpm-input {
  font-family: "Space Grotesk", "Inter", sans-serif; font-weight: 800;
  font-size: clamp(3.6rem, 16vw, 5.4rem); line-height: 1; letter-spacing: -0.04em;
  color: #fff; background: transparent; border: 0; border-bottom: 2px solid transparent;
  width: 3.3ch; text-align: center; padding: 0; margin: 0;
  -moz-appearance: textfield; appearance: textfield;
}
#bpm-input::-webkit-outer-spin-button, #bpm-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#bpm-input:hover { border-bottom-color: var(--border); }
#bpm-input:focus { outline: none; border-bottom-color: var(--indigo-strong); }
.metro[data-celebrate="true"] #bpm-input { color: var(--good); text-shadow: 0 0 28px rgba(52, 211, 153, 0.7); }
.bpm-unit {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700;
  font-size: 0.85rem; letter-spacing: 0.18em; color: var(--indigo);
}
.tempo-mark { margin: 0.3rem 0 0; font-size: 0.95rem; color: var(--text-muted); }
.tempo-mark #tempo-name { font-weight: 800; color: #c7d2fe; font-style: italic; font-family: "Space Grotesk", "Inter", sans-serif; font-size: 1.15rem; }

.slider-row { margin: 0.9rem 0 0; display: flex; align-items: center; gap: 0.6rem; }
.slider-row .end { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.7rem; color: var(--text-dim); }
input[type="range"] { flex: 1; accent-color: var(--indigo-strong); min-height: 44px; cursor: pointer; }

.metro-actions { display: flex; gap: 0.6rem; margin-top: 0.6rem; }
.play-btn, .tap-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
  cursor: pointer; border-radius: 14px; font: inherit; font-weight: 800;
  min-height: 3.4rem; touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.play-btn {
  flex: 1.6; border: 0; font-size: 1.15rem;
  background: linear-gradient(135deg, #818cf8, #22d3ee); color: #0b0620;
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn .ico { width: 0; height: 0; border-style: solid; border-width: 0.5rem 0 0.5rem 0.8rem; border-color: transparent transparent transparent currentColor; }
.play-btn[data-state="playing"] { background: rgba(52, 211, 153, 0.16); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.45); }
.play-btn[data-state="playing"] .ico { width: 0.8rem; height: 0.8rem; border: 0; background: currentColor; border-radius: 2px; }
.tap-btn {
  flex: 1; font-size: 1rem; color: var(--text);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
}
.tap-btn:hover { border-color: rgba(129, 140, 248, 0.6); }
.tap-btn[data-hit="true"] { background: rgba(129, 140, 248, 0.3); border-color: var(--indigo-strong); }
.tap-msg { margin: 0.5rem 0 0; min-height: 1.3em; text-align: center; font-size: 0.85rem; color: var(--text-dim); }

/* ------------------------------------------------------------ Visuals */
.viz {
  position: relative; display: grid; justify-items: center; gap: 0.5rem;
  background: rgba(0, 0, 0, 0.18); border: 1px solid var(--border-soft);
  border-radius: 18px; padding: 0.8rem 0.6rem 0.9rem;
}
.pendulum { width: 100%; max-width: 19rem; display: block; }
.pendulum .arm {
  transform-box: view-box; transform-origin: 150px 186px;
  will-change: transform;
}
.pendulum .flash { opacity: 0; fill: url(#flashIndigo); }
.pendulum .flash[data-level="down"] { fill: url(#flashCyan); }
.pendulum .flash[data-level="sub"] { fill: url(#flashDim); }

.gap-veil {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
  margin: 0; padding: 0.45rem 0.8rem; border-radius: 10px; width: max-content; max-width: 90%;
  text-align: center; font-weight: 700; font-size: 0.92rem; color: #fde68a;
  background: rgba(10, 11, 18, 0.88); border: 1px solid rgba(251, 191, 36, 0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.viz[data-gap="true"] .gap-veil { opacity: 1; }
.viz[data-gap="true"] .pendulum { opacity: 0.45; }
.bar-count {
  position: absolute; top: 0.6rem; right: 0.8rem; margin: 0;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.7rem; color: var(--text-dim);
}

.beat-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; }
.beat-dot {
  position: relative; cursor: pointer; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  padding: 0; font: inherit; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.04); border: 2px solid var(--border); color: var(--text-dim);
  touch-action: manipulation; transition: background 0.06s linear, border-color 0.15s ease, transform 0.06s linear;
}
.beat-dot .num { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.78rem; font-weight: 700; }
.beat-dot.group-start { margin-left: 0.55rem; }
.beat-dot[data-level="accent"] { border-color: var(--accent); color: #c7d2fe; }
.beat-dot[data-level="accent"]:first-child { border-color: var(--down); color: #a5f3fc; }
.beat-dot[data-level="accent"]::after {
  content: ""; position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 6px solid currentColor;
}
.beat-dot[data-level="muted"] { border-style: dashed; border-color: var(--mute); color: var(--mute); }
.beat-dot[data-level="muted"] .num { text-decoration: line-through; }
.beat-dot[data-now="true"] { background: rgba(129, 140, 248, 0.55); color: #fff; transform: scale(1.08); }
.beat-dot[data-now="true"]:first-child { background: rgba(34, 211, 238, 0.55); }
.beat-dot[data-now="true"][data-level="muted"] { background: rgba(75, 82, 99, 0.45); }
.beat-unit { margin: 0; font-size: 0.78rem; color: var(--text-dim); text-align: center; }

/* ------------------------------------------------------------ Controls */
.metro-controls {
  display: grid; gap: 0.75rem; margin-top: 1.1rem; padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.field { display: grid; gap: 0.35rem; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > .lbl, .panel .lbl, .suno-box .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;
}
.field select, .panel input[type="number"], .panel select {
  font: inherit; font-size: 0.92rem; font-weight: 600; color: var(--text);
  background: #07080d; border: 1px solid var(--border); border-radius: 10px;
  padding: 0.55rem 0.6rem; min-height: 44px; width: 100%;
}
.vol-row { display: flex; align-items: center; gap: 0.5rem; }

.seg { display: flex; flex-wrap: wrap; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 12px; padding: 0.22rem; gap: 0.15rem; }
.seg button {
  flex: 1 1 auto; font: inherit; font-size: 0.86rem; font-weight: 700; cursor: pointer;
  border: 0; border-radius: 9px; padding: 0.5rem 0.65rem; min-height: 40px;
  background: transparent; color: var(--text-muted); touch-action: manipulation;
}
.seg button:hover { color: #fff; }
.seg button[aria-pressed="true"] { background: rgba(99, 102, 241, 0.26); color: #fff; }
.seg .sym { color: var(--indigo); }

/* ------------------------------------------------------------ Practice */
.practice {
  display: grid; gap: 0.75rem; margin-top: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.panel {
  background: rgba(255, 255, 255, 0.025); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.8rem; display: grid; gap: 0.55rem; align-content: start;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.panel[data-on="true"] { border-color: rgba(129, 140, 248, 0.55); background: rgba(99, 102, 241, 0.07); }
.panel h3 { margin: 0; font-size: 0.98rem; }
.panel .toggle { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 700; font-size: 0.95rem; min-height: 32px; }
.panel .toggle input { width: 1.15rem; height: 1.15rem; accent-color: var(--indigo-strong); }
.panel .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.panel label.mini { display: grid; gap: 0.25rem; }
.panel .check { display: flex; gap: 0.45rem; align-items: center; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; }
.panel .check input { accent-color: var(--indigo-strong); width: 1rem; height: 1rem; }
.panel .readout { margin: 0; font-size: 0.82rem; color: var(--text-dim); min-height: 1.2em; }
.progress { height: 6px; border-radius: 6px; background: rgba(255,255,255,0.06); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #818cf8, #34d399); transition: width 0.3s ease; }
.timer-big {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700;
  font-size: 2rem; color: #fff; line-height: 1.1; margin: 0;
}
.small-btn {
  font: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer; min-height: 40px;
  border-radius: 10px; padding: 0.45rem 0.8rem; color: var(--text);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
}
.end-btn { align-self: end; }
.small-btn:hover { border-color: rgba(129, 140, 248, 0.6); }

/* ------------------------------------------------------------ Suno box */
.suno-box {
  margin-top: 1rem; padding: 0.85rem; border-radius: 14px;
  background: rgba(8, 145, 178, 0.07); border: 1px solid rgba(34, 211, 238, 0.25);
  display: grid; gap: 0.5rem;
}
.suno-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
#suno-snippet {
  flex: 1 1 15rem; min-width: 0; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.88rem;
  color: #a5f3fc; background: #07080d; border: 1px solid var(--border); border-radius: 10px;
  padding: 0.55rem 0.7rem; min-height: 44px;
}
.studio-btn {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0.45rem 0.9rem; border-radius: 10px;
  font-weight: 800; font-size: 0.88rem; background: linear-gradient(135deg, #818cf8, #22d3ee); color: #0b0620;
}
.studio-btn:hover { text-decoration: none; filter: brightness(1.08); }

/* ------------------------------------------------------------ Status */
.celebrate {
  position: absolute; left: 50%; top: 0.8rem; transform: translate(-50%, -8px);
  z-index: 3; margin: 0; padding: 0.55rem 1rem; border-radius: 12px; width: max-content; max-width: calc(100% - 1.6rem);
  text-align: center; font-weight: 800; color: #052e1f; background: linear-gradient(135deg, #6ee7b7, #67e8f9);
  box-shadow: 0 12px 40px -10px rgba(52, 211, 153, 0.8);
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease;
}
.metro[data-celebrate="true"] .celebrate { opacity: 1; transform: translate(-50%, 0); }
.metro-status { margin: 0.85rem 0 0; font-size: 0.88rem; color: var(--text-muted); min-height: 1.3em; }
.metro-status.err { color: #fca5a5; font-weight: 600; }
.tuner-hint { margin: 0.6rem 0 0; text-align: center; font-size: 0.85rem; color: var(--text-dim); line-height: 1.8; }
.tuner-hint kbd, .article-body kbd {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.78rem;
  background: rgba(129, 140, 248, 0.14); border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 0.05em 0.35em; color: #c7d2fe;
}

/* ------------------------------------------------------------ Prose tables */
.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-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.68rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--indigo); font-weight: 700;
  background: rgba(255, 255, 255, 0.03);
}
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; white-space: nowrap; }
table.data tbody tr:hover { background: rgba(129, 140, 248, 0.05); }

/* ------------------------------------------------------------ Motion */
@media (prefers-reduced-motion: reduce) {
  .metro, .celebrate, .gap-veil, .progress > span, .beat-dot { transition: none; }
  .beat-dot[data-now="true"] { transform: none; }
  .metro[data-celebrate="true"] .celebrate { transform: translate(-50%, 0); }
}

/* ------------------------------------------------------------ Responsive */
@media (max-width: 860px) {
  .practice { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .metro-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .metro { padding: 0.85rem; border-radius: 18px; }
  .metro-controls { grid-template-columns: 1fr; }
  .bpm-step { width: 2.9rem; height: 2.9rem; }
  .beat-dot { width: 2.75rem; height: 2.75rem; }
  .beat-dot.group-start { margin-left: 0.3rem; }
  .seg button { padding: 0.5rem 0.45rem; font-size: 0.82rem; }
}
