/* ==========================================================================
   DIAGRAMMES.CSS - Feuille de style dédiée aux planches de diagrammes d'accords
   Thème : Lutherie & Papier à musique, impression A4 haute définition
   Zéro style inline - Conformité W3C & CSP Stricte
   ========================================================================== */

:root {
	--bg-app: #f6f4ee;
	--bg-surface: #ffffff;
	--bg-subtle: #eae5d9;
	--border-color: #dcd4c3;
	--border-focus: #b45309;

	--text-primary: #1c1917;
	--text-secondary: #57534e;
	--text-muted: #78716c;

	--accent-gold: #b45309;
	--accent-gold-hover: #92400e;

	--fret-color: #292524;
	--string-color: #1c1917;

	--font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

	--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
	--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
	--shadow-sheet: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* Réinitialisation de base */
*, *::before, *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	font-family: var(--font-stack);
	background-color: var(--bg-app);
	color: var(--text-primary);
	line-height: 1.5;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

/* Accessibilité */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

/* ==========================================================================
   BARRE D'OUTILS SUPÉRIEURE (NON IMPRIMÉE)
   ========================================================================== */

.toolbar {
	position: sticky;
	top: 0;
	z-index: 100;
	background-color: var(--bg-surface);
	border-bottom: 1px solid var(--border-color);
	box-shadow: var(--shadow-sm);
	padding: 10px 16px;
}

.toolbar-inner {
	max-width: 1250px;
	margin: 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.toolbar-left,
.toolbar-right {
	display: flex;
	align-items: center;
	gap: 10px;
}

.toolbar-options {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 16px;
	background-color: var(--bg-subtle);
	padding: 6px 14px;
	border-radius: 8px;
	border: 1px solid var(--border-color);
}

.option-item {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.85rem;
	font-weight: 500;
	color: var(--text-secondary);
}

.option-item select {
	font-family: inherit;
	font-size: 0.85rem;
	padding: 4px 8px;
	border-radius: 6px;
	border: 1px solid var(--border-color);
	background-color: var(--bg-surface);
	color: var(--text-primary);
	cursor: pointer;
}

.option-item select:focus {
	outline: 2px solid var(--border-focus);
	border-color: var(--border-focus);
}

.checkbox-label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	user-select: none;
}

.checkbox-label input[type="checkbox"] {
	cursor: pointer;
	accent-color: var(--accent-gold);
	width: 16px;
	height: 16px;
}

/* Boutons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 8px 14px;
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	border-radius: 6px;
	border: 1px solid transparent;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
	transform: scale(0.98);
}

.btn-primary {
	background-color: var(--accent-gold);
	color: #ffffff;
}

.btn-primary:hover {
	background-color: var(--accent-gold-hover);
}

.btn-secondary {
	background-color: #f5f5f4;
	color: var(--text-secondary);
	border-color: var(--border-color);
}

.btn-secondary:hover {
	background-color: #e7e5e4;
	color: var(--text-primary);
}

.btn-outline {
	background-color: transparent;
	color: var(--text-secondary);
	border-color: var(--border-color);
}

.btn-outline:hover {
	background-color: var(--bg-subtle);
	color: var(--text-primary);
}

/* ==========================================================================
   CONTENEUR ET FEUILLE A4 (SIMULATION ÉCRAN)
   ========================================================================== */

.sheet-container {
	flex: 1;
	display: flex;
	justify-content: center;
	padding: 24px 16px 40px;
}

.sheet-a4 {
	background-color: #ffffff;
	width: 210mm;
	min-height: 297mm;
	padding: 10mm 14mm 10mm 14mm;
	box-shadow: var(--shadow-sheet);
	border-radius: 4px;
	display: flex;
	flex-direction: column;
	position: relative;
	box-sizing: border-box;
}

/* ==========================================================================
   EN-TÊTE DE LA FEUILLE (CARTOUCHE PLANCHE D'ACCORDS)
   ========================================================================== */

.sheet-header {
	margin-bottom: 12px;
	border-bottom: 2px solid #1c1917;
	padding-bottom: 8px;
}

.header-main-block {
	text-align: center;
	margin-bottom: 8px;
}

.sheet-title {
	font-size: 1.6rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	color: #000000;
	outline: none;
	padding: 2px 8px;
	border-radius: 4px;
	transition: background-color 0.15s ease;
	display: inline-block;
	min-width: 250px;
}

.sheet-title:hover,
.sheet-title:focus {
	background-color: #fef3c7;
}

.sheet-hint {
	font-size: 0.75rem;
	color: var(--text-muted);
	margin-top: 2px;
}

.header-meta-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px 24px;
	font-size: 0.85rem;
}

.meta-field {
	display: flex;
	align-items: baseline;
	gap: 6px;
}

.meta-label {
	font-weight: 600;
	color: #44403c;
	font-size: 0.8rem;
	white-space: nowrap;
}

.meta-value {
	flex: 1;
	border-bottom: 1px dotted #a8a29e;
	min-height: 1.2em;
	padding: 1px 4px;
	outline: none;
	font-weight: 500;
}

.meta-value:hover,
.meta-value:focus {
	background-color: #fef3c7;
	border-bottom-style: solid;
	border-bottom-color: var(--accent-gold);
}

/* ==========================================================================
   GRILLE DES DIAGRAMMES D'ACCORDS
   ========================================================================== */

.diagrams-grid {
	flex: 1;
	display: grid;
	align-content: space-between;
	justify-items: center;
	gap: 12px 14px;
	margin: 8px 0;
}

.diagrams-grid.cols-4 {
	grid-template-columns: repeat(4, 1fr);
}

.diagrams-grid.cols-5 {
	grid-template-columns: repeat(5, 1fr);
	gap: 10px 10px;
}

.diagrams-grid.cols-6 {
	grid-template-columns: repeat(6, 1fr);
	gap: 6px 6px;
}

/* Carte de diagramme */
.diagram-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	max-width: 100px;
	break-inside: avoid;
	page-break-inside: avoid;
}

.cols-5 .diagram-card {
	max-width: 82px;
}

.cols-6 .diagram-card {
	max-width: 68px;
}

/* Emplacement du titre de l'accord */
.chord-title-slot {
	font-size: 0.95rem;
	font-weight: 700;
	width: 100%;
	text-align: center;
	border-bottom: 1px dotted #a8a29e;
	height: 22px;
	outline: none;
	margin-bottom: 4px;
	color: #000000;
	transition: background-color 0.15s ease;
}

.cols-5 .chord-title-slot {
	font-size: 0.85rem;
	height: 20px;
}

.cols-6 .chord-title-slot {
	font-size: 0.8rem;
	height: 18px;
	margin-bottom: 2px;
}

.chord-title-slot:hover,
.chord-title-slot:focus {
	background-color: #fef3c7;
	border-bottom-color: var(--accent-gold);
}

/* Conteneur interne avec SVG et repère de frette */
.diagram-inner {
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	width: 100%;
}

.fret-num-slot {
	position: absolute;
	left: -2px;
	top: 14px;
	font-size: 0.72rem;
	font-family: var(--font-mono);
	font-weight: 700;
	color: #44403c;
	width: 18px;
	text-align: right;
	outline: none;
	border-bottom: 1px dotted transparent;
}

.cols-6 .fret-num-slot {
	font-size: 0.64rem;
	left: -4px;
	top: 10px;
	width: 14px;
}

.fret-num-slot:hover,
.fret-num-slot:focus {
	background-color: #fef3c7;
	border-bottom-color: var(--accent-gold);
}

/* SVG du diagramme */
.chord-svg {
	display: block;
	width: 72px;
	height: 84px;
}

.cols-5 .chord-svg {
	width: 62px;
	height: 74px;
}

.cols-6 .chord-svg {
	width: 54px;
	height: 64px;
}

/* Emplacement inférieur pour doigté / notes */
.chord-footer-slot {
	font-size: 0.72rem;
	font-family: var(--font-mono);
	letter-spacing: 2px;
	width: 100%;
	text-align: center;
	height: 18px;
	outline: none;
	margin-top: 3px;
	border-top: 1px dotted #d6d3d1;
	color: #57534e;
	transition: background-color 0.15s ease;
}

.cols-5 .chord-footer-slot {
	font-size: 0.68rem;
	letter-spacing: 1px;
}

.cols-6 .chord-footer-slot {
	font-size: 0.62rem;
	letter-spacing: 0.5px;
	height: 16px;
	margin-top: 2px;
}

.chord-footer-slot:hover,
.chord-footer-slot:focus {
	background-color: #fef3c7;
	border-top-color: var(--accent-gold);
}

/* ==========================================================================
   PIED DE PAGE DE LA FEUILLE
   ========================================================================== */

.sheet-footer {
	margin-top: 8px;
	padding-top: 6px;
	border-top: 1px solid var(--border-color);
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 0.7rem;
	color: var(--text-muted);
}

/* ==========================================================================
   RÈGLES D'IMPRESSION HAUTE RÉSOLUTION (@media print)
   ========================================================================== */

@media print {
	@page {
		size: A4 portrait;
		margin: 8mm 10mm 8mm 10mm;
	}

	html, body {
		background: #ffffff !important;
		color: #000000 !important;
		width: 100% !important;
		height: auto !important;
		margin: 0 !important;
		padding: 0 !important;
		-webkit-print-color-adjust: exact !important;
		print-color-adjust: exact !important;
	}

	.no-print {
		display: none !important;
	}

	.sheet-container {
		padding: 0 !important;
		margin: 0 !important;
		width: 100% !important;
		background: transparent !important;
	}

	.sheet-a4 {
		box-shadow: none !important;
		border: none !important;
		border-radius: 0 !important;
		width: 100% !important;
		max-width: none !important;
		min-height: auto !important;
		margin: 0 !important;
		padding: 0 !important;
	}

	.sheet-header {
		margin-bottom: 8px !important;
		border-bottom: 2px solid #000000 !important;
	}

	.sheet-title {
		font-size: 1.5rem !important;
		color: #000000 !important;
	}

	.meta-label {
		color: #000000 !important;
	}

	.meta-value {
		border-bottom: 1px dotted #666666 !important;
	}

	.diagram-card {
		break-inside: avoid !important;
		page-break-inside: avoid !important;
	}

	.chord-title-slot {
		border-bottom: 1px dotted #444444 !important;
		color: #000000 !important;
	}

	.fret-num-slot {
		color: #000000 !important;
	}

	.chord-footer-slot {
		border-top: 1px dotted #888888 !important;
		color: #000000 !important;
	}

	.sheet-footer {
		border-top: 1px solid #999999 !important;
		color: #555555 !important;
	}
}

/* Écrans mobiles */
@media screen and (max-width: 820px) {
	.toolbar-inner {
		flex-direction: column;
		align-items: stretch;
	}

	.toolbar-options {
		justify-content: center;
	}

	.sheet-a4 {
		width: 100%;
		min-height: auto;
		padding: 16px 12px;
	}

	.header-meta-grid {
		grid-template-columns: 1fr 1fr;
	}
}
