/**
 * Lernset-Bibliothek styles.
 * Scoped under .mlb-enhanced-library (tab) and .mlb-share-overlay (share
 * modal). Reuses the MeineLernbox visual language (rounded cards, soft
 * shadows, blue accent). Responsive: the grid collapses to one column on
 * small screens and the share modal becomes near-full-width.
 */

/* ---- shared helpers ------------------------------------------------- */
.mlb-enhanced-library .mlb-hidden,
.mlb-share-overlay .mlb-hidden {
	display: none !important;
}

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

/* Hide the legacy plugin header ONLY on the Lernset-Bibliothek tab. The tab
   wrapper carries .ays-pd-content-import and the header lives inside it, so
   this is scoped to that tab — other views and the .mlb-word-header used in
   regular Lernset views are untouched. */
.ays-pd-content-import .ays-pd-header-wrap {
	display: none !important;
}

/* ---- tab shell + toolbar -------------------------------------------- */
.mlb-enhanced-library {
	box-sizing: border-box;
	width: 100%;
	padding: 4px 2px 24px;
}

.mlb-enhanced-library * {
	box-sizing: border-box;
}

.mlb-library-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	margin: 0 0 18px;
}

.mlb-library-search {
	flex: 1 1 100%;
	min-width: 200px;
}

.mlb-library-search-input {
	width: 100%;
	min-height: 44px;
	padding: 10px 14px;
	border: 1px solid rgba(14, 41, 74, 0.15);
	border-radius: 12px;
	background: #fff;
	font-size: 1em;
}

.mlb-library-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.mlb-library-filter {
	min-height: 44px;
	max-width: 100%;
	padding: 9px 12px;
	border: 1px solid rgba(14, 41, 74, 0.15);
	border-radius: 12px;
	background: #fff;
	font-size: 0.95em;
	cursor: pointer;
}

.mlb-library-search-input:focus,
.mlb-library-filter:focus {
	outline: 3px solid rgba(37, 99, 235, 0.35);
	outline-offset: 1px;
	border-color: #2563eb;
}

/* ---- card grid: two columns on desktop, one on mobile --------------- */
.mlb-library-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 20px;
}

@media (min-width: 700px) {
	.mlb-library-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* ---- library card (reference layout) -------------------------------- */
.mlb-library-card {
	display: flex;
	flex-direction: column;
	padding: 26px 28px;
	border: 1px solid #e3e8f0;
	border-radius: 18px;
	background: #fff;
	box-shadow: 0 10px 26px rgba(14, 41, 74, 0.06);
	cursor: pointer;
	transition: box-shadow 0.18s ease, transform 0.12s ease, border-color 0.18s ease;
}

.mlb-library-card:hover {
	border-color: #c7d2fe;
	box-shadow: 0 14px 32px rgba(14, 41, 74, 0.1);
	transform: translateY(-2px);
}

.mlb-library-card:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.4);
	outline-offset: 2px;
}

.mlb-library-card-top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
}

.mlb-library-card-title {
	margin: 0;
	font-size: 1.5em;
	font-weight: 800;
	line-height: 1.25;
	color: #0e294a;
	overflow-wrap: anywhere;
}

.mlb-library-level-badge {
	flex: 0 0 auto;
	padding: 6px 16px;
	border-radius: 999px;
	font-size: 0.8em;
	font-weight: 700;
	line-height: 1.4;
	white-space: nowrap;
}

.mlb-library-level-easy { background: rgba(88, 204, 2, 0.16); color: #3f8f00; }
.mlb-library-level-mid  { background: rgba(37, 99, 235, 0.12); color: #1d4ed8; }
.mlb-library-level-adv  { background: rgba(139, 92, 246, 0.16); color: #6d28d9; }

.mlb-library-card-accent {
	display: block;
	width: 46px;
	height: 5px;
	margin: 14px 0 0;
	border-radius: 999px;
	background: #2563eb;
}

.mlb-library-card-description {
	margin: 18px 0 0;
	font-size: 1.02em;
	line-height: 1.55;
	color: #5b6675;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	overflow-wrap: anywhere;
}

.mlb-library-card-divider {
	height: 1px;
	margin: 22px 0 16px;
	background: #eaeef4;
}

.mlb-library-card-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px 22px;
	font-size: 0.98em;
	color: #5b6675;
}

.mlb-library-card-count,
.mlb-library-card-subject {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.mlb-library-meta-icon {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	color: #94a3b8;
}

.mlb-library-card-imported {
	align-self: flex-start;
	margin-top: 14px;
	padding: 4px 12px;
	border-radius: 999px;
	background: rgba(22, 163, 74, 0.12);
	color: #15803d;
	font-size: 0.82em;
	font-weight: 700;
}

.mlb-lib-detail-title {
	margin: 0;
	font-size: 1.4em;
	font-weight: 800;
	line-height: 1.3;
	color: #0e294a;
}

.mlb-lib-card-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 2px;
}

.mlb-lib-chip {
	display: inline-flex;
	align-items: center;
	padding: 3px 10px;
	border-radius: 999px;
	background: rgba(37, 99, 235, 0.1);
	color: #1d4ed8;
	font-size: 0.78em;
	font-weight: 600;
	line-height: 1.4;
}

.mlb-lib-detail-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 18px;
}

.mlb-lib-btn {
	flex: 1 1 auto;
	min-height: 42px;
	padding: 9px 16px;
	border: 0;
	border-radius: 10px;
	font-size: 0.95em;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.mlb-lib-import {
	background: #2563eb;
	color: #fff;
}

.mlb-lib-import:hover {
	background: #1d4ed8;
}

.mlb-lib-import.is-loading {
	cursor: progress;
	opacity: 0.7;
}

.mlb-lib-import.is-imported {
	background: #16a34a;
	color: #fff;
	cursor: default;
	opacity: 1;
}

.mlb-lib-btn:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.4);
	outline-offset: 2px;
}

.mlb-lib-delete {
	flex: 1 1 auto;
	min-height: 38px;
	padding: 8px 14px;
	border: 1px solid rgba(185, 28, 28, 0.4);
	border-radius: 10px;
	background: #fff;
	color: #b91c1c;
	font-size: 0.88em;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.mlb-lib-delete:hover {
	background: rgba(185, 28, 28, 0.08);
}

.mlb-lib-delete:focus-visible {
	outline: 3px solid rgba(185, 28, 28, 0.35);
	outline-offset: 2px;
}

.mlb-lib-delete.is-loading {
	opacity: 0.6;
	cursor: progress;
}

.mlb-lib-status {
	flex-basis: 100%;
	margin: 4px 0 0;
	font-size: 0.85em;
	font-weight: 600;
}

.mlb-lib-status.is-success { color: #15803d; }
.mlb-lib-status.is-error { color: #b91c1c; }
.mlb-lib-status.is-warn { color: #b45309; }

/* ---- empty + loading ------------------------------------------------ */
.mlb-library-empty {
	margin: 28px 0;
	text-align: center;
	font-style: italic;
	color: #6b7280;
}

.mlb-library-loading {
	display: none;
	justify-content: center;
	padding: 22px 0;
}

.mlb-library-loading.is-active {
	display: flex;
}

.mlb-library-spinner {
	width: 28px;
	height: 28px;
	border: 3px solid rgba(37, 99, 235, 0.25);
	border-top-color: #2563eb;
	border-radius: 50%;
	animation: mlb-lib-spin 0.8s linear infinite;
}

@keyframes mlb-lib-spin {
	to { transform: rotate(360deg); }
}

.mlb-library-more {
	display: flex;
	justify-content: center;
	margin-top: 18px;
}

.mlb-library-more-btn {
	min-height: 42px;
	padding: 9px 22px;
	border: 1px solid rgba(37, 99, 235, 0.4);
	border-radius: 10px;
	background: #fff;
	color: #1d4ed8;
	font-weight: 600;
	cursor: pointer;
}

/* ---- detail / preview ----------------------------------------------- */
.mlb-library-detail {
	padding: 4px 2px 8px;
}

.mlb-library-detail:focus {
	outline: none;
}

.mlb-lib-back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 14px;
	padding: 8px 14px;
	border: 0;
	border-radius: 10px;
	background: rgba(14, 41, 74, 0.06);
	color: #0e294a;
	font-weight: 600;
	cursor: pointer;
}

.mlb-lib-back:hover {
	background: rgba(14, 41, 74, 0.12);
}

.mlb-lib-detail-desc {
	margin: 12px 0 0;
	line-height: 1.55;
	color: #374151;
}

.mlb-lib-cards-heading {
	margin: 22px 0 10px;
	font-size: 1em;
	font-weight: 700;
	color: #0e294a;
}

/* ---- preview word cards: SCOPED to the library detail view only -------
   These rules intentionally live only under .mlb-library-detail so they can
   never affect the listing cards, the user's own Lernset dashboard, imported
   private Lernset views, normal word rows, or games/flashcards. A friendly,
   Duolingo-inspired learning-card style tuned for readability (generous
   sizing/spacing, strong-but-calm contrast, large touch targets). */
.mlb-library-detail .mlb-lib-words {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 16px;
}

.mlb-library-detail .mlb-lib-word {
	display: flex;
	flex-direction: column;
	background: #ffffff;
	border: 1px solid #dcebfa;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 4px 14px rgba(28, 176, 246, 0.08);
}

.mlb-library-detail .mlb-lib-word-media {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1 / 1;
	padding: 0;
	background: #f5faff;
	width: 100%;
}

/* graceful fallback where aspect-ratio is unsupported */
@supports not (aspect-ratio: 1 / 1) {
	.mlb-library-detail .mlb-lib-word-media {
		min-height: 132px;
	}
}

.mlb-library-detail .mlb-lib-word-image {
	max-width: 100%;
	max-height: 100%;
	object-fit: cover;
	object-position: center;
	width: 100%;
	height: 100%;
	border-radius: 12px 12px 0 0;
}

.mlb-library-detail .mlb-lib-word-audio {
	position: absolute;
	top: 10px;
	right: 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0.5em;
	border: 1px solid #dcebfa;
	border-radius: 12px;
	background: #eaf6ff;
	color: #1cb0f6;
	cursor: pointer;
	box-shadow: 0 2px 8px #1cb0f633;
	transition: background-color .15s ease, transform .08s ease;
}

.mlb-library-detail .mlb-lib-word-audio svg {
	width: 22px;
	height: 22px;
}

.mlb-library-detail .mlb-lib-word-audio:hover {
	background: #d6ecff;
}

.mlb-library-detail .mlb-lib-word-audio:active {
	transform: scale(0.94);
}

.mlb-library-detail .mlb-lib-word-audio:focus-visible {
	outline: 3px solid rgba(28, 176, 246, 0.55);
	outline-offset: 2px;
}

.mlb-library-detail .mlb-lib-word-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 14px 16px 16px;
}

.mlb-library-detail .mlb-lib-word-term {
	font-size: 1.15em;
	font-weight: 700;
	line-height: 1.35;
	color: #1f2937;
	overflow-wrap: anywhere;
}

.mlb-library-detail .mlb-lib-word-translation {
	font-size: 1em;
	font-weight: 500;
	line-height: 1.45;
	color: #4b5563;
	overflow-wrap: anywhere;
}

.mlb-library-detail .mlb-lib-words-more {
	margin: 16px 0 0;
	font-style: italic;
	color: #4b5563;
}

@media (prefers-reduced-motion: reduce) {
	.mlb-library-detail .mlb-lib-word-audio {
		transition: none;
	}
	.mlb-library-detail .mlb-lib-word-audio:active {
		transform: none;
	}
}

/* ---- share button (in the word header) ------------------------------ */
.mlb-share-set-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 38px;
	padding: 7px 14px;
	border: 0;
	border-radius: 10px;
	background: #2563eb;
	color: #fff;
	font-size: 0.9em;
	font-weight: 600;
	cursor: pointer;
}

.mlb-share-set-btn:hover { background: #1d4ed8; }

.mlb-share-set-btn:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.4);
	outline-offset: 2px;
}

/* ---- share modal ---------------------------------------------------- */
.mlb-share-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 100000;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(15, 23, 42, 0.45);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
}

.mlb-share-overlay.mlb-share-open {
	display: flex;
}

.mlb-share-dialog {
	width: 100%;
	max-width: 460px;
	max-height: 90vh;
	overflow-y: auto;
	padding: 22px;
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 24px 60px rgba(14, 41, 74, 0.3);
}

.mlb-share-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.mlb-share-title {
	margin: 0;
	font-size: 1.15em;
	font-weight: 700;
	color: #0e294a;
}

.mlb-share-close {
	border: 0;
	background: transparent;
	font-size: 1.6em;
	line-height: 1;
	color: #6b7280;
	cursor: pointer;
}

.mlb-share-intro {
	margin: 8px 0 16px;
	font-size: 0.92em;
	color: #4b5563;
}

.mlb-share-field {
	margin-bottom: 14px;
}

.mlb-share-field label {
	display: block;
	margin-bottom: 5px;
	font-size: 0.88em;
	font-weight: 600;
	color: #0e294a;
}

.mlb-share-input {
	width: 100%;
	min-height: 42px;
	padding: 9px 12px;
	border: 1px solid rgba(14, 41, 74, 0.18);
	border-radius: 10px;
	font-size: 0.95em;
	font-family: inherit;
}

textarea.mlb-share-input {
	min-height: 76px;
	resize: vertical;
}

.mlb-share-input:focus {
	outline: 3px solid rgba(37, 99, 235, 0.35);
	outline-offset: 1px;
	border-color: #2563eb;
}

.mlb-share-status {
	min-height: 1.1em;
	margin: 4px 0 0;
	font-size: 0.88em;
	font-weight: 600;
}

.mlb-share-status.is-success { color: #15803d; }
.mlb-share-status.is-error { color: #b91c1c; }

.mlb-share-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 16px;
}

.mlb-share-cancel {
	min-height: 42px;
	padding: 9px 18px;
	border: 1px solid rgba(14, 41, 74, 0.18);
	border-radius: 10px;
	background: #fff;
	color: #0e294a;
	font-weight: 600;
	cursor: pointer;
}

.mlb-share-submit {
	min-height: 42px;
	padding: 9px 20px;
	border: 0;
	border-radius: 10px;
	background: #2563eb;
	color: #fff;
	font-weight: 600;
	cursor: pointer;
}

.mlb-share-submit:hover { background: #1d4ed8; }
.mlb-share-submit:disabled { opacity: 0.7; cursor: progress; }

body.mlb-modal-lock {
	overflow: hidden;
}

/* ---- responsive ----------------------------------------------------- */
@media (max-width: 600px) {
	.mlb-library-toolbar {
		flex-direction: column;
		align-items: stretch;
	}
	.mlb-library-filters {
		justify-content: stretch;
	}
	.mlb-library-filter {
		flex: 1 1 auto;
	}
	.mlb-library-card {
		padding: 20px;
	}
	.mlb-library-card-title {
		font-size: 1.3em;
	}
	.mlb-library-card-meta {
		gap: 10px 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mlb-library-spinner { animation-duration: 1.6s; }
	.mlb-lib-btn,
	.mlb-share-submit { transition: none; }
}

/* ---- dark mode (device prefers-color-scheme: dark) ------------------ */
@media (prefers-color-scheme: dark) {
	.mlb-library-search-input,
	.mlb-library-filter { background: #262a33; border-color: #333a46; color: #e8edf4; }
	.mlb-library-card { background: #1e2128; border-color: #333a46; box-shadow: 0 10px 26px rgba(0,0,0,.5); }
	.mlb-library-card:hover { border-color: #3a4a66; }
	.mlb-library-card-title, .mlb-lib-detail-title, .mlb-lib-cards-heading { color: #e8edf4; }
	.mlb-library-card-description, .mlb-library-card-meta, .mlb-library-empty,
	.mlb-lib-words-more, .mlb-lib-detail-desc { color: #aab4c2; }
	.mlb-library-card-divider { background: #333a46; }
	.mlb-library-meta-icon { color: #7e8b9c; }
	.mlb-library-more-btn { background: #1e2128; color: #5db4f6; border-color: rgba(37,99,235,.6); }
	.mlb-lib-chip { background: rgba(37,99,235,.22); color: #9ecbff; }
	.mlb-lib-back { background: #262a33; color: #e8edf4; }
	.mlb-library-detail .mlb-lib-word { background: #1e2128; border-color: #333a46; }
	.mlb-library-detail .mlb-lib-word-media { background: #20262f; }
	.mlb-library-detail .mlb-lib-word-term { color: #e8edf4; }
	.mlb-library-detail .mlb-lib-word-translation { color: #aab4c2; }
	.mlb-library-detail .mlb-lib-word-audio { background: #11202b; border-color: #1f3a4d; color: #3cc0ff; }
	.mlb-share-overlay { background: rgba(0,0,0,.62); }
	.mlb-share-dialog { background: #1e2128; color: #e8edf4; box-shadow: 0 24px 60px rgba(0,0,0,.6); }
	.mlb-share-title, .mlb-share-field label { color: #e8edf4; }
	.mlb-share-intro { color: #aab4c2; }
	.mlb-share-close { color: #aab4c2; }
	.mlb-share-close:hover { background: #262a33; color: #e8edf4; }
	.mlb-share-input { background: #262a33; border-color: #333a46; color: #e8edf4; }
	.mlb-share-cancel { background: #262a33; color: #e8edf4; border-color: #333a46; }
}
