/* ===== ACCESSIBILITY ===== */
:root {
	--green-dark: #00483c;
	--green-darker: #1a2e28;
	--green-text: #313e3b;
	--yellow: #d5d52b;
	--yellow-dark: #b8b824;
	--radius: 6px;
}

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

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-5px) } to { opacity: 1; transform: translateY(0) } }
.fade-in  { animation: fadeIn 0.2s ease }
.slide-down { animation: slideDown 0.2s ease }
.sidebar-nav::-webkit-scrollbar       { width: 4px }
.sidebar-nav::-webkit-scrollbar-track { background: transparent }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(213,213,43,.45); border-radius: 2px }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden }

body {
	font-family: 'Space Grotesk', sans-serif;
	background: #f3f7f5;
	color: var(--green-text);
}

#app { display: block; }

/* ===== PHILO-LYCEE THEME OVERRIDES (TAILWIND UTILITIES) ===== */
.bg-gray-50, .bg-slate-50  { background-color: #f3f7f5 !important; }
.bg-slate-900              { background-color: var(--green-darker) !important; }
.hover\:bg-slate-800:hover { background-color: #28423b !important; }
.text-slate-900, .text-slate-800 { color: #21332e !important; }
.text-slate-700, .text-slate-600 { color: #3a4c47 !important; }
.text-slate-500, .text-slate-400 { color: #667a74 !important; }
.text-slate-300            { color: rgba(255,255,255,.84) !important; }

.bg-emerald-700, .bg-emerald-800   { background-color: var(--green-dark) !important; }
.hover\:bg-emerald-800:hover       { background-color: #006457 !important; }
.text-emerald-700, .text-emerald-800, .text-emerald-900 { color: var(--green-dark) !important; }
.bg-emerald-50, .bg-emerald-100    { background-color: rgba(0,72,60,.08) !important; }
.border-emerald-200, .border-emerald-500 { border-color: rgba(0,72,60,.2) !important; }

.bg-amber-50  { background-color: rgba(213,213,43,.15) !important; }
.border-amber-200 { border-color: rgba(213,213,43,.42) !important; }
.text-amber-700, .text-amber-800 { color: #5d5d14 !important; }

.border-slate-700  { border-color: rgba(255,255,255,.12) !important; }
.border-slate-200, .border-gray-200 { border-color: rgba(0,0,0,.09) !important; }
.bg-white {
	background: #ffffff !important;
	box-shadow: 0 6px 22px rgba(0,0,0,.05);
}

.rounded, .rounded-md, .rounded-lg, .rounded-xl, .rounded-2xl {
	border-radius: var(--radius) !important;
}

.fixed.inset-y-0.left-0.z-40.w-72 {
	box-shadow: 10px 0 30px rgba(0,0,0,.22);
}

/* ===== ENTRY TYPE BADGES ===== */
.entry-type-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	font-size: 0.72rem;
	font-weight: 600;
	padding: 0.2rem 0.65rem;
	border-radius: 99px;
	border: 1px solid;
}
.entry-type-badge.type-cours   { background: rgba(0,72,60,.09); color: var(--green-dark); border-color: rgba(0,72,60,.2); }
.entry-type-badge.type-philo   { background: rgba(90,60,170,.09); color: #4c1d95; border-color: rgba(90,60,170,.2); }
.entry-type-badge.type-litt    { background: rgba(180,140,0,.12); color: #78600a; border-color: rgba(180,140,0,.28); }
.entry-type-badge.type-concept { background: rgba(0,0,0,.05); color: #374151; border-color: rgba(0,0,0,.12); }
.entry-type-badge.type-couple  { background: rgba(0,0,0,.05); color: #374151; border-color: rgba(0,0,0,.12); }
.entry-type-badge.type-argument { background: rgba(220,38,38,.08); color: #991b1b; border-color: rgba(220,38,38,.22); }

/* ===== ENTRY CONTENT — PROSE STYLES ===== */
.entry-content {
	color: #2d3d39;
	line-height: 1.72;
	font-size: 0.95rem;
}

/* Preamble (before first h2) */
.entry-preamble {
	margin-bottom: 1.5rem;
}

/* Section cards */
.section-card {
	background: #fff;
	border: 1px solid rgba(0,0,0,.08);
	border-radius: 10px;
	padding: 1.5rem 1.75rem;
	margin-bottom: 1.25rem;
	box-shadow: 0 2px 8px rgba(0,72,60,.05);
}

/* Headings */
.entry-content h1 {
	font-size: 1.5rem;
	font-weight: 700;
	color: #1a2e28;
	margin-bottom: 0.75rem;
}
.entry-content h2 {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--green-dark);
	margin-bottom: 1rem;
	padding-bottom: 0.4rem;
	border-bottom: 2px solid rgba(0,72,60,.12);
}
.entry-content h3 {
	font-size: 0.95rem;
	font-weight: 700;
	color: #2d3d39;
	margin-top: 1.25rem;
	margin-bottom: 0.5rem;
}

/* Aside blocks (Notion callouts) */
.entry-content aside {
	background: rgba(213,213,43,.13);
	border-left: 3px solid var(--yellow);
	padding: 0.85rem 1.1rem;
	border-radius: 0 var(--radius) var(--radius) 0;
	font-style: italic;
	color: #4a5042;
	margin: 0.75rem 0 1.25rem;
	font-size: 0.9rem;
}

/* Blockquotes (text extracts in corpus) */
.entry-content blockquote {
	border-left: 3px solid var(--green-dark);
	background: rgba(0,72,60,.05);
	padding: 1rem 1.25rem;
	border-radius: 0 var(--radius) var(--radius) 0;
	font-style: italic;
	color: #2d3d39;
	margin: 1rem 0;
}
.entry-content blockquote p { margin: 0 0 0.5rem; }
.entry-content blockquote p:last-child { margin-bottom: 0; }

/* Lists */
.entry-content ul, .entry-content ol {
	padding-left: 1.35rem;
	margin: 0.6rem 0;
}
.entry-content ul { list-style: disc; }
.entry-content ol { list-style: decimal; }
.entry-content li { margin-bottom: 0.3rem; }
.entry-content li > ul, .entry-content li > ol { margin: 0.2rem 0 0.2rem 0.75rem; }

/* Inline emphasis */
.entry-content strong { font-weight: 700; color: #1a2e28; }
.entry-content em     { font-style: italic; }

/* Paragraphs */
.entry-content p { margin-bottom: 0.75rem; }
.entry-content p:last-child { margin-bottom: 0; }

/* Code */
.entry-content code {
	font-family: 'JetBrains Mono', 'Fira Code', monospace;
	background: rgba(0,72,60,.08);
	padding: 0.1em 0.35em;
	border-radius: 4px;
	font-size: 0.88em;
	color: var(--green-dark);
}

/* Internal navigation links */
.entry-content .internal-link {
	color: var(--green-dark);
	text-decoration: underline;
	text-decoration-color: rgba(0,72,60,.35);
	text-underline-offset: 2px;
	cursor: pointer;
	transition: text-decoration-color 0.15s;
}
.entry-content .internal-link:hover {
	text-decoration-color: var(--green-dark);
}

/* Dead links (unresolved .md links) */
.entry-content .dead-link {
	color: #667a74;
	font-style: italic;
}

/* Horizontal rules */
.entry-content hr {
	border: none;
	border-top: 1px solid rgba(0,72,60,.12);
	margin: 1.25rem 0;
}

/* ===== IMAGES ===== */
.entry-content figure {
	margin: 1.25rem auto;
	text-align: center;
}
.entry-content figure img {
	max-width: 100%;
	height: auto;
	border-radius: var(--radius);
	display: block;
	margin: 0 auto;
	box-shadow: 0 4px 16px rgba(0,0,0,.10);
}
.entry-content figcaption {
	margin-top: 0.45rem;
	font-size: 0.8rem;
	color: #667a74;
	font-style: italic;
}

/* ===== YOUTUBE EMBEDS ===== */
.youtube-embed {
	position: relative;
	width: 100%;
	padding-top: 56.25%; /* 16:9 */
	margin: 1.25rem 0;
	border-radius: var(--radius);
	overflow: hidden;
	background: #000;
	box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.youtube-embed iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: none;
}

/* ===== CARD HOVER ===== */
.card-hover {
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card-hover:hover {
	transform: translateY(-3px);
	box-shadow: 0 12px 28px rgba(0,72,60,.14);
}

/* ===== INTERNAL LINKS (global) ===== */
.internal-link {
	color: var(--green-dark);
	text-decoration: underline;
	text-decoration-color: rgba(0,72,60,.35);
	text-underline-offset: 2px;
	cursor: pointer;
	transition: text-decoration-color 0.15s;
}
.internal-link:hover { text-decoration-color: var(--green-dark); }
.dead-link { color: #667a74; font-style: italic; }

/* ===== HIDE SCROLLBAR (internal nav) ===== */
.hide-scrollbar { -ms-overflow-style: none; }
.hide-scrollbar::-webkit-scrollbar { display: none; }

/* ===== A4 EDITOR ===== */
body.editor-page {
	overflow: hidden;
}

.editor-shell {
	font-family: 'Space Grotesk', sans-serif;
}

.editor-canvas-scroll {
	overflow: auto;
	max-width: 100%;
	padding-bottom: 0.5rem;
	overscroll-behavior: contain;
}

.editor-plan-sheet {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	min-height: 100%;
}

.editor-plan-toolbar {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem;
	border: 1px solid rgba(0,0,0,.08);
	border-radius: 14px;
	background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(247,249,248,.96));
}

.editor-plan-list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding-bottom: 0.5rem;
}

.editor-plan-row {
	border: 1px solid rgba(0,0,0,.08);
	border-radius: 14px;
	background: #fff;
	padding: 0.9rem;
	box-shadow: 0 8px 18px rgba(0,0,0,.05);
	cursor: pointer;
}

.editor-plan-row.is-active {
	border-color: rgba(0,72,60,.36);
	box-shadow: 0 0 0 2px rgba(0,72,60,.08), 0 10px 22px rgba(0,0,0,.06);
}

.editor-plan-row-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.8rem;
}

.editor-plan-kind,
.editor-plan-index,
.editor-plan-icon,
.editor-plan-remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.editor-plan-kind {
	padding: 0.28rem 0.65rem;
	background: rgba(0,72,60,.08);
	color: var(--green-dark);
	border: 1px solid rgba(0,72,60,.16);
}

.editor-plan-index {
	min-width: 1.7rem;
	height: 1.7rem;
	background: rgba(213,213,43,.18);
	color: #5d5d14;
	border: 1px solid rgba(213,213,43,.34);
}

.editor-plan-icon,
.editor-plan-remove {
	border: 1px solid rgba(0,0,0,.08);
	background: #fff;
	width: 1.9rem;
	height: 1.9rem;
	color: #3a4c47;
	cursor: pointer;
}

.editor-plan-remove {
	color: #991b1b;
	border-color: rgba(220,38,38,.18);
	background: rgba(220,38,38,.06);
}

.editor-plan-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.75rem;
}

.editor-plan-grid label {
	display: block;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: #667a74;
}

.editor-plan-grid input,
.editor-plan-grid select {
	display: block;
	width: 100%;
	margin-top: 0.35rem;
	padding: 0.58rem 0.75rem;
	border: 1px solid rgba(0,0,0,.12);
	border-radius: 10px;
	background: #fff;
	color: #21332e;
	font-family: inherit;
	font-size: 0.92rem;
}

.editor-plan-grid select {
	appearance: none;
}

.editor-plan-grid input:focus,
.editor-plan-grid select:focus,
.editor-plan-toolbar button:focus,
.editor-plan-row button:focus {
	outline: 2px solid rgba(0,72,60,.18);
	outline-offset: 2px;
}

.editor-pages-stack {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	align-items: center;
}

.editor-sheet {
	position: relative;
	margin: 0 auto;
	flex: 0 0 auto;
}

.editor-sheet-inner {
	position: relative;
	width: 100%;
	height: 100%;
}

.editor-sheet-inner > .editor-canvas {
	position: absolute;
	left: 0;
	top: 0;
}

.editor-toc-sheet .editor-canvas {
	background-image: none;
}

.editor-toc-title {
	position: absolute;
	left: 72px;
	top: 92px;
	font-size: 2rem;
	font-weight: 700;
	letter-spacing: -0.03em;
	color: #1a2e28;
	z-index: 1;
}

.editor-toc-list {
	position: absolute;
	left: 72px;
	right: 72px;
	top: 172px;
	bottom: 88px;
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
	z-index: 1;
}

.editor-toc-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.7rem 0.8rem;
	border-bottom: 1px solid rgba(0,72,60,.12);
	background: rgba(255,255,255,.6);
	border-radius: 8px;
}

.editor-toc-row span {
	font-weight: 500;
	color: #21332e;
	min-width: 0;
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.editor-toc-row strong {
	font-size: 0.72rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--green-dark);
}

.editor-canvas-stage {
	position: relative;
	margin: 0 auto;
	transform-origin: top center;
}

.editor-page-chrome {
	position: absolute;
	left: 0;
	right: 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.55rem 0.8rem;
	font-size: 0.68rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	font-weight: 700;
	color: var(--green-text);
	pointer-events: none;
	z-index: 2;
}

.editor-page-header {
	top: 0;
	border-bottom: 1px solid rgba(0,72,60,.14);
	background: linear-gradient(to bottom, rgba(255,255,255,.95), rgba(255,255,255,.68));
}

.editor-page-footer {
	bottom: 0;
	border-top: 1px solid rgba(0,72,60,.14);
	background: linear-gradient(to top, rgba(255,255,255,.95), rgba(255,255,255,.68));
}

.editor-canvas {
	position: relative;
	width: 794px;
	height: 1123px;
	margin: 0 auto;
	background: #fff;
	border: 1px solid rgba(0,0,0,.08);
	box-shadow: 0 14px 34px rgba(0,0,0,.08);
	background-image:
		linear-gradient(to right, rgba(0,72,60,.06) 1px, transparent 1px),
		linear-gradient(to bottom, rgba(0,72,60,.06) 1px, transparent 1px);
	background-size: 8px 8px;
	background-position: 0 0;
}

.editor-canvas-blank {
	background-image: none;
}

.editor-page-grid {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background-image:
		linear-gradient(to right, rgba(0,72,60,.08) 1px, transparent 1px),
		linear-gradient(to bottom, rgba(0,72,60,.08) 1px, transparent 1px);
	background-size: 8px 8px;
	opacity: .24;
}

.editor-block {
	position: absolute;
	border: 1px solid transparent;
	border-radius: 10px;
	box-sizing: border-box;
	overflow: hidden;
	background-clip: padding-box;
}

.editor-block.is-selected {
	border-color: var(--green-dark);
	box-shadow: 0 0 0 2px rgba(0,72,60,.12);
}

.editor-block-handle {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.35rem 0.55rem;
	background: rgba(255,255,255,.9);
	border-bottom: 1px dashed rgba(0,0,0,.08);
	cursor: move;
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
}

.editor-drag-grip {
	width: 18px;
	height: 10px;
	display: inline-block;
	background: radial-gradient(circle, rgba(0,72,60,.48) 1.2px, transparent 1.3px) 0 0 / 6px 5px;
	opacity: .7;
}

.editor-block-label {
	font-size: 0.65rem;
	text-transform: uppercase;
	letter-spacing: 0.16em;
	font-weight: 700;
	color: var(--green-text);
}

.editor-block-body {
	height: calc(100% - 34px);
	padding: 0.65rem 0.75rem 0.8rem;
	outline: none;
	white-space: pre-wrap;
	overflow: hidden;
	line-height: 1.5;
	word-break: break-word;
}

.editor-block.type-title .editor-block-body {
	line-height: 1.1;
}

.editor-block.type-text .editor-block-body {
	line-height: 1.65;
}

.editor-block.type-quote .editor-block-body {
	font-style: italic;
}

.editor-block.type-image {
	background: #fff;
}

.editor-image-frame {
	position: absolute;
	inset: 34px 0 0 0;
	width: 100%;
	height: calc(100% - 34px);
	background: #fff;
	overflow: hidden;
}

.editor-image {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
	background: #f3f7f5;
}

.editor-block.type-image .editor-block-handle {
	position: relative;
	z-index: 1;
}

.editor-block.type-image .editor-resize-handle {
	z-index: 2;
}

.editor-block.type-image .editor-block-body {
	display: none;
}

.editor-block.type-divider {
	background: transparent !important;
	border: none !important;
	box-shadow: none !important;
	height: 20px;
}

.editor-block.type-divider::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 2px;
	background: currentColor;
	opacity: .3;
}

.editor-block.type-divider .editor-block-handle,
.editor-block.type-divider .editor-block-body {
	display: none;
}

.editor-resize-handle {
	position: absolute;
	right: 4px;
	bottom: 4px;
	width: 14px;
	height: 14px;
	border: none;
	border-radius: 4px;
	background: var(--green-dark);
	cursor: nwse-resize;
	touch-action: none;
	opacity: .88;
	padding: 0;
}

.editor-resize-handle::after {
	content: '';
	position: absolute;
	inset: 3px;
	border-right: 2px solid rgba(255,255,255,.92);
	border-bottom: 2px solid rgba(255,255,255,.92);
}

@media (max-width: 1023px) {
	.editor-canvas-stage {
		margin-inline: auto;
	}

	.editor-shell main {
		padding-left: 0.75rem;
		padding-right: 0.75rem;
	}

	.editor-canvas-scroll {
		overflow-x: auto;
		padding-bottom: 0.75rem;
	}

	.editor-page-chrome {
		font-size: 0.6rem;
		padding-inline: 0.65rem;
	}

	.editor-plan-grid {
		grid-template-columns: 1fr;
	}
}

@media print {
	@page {
		size: A4 portrait;
		margin: 0;
	}
	body.editor-page {
		background: #fff !important;
	}
	body.editor-page .editor-shell,
	body.editor-page .editor-shell * {
		visibility: hidden !important;
	}
	body.editor-page .editor-canvas-scroll,
	body.editor-page .editor-canvas-scroll * {
		visibility: visible !important;
	}
	body.editor-page .editor-canvas-scroll {
		position: fixed;
		inset: 0;
		margin: 0;
		padding: 0;
		overflow: visible !important;
	}
	body.editor-page .editor-pages-stack {
		display: block;
		gap: 0;
	}
	body.editor-page .editor-sheet {
		break-after: page;
		page-break-after: always;
		width: 210mm !important;
		height: 297mm !important;
		margin: 0 !important;
	}
	body.editor-page .editor-sheet:last-child {
		break-after: auto;
		page-break-after: auto;
	}
	body.editor-page .editor-canvas {
		position: absolute;
		left: 0;
		top: 0;
		margin: 0;
		width: 210mm;
		height: 297mm;
		border: none;
		box-shadow: none;
		background: #fff !important;
		transform: none !important;
	}
	body.editor-page .editor-page-grid,
	body.editor-page .editor-block-handle,
	body.editor-page .editor-resize-handle {
		display: none !important;
	}
}
