/* =============================================
   Speakable - Frontend Player
   Primary: #d60017  Dark: #b50014
   ============================================= */

/* ---- Player Container ---- */
.speakable-player {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 20px 24px;
	margin-bottom: 28px;
	background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
	border: 1px solid #fecaca;
	border-radius: 14px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
	font-size: 14px;
	box-shadow: 0 1px 3px rgba(214, 0, 23, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
	transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

/* Active state when playing */
.speakable-player.speakable-active {
	border-color: var(--speakable-color, #d60017);
	background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
	box-shadow: 0 2px 16px rgba(214, 0, 23, 0.12), 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ---- Header Row ---- */
.speakable-header-row {
	display: flex;
	align-items: center;
	gap: 10px;
}

.speakable-headphone-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 10px;
	background: linear-gradient(135deg, var(--speakable-color, #d60017), #b50014);
	color: #fff;
	flex-shrink: 0;
	box-shadow: 0 2px 6px rgba(214, 0, 23, 0.3);
}

.speakable-player-title {
	font-size: 14px;
	font-weight: 600;
	color: #334155;
	margin: 0;
	padding: 0;
	line-height: 1.3;
	margin-bottom: 0 !important;
}

/* ---- Controls Row ---- */
.speakable-controls {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

/* ---- Buttons ---- */
.speakable-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	min-width: 44px;
	padding: 10px 22px;
	border: none;
	border-radius: 10px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	user-select: none;
	transition: all 0.25s ease;
}

.speakable-btn:focus-visible {
	outline: 2px solid var(--speakable-color, #d60017);
	outline-offset: 2px;
}

.speakable-btn:active {
	transform: scale(0.96);
}

/* Play / Pause Button */
.speakable-play {
	background: linear-gradient(135deg, var(--speakable-color, #d60017), #b50014);
	color: #fff;
	box-shadow: 0 2px 8px rgba(214, 0, 23, 0.35);
}

.speakable-play:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(214, 0, 23, 0.45);
}

.speakable-play:active {
	transform: translateY(0) scale(0.97);
	box-shadow: 0 1px 4px rgba(214, 0, 23, 0.3);
}

/* Playing state - brighter glow */
.speakable-player.speakable-active .speakable-play {
	box-shadow: 0 2px 12px rgba(214, 0, 23, 0.45);
}

.speakable-player.speakable-active .speakable-play:hover {
	box-shadow: 0 4px 18px rgba(214, 0, 23, 0.5);
}

/* Stop Button */
.speakable-stop {
	background: #fee2e2;
	color: #dc2626;
	padding: 10px 14px;
}
.speakable-stop:hover {
	background: #fecaca;
}

.speakable-stop:disabled {
	background: #f1f5f9;
	color: #64748b;
	opacity: 0.6;
	cursor: not-allowed;
	box-shadow: none;
}

.speakable-stop:not(:disabled):hover {
	background: #fecaca;
	transform: translateY(-1px);
}

.speakable-stop:not(:disabled):active {
	transform: scale(0.96);
}

/* ---- Audio Wave Animation ---- */
.speakable-wave {
	display: none;
	align-items: center;
	gap: 3px;
	height: 24px;
	margin-left: 4px;
}

.speakable-player.speakable-active .speakable-wave {
	display: flex;
}

.speakable-wave span {
	width: 3px;
	height: 8px;
	background: var(--speakable-color, #d60017);
	border-radius: 2px;
	animation: speakable-wave 0.6s ease-in-out infinite;
}

.speakable-wave span:nth-child(1) { animation-delay: 0s; }
.speakable-wave span:nth-child(2) { animation-delay: 0.1s; }
.speakable-wave span:nth-child(3) { animation-delay: 0.2s; }
.speakable-wave span:nth-child(4) { animation-delay: 0.3s; }
.speakable-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes speakable-wave {
	0%, 100% { height: 6px; }
	50% { height: 20px; }
}

/* ---- Speed Control ---- */
.speakable-speed-control {
	position: relative;
}

.speakable-speed-select {
	min-height: 38px;
	padding: 6px 12px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 600;
	color: #334155;
	background: #fff;
	-webkit-appearance: none;
	appearance: none;
	touch-action: manipulation;
	cursor: pointer;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.speakable-speed-select:focus-visible {
	border-color: var(--speakable-color, #d60017);
	box-shadow: 0 0 0 3px rgba(214, 0, 23, 0.25);
	outline: none;
}

/* ---- Sentence Counter ---- */
.speakable-time {
	margin-left: auto;
	font-size: 12px;
	font-weight: 600;
	color: #7f1d1d;
	background: #fee2e2;
	padding: 4px 10px;
	border-radius: 6px;
	white-space: nowrap;
	opacity: 0;
	transition: opacity 0.3s;
}

.speakable-player.speakable-active .speakable-time {
	opacity: 1;
}

/* ---- Progress Bar ---- */
.speakable-progress-bar {
	height: 6px;
	background: #fecaca;
	border-radius: 3px;
	overflow: hidden;
	position: relative;
}

.speakable-progress-fill {
	height: 100%;
	background: linear-gradient(90deg, var(--speakable-color, #d60017), #b50014);
	border-radius: 3px;
	width: 0;
	transition: width 0.4s ease;
	position: relative;
}

/* Glow dot at progress tip */
.speakable-player.speakable-active .speakable-progress-fill::after {
	content: '';
	position: absolute;
	right: 0;
	top: 50%;
	transform: translateY(-50%);
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--speakable-color, #d60017);
	box-shadow: 0 0 8px rgba(214, 0, 23, 0.5);
}

/* ---- Sticky Mini Player ---- */
.speakable-sticky {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	gap: 12px;
	padding: 12px 20px;
	background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
	border-top: 2px solid var(--speakable-color, #d60017);
	box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
	font-size: 13px;
	color: #fff;
	transform: translateY(100%);
	transition: transform 0.3s ease;
}

.speakable-sticky.speakable-sticky-visible {
	display: flex;
	transform: translateY(0);
}

/* Sticky play button */
.speakable-sticky .speakable-sticky-play {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--speakable-color, #d60017), #b50014);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	box-shadow: 0 2px 8px rgba(214, 0, 23, 0.4);
	transition: transform 0.15s, box-shadow 0.15s;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	padding: 0 !important;
}

.speakable-sticky .speakable-sticky-play:hover {
	transform: scale(1.05);
	box-shadow: 0 3px 12px rgba(214, 0, 23, 0.5);
}

.speakable-sticky .speakable-sticky-play:active {
	transform: scale(0.95);
}

.speakable-sticky .speakable-sticky-play:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Sticky info */
.speakable-sticky-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.speakable-sticky-title {
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.speakable-sticky-progress {
	height: 4px;
	background: rgba(255, 255, 255, 0.15);
	border-radius: 2px;
	overflow: hidden;
}

.speakable-sticky-progress-fill {
	height: 100%;
	background: var(--speakable-color, #d60017);
	border-radius: 2px;
	width: 0;
	transition: width 0.4s ease;
}

/* Sticky wave */
.speakable-sticky-wave {
	display: flex;
	align-items: center;
	gap: 2px;
	height: 20px;
}

.speakable-sticky-wave span {
	width: 2px;
	height: 6px;
	background: var(--speakable-color, #d60017);
	border-radius: 1px;
	animation: speakable-wave 0.6s ease-in-out infinite;
}

.speakable-sticky-wave span:nth-child(1) { animation-delay: 0s; }
.speakable-sticky-wave span:nth-child(2) { animation-delay: 0.1s; }
.speakable-sticky-wave span:nth-child(3) { animation-delay: 0.15s; }
.speakable-sticky-wave span:nth-child(4) { animation-delay: 0.25s; }

/* Sticky counter */
.speakable-sticky-counter {
	font-size: 11px;
	color: rgba(255, 255, 255, 0.6);
	white-space: nowrap;
}

/* Sticky stop */
.speakable-sticky .speakable-sticky-stop {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.1);
	color: rgba(255, 255, 255, 0.7);
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.speakable-sticky .speakable-sticky-stop:hover {
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
}

.speakable-sticky .speakable-sticky-stop:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* ---- Unsupported Browser ---- */
.speakable-unsupported {
	color: #94a3b8;
	font-style: italic;
	font-size: 13px;
	margin: 0;
	text-align: center;
	padding: 8px 0;
}

/* ========== Tablet ========== */
@media (max-width: 768px) {
	.speakable-player {
		padding: 16px 18px;
		margin-bottom: 22px;
		border-radius: 12px;
		gap: 12px;
	}

	.speakable-controls {
		gap: 8px;
	}

	.speakable-btn {
		padding: 10px 18px;
		font-size: 13px;
	}

	.speakable-progress-bar {
		height: 8px;
		border-radius: 4px;
	}

	.speakable-progress-fill {
		border-radius: 4px;
	}
}

/* ========== Small Phones ========== */
@media (max-width: 480px) {
	.speakable-player {
		padding: 14px;
		gap: 10px;
	}

	.speakable-header-row {
		gap: 8px;
	}

	.speakable-headphone-icon {
		width: 32px;
		height: 32px;
		border-radius: 8px;
	}

	.speakable-headphone-icon svg {
		width: 14px;
		height: 14px;
	}

	.speakable-player-title {
		font-size: 13px;
	}

	.speakable-controls {
		gap: 6px;
	}

	.speakable-play {
		flex: 1;
		justify-content: center;
	}

	.speakable-btn-label {
		font-size: 13px;
	}

	.speakable-time {
		margin-left: 0;
		font-size: 11px;
		padding: 3px 8px;
	}
}

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
	.speakable-wave span,
	.speakable-sticky-wave span {
		animation: none;
		height: 12px;
	}

	.speakable-player,
	.speakable-btn,
	.speakable-progress-fill,
	.speakable-time,
	.speakable-sticky,
	.speakable-sticky-progress-fill {
		transition: none;
	}

	.speakable-btn:hover,
	.speakable-sticky .speakable-sticky-play:hover {
		transform: none;
	}
}
