/* ===========================================================================
   FTM Vocal — Design System + Widget Styles

   All colors and fonts reference the freethemusic theme's tokens first, then
   fall back to the same values hard-coded. If the theme updates its tokens,
   this plugin's widgets update automatically — no CSS edits needed.

   Architecture mirrors ftm-music-theory.css so the two plugins look identical
   when rendered on the same page.
   =========================================================================== */

/* Prequel display font bundled with the plugin so typography is self-sufficient
   even if the host theme's own @font-face declaration is broken. Same TTF file
   ftm-songbook bundles — keep these in sync if Prequel is ever updated. */
@font-face {
	font-family: 'Prequel';
	src: url('../fonts/PrequelDemo-Regular.ttf') format('truetype');
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

.ftm-vocal {
	/* tokens — use theme if defined, else fall back to FTM brand values */
	--nav:        var(--ftm-nav,        #1A2747);
	--nav-soft:   var(--ftm-nav-soft,   #2E3C63);
	--cream:      var(--ftm-cream,      #F6F3EC);
	--page:       var(--ftm-page,       #EEF1F5);
	--card:       var(--ftm-card,       #FFFFFF);
	--muted:      var(--ftm-muted,      #6B7280);
	--line:       var(--ftm-line,       #E4E8EE);
	--gold:       var(--ftm-gold,       #F2B230);
	--red:        var(--ftm-red,        #E63946);
	--orange:     var(--ftm-orange,     #F77F00);
	--yellow:     var(--ftm-yellow,     #FCBF49);
	--green:      var(--ftm-green,      #80B918);
	--blue:       var(--ftm-blue,       #277DA1);
	--violet:     var(--ftm-violet,     #7209B7);
	--rainbow:    var(--ftm-rainbow,    linear-gradient(90deg, #E63946, #F77F00, #FCBF49, #80B918, #277DA1, #7209B7));
	--radius:     var(--ftm-radius,     16px);
	--radius-sm:                        10px;
	--radius-pill:var(--ftm-radius-pill,999px);
	--shadow-sm:  var(--ftm-shadow-sm,  0 1px 2px rgba(26,39,71,.06));
	--shadow-md:  var(--ftm-shadow-md,  0 8px 24px rgba(26,39,71,.08));
	--shadow-lg:  var(--ftm-shadow-lg,  0 24px 48px rgba(26,39,71,.12));
	--title-font: var(--ftm-title-font, 'Prequel', 'Playfair Display', Georgia, serif);
	--body-font:  var(--ftm-body-font,  'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
	--mono-font:                        'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

	font-family: var(--body-font);
	color: var(--nav);
	line-height: 1.55;
	box-sizing: border-box;
}
.ftm-vocal *,
.ftm-vocal *::before,
.ftm-vocal *::after { box-sizing: border-box; }

.ftm-vocal p { margin: 0 0 14px; }
.ftm-vocal h1, .ftm-vocal h2, .ftm-vocal h3, .ftm-vocal h4 {
	font-family: var(--title-font); font-weight: 400; color: var(--nav); line-height: 1.2;
	margin: 0 0 14px;
}
.ftm-vocal a { color: var(--nav); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ftm-vocal a:hover { color: var(--blue); }
/* Force color inheritance on buttons so host-theme / Elementor button rules
   (e.g. `.elementor button { color: #fff }`) don't leak through and make our
   text invisible. Inherit from the widget root, which is --nav. */
.ftm-vocal button { font-family: inherit; cursor: pointer; color: inherit; background: transparent; }

.ftm-vocal-kicker {
	display: inline-block;
	font-size: 11px;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--nav-soft);
	font-weight: 600;
	margin-bottom: 8px;
}
.ftm-vocal-muted { color: var(--muted); }
.ftm-vocal-tiny  { font-size: 12px; }

/* ------- Buttons -------
   We use a compound selector `.ftm-vocal .ftm-vocal-btn` + !important on the
   text-affecting properties to defeat Elementor/theme button overrides that
   otherwise leak white text onto our buttons. Belt-and-braces: the specificity
   jump handles most cases, the !important handles the rest. */
.ftm-vocal .ftm-vocal-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 18px;
	border: 1px solid var(--line);
	background: var(--card) !important;
	color: var(--nav) !important;
	border-radius: var(--radius-pill);
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	transition: transform .1s ease, box-shadow .2s ease, background .2s ease;
	text-decoration: none;
}
.ftm-vocal .ftm-vocal-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ftm-vocal .ftm-vocal-btn:active { transform: translateY(0); }
.ftm-vocal .ftm-vocal-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.ftm-vocal .ftm-vocal-btn-primary { background: var(--nav) !important; color: var(--cream) !important; border-color: var(--nav); }
.ftm-vocal .ftm-vocal-btn-primary:hover { background: var(--nav-soft) !important; }
.ftm-vocal .ftm-vocal-btn-ghost    { background: transparent !important; }
.ftm-vocal .ftm-vocal-btn-gold     { background: var(--gold) !important; color: var(--nav) !important; border-color: var(--gold); }
.ftm-vocal .ftm-vocal-btn-gold:hover { filter: brightness(0.95); }

/* =================================================================
   Hub — the /learn/vocal/ landing page
   ================================================================= */
.ftm-vocal-hub {
	max-width: 1120px;
	margin: 0 auto;
	padding: 32px 20px 64px;
	background: var(--page);
}
.ftm-vocal-hub-header { text-align: center; margin-bottom: 36px; }
.ftm-vocal-hub-title {
	font-size: clamp(32px, 5vw, 52px);
	margin: 4px 0 12px;
}
.ftm-vocal-hub-lead {
	max-width: 640px;
	margin: 0 auto;
	color: var(--muted);
	font-size: 17px;
}

.ftm-vocal-hub-topgrid {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 20px;
	margin-bottom: 48px;
}
.ftm-vocal-hub-topgrid > * {
	background: var(--card);
	border-radius: var(--radius);
	padding: 22px;
	box-shadow: var(--shadow-sm);
	border: 1px solid var(--line);
	position: relative;
	overflow: hidden;
}
.ftm-vocal-hub-topgrid > *::before {
	content: '';
	position: absolute;
	top: 0; left: 0; right: 0;
	height: 4px;
	background: var(--rainbow);
}

.ftm-vocal-today h3 { font-size: 22px; margin-bottom: 6px; }
.ftm-vocal-today p { font-size: 14px; }

.ftm-vocal-hub-section {
	margin-bottom: 48px;
}
.ftm-vocal-section-head h2 {
	font-size: 28px;
	margin-bottom: 4px;
}
.ftm-vocal-section-head p { font-size: 15px; margin-bottom: 20px; }

/* =================================================================
   Range picker
   ================================================================= */
.ftm-vocal-range-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 10px;
	margin-top: 10px;
}
/* Range cards are <button>s — pin text color so theme button rules can't
   leak white onto them. Inner spans inherit from the button. */
.ftm-vocal .ftm-vocal-range-card {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	padding: 14px;
	border: 1.5px solid var(--line);
	background: var(--card) !important;
	color: var(--nav) !important;
	border-radius: var(--radius-sm);
	text-align: left;
	cursor: pointer;
	transition: border-color .2s ease, transform .1s ease;
}
.ftm-vocal .ftm-vocal-range-card:hover { border-color: var(--nav-soft); transform: translateY(-1px); }
.ftm-vocal .ftm-vocal-range-card.is-active {
	border-color: var(--nav);
	background: linear-gradient(135deg, rgba(26,39,71,.06), rgba(26,39,71,.02)) !important;
	color: var(--nav) !important;
}
.ftm-vocal .ftm-vocal-range-card > * { color: inherit; }
.ftm-vocal-range-label { font-weight: 600; font-size: 14px; color: var(--nav); }
.ftm-vocal-range-sub   { font-size: 12px; color: var(--muted); }
.ftm-vocal-range-notes { font-family: var(--mono-font); font-size: 12px; color: var(--nav-soft); margin-top: 4px; }

.ftm-vocal-range-select {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	background: var(--card);
	font-family: inherit;
	font-size: 14px;
	margin-top: 8px;
}

.ftm-vocal-custom-range-form {
	margin-top: 14px;
	padding: 14px;
	background: var(--cream);
	border-radius: var(--radius-sm);
}
.ftm-vocal-custom-range-form label {
	display: block;
	font-size: 12px;
	margin-bottom: 10px;
	font-weight: 600;
}
.ftm-vocal-custom-range-form input {
	display: block;
	width: 100%;
	margin-top: 4px;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
	font-family: var(--mono-font);
	font-size: 14px;
	background: var(--card);
}

/* =================================================================
   Streak card
   ================================================================= */
.ftm-vocal-streak-bignum {
	font-family: var(--title-font);
	font-size: 64px;
	line-height: 1;
	color: var(--nav);
	margin: 6px 0 4px;
}
.ftm-vocal-streak-label { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.ftm-vocal-streak-meta {
	display: flex; gap: 8px; font-size: 12px; color: var(--muted);
}
.ftm-vocal-streak-loginhint { font-size: 12px; color: var(--muted); margin-top: 14px; }
.ftm-vocal-streak-inline {
	display: inline-flex; align-items: center; gap: 6px;
	background: var(--cream); padding: 4px 12px;
	border-radius: var(--radius-pill); font-size: 14px;
}
.ftm-vocal-streak-flame { font-size: 16px; }
.ftm-vocal-streak-heatmap {
	display: grid;
	grid-template-columns: repeat(10, 1fr);
	gap: 4px;
}
.ftm-vocal-heat-cell {
	aspect-ratio: 1;
	background: var(--line);
	border-radius: 3px;
}
.ftm-vocal-heat-cell.is-on { background: var(--nav); }

/* =================================================================
   Routine builder
   ================================================================= */
.ftm-vocal-routine-builder {
	background: var(--card);
	border-radius: var(--radius);
	padding: 22px;
	box-shadow: var(--shadow-sm);
	border: 1px solid var(--line);
}
.ftm-vocal-routine-empty {
	text-align: center;
	padding: 30px 20px;
	color: var(--muted);
	border: 2px dashed var(--line);
	border-radius: var(--radius-sm);
}
.ftm-vocal-routine-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.ftm-vocal-routine-item {
	display: flex; align-items: center; gap: 12px;
	padding: 12px 14px;
	background: var(--cream);
	border-radius: var(--radius-sm);
	border: 1px solid var(--line);
	cursor: grab;
	transition: background .2s ease, border-color .2s ease;
}
.ftm-vocal-routine-item:hover { background: #f1eadb; }
.ftm-vocal-routine-item.is-dragging { opacity: .4; }
.ftm-vocal-routine-item.is-drop-target { border-color: var(--nav); background: #e9e1cf; }
.ftm-vocal-routine-grip { color: var(--muted); font-size: 18px; user-select: none; }
.ftm-vocal-routine-num {
	width: 28px; height: 28px;
	background: var(--nav); color: var(--cream);
	border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	font-size: 12px; font-weight: 600;
	flex-shrink: 0;
}
.ftm-vocal-routine-body { flex: 1; }
.ftm-vocal-routine-name { font-weight: 600; font-size: 15px; }
.ftm-vocal-routine-sub { font-size: 12px; color: var(--muted); }
.ftm-vocal-routine-remove {
	width: 28px; height: 28px;
	background: transparent;
	border: 1px solid var(--line);
	border-radius: 50%;
	color: var(--muted);
	font-size: 18px;
	cursor: pointer;
	line-height: 1;
	flex-shrink: 0;
}
.ftm-vocal-routine-remove:hover { color: var(--red); border-color: var(--red); }
.ftm-vocal-routine-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* =================================================================
   Category tabs (hub)
   ================================================================= */
.ftm-vocal-cat-tabs {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 8px;
	margin-bottom: 16px;
}
.ftm-vocal-cat-tab {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	padding: 14px 12px;
	background: var(--card);
	border: 1.5px solid var(--line);
	border-radius: var(--radius-sm);
	text-align: left;
	cursor: pointer;
	transition: border-color .2s ease, transform .1s ease;
	position: relative;
	overflow: hidden;
}
.ftm-vocal-cat-tab:hover { transform: translateY(-1px); }
.ftm-vocal-cat-tab.is-active { border-color: var(--nav); }
.ftm-vocal-cat-tab.is-active::before {
	content: ''; position: absolute; top: 0; left: 0; right: 0;
	height: 3px;
}
.ftm-vocal-cat-tab[data-accent="red"].is-active::before    { background: var(--red); }
.ftm-vocal-cat-tab[data-accent="orange"].is-active::before { background: var(--orange); }
.ftm-vocal-cat-tab[data-accent="yellow"].is-active::before { background: var(--yellow); }
.ftm-vocal-cat-tab[data-accent="green"].is-active::before  { background: var(--green); }
.ftm-vocal-cat-tab[data-accent="violet"].is-active::before { background: var(--violet); }
.ftm-vocal-cat-label { font-weight: 600; font-size: 14px; }
.ftm-vocal-cat-sub { font-size: 11px; color: var(--muted); }

.ftm-vocal-cat-descriptions { margin-bottom: 20px; }
.ftm-vocal-cat-desc { display: none; padding: 14px 18px; background: var(--cream); border-radius: var(--radius-sm); }
.ftm-vocal-cat-desc.is-active { display: block; }
.ftm-vocal-cat-desc p { margin: 0; font-size: 14px; color: var(--nav-soft); }

/* =================================================================
   Exercise card grid
   ================================================================= */
.ftm-vocal-library-grid,
.ftm-vocal-library-grid-filtered {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 16px;
}
.ftm-vocal-cat-panel { display: none; grid-column: 1 / -1; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.ftm-vocal-cat-panel.is-active { display: grid; }

.ftm-vocal-ex-card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	transition: transform .1s ease, box-shadow .2s ease;
}
.ftm-vocal-ex-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ftm-vocal-ex-card-head {
	display: flex; justify-content: space-between; align-items: center;
	min-height: 24px;
}
.ftm-vocal-ex-vowel {
	font-family: var(--mono-font);
	font-size: 13px;
	padding: 2px 8px;
	background: var(--cream);
	border-radius: var(--radius-pill);
	color: var(--nav-soft);
	font-weight: 600;
}
.ftm-vocal-ex-title { font-size: 19px; margin: 4px 0 2px; line-height: 1.25; }
.ftm-vocal-ex-desc  { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.ftm-vocal-ex-meta {
	display: flex; gap: 8px; flex-wrap: wrap;
	font-size: 11px; color: var(--nav-soft); font-weight: 600;
	margin-bottom: 6px;
}
.ftm-vocal-ex-meta span {
	padding: 2px 8px; background: #f3f5f9; border-radius: var(--radius-pill);
}
.ftm-vocal-ex-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }

.ftm-vocal-coach-chip {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	padding: 3px 8px;
	border-radius: var(--radius-pill);
	color: #fff;
}
.ftm-vocal-coach-brett-manning { background: var(--blue); }
.ftm-vocal-coach-ken-tamplin   { background: var(--violet); }

/* =================================================================
   Player (inline or modal)
   ================================================================= */
.ftm-vocal-player-inner {
	background: var(--card);
	border-radius: var(--radius);
	padding: 28px;
	box-shadow: var(--shadow-sm);
	border: 1px solid var(--line);
	position: relative;
	overflow: hidden;
}
.ftm-vocal-player-inner::before {
	content: ''; position: absolute; top: 0; left: 0; right: 0;
	height: 4px; background: var(--rainbow);
}
.ftm-vocal-player-head { margin-bottom: 18px; }
.ftm-vocal-player-title { font-size: 28px; margin-bottom: 6px; }
.ftm-vocal-player-desc { font-size: 15px; color: var(--nav-soft); margin-bottom: 8px; }
.ftm-vocal-player-meta {
	display: flex; gap: 10px; flex-wrap: wrap;
	font-size: 13px; color: var(--nav-soft);
	margin-bottom: 20px;
}
.ftm-vocal-player-meta span {
	padding: 4px 10px; background: var(--cream); border-radius: var(--radius-pill);
	font-weight: 600;
}
/* Optional demo video embed — rendered when the exercise has a videoUrl */
.ftm-vocal-player-video {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	margin-bottom: 20px;
	border-radius: var(--radius-sm);
	overflow: hidden;
	background: #000;
	box-shadow: var(--shadow-sm);
}
.ftm-vocal-player-video iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.ftm-vocal-player-instructions {
	background: var(--cream);
	padding: 18px 22px 18px 38px;
	border-radius: var(--radius-sm);
	margin-bottom: 20px;
	font-size: 14px;
	line-height: 1.7;
}
.ftm-vocal-player-instructions li { margin-bottom: 6px; }
.ftm-vocal-player-controls {
	display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.ftm-vocal-player-status {
	font-size: 14px;
	color: var(--nav-soft);
	margin-bottom: 10px;
	font-weight: 600;
}
.ftm-vocal-player-progress {
	height: 8px;
	background: var(--line);
	border-radius: 999px;
	overflow: hidden;
}
.ftm-vocal-player-progress-bar {
	height: 100%;
	width: 0;
	background: var(--rainbow);
	transition: width .3s ease;
}

/* =================================================================
   Player modal
   ================================================================= */
.ftm-vocal-player-modal[hidden] { display: none; }
.ftm-vocal-modal-backdrop {
	position: fixed; inset: 0;
	background: rgba(26,39,71,.55);
	z-index: 9998;
	animation: ftmvFadeIn .2s ease;
}
.ftm-vocal-modal-panel {
	position: fixed;
	top: 50%; left: 50%;
	transform: translate(-50%, -50%);
	width: min(720px, 94vw);
	max-height: 92vh;
	overflow-y: auto;
	background: var(--card);
	border-radius: var(--radius);
	z-index: 9999;
	box-shadow: var(--shadow-lg);
	animation: ftmvPop .25s cubic-bezier(.2,.7,.3,1);
}
.ftm-vocal-modal-close {
	position: absolute;
	top: 14px; right: 14px;
	width: 36px; height: 36px;
	border-radius: 50%;
	border: 1px solid var(--line);
	background: var(--card);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	z-index: 2;
}
.ftm-vocal-modal-body { padding: 12px; }
.ftm-vocal-modal-body .ftm-vocal-player-inner::before { display: none; }
.ftm-vocal-modal-body .ftm-vocal-player-inner { box-shadow: none; border: none; }

@keyframes ftmvFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ftmvPop { from { opacity: 0; transform: translate(-50%, -48%); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* =================================================================
   Breath timer
   ================================================================= */
.ftm-vocal-bt-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
	padding: 40px 20px;
	background: var(--card);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
	border: 1px solid var(--line);
}
.ftm-vocal-bt-circle {
	--bt-scale: 1;
	--bt-dur: 4s;
	width: 180px; height: 180px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--nav), var(--nav-soft));
	color: var(--cream);
	display: flex;
	align-items: center;
	justify-content: center;
	transform: scale(var(--bt-scale));
	transition: transform var(--bt-dur) cubic-bezier(.4,0,.2,1);
	box-shadow: var(--shadow-md);
}
.ftm-vocal-bt-label {
	font-family: var(--title-font);
	font-size: 28px;
}
.ftm-vocal-bt-status {
	font-family: var(--mono-font);
	font-size: 14px;
	color: var(--muted);
}

/* =================================================================
   Responsive
   ================================================================= */
@media (max-width: 900px) {
	.ftm-vocal-hub-topgrid { grid-template-columns: 1fr; }
	.ftm-vocal-cat-tabs { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
	.ftm-vocal-range-grid { grid-template-columns: 1fr; }
	.ftm-vocal-hub-title { font-size: 30px; }
	.ftm-vocal-cat-tabs { grid-template-columns: 1fr; }

	/* Player controls: 2-column grid with Play + Mark complete spanning the
	   full row. This stops the buttons from wrapping into narrow circles with
	   multi-line labels on small screens. */
	.ftm-vocal-player-controls {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 10px;
	}
	.ftm-vocal .ftm-vocal-player-controls .ftm-vocal-btn {
		width: 100%;
		padding: 14px 10px;
		font-size: 14px;
		line-height: 1.2;
		white-space: nowrap;
	}
	.ftm-vocal .ftm-vocal-player-controls .ftm-vocal-btn-primary,
	.ftm-vocal .ftm-vocal-player-controls .ftm-vocal-btn-gold {
		grid-column: 1 / -1;
	}

	/* Breathing room at the bottom so the floating WooCommerce cart button
	   doesn't overlap Mark Complete on mobile. */
	.ftm-vocal-player-inner { padding-bottom: 90px; }
	.ftm-vocal-modal-panel  { max-height: 94vh; }
	.ftm-vocal-modal-body .ftm-vocal-player-inner { padding-bottom: 100px; }

	/* Tighter player typography on mobile so instructions fit without scrolling */
	.ftm-vocal-player-title { font-size: 22px; }
	.ftm-vocal-player-instructions { padding: 14px 18px 14px 30px; font-size: 13px; }
	.ftm-vocal-player-meta span { font-size: 12px; }
}
