/* ==========================================================================
   VIERGE.CSS - Feuille de style dédiée aux tablatures vierges imprimables
   Thème : Lutherie & Papier à musique, rendu d'impression A4 haute fidélité
   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;

	--tab-line-color: #292524;
	--tab-bar-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;
}

/* Utilitaires pour 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: 1200px;
	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: 12mm 15mm 10mm 15mm;
	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 MUSICAL)
   ========================================================================== */

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

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

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

.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: 2fr 1.5fr 1fr 1fr 1fr;
	gap: 12px;
	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);
}

/* ==========================================================================
   SECTION DIAGRAMMES D'ACCORDS VIERGES (OPTIONNELLE)
   ========================================================================== */

.chord-grids-section {
	margin-top: 10px;
	padding-top: 8px;
	border-top: 1px dashed var(--border-color);
}

.chord-grids-row {
	display: flex;
	justify-content: space-around;
	align-items: flex-end;
	gap: 8px;
}

.chord-grid-box {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 52px;
}

.chord-name-slot {
	font-size: 0.85rem;
	font-weight: 700;
	height: 18px;
	border-bottom: 1px dotted #78716c;
	width: 100%;
	text-align: center;
	margin-bottom: 4px;
	outline: none;
}

.chord-name-slot:focus {
	background-color: #fef3c7;
}

.chord-grid-svg {
	display: block;
	width: 48px;
	height: 54px;
}

/* ==========================================================================
   SYSTÈMES DE TABLATURES (PORTÉES 6 CORDES)
   ========================================================================== */

.systems-container {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 16px;
}

.tab-system {
	display: flex;
	flex-direction: column;
	width: 100%;
	break-inside: avoid;
	page-break-inside: avoid;
}

.system-lane-chords {
	height: 16px;
	display: flex;
	font-family: var(--font-stack);
	font-size: 0.8rem;
	font-weight: 600;
	color: #000000;
	padding-left: 36px;
	user-select: none;
}

.system-body {
	display: flex;
	align-items: stretch;
	height: 44px;
	position: relative;
}

/* Clé TAB verticale à gauche */
.system-clef {
	width: 32px;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	font-family: var(--font-mono);
	font-weight: 900;
	font-size: 0.85rem;
	line-height: 1.1;
	color: #000000;
	border-right: 2px solid #000000;
	padding-right: 4px;
	user-select: none;
}

.clef-letter {
	display: block;
}

/* Grille des 6 lignes de cordes */
.system-staff {
	flex: 1;
	position: relative;
	border-right: 2px solid #000000;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}

.staff-string {
	width: 100%;
	height: 1px;
	background-color: var(--tab-line-color);
	position: relative;
}

.string-label {
	position: absolute;
	left: -24px;
	top: -6px;
	font-size: 0.65rem;
	font-family: var(--font-mono);
	font-weight: 700;
	color: #44403c;
	width: 16px;
	text-align: right;
	user-select: none;
}

/* Barres de mesure verticales */
.system-bars-overlay {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	pointer-events: none;
	display: flex;
	justify-content: space-evenly;
}

.bar-divider {
	width: 1px;
	height: 100%;
	background-color: var(--tab-bar-color);
}

.system-lane-notes {
	height: 12px;
	padding-left: 36px;
}

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

.sheet-footer {
	margin-top: 10px;
	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 12mm 8mm 12mm;
	}

	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;
	}

	.tab-system {
		break-inside: avoid !important;
		page-break-inside: avoid !important;
	}

	.staff-string {
		background-color: #000000 !important;
		height: 1px !important;
	}

	.system-clef,
	.system-staff {
		border-color: #000000 !important;
	}

	.bar-divider {
		background-color: #000000 !important;
	}

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

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

/* Écrans mobiles et étroits */
@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;
	}
}
