/* ================================================
   GZ2H Chord Transition Trainer
   Visual language shared with the GZ2H Chord Library
   ================================================ */

@font-face { font-family: 'Mabry Pro'; src: url('../fonts/Mabry_Pro_Light.otf') format('opentype'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Mabry Pro'; src: url('../fonts/Mabry_Pro_Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Mabry Pro'; src: url('../fonts/Mabry_Pro_Medium.otf') format('opentype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Mabry Pro'; src: url('../fonts/Mabry_Pro_Bold.otf') format('opentype'); font-weight: 700; font-display: swap; }

:root {
  --red: #BF0017;
  --red-hover: #D6001A;
  --maroon: #56000F;
  --bone: #F8F7F3;
  --cream: #F2EFE7;
  --white: #FFFFFF;
  --text: #1A0005;
  --text-sec: #56000F;
  --text-muted: rgba(86, 0, 15, 0.45);
  --accent: #BF0017;
  --glow: rgba(191, 0, 23, 0.15);
  --border: rgba(86, 0, 15, 0.1);
  --border-med: rgba(86, 0, 15, 0.18);
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --font: 'Mabry Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font); background: var(--bone); color: var(--text); line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* Touch feel: no double-tap zoom delay, no long-press text selection on controls */
button, input[type="range"] { font-family: var(--font); touch-action: manipulation; }
button { -webkit-user-select: none; user-select: none; }

.app { max-width: 860px; margin: 0 auto; padding: 18px 20px 36px; }

/* ---- Header ---- */
.header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; margin-bottom: 20px; position: relative; }
.header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px;
  background: linear-gradient(90deg, var(--red) 0%, var(--red) 34%, var(--border) 34%, var(--border) 100%);
  border-radius: 1px;
}
.header-logo { height: 20px; display: block; }
.header-right { display: flex; align-items: center; gap: 14px; }
.header-kicker { font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }

/* "Full Screen" CTA — hidden by default, shown only when embedded in an iframe */
.fullscreen-btn { display: none; }
body.is-embedded .fullscreen-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1.5px solid var(--border-med); border-radius: 9999px;
  background: var(--white); color: var(--maroon);
  font-family: var(--font); font-size: 0.72rem; font-weight: 700; cursor: pointer;
  transition: all 120ms ease; box-shadow: 0 1px 6px rgba(86, 0, 15, 0.08);
}
body.is-embedded .fullscreen-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 2px 12px rgba(191, 0, 23, 0.15); }
body.is-embedded .fullscreen-btn:active { transform: scale(0.95); }

/* Embedded in the course player: the platform already provides GZ2H branding,
   so strip the logo, kicker, divider, and footer. The header collapses to just
   the Full Screen button. */
body.is-embedded .header-logo,
body.is-embedded .header-kicker,
body.is-embedded .footer { display: none; }
body.is-embedded .header { justify-content: flex-end; padding-bottom: 0; margin-bottom: 6px; }
body.is-embedded .header::after { display: none; }
body.is-embedded .app { padding-top: 10px; }
body.is-embedded .home-intro { margin-top: 0; }

/* ---- Shared bits ---- */
.section-label {
  display: block; font-size: 0.7rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px;
}

.back-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.back-btn {
  width: 32px; height: 32px; border: 1.5px solid var(--border-med); border-radius: 50%;
  background: var(--white); color: var(--text-sec); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 150ms ease;
}
.back-btn svg { width: 16px; height: 16px; }
.back-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--glow); }
.back-btn:active { transform: scale(0.92); }
.back-row-title { font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }

.icon-btn {
  width: 34px; height: 34px; border: 1.5px solid var(--border-med); border-radius: 50%;
  background: var(--white); color: var(--text-sec); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all 150ms ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--glow); }
.icon-btn:active { transform: scale(0.92) rotate(180deg); }

/* ================================================
   HOME
   ================================================ */
.home-intro { text-align: center; margin: 10px 0 24px; }
.home-title { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); line-height: 1.15; }
.home-tagline { font-size: 0.95rem; font-weight: 300; color: var(--text-sec); margin-top: 8px; max-width: 440px; margin-left: auto; margin-right: auto; }

.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.mode-card {
  background: var(--white); border: 1.5px solid var(--border); border-radius: var(--r-lg);
  padding: 0; cursor: pointer; text-align: left; overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
  animation: card-in 400ms ease backwards;
}
.mode-card:nth-child(2) { animation-delay: 80ms; }
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } }
.mode-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(86, 0, 15, 0.08); }
.mode-card:active { transform: translateY(0); }

.mode-card-visual {
  background: var(--cream); padding: 20px 16px 14px;
  display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 128px;
}
.mode-mini-chord { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px 8px 4px; }
.mode-arrow { font-size: 1.6rem; color: var(--accent); font-weight: 700; }

.mode-card-visual-random { gap: 8px; flex-wrap: wrap; }
.random-tile {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; height: 46px; padding: 0 10px;
  background: var(--white); border: 1.5px solid var(--border-med); border-radius: var(--r-md);
  font-size: 1.15rem; font-weight: 700; color: var(--maroon);
}
.random-tile:nth-child(1) { transform: rotate(-6deg); }
.random-tile:nth-child(2) { transform: rotate(4deg) translateY(6px); }
.random-tile:nth-child(3) { transform: rotate(-2deg) translateY(-4px); }
.random-tile:nth-child(4) { transform: rotate(7deg) translateY(4px); }
.random-tile:nth-child(5) { transform: rotate(-5deg); }
.random-tile.alt { background: var(--red); border-color: var(--red); color: var(--white); }

.mode-card-body { padding: 16px 18px 6px; }
.mode-card-name { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.mode-card-desc { font-size: 0.88rem; font-weight: 300; color: var(--text-sec); margin-top: 4px; }
.mode-card-cta {
  padding: 12px 18px 16px; font-size: 0.78rem; font-weight: 500; color: var(--accent);
  margin-top: auto;
}
.mode-card-cta::after { content: ' \2192'; transition: margin-left 150ms ease; }
.mode-card:hover .mode-card-cta::after { margin-left: 4px; }

/* ================================================
   SETUP SCREENS
   ================================================ */
.setup-prompt { font-size: 1.1rem; font-weight: 500; color: var(--text); margin-bottom: 14px; text-align: center; }

.pair-chips-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pair-chips-label { font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-right: 2px; }
.pair-chip {
  padding: 6px 14px; border: 1.5px solid var(--border-med); border-radius: 9999px;
  background: var(--white); font-size: 0.82rem; font-weight: 500; color: var(--text-sec);
  cursor: pointer; transition: all 150ms ease;
}
.pair-chip:hover { border-color: var(--accent); color: var(--accent); }
.pair-chip.selected { background: var(--accent); border-color: var(--accent); color: var(--white); }
.pair-chip:active { transform: scale(0.95); }

/* Preset chips live in their own scroller so mobile can swipe them */
.preset-scroll-wrap { min-width: 0; }
.preset-scroll { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.chord-grid {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 10px; margin-bottom: 18px;
}
.chord-card {
  position: relative; background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 10px 4px 8px; cursor: pointer; flex: 0 1 106px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.chord-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.chord-card:active { transform: scale(0.97); }
.chord-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.chord-card-name { font-size: 1rem; font-weight: 700; color: var(--text); }
/* Corner controls sit ON the card edge so they never cover the diagram's
   open/muted string markers. */
.chord-card-remove {
  position: absolute; top: -7px; left: -7px; width: 20px; height: 20px;
  border: 1.5px solid var(--border-med); border-radius: 50%;
  background: var(--white); color: var(--text-muted);
  font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: all 150ms ease; z-index: 2;
  box-shadow: 0 1px 5px rgba(86, 0, 15, 0.15);
}
.chord-card-remove:hover { border-color: var(--accent); color: var(--accent); background: var(--glow); }
.chord-card-check {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px;
  border: 1.5px solid var(--accent); border-radius: 50%;
  background: var(--accent); color: var(--white);
  display: flex; align-items: center; justify-content: center; z-index: 2;
  box-shadow: 0 1px 5px rgba(86, 0, 15, 0.15);
}
.chord-card-check svg { width: 11px; height: 11px; }

/* F version picker */
.fversion-block { background: var(--cream); border-radius: var(--r-md); padding: 14px 16px 16px; margin-bottom: 18px; }
.fversion-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.fversion-card {
  flex: 1; min-width: 96px; background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--r-md); padding: 10px 6px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.fversion-card:hover { border-color: var(--accent); }
.fversion-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.fversion-name { font-size: 0.92rem; font-weight: 700; color: var(--text); margin-top: 2px; }
.fversion-label { font-size: 0.7rem; font-weight: 400; color: var(--text-muted); }

/* Random settings */
.random-settings { margin-bottom: 18px; text-align: center; }
.push-note { font-size: 0.78rem; color: var(--text-muted); margin: 8px auto 0; max-width: 420px; }
.seg-toggle { display: inline-flex; border: 1.5px solid var(--border-med); border-radius: 9999px; background: var(--white); padding: 3px; gap: 2px; }
.seg-btn {
  padding: 7px 18px; border: none; border-radius: 9999px; background: transparent;
  font-size: 0.85rem; font-weight: 500; color: var(--text-sec); cursor: pointer;
  transition: all 150ms ease;
}
.seg-btn:hover { color: var(--accent); }
.seg-btn.selected { background: var(--accent); color: var(--white); }

/* Setup actions */
.setup-actions { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.pool-count { font-size: 0.82rem; color: var(--text-muted); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 34px; border: none; border-radius: 9999px;
  background: var(--red); color: var(--white);
  font-size: 1rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(191, 0, 23, 0.28);
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.btn-primary svg { width: 15px; height: 15px; }
.btn-primary:hover { background: var(--red-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:disabled {
  background: var(--cream); color: var(--text-muted); cursor: not-allowed;
  box-shadow: none; transform: none;
}

/* ================================================
   PRACTICE SCREENS
   ================================================ */
.pair-select-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 18px; }
.pair-title-arrow { color: var(--accent); font-size: 2rem; font-weight: 700; line-height: 1; }

/* Chord selector (popover grid) */
.chord-select { position: relative; }
.chord-select-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 20px; border: 1.5px solid var(--border-med); border-radius: var(--r-lg);
  background: var(--white); cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.chord-select-btn:hover { border-color: var(--accent); }
.chord-select.open .chord-select-btn { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.chord-select-name { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); line-height: 1.2; }
.chord-select-caret { width: 18px; height: 18px; color: var(--text-sec); transition: transform 200ms ease; }
.chord-select.open .chord-select-caret { transform: rotate(180deg); }

.chord-select-pop {
  display: none; position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--white); border: 1.5px solid var(--border-med); border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(26, 0, 5, 0.14); z-index: 60;
  padding: 10px; width: min(92vw, 372px);
}
.chord-select.open .chord-select-pop { display: block; }
.chord-select-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chord-option {
  position: relative; border: 1.5px solid transparent; border-radius: var(--r-md);
  background: transparent; padding: 6px 2px 5px; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center;
  transition: border-color 120ms ease, background 120ms ease;
}
.chord-option:hover { background: var(--glow); }
.chord-option.selected { border-color: var(--accent); background: var(--glow); }
.chord-option:disabled { opacity: 0.3; cursor: not-allowed; }
.chord-option:disabled:hover { background: transparent; }
.chord-option-name { font-size: 0.88rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.chord-option-sub { font-size: 0.62rem; font-weight: 400; color: var(--text-muted); }

/* Step tabs */
.step-tabs {
  display: flex; background: var(--white); border: 1.5px solid var(--border-med);
  border-radius: 9999px; padding: 4px; gap: 4px; margin-bottom: 12px;
}
.step-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 8px; border: none; border-radius: 9999px; background: transparent;
  cursor: pointer; transition: background 180ms ease;
}
.step-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--cream);
  color: var(--text-sec); font-size: 0.78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 180ms ease;
}
.step-name { font-size: 0.88rem; font-weight: 500; color: var(--text-sec); transition: color 180ms ease; white-space: nowrap; }
.step-tab:hover .step-name { color: var(--accent); }
.step-tab.active { background: var(--red); }
.step-tab.active .step-num { background: var(--white); color: var(--red); }
.step-tab.active .step-name { color: var(--white); }

.step-tip { text-align: center; font-size: 0.9rem; font-weight: 300; color: var(--text-sec); max-width: 520px; margin: 0 auto 18px; }

/* Focus mode toggle (Guided / Explore) */
.focus-mode-row { display: flex; justify-content: center; margin-bottom: 12px; }
.focus-mode-row .seg-btn { padding: 6px 20px; font-size: 0.8rem; }

/* Stage middle */
.stage-mid { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; position: relative; }

/* Guided session: phase-based emphasis. The layout never changes — the parts
   that don't matter for the current phase just dim. */
/* Step 1 is about the chords only — hide the pattern UI entirely rather than
   dim it (a greyed pattern reads as "play this quietly" to learners). It
   reappears with the warmup count-in. */
.stage-mid[data-phase="1"] .pattern-setup-box { display: none; }

/* Guided setup: the pattern area is clearly scoped to steps 2 + 3 */
.pattern-setup-box {
  background: var(--cream); border-radius: var(--r-lg);
  padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 12px;
}
.pattern-setup-head { display: flex; align-items: center; justify-content: center; gap: 10px; }
.pattern-setup-head .section-label { margin-bottom: 0; }
.pattern-setup-badge {
  background: var(--maroon); color: var(--white);
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 10px; border-radius: 9999px;
}
.pattern-setup-box .pattern-block .section-label { display: none; }
.pattern-setup-box .pattern-strip { background: var(--white); }
.pattern-setup-note { text-align: center; font-size: 0.76rem; color: var(--text-muted); margin: 0; }
/* Once the session is in steps 2/3, the setup framing quiets down */
.stage-mid[data-phase="2"] .pattern-setup-note,
.stage-mid[data-phase="3"] .pattern-setup-note,
.stage-mid[data-phase="countin"] .pattern-setup-note { display: none; }
.stage-mid[data-phase="2"] .chord-diagrams-row,
.stage-mid[data-phase="countin"] .chord-diagrams-row { opacity: 0.55; transition: opacity 400ms ease; }
.stage-mid[data-phase="2"] .pattern-strip,
.stage-mid[data-phase="3"] .pattern-strip,
.stage-mid[data-phase="2"] .chord-diagrams-row,
.stage-mid[data-phase="3"] .chord-diagrams-row,
.stage-mid[data-phase="countin"] .pattern-strip { transition: opacity 400ms ease; }

/* Guided phase banner */
.phase-banner {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%) translateY(-4px);
  background: var(--maroon); color: var(--white);
  font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 8px 20px; border-radius: 9999px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(86, 0, 15, 0.3);
  opacity: 0; pointer-events: none; z-index: 20;
  transition: opacity 250ms ease, transform 250ms ease;
}
.phase-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Guided count-in: big numbers over the whole stage */
.count-overlay {
  position: absolute; inset: -4px; z-index: 30; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(248, 247, 243, 0.92); border-radius: var(--r-lg);
}
.count-overlay.show { display: flex; }
.count-overlay-sub { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.count-next {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--maroon);
}
.count-pattern {
  display: flex; align-items: center; gap: 7px;
  background: var(--white); border: 1.5px solid var(--border-med);
  border-radius: 9999px; padding: 9px 16px;
}
.count-pattern .strip-arrow { width: 17px; height: 17px; color: var(--maroon); }
.count-pattern-gap { width: 12px; height: 3px; background: var(--border-med); border-radius: 2px; }
.count-overlay-num {
  font-size: 7rem; font-weight: 700; color: var(--red); line-height: 1;
  text-shadow: 0 8px 30px rgba(191, 0, 23, 0.25);
}
.count-overlay-num.pulse { animation: count-pulse 300ms ease; }
@keyframes count-pulse {
  from { transform: scale(1.35); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

.chord-diagrams-row { display: flex; justify-content: center; gap: 18px; }
.chord-panel {
  background: var(--white); border: 2px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 18px 10px; text-align: center; max-width: 240px; flex: 1;
  transition: border-color 200ms ease, box-shadow 200ms ease, opacity 200ms ease;
}
.chord-panel-svg svg { max-width: 100%; height: auto; }
.chord-panel-name { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-top: 2px; }
.chord-panel.active { border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.chord-panel.inactive { opacity: 0.42; }

.muted-hint { text-align: center; }
.muted-hint-text { font-size: 0.8rem; color: var(--text-muted); font-style: normal; }

/* Beat dots */
.beat-dots-row { display: flex; justify-content: center; align-items: flex-start; }
.beat-dots-row.grouped { gap: 30px; }
.beat-bar-group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.beat-bar-dots { display: flex; gap: 14px; }
.beat-bar-label {
  font-size: 0.62rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); transition: color 150ms ease;
}
.beat-bar-group.current .beat-bar-label { color: var(--accent); font-weight: 700; }
.beat-dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--border-med);
  transition: transform 120ms ease, background 120ms ease;
}
.beat-dot.active { background: var(--red); transform: scale(1.45); }

/* Pattern strip */
.pattern-strip {
  background: var(--white); border: 1.5px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 16px 10px; max-width: 480px; margin: 0 auto; width: 100%;
}
.strip-slots { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; position: relative; }
.strip-playhead {
  position: absolute; top: -6px; bottom: -6px; left: 0; width: 2.5px;
  background: var(--red); border-radius: 2px; opacity: 0;
  transform: translateX(-50%); pointer-events: none;
  box-shadow: 0 0 6px rgba(191, 0, 23, 0.4);
  transition: opacity 150ms ease;
}
.strip-slot {
  height: 44px; border-radius: var(--r-md); background: var(--cream);
  display: flex; align-items: center; justify-content: center; color: var(--maroon);
  transition: background 100ms ease, color 100ms ease, transform 100ms ease;
}
.strip-slot.empty { background: transparent; }
.strip-slot.active { background: var(--red); color: var(--white); transform: scale(1.06); }

/* Custom pattern: slots become tappable toggles */
.strip-slot.editable { border: none; font-family: var(--font); cursor: pointer; transition: background 100ms ease, box-shadow 100ms ease, transform 100ms ease; }
.strip-slot.editable.empty { background: var(--cream); box-shadow: inset 0 0 0 1.5px var(--border); }
.strip-slot.editable:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
.strip-slot.editable:active { transform: scale(0.94); }
.strip-slot.editable.active { box-shadow: none; }
.strip-hint { text-align: center; font-size: 0.72rem; color: var(--text-muted); margin-top: 8px; }

/* The Push: marker on the slot where the chord change lands */
.pattern-strip:has(.push-slot) { padding-top: 30px; }
.strip-slot.push-slot { position: relative; box-shadow: inset 0 0 0 2px var(--maroon); overflow: visible; }
.push-flag {
  position: absolute; top: -17px; left: 50%; transform: translateX(-50%);
  background: var(--maroon); color: var(--white);
  font-size: 0.5rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 6px; border-radius: 9999px; white-space: nowrap;
}
.strip-count.push-count { color: var(--maroon); font-weight: 700; }

/* 16th-note grid variant */
.strip-slots.slots-16 { grid-template-columns: repeat(16, 1fr); gap: 3px; }
.strip-slots.slots-16 .strip-slot { height: 36px; border-radius: var(--r-sm); }
.strip-slots.slots-16 .strip-arrow { width: 13px; height: 13px; }
.strip-counts.slots-16 { grid-template-columns: repeat(16, 1fr); gap: 3px; }
.strip-counts.slots-16 .strip-count { font-size: 0.58rem; }
.custom-mode-row { display: flex; justify-content: center; margin-top: 12px; }
.custom-mode-row .seg-btn { padding: 6px 16px; font-size: 0.78rem; }
.strip-arrow { width: 22px; height: 22px; }
.strip-counts { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 4px; }
.strip-count { text-align: center; font-size: 0.72rem; font-weight: 500; color: var(--text-muted); }

/* Pattern picker: mini cards showing each pattern's arrows */
.pattern-block { text-align: center; }
.pattern-block .section-label { text-align: center; }
.pattern-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pattern-card {
  background: var(--white); border: 1.5px solid var(--border); border-radius: var(--r-md);
  padding: 11px 8px 9px; cursor: pointer; flex: 0 1 156px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 8px;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.pattern-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.pattern-card:active { transform: scale(0.97); }
.pattern-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.pattern-card-name { font-size: 0.76rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.pattern-card-preview { display: flex; align-items: center; gap: 3px; min-height: 14px; }
.pattern-card-preview .strip-arrow { width: 12px; height: 12px; color: var(--maroon); }
.pattern-card-preview.dense { gap: 2px; }
.pattern-card-preview.dense .strip-arrow { width: 8px; height: 8px; }
.pp-slot { display: inline-flex; align-items: center; }
.pp-gap { display: inline-block; width: 8px; height: 2px; background: var(--border-med); border-radius: 1px; }
.pattern-card-preview.dense .pp-gap { width: 5px; }
.pp-slot.pp-change { position: relative; }
.pp-slot.pp-change .strip-arrow { color: var(--red); }
.pp-slot.pp-change::after {
  content: ''; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--red);
}

/* ================================================
   RANDOM PLAY
   ================================================ */
.random-stage { display: flex; justify-content: center; align-items: stretch; gap: 18px; }
.random-now {
  background: var(--white); border: 2px solid var(--accent); border-radius: var(--r-lg);
  box-shadow: 0 0 0 4px var(--glow); padding: 14px 22px 0; text-align: center;
  position: relative; overflow: hidden;
}
.random-now.pop { animation: now-pop 340ms ease; }
@keyframes now-pop {
  0% { transform: scale(0.97); box-shadow: 0 0 0 8px rgba(191, 0, 23, 0.3); }
  100% { transform: scale(1); box-shadow: 0 0 0 4px var(--glow); }
}
.random-slot-label { font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 2px; }
.random-now .random-slot-label { color: var(--accent); }
.random-now-svg svg, .random-next-svg svg { max-width: 100%; height: auto; }
.random-now-name { font-size: 1.9rem; font-weight: 700; color: var(--text); line-height: 1.1; padding-bottom: 14px; }
.change-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--cream); }
.change-progress-fill { height: 100%; width: 0%; background: var(--red); }

.random-next {
  background: var(--white); border: 2px dashed var(--border-med); border-radius: var(--r-lg);
  padding: 14px 16px 10px; text-align: center; opacity: 0.75;
  display: flex; flex-direction: column; justify-content: flex-start; align-self: center;
}
.random-next-name { font-size: 1.15rem; font-weight: 700; color: var(--text-sec); }

/* ================================================
   TRANSPORT
   ================================================ */
.transport-row {
  display: flex; align-items: center; justify-content: center; gap: 22px; flex-wrap: wrap;
  background: var(--white); border: 1.5px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 20px;
}
.play-cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 30px; border: none; border-radius: 9999px;
  background: var(--red); color: var(--white); font-size: 0.98rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 6px 18px rgba(191, 0, 23, 0.28);
  transition: background 150ms ease, transform 150ms ease;
}
.play-cta-icon { display: inline-flex; }
.play-cta-icon svg { width: 15px; height: 15px; }
.play-cta:hover { background: var(--red-hover); }
.play-cta:active { transform: scale(0.97); }
.play-cta:disabled { opacity: 0.7; cursor: wait; }
.play-cta.is-playing { background: var(--maroon); box-shadow: none; }

.tempo-control { display: flex; flex-direction: column; min-width: 190px; }
.tempo-control .section-label { margin-bottom: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.tempo-label { font-size: 0.82rem; font-weight: 700; color: var(--accent); letter-spacing: 0; text-transform: none; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: var(--cream); border: 1px solid var(--border); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); border: 3px solid var(--white);
  box-shadow: 0 1px 5px rgba(86, 0, 15, 0.3); margin-top: -8.5px;
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--cream); border: 1px solid var(--border); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--red); border: 3px solid var(--white);
  box-shadow: 0 1px 5px rgba(86, 0, 15, 0.3);
}

/* Volume popover */
.volume-wrap { position: relative; }
.volume-wrap .icon-btn svg { width: 17px; height: 17px; }
.volume-wrap.open .icon-btn { border-color: var(--accent); color: var(--accent); background: var(--glow); }
.volume-pop {
  display: none; position: absolute; bottom: calc(100% + 10px); right: -6px;
  background: var(--white); border: 1.5px solid var(--border-med); border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(26, 0, 5, 0.14); z-index: 70;
  padding: 14px 16px; width: 210px;
}
.volume-wrap.open .volume-pop { display: block; }
.volume-row { margin-bottom: 10px; }
.volume-row:last-child { margin-bottom: 0; }
.volume-row .section-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.volume-val { font-size: 0.78rem; font-weight: 700; color: var(--accent); letter-spacing: 0; text-transform: none; }

/* Chord sound toggle */
.chord-audio-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 500; color: var(--text-sec); cursor: pointer; user-select: none;
}
.chord-audio-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  width: 38px; height: 22px; border-radius: 9999px; background: var(--border-med);
  position: relative; transition: background 180ms ease; flex-shrink: 0;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--white); transition: transform 180ms ease; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.chord-audio-toggle input:checked + .toggle-track { background: var(--red); }
.chord-audio-toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }

/* ================================================
   CHORD LIBRARY BROWSER
   ================================================ */
.chord-select-browse {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 8px; padding: 10px 12px;
  border: 1.5px dashed var(--border-med); border-radius: var(--r-md);
  background: var(--cream); font-size: 0.8rem; font-weight: 500; color: var(--text-sec);
  cursor: pointer; transition: all 150ms ease;
}
.chord-select-browse svg { width: 14px; height: 14px; }
.chord-select-browse:hover { border-color: var(--accent); color: var(--accent); background: var(--glow); }

.chord-card-add {
  border-style: dashed; border-color: var(--border-med); background: var(--cream);
  justify-content: center; min-height: 120px;
}
.chord-card-add:hover { background: var(--glow); }
.chord-card-add-plus { font-size: 1.9rem; font-weight: 300; color: var(--accent); line-height: 1; }
.chord-card-add-label { font-size: 0.76rem; font-weight: 500; color: var(--text-sec); }

.lib-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(26, 0, 5, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.lib-modal {
  background: var(--white); border-radius: var(--r-lg); width: min(100%, 440px);
  padding: 18px 20px 20px; box-shadow: 0 24px 64px rgba(26, 0, 5, 0.3);
  animation: modal-in 200ms ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } }
.lib-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.lib-modal-title { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.lib-close {
  width: 30px; height: 30px; border: none; border-radius: 50%; background: var(--cream);
  color: var(--text-sec); font-size: 19px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 150ms ease;
}
.lib-close:hover { background: var(--glow); color: var(--accent); }

.lib-pill {
  border: 1.5px solid var(--border-med); border-radius: var(--r-sm); background: var(--white);
  font-family: var(--font); font-weight: 500; color: var(--text); cursor: pointer;
  transition: all 120ms ease; text-align: center;
}
.lib-pill:hover { border-color: var(--accent); color: var(--accent); }
.lib-pill.selected { background: var(--accent); border-color: var(--accent); color: var(--white); }

.lib-roots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 14px; }
.lib-root { font-size: 0.85rem; padding: 7px 2px; }
.lib-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 14px; }
.lib-type { font-size: 0.72rem; padding: 6px 2px; }

.lib-preview { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 14px; }
.lib-preview-empty { font-size: 0.85rem; color: var(--text-muted); padding: 40px 0; }
.lib-preview-mid { text-align: center; }
.lib-preview-name { font-size: 1.3rem; font-weight: 700; color: var(--text); margin-top: 2px; }
.lib-voicing-counter { font-size: 0.68rem; color: var(--text-muted); margin-top: 1px; }
.lib-voicing-nav {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--border-med); transition: color 150ms ease;
}
.lib-voicing-nav svg { width: 22px; height: 22px; }
.lib-voicing-nav:hover:not(:disabled) { color: var(--accent); }
.lib-voicing-nav:disabled { opacity: 0.3; cursor: default; }

.lib-confirm { width: 100%; }

/* ================================================
   ONBOARDING TOOLTIPS (ported from the Chord Library)
   ================================================ */
.onboarding-tooltip {
  display: none; position: absolute; z-index: 1001;
  background: var(--white); border-radius: var(--r-lg); padding: 16px 18px; max-width: 280px;
  box-shadow: 0 8px 24px rgba(86, 0, 15, 0.25), 0 2px 8px rgba(86, 0, 15, 0.15);
  font-family: var(--font);
}
.onboarding-tooltip.active { display: block; }
.onboarding-tooltip__step {
  font-size: 0.68rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.onboarding-tooltip__text {
  font-size: 0.88rem; font-weight: 400; color: var(--text);
  line-height: 1.45; margin-bottom: 14px;
}
.onboarding-tooltip__actions { display: flex; justify-content: space-between; align-items: center; }
.onboarding-tooltip__skip {
  background: none; border: none; font-family: inherit; font-size: 0.8rem;
  color: var(--text-muted); cursor: pointer; padding: 4px 0;
}
.onboarding-tooltip__skip:hover { color: var(--text-sec); }
.onboarding-tooltip__next {
  background: var(--accent); border: none; border-radius: var(--r-md); color: var(--white);
  font-family: inherit; font-size: 0.8rem; font-weight: 700;
  padding: 8px 18px; cursor: pointer;
}
.onboarding-tooltip__next:hover { background: var(--red-hover); }
.onboarding-tooltip__arrow { position: absolute; width: 12px; height: 12px; background: var(--white); }
.onboarding-tooltip__arrow.top {
  top: -6px; left: 50%; margin-left: -6px; transform: rotate(45deg);
  box-shadow: -2px -2px 4px rgba(86, 0, 15, 0.06);
}
.onboarding-tooltip__arrow.bottom {
  bottom: -6px; left: 50%; margin-left: -6px; transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(86, 0, 15, 0.06);
}

/* Highlight on target element */
.onboarding-highlight {
  position: relative; z-index: 950;
  border-radius: var(--r-lg);
  box-shadow: 0 0 0 3px rgba(191, 0, 23, 0.5);
  animation: onboardPulse 1.2s ease-in-out infinite;
}
.step-tabs.onboarding-highlight, .seg-toggle.onboarding-highlight { border-radius: 9999px; }
@keyframes onboardPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(191, 0, 23, 0.5); }
  50% { box-shadow: 0 0 0 3px rgba(191, 0, 23, 0.15); }
}

/* Help Button */
.help-btn {
  position: fixed; bottom: 16px; right: 16px; z-index: 90;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--border-med); background: var(--white); color: var(--text-sec);
  font-family: var(--font); font-size: 1rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 10px rgba(86, 0, 15, 0.12); transition: all 150ms ease;
}
.help-btn:hover { border-color: var(--accent); color: var(--accent); }
.help-btn.hidden { display: none; }

/* ---- Footer ---- */
.footer { margin-top: 28px; text-align: center; }
.footer-text { font-size: 0.72rem; color: var(--text-muted); }
.footer-link { color: var(--text-sec); text-decoration: none; font-weight: 500; }
.footer-link:hover { color: var(--accent); }

/* ================================================
   RESPONSIVE
   ================================================ */
/* ================================================
   MOBILE — app-like: tight vertical rhythm, sticky transport,
   swipeable pattern carousel, minimal scrolling
   ================================================ */
@media (max-width: 640px) {
  .app { padding: 10px 12px 16px; }
  .header { padding-bottom: 8px; margin-bottom: 10px; }
  .header-logo { height: 16px; }
  .header-kicker { display: none; }
  /* Icon-only full-screen button on mobile to save space */
  body.is-embedded .fullscreen-btn { padding: 8px; }
  body.is-embedded .fullscreen-btn span { display: none; }

  .home-title { font-size: 1.6rem; }
  .home-intro { margin: 4px 0 16px; }
  .mode-cards { grid-template-columns: 1fr; gap: 12px; }
  .mode-card-visual { min-height: 104px; padding: 14px 12px 10px; }

  .back-row { margin-bottom: 8px; }
  .back-btn { width: 28px; height: 28px; }

  /* Compact selectors and controls */
  .pair-select-row { gap: 8px; margin-bottom: 10px; }
  .pair-title-arrow { font-size: 1.5rem; }
  .chord-select-btn { padding: 5px 12px 5px 16px; gap: 7px; }
  .chord-select-name { font-size: 1.45rem; }
  .focus-mode-row { margin-bottom: 8px; }
  .focus-mode-row .seg-btn { padding: 5px 16px; font-size: 0.76rem; }
  .step-tabs { margin-bottom: 8px; padding: 3px; }
  /* All three step names stay readable: drop the number circles instead */
  .step-tab .step-num { display: none; }
  .step-name { font-size: 0.72rem; }
  .step-tab { gap: 0; padding: 8px 2px; }
  .step-tip { font-size: 0.78rem; margin-bottom: 10px; }

  /* Stage density */
  .stage-mid { gap: 10px; margin-bottom: 12px; }
  .chord-diagrams-row { gap: 8px; }
  .chord-panel { padding: 8px 8px 6px; }
  .chord-panel-name { font-size: 1.15rem; margin-top: 0; }
  .pattern-strip { padding: 10px 10px 8px; }
  .strip-slot { height: 38px; }
  .pattern-setup-box { padding: 10px 10px 8px; gap: 8px; }
  .pattern-setup-note { font-size: 0.7rem; }
  .random-stage { gap: 8px; }
  .random-now { padding: 10px 10px 0; }
  .random-now-name { font-size: 1.4rem; padding-bottom: 10px; }
  .count-overlay-num { font-size: 4.5rem; }

  /* Pattern picker becomes a swipeable one-row carousel */
  .pattern-picker {
    flex-wrap: nowrap; justify-content: flex-start;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 2px 2px 6px; margin: 0 -2px;
    scrollbar-width: none;
  }
  .pattern-picker::-webkit-scrollbar { display: none; }
  .pattern-card { flex: 0 0 132px; scroll-snap-align: center; }
  /* Edge fades + pulsing chevrons signal there is more to swipe; both melt
     away at the ends. --fade-bg matches the surface behind the carousel. */
  .pattern-block { position: relative; --fade-bg: var(--bone); }
  .pattern-setup-box .pattern-block { --fade-bg: var(--cream); }
  .pattern-block::before, .pattern-block::after {
    position: absolute; top: 24px; bottom: 6px; width: 52px;
    pointer-events: none; z-index: 3; transition: opacity 200ms ease;
    display: flex; align-items: center;
    font-size: 1.5rem; font-weight: 700; color: var(--accent); line-height: 1;
  }
  /* Inside the guided setup box the picker's own label is hidden, so the
     carousel starts at the top of the block — align the fades with it. */
  .pattern-setup-box .pattern-block::before,
  .pattern-setup-box .pattern-block::after { top: 2px; }
  .pattern-block::before {
    content: '\2039'; left: -2px; justify-content: flex-start; padding-left: 2px;
    background: linear-gradient(to right, var(--fade-bg) 35%, transparent);
    animation: fade-nudge-left 1.6s ease-in-out infinite;
  }
  .pattern-block::after {
    content: '\203A'; right: -2px; justify-content: flex-end; padding-right: 2px;
    background: linear-gradient(to left, var(--fade-bg) 35%, transparent);
    animation: fade-nudge-right 1.6s ease-in-out infinite;
  }
  .pattern-block.scroll-start::before { opacity: 0; animation: none; }
  .pattern-block.scroll-end::after { opacity: 0; animation: none; }

  /* Random Challenge presets: one swipeable row with the same edge fades */
  .pair-chips-row { flex-wrap: nowrap; }
  .pair-chips-label { flex-shrink: 0; }
  .preset-scroll-wrap { position: relative; flex: 1; }
  .preset-scroll {
    flex-wrap: nowrap; justify-content: flex-start;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity; scrollbar-width: none;
    padding: 2px 0;
  }
  .preset-scroll::-webkit-scrollbar { display: none; }
  .preset-scroll .pair-chip { flex-shrink: 0; scroll-snap-align: start; font-size: 0.78rem; padding: 5px 12px; }
  .preset-scroll-wrap::before, .preset-scroll-wrap::after {
    position: absolute; top: 0; bottom: 0; width: 38px;
    pointer-events: none; z-index: 3; transition: opacity 200ms ease;
    display: flex; align-items: center;
    font-size: 1.25rem; font-weight: 700; color: var(--accent); line-height: 1;
  }
  .preset-scroll-wrap::before {
    content: '\2039'; left: 0; justify-content: flex-start;
    background: linear-gradient(to right, var(--bone) 35%, transparent);
    animation: fade-nudge-left 1.6s ease-in-out infinite;
  }
  .preset-scroll-wrap::after {
    content: '\203A'; right: 0; justify-content: flex-end;
    background: linear-gradient(to left, var(--bone) 35%, transparent);
    animation: fade-nudge-right 1.6s ease-in-out infinite;
  }
  .preset-scroll-wrap.scroll-start::before { opacity: 0; animation: none; }
  .preset-scroll-wrap.scroll-end::after { opacity: 0; animation: none; }

  @keyframes fade-nudge-right {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(3px); }
  }
  @keyframes fade-nudge-left {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-3px); }
  }

  /* Sticky transport: play/tempo always in thumb reach, like an app bar.
     Respects the iPhone home-indicator safe area. */
  .transport-row {
    position: sticky; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 80;
    flex-wrap: nowrap; gap: 10px; padding: 10px 12px;
    box-shadow: 0 6px 24px rgba(86, 0, 15, 0.16);
  }
  /* Icon-only round play button keeps the bar to a single row */
  .play-cta { padding: 14px; border-radius: 50%; flex-shrink: 0; }
  .play-cta .play-cta-label { display: none; }
  .play-cta-icon svg { width: 17px; height: 17px; }
  .tempo-control { min-width: 0; flex: 1; }
  .chord-audio-toggle { font-size: 0.7rem; gap: 5px; flex-shrink: 0; }

  .footer { margin-top: 12px; }
  .footer-text { font-size: 0.62rem; }
  /* Keep the help button clear of the sticky transport */
  .help-btn { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); right: 12px; }
}
