/* ============================================================
   DOCUMENTS PAGE — /documents/
   Loaded only on this page. Reads live from a shared Google Drive
   folder (see js/documents.js) — this file just styles the
   library grid and the in-page preview modal.
============================================================ */

.documents-section {
	padding-top: 40px;
}

.documents-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	margin-bottom: 32px;
}

.documents-count {
	font-size: 0.95rem;
	color: var(--text-on-dark-secondary);
	margin-top: 0;
}

@keyframes docSyncPulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.4;
	}
}

/* ---------- document grid ---------- */
.documents-grid {
	list-style: none;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 16px;
}

.doc-card {
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 22px;
	background: var(--card-bg);
	border: 1px solid var(--dark-border);
	border-radius: 8px;
	transition:
		border-color 0.3s ease,
		background 0.3s ease,
		transform 0.3s ease;
}

.doc-card:hover,
.doc-card:focus-visible {
	border-color: var(--accent);
	background: var(--elevated-surface);
	transform: translateY(-3px);
}

.doc-card:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.doc-card--skeleton {
	cursor: default;
	min-height: 132px;
	animation: docSyncPulse 1.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
	.doc-card--skeleton {
		animation: none;
		opacity: 0.6;
	}
}

.doc-card-top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 10px;
}

.doc-icon {
	width: 44px;
	height: 44px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.doc-icon--pdf {
	background: rgba(34, 211, 238, 0.1);
	border: 1px solid rgba(34, 211, 238, 0.2);
	color: var(--accent);
}

.doc-icon--docx {
	background: rgba(203, 213, 225, 0.08);
	border: 1px solid var(--dark-border);
	color: var(--text-on-dark-secondary);
}

.doc-type-badge {
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	padding: 3px 8px;
	border-radius: 4px;
	flex-shrink: 0;
}

.doc-type-badge--pdf {
	background: rgba(34, 211, 238, 0.14);
	color: var(--accent);
}

.doc-type-badge--docx {
	background: rgba(203, 213, 225, 0.12);
	color: var(--text-on-dark-secondary);
}

.doc-card h3 {
	font-family: "IBM Plex Sans", sans-serif;
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--text-on-dark);
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.doc-card-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: auto;
	padding-top: 14px;
	border-top: 1px solid var(--dark-divider);
	font-size: 0.78rem;
	color: var(--text-on-dark-muted);
}

.doc-download-btn {
	width: 32px;
	height: 32px;
	border-radius: var(--border-radius);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--text-on-dark-muted);
	background: none;
	border: none;
	cursor: pointer;
	flex-shrink: 0;
	transition:
		background 0.25s ease,
		color 0.25s ease;
}

.doc-download-btn:hover {
	background: rgba(255, 255, 255, 0.06);
	color: var(--accent);
}

.doc-download-btn:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.documents-empty,
.documents-error {
	text-align: center;
	color: var(--text-on-dark-secondary);
	padding: 50px 0;
}

.documents-error a {
	color: var(--accent);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ---------- preview modal ---------- */
.doc-preview-overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(7, 26, 38, 0.72);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	z-index: 10000;
	opacity: 0;
	visibility: hidden;
	transition:
		opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
		visibility 0.4s;
}

.doc-preview-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

.doc-preview-modal {
	position: relative;
	width: 100%;
	max-width: 640px;
	height: min(880px, 92vh);
	background: var(--section-dark);
	border: 1px solid var(--dark-border);
	border-radius: 16px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform: scale(0.96) translateY(10px);
	opacity: 0;
	transition:
		transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
		opacity 0.4s ease;
	box-shadow: 0 40px 80px rgba(0, 0, 0, 0.45);
}

.doc-preview-modal:focus {
	outline: none;
}

.doc-preview-overlay.is-open .doc-preview-modal {
	transform: scale(1) translateY(0);
	opacity: 1;
}

.doc-preview-header {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 20px 60px 20px 24px;
	border-bottom: 1px solid var(--dark-border);
}

.doc-preview-header h2 {
	flex: 1;
	font-family: "IBM Plex Sans", sans-serif;
	font-size: 1rem;
	font-weight: 500;
	color: var(--text-on-dark);
	margin: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.doc-preview-download {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 0.85rem;
	color: var(--text-on-dark-secondary);
	background: none;
	border: 1px solid var(--dark-border);
	padding: 8px 14px;
	border-radius: var(--border-radius);
	cursor: pointer;
	flex-shrink: 0;
	transition:
		border-color 0.3s ease,
		color 0.3s ease;
}

.doc-preview-download:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.doc-preview-body {
	flex: 1;
	overflow-y: auto;
	padding: 28px 24px;
	background: var(--primary-dark);
}

.doc-preview-loading,
.doc-preview-error {
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	text-align: center;
	color: var(--text-on-dark-muted);
	font-size: 0.88rem;
}

.doc-preview-error a {
	color: var(--accent);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.doc-spinner {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: 2px solid var(--dark-border);
	border-top-color: var(--accent);
	animation: docSpin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
	.doc-spinner {
		animation: none;
	}
}

@keyframes docSpin {
	to {
		transform: rotate(360deg);
	}
}

/* PDF pages — each canvas is a real page, stacked and scrolled continuously */
.doc-pdf-pages {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 20px;
}

.doc-pdf-pages canvas {
	max-width: 100%;
	height: auto;
	background: #fff;
	border-radius: 2px;
	box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.5);
}

/* Word documents — rendered inline as one continuous flowing sheet */
.doc-article {
	max-width: 520px;
	margin: 0 auto;
	background: #f4f1ea;
	color: #2b2620;
	padding: 40px 36px;
	border-radius: 2px;
	box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.4);
	font-family: "IBM Plex Sans", sans-serif;
}

.doc-article h1,
.doc-article h2,
.doc-article h3,
.doc-article h4 {
	font-family: "Libre Caslon Display", Georgia, serif;
	font-weight: 400;
	color: #2b2620;
	line-height: 1.3;
	margin: 24px 0 10px;
}

.doc-article h1:first-child,
.doc-article h2:first-child,
.doc-article h3:first-child {
	margin-top: 0;
}

.doc-article p {
	margin: 0 0 14px;
	line-height: 1.7;
	font-size: 0.92rem;
	color: #3a352c;
}

.doc-article ul,
.doc-article ol {
	margin: 0 0 14px 20px;
}

.doc-article li {
	margin-bottom: 6px;
	font-size: 0.92rem;
	color: #3a352c;
}

.doc-article table {
	width: 100%;
	border-collapse: collapse;
	margin: 18px 0;
	font-size: 0.85rem;
}

.doc-article th,
.doc-article td {
	padding: 8px 10px;
	border-bottom: 1px solid #ddd6c7;
	text-align: left;
	vertical-align: top;
}

.doc-article th {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #8a8272;
	font-weight: 600;
}

.doc-article strong {
	color: #2b2620;
}

.doc-article a {
	color: #0891a8;
	text-decoration: underline;
	text-underline-offset: 2px;
}

@media (max-width: 640px) {
	.doc-preview-overlay {
		padding: 12px;
	}

	.doc-preview-modal {
		max-width: 100%;
		height: 94vh;
		border-radius: 14px;
	}

	.doc-preview-header {
		padding: 18px 54px 18px 18px;
	}

	.doc-article {
		padding: 28px 22px;
	}
}
