/* --- Recherche / grille --- */

.chacc-recherche__topbar {
	display: flex;
	justify-content: flex-end;
	margin-bottom: 8px;
}

.chacc-recherche__history {
	margin-bottom: 18px;
}
.chacc-recherche__history h4 {
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #888;
	margin: 0 0 8px;
}
.chacc-recherche__history-row {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 4px;
}
.chacc-history-chip {
	flex: 0 0 auto;
	padding: 6px 14px;
	background: #f3f4f6;
	border-radius: 999px;
	font-size: 0.85em;
	text-decoration: none;
	color: inherit;
	white-space: nowrap;
}

.chacc-recherche__fav-toggle {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.9em;
	cursor: pointer;
}

.chacc-recherche__input {
	width: 100%;
	box-sizing: border-box;
	padding: 14px 16px;
	font-size: 16px; /* évite le zoom auto sur iOS */
	border: 1px solid #ddd;
	border-radius: 10px;
	margin-bottom: 12px;
}

.chacc-recherche__filters {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	margin-bottom: 16px;
}

.chacc-recherche__filter {
	padding: 8px 12px;
	border: 1px solid #ddd;
	border-radius: 8px;
	background: #fff;
}

.chacc-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 12px;
}

.chacc-card {
	display: flex;
	flex-direction: column;
	text-decoration: none;
	color: inherit;
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
	position: relative;
}

.chacc-card__vignette {
	width: 100%;
	aspect-ratio: 1 / 1;
	background-size: cover;
	background-position: center;
	background-color: #eee;
}

.chacc-card__fav {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.85);
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
	z-index: 2;
}
.chacc-card__fav.is-active {
	color: #b45309;
}

.chacc-card__vignette--fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2.2em;
	font-weight: bold;
	color: #fff;
	background-color: hsl(var(--chacc-hue, 200), 55%, 55%);
}

.chacc-card__titre {
	font-weight: 600;
	font-size: 0.95em;
	padding: 8px 10px 0;
	line-height: 1.25;
}

.chacc-card__artiste {
	font-size: 0.82em;
	color: #666;
	padding: 2px 10px 10px;
}

.chacc-card__tonalite {
	position: absolute;
	top: 8px;
	right: 8px;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	font-size: 0.7em;
	padding: 2px 7px;
	border-radius: 999px;
}

.chacc-recherche__empty {
	text-align: center;
	color: #777;
	margin-top: 24px;
}

/* --- Affichage d'une chanson --- */

.chacc-chanson__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 12px;
}

.chacc-badge {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 0.8em;
	background: #f0f0f0;
}

.chacc-toolbar {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	background: #fff;
	padding: 10px 0;
	border-bottom: 1px solid #eee;
	margin-bottom: 16px;
}

.chacc-btn {
	border: 1px solid #ddd;
	background: #fafafa;
	border-radius: 8px;
	padding: 8px 12px;
	font-size: 0.9em;
	min-width: 40px;
	touch-action: manipulation;
}

.chacc-btn.is-active,
.chacc-btn--scroll.is-active {
	background: #222;
	color: #fff;
	border-color: #222;
}

.chacc-toolbar__label {
	min-width: 60px;
	text-align: center;
	font-weight: 600;
}

.chacc-toolbar__group {
	display: flex;
	align-items: center;
	gap: 6px;
	padding-right: 10px;
	margin-right: 2px;
	border-right: 1px solid #e5e5e5;
}
.chacc-toolbar__group:last-child {
	border-right: none;
	padding-right: 0;
}

.chacc-render {
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	line-height: 1.7;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* Structure générée par ChordSheetJS (HtmlDivFormatter) */
.chacc-render .chord {
	color: #b5121b;
	font-weight: bold;
	display: block;
	font-size: 0.85em;
}

.chacc-render .lyrics {
	display: block;
}

.chacc-loading,
.chacc-error {
	color: #888;
	text-align: center;
	padding: 20px 0;
}

/* --- Grille d'accords --- */
.chacc-chord-grid {
	margin: 16px 0 24px;
	padding: 14px 0;
	border-top: 1px solid #eee;
	border-bottom: 1px solid #eee;
}

.chacc-chord-grid__section {
	margin-bottom: 16px;
}
.chacc-chord-grid__section:last-child {
	margin-bottom: 0;
}

.chacc-chord-grid__title {
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #888;
	margin: 0 0 8px;
}

.chacc-chord-grid__row {
	display: flex;
	gap: 12px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scroll-snap-type: x proximity;
	padding-bottom: 4px;
}

.chacc-chord-grid__empty {
	color: #888;
	font-size: 0.9em;
}

.chacc-chord-grid__switch {
	display: flex;
	gap: 16px;
	margin-bottom: 14px;
	font-size: 0.9em;
}
.chacc-chord-grid__switch label {
	display: flex;
	align-items: center;
	gap: 4px;
	cursor: pointer;
}

.chacc-chord-box {
	flex: 0 0 auto;
	width: 74px;
	display: flex;
	flex-direction: column;
	align-items: center;
	scroll-snap-align: start;
}

.chacc-chord-box--fallback {
	justify-content: center;
	min-height: 60px;
	border: 1px dashed #ddd;
	border-radius: 8px;
}

.chacc-chord-svg {
	width: 100%;
	height: auto;
}
.chacc-chord-svg__string {
	stroke: #444;
	stroke-width: 1;
}
.chacc-chord-svg__fret {
	stroke: #999;
	stroke-width: 1;
}
.chacc-chord-svg__fret--nut {
	stroke: #222;
	stroke-width: 3;
}
.chacc-chord-svg__dot {
	fill: #222;
}
.chacc-chord-svg__barre {
	stroke: #222;
	stroke-width: 8;
	stroke-linecap: round;
}
.chacc-chord-svg__mark {
	font-size: 10px;
	fill: #444;
}
.chacc-chord-svg__position {
	font-size: 9px;
	fill: #666;
}

.chacc-chord-box__label {
	margin-top: 4px;
	font-size: 0.85em;
	font-weight: 600;
	text-align: center;
}

/* --- QR code --- */
.chacc-qr-modal {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.chacc-qr-modal[hidden] {
	display: none;
}
.chacc-qr-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
}
.chacc-qr-modal__panel {
	position: relative;
	background: #fff;
	border-radius: 16px;
	padding: 28px 24px;
	max-width: 320px;
	width: 100%;
	text-align: center;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.chacc-qr-modal__panel h3 {
	margin: 0 0 6px;
	font-size: 1.1em;
}
.chacc-qr-modal__panel p {
	margin: 0 0 14px;
	color: #666;
	font-size: 0.9em;
}
.chacc-qr-modal__close {
	position: absolute;
	top: 10px;
	right: 10px;
	border: none;
	background: none;
	font-size: 1.1em;
	cursor: pointer;
	padding: 6px;
	line-height: 1;
}
.chacc-qr-modal__code {
	display: flex;
	justify-content: center;
	margin-bottom: 12px;
}
.chacc-qr-modal__code img {
	width: 200px;
	height: 200px;
	max-width: 100%;
	image-rendering: pixelated;
}
.chacc-qr-modal__link {
	word-break: break-all;
	font-size: 0.75em;
	color: #999;
	margin-bottom: 16px !important;
}

/* --- Masquer les accords --- */
.chacc-render.chacc-hide-chords .chord {
	display: none;
}

/* --- Bouton favori --- */
.chacc-btn[data-action="toggle-favorite"].is-active {
	color: #b45309;
	border-color: #b45309;
}

/* --- Karaoké minute : ligne en cours pendant le défilement auto --- */
.chacc-current-line {
	background: rgba(251, 191, 36, 0.25);
	border-radius: 4px;
	transition: background 0.25s ease;
}

/* --- Vue scène : plein écran, fond sombre, gros texte --- */
.chacc-chanson.chacc-scene-active {
	position: fixed;
	inset: 0;
	z-index: 9999;
	overflow-y: auto;
	background: #111827;
	color: #f9fafb;
	padding: 32px 40px;
}
.chacc-chanson.chacc-scene-active .chacc-badge {
	background: rgba(255, 255, 255, 0.1);
	color: #f9fafb;
}
.chacc-chanson.chacc-scene-active .chacc-toolbar {
	background: transparent;
	border-bottom-color: rgba(255, 255, 255, 0.15);
}
.chacc-chanson.chacc-scene-active .chacc-toolbar__group {
	border-right-color: rgba(255, 255, 255, 0.2);
}
.chacc-chanson.chacc-scene-active .chacc-btn {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.2);
	color: #f9fafb;
}
.chacc-chanson.chacc-scene-active .chacc-render {
	font-size: 1.3em !important;
	line-height: 2;
}
.chacc-chanson.chacc-scene-active .chacc-render .chord {
	color: #fbbf24;
}
.chacc-chanson.chacc-scene-active .chacc-chord-grid {
	border-color: rgba(255, 255, 255, 0.15);
}
.chacc-chanson.chacc-scene-active .chacc-chord-grid__title {
	color: rgba(255, 255, 255, 0.6);
}
.chacc-chanson.chacc-scene-active .chacc-chord-svg__string {
	stroke: #f9fafb;
}
.chacc-chanson.chacc-scene-active .chacc-chord-svg__fret--nut {
	stroke: #fff;
}
.chacc-chanson.chacc-scene-active .chacc-chord-svg__dot {
	fill: #fbbf24;
}
.chacc-chanson.chacc-scene-active .chacc-chord-svg__barre {
	stroke: #fbbf24;
}
.chacc-chanson.chacc-scene-active .chacc-chord-svg__mark,
.chacc-chanson.chacc-scene-active .chacc-chord-svg__position {
	fill: #f9fafb;
}

/* --- Setlist imprimable --- */
.chacc-setlist-print__song {
	page-break-after: always;
	margin-bottom: 40px;
	scroll-margin-top: 90px;
}
.chacc-setlist-print__song--current {
	outline: 3px solid #b45309;
	outline-offset: 6px;
	border-radius: 12px;
}

.chacc-setlist-leader,
.chacc-setlist-follow {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	background: #f3f4f6;
	border-radius: 10px;
	padding: 10px 14px;
	margin-bottom: 18px;
	font-size: 0.9em;
	position: sticky;
	top: 0;
	z-index: 100;
}
.chacc-setlist-leader button {
	border: 1px solid #ddd;
	background: #fff;
	border-radius: 8px;
	padding: 6px 12px;
	cursor: pointer;
}
.chacc-setlist-print__toolbar {
	display: flex;
	gap: 8px;
	margin-bottom: 14px;
}
.chacc-setlist-print__toolbar button {
	border: 1px solid #ddd;
	background: #fff;
	border-radius: 8px;
	padding: 8px 14px;
	cursor: pointer;
}

/* --- Impression : mise en page propre pour l'export PDF via le navigateur --- */
@media print {
	@page {
		margin: 1.5cm;
	}

	.chacc-no-print,
	.chacc-toolbar,
	.chacc-chord-grid,
	.chacc-qr-modal,
	.chacc-recherche__filters {
		display: none !important;
	}

	.chacc-chanson.chacc-scene-active {
		position: static;
		background: none;
		color: inherit;
	}

	.chacc-chanson,
	.chacc-setlist-print {
		background: #fff !important;
		color: #000 !important;
		border: none !important;
		box-shadow: none !important;
		max-width: 100%;
	}

	.chacc-badge {
		background: #f3f4f6 !important;
		color: #000 !important;
		border: 1px solid #ccc !important;
	}

	.chacc-render .chord {
		color: #000 !important;
		font-weight: 700;
	}

	.chacc-song-line,
	.row {
		page-break-inside: avoid;
	}

	.chacc-setlist-print__song {
		page-break-inside: avoid;
	}

	.chacc-setlist-print__toolbar {
		display: none !important;
	}
}

@media (min-width: 700px) {
	.chacc-grid {
		grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
	}
}

/* ==========================================================================
   Thème sombre manuel (bouton 🌓, préférence mémorisée par appareil).
   Appliqué via l'attribut data-chacc-theme="dark" sur <html>.
   ========================================================================== */

html[data-chacc-theme="dark"] body {
	background: #111827;
	color: #f3f4f6;
}

html[data-chacc-theme="dark"] .chacc-chanson {
	background: #1f2937;
	border-color: #374151;
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-chanson .chacc-badge {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.12);
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-toolbar {
	background: rgba(255, 255, 255, 0.05);
}
html[data-chacc-theme="dark"] .chacc-toolbar__group {
	border-right-color: rgba(255, 255, 255, 0.12);
}
html[data-chacc-theme="dark"] .chacc-btn {
	background: rgba(255, 255, 255, 0.06);
	border-color: rgba(255, 255, 255, 0.15);
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-render .chord {
	color: #fbbf24;
}
html[data-chacc-theme="dark"] .chacc-current-line {
	background: rgba(251, 191, 36, 0.35);
}
html[data-chacc-theme="dark"] .chacc-chord-grid {
	border-color: #374151;
}
html[data-chacc-theme="dark"] .chacc-chord-grid__title {
	color: #9ca3af;
}
html[data-chacc-theme="dark"] .chacc-chord-svg__string {
	stroke: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-chord-svg__fret--nut {
	stroke: #fff;
}
html[data-chacc-theme="dark"] .chacc-chord-svg__dot {
	fill: #fbbf24;
}
html[data-chacc-theme="dark"] .chacc-chord-svg__barre {
	stroke: #fbbf24;
}
html[data-chacc-theme="dark"] .chacc-chord-svg__mark,
html[data-chacc-theme="dark"] .chacc-chord-svg__position {
	fill: #f3f4f6;
}

html[data-chacc-theme="dark"] .chacc-recherche__input,
html[data-chacc-theme="dark"] .chacc-recherche__filter {
	background: #1f2937;
	border-color: #374151;
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-card {
	background: #1f2937;
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-recherche__empty,
html[data-chacc-theme="dark"] .chacc-card__artiste {
	color: #9ca3af;
}
html[data-chacc-theme="dark"] .chacc-history-chip {
	background: rgba(255, 255, 255, 0.08);
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-card__fav {
	background: rgba(0, 0, 0, 0.4);
	color: #f3f4f6;
}

html[data-chacc-theme="dark"] .chacc-qr-modal__panel {
	background: #1f2937;
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-qr-modal__panel p {
	color: #9ca3af;
}
html[data-chacc-theme="dark"] .chacc-qr-modal__close {
	color: #f3f4f6;
}

html[data-chacc-theme="dark"] .chacc-setlist-print {
	background: #111827;
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-setlist-leader,
html[data-chacc-theme="dark"] .chacc-setlist-follow {
	background: rgba(255, 255, 255, 0.06);
	color: #f3f4f6;
}
html[data-chacc-theme="dark"] .chacc-setlist-leader button,
html[data-chacc-theme="dark"] .chacc-setlist-print__toolbar button {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.15);
	color: #f3f4f6;
}

/* Le mode sombre ne s'applique jamais à l'impression : on force toujours
   un rendu clair et lisible sur papier, quel que soit le thème à l'écran. */
@media print {
	html[data-chacc-theme="dark"] .chacc-chanson,
	html[data-chacc-theme="dark"] .chacc-setlist-print,
	html[data-chacc-theme="dark"] body {
		background: #fff !important;
		color: #000 !important;
	}
	html[data-chacc-theme="dark"] .chacc-render .chord,
	html[data-chacc-theme="dark"] .chacc-chord-svg__dot,
	html[data-chacc-theme="dark"] .chacc-chord-svg__barre {
		color: #000 !important;
		fill: #000 !important;
		stroke: #000 !important;
	}
}
