/* VTU Syllabus Viewer – frontend
 * Direction: precise "study desk" — ruled dividers, uppercase micro-labels,
 * restrained shadows, one signature gradient (the theme's button) used only
 * for the primary action. Consumes the site theme's CS tokens (--cs-*) so the
 * widget follows light/dark scheme; fallbacks mirror the theme defaults.
 */

.vsv-wrap {
	--vsv-accent: var(--cs-color-accent, #5955D1);
	--vsv-primary: var(--cs-color-primary, #29294B);
	--vsv-secondary: var(--cs-color-secondary, #696981);
	--vsv-border: var(--cs-color-border, #E1E1E8);
	--vsv-input-bg: var(--cs-color-input, #FFFFFF);
	--vsv-input-fg: var(--cs-color-input-contrast, #29294B);
	--vsv-highlight: var(--cs-color-highlight-background, #F2F2F6);
	--vsv-surface: var(--cs-layout-background, #FFFFFF);
	--vsv-button: var(--cs-color-button, linear-gradient(180deg, #9895FF 0%, #514DCC 100%));
	--vsv-button-hover: var(--cs-color-button-hover, linear-gradient(180deg, #8E8BFF 0%, #4440B4 100%));
	--vsv-button-contrast: var(--cs-color-button-contrast, #FFFFFF);
	--vsv-shadow-rgb: var(--cs-color-box-shadow-rgb, 114, 114, 255);
	--vsv-radius: var(--cs-button-border-radius, 8px);
	--vsv-radius-lg: var(--cs-thumbnail-border-radius, 16px);
	--vsv-font-display: var(--cs-font-headings-family, 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif);
	--vsv-font-body: var(--cs-font-primary-family, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif);

	max-width: 980px;
	margin: 0 auto;
	font-family: var(--vsv-font-body);
	line-height: 1.55;
	color: var(--vsv-primary);
}

/* Finder card */
.vsv-finder {
	background: var(--vsv-surface);
	border: 1px solid var(--vsv-border);
	border-radius: var(--vsv-radius-lg);
	box-shadow: 0 5px 25px 0 rgba(var(--vsv-shadow-rgb), 0.1);
	overflow: hidden;
	position: relative;
}

/* Header */
.vsv-finder-head {
	padding: 30px 30px 22px;
	border-bottom: 1px solid var(--vsv-border);
	position: relative;
}

.vsv-finder-head::after {
	content: '';
	position: absolute;
	left: 30px;
	bottom: -1px;
	width: 56px;
	height: 3px;
	border-radius: 3px;
	background: var(--vsv-button);
}

.vsv-eyebrow {
	display: inline-block;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--vsv-secondary);
	margin-bottom: 6px;
}

.vsv-title {
	margin: 0;
	font-family: var(--vsv-font-display);
	font-size: clamp(24px, 3.4vw, 32px);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: -0.01em;
	color: var(--vsv-primary);
}

.vsv-subtitle {
	margin: 8px 0 0;
	font-size: 14px;
	color: var(--vsv-secondary);
}

/* Controls */
.vsv-controls {
	display: flex;
	gap: 16px;
	align-items: flex-end;
	padding: 22px 30px;
	background: var(--vsv-surface);
	position: relative;
}

.vsv-control-group {
	display: flex;
	flex-direction: column;
	gap: 7px;
	min-width: 0;
}

.vsv-control-scheme {
	flex: 0 0 190px;
}

.vsv-control-branch {
	flex: 1 1 260px;
}

.vsv-control-search {
	flex: 1 1 280px;
}

.vsv-control-group label {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--vsv-secondary);
}

.vsv-scheme,
.vsv-branch,
.vsv-search {
	padding: 12px 15px;
	border: 1px solid var(--vsv-border);
	border-radius: var(--vsv-radius);
	font-size: 15px;
	font-weight: 500;
	font-family: var(--vsv-font-body);
	background: var(--vsv-input-bg);
	color: var(--vsv-input-fg);
	transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	outline: none;
	width: 100%;
}

.vsv-scheme,
.vsv-branch {
	cursor: pointer;
	background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23696981"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>');
	background-repeat: no-repeat;
	background-position: right 13px center;
	background-size: 17px;
	appearance: none;
	padding-right: 40px;
}

.vsv-search {
	background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%239ca3af"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>');
	background-repeat: no-repeat;
	background-position: right 15px center;
	background-size: 17px;
	padding-right: 44px;
}

.vsv-scheme:focus,
.vsv-branch:focus,
.vsv-search:focus {
	border-color: var(--vsv-accent);
	box-shadow: 0 0 0 4px rgba(var(--vsv-shadow-rgb), 0.14);
}

/* Results meta */
.vsv-results-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 0 30px 4px;
}

.vsv-results-count {
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--vsv-secondary);
}

.vsv-results-hint {
	font-size: 12px;
	color: var(--vsv-secondary);
}

/* Results */
.vsv-results {
	padding: 12px 30px 30px;
	min-height: 240px;
	position: relative;
	max-height: 70vh;
	overflow-y: auto;

	scrollbar-width: thin;
	scrollbar-color: var(--vsv-accent) var(--vsv-border);
}

@supports not (scrollbar-color: auto) {
	.vsv-results::-webkit-scrollbar {
		width: 6px;
	}
	.vsv-results::-webkit-scrollbar-track {
		background: var(--vsv-border);
		border-radius: 3px;
	}
	.vsv-results::-webkit-scrollbar-thumb {
		background: var(--vsv-accent);
		border-radius: 3px;
	}
}

.vsv-category-section {
	margin-bottom: 8px;
}

.vsv-category-title {
	display: flex;
	align-items: center;
	gap: 10px;
	font-family: var(--vsv-font-display);
	font-weight: 700;
	font-size: 12px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--vsv-primary);
	padding: 22px 0 12px;
	margin: 0;
}

.vsv-category-section:first-child .vsv-category-title {
	padding-top: 10px;
}

.vsv-category-title::before {
	content: '';
	width: 18px;
	height: 3px;
	border-radius: 3px;
	background: var(--vsv-button);
	flex: none;
}

/* Ruled rows */
.vsv-subject-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	padding: 14px 2px;
	border-top: 1px solid var(--vsv-border);
	transition: background-color 0.2s ease, padding 0.2s ease;
	animation: vsv-fade-in-up 0.35s ease-out;
}

.vsv-subject-item:last-child {
	border-bottom: 1px solid var(--vsv-border);
}

.vsv-subject-item:hover {
	background: var(--vsv-highlight);
	padding-left: 10px;
	padding-right: 10px;
	border-radius: var(--vsv-radius);
}

.vsv-subject-info {
	flex: 1;
	min-width: 0;
}

.vsv-subject-info h4 {
	margin: 0 0 6px 0;
	color: var(--vsv-primary);
	font-family: var(--vsv-font-display);
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
}

.vsv-subject-details {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.vsv-chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 10px;
	border-radius: var(--cs-tag-border-radius, 6px);
	background: var(--vsv-highlight);
	border: 1px solid var(--vsv-border);
	color: var(--vsv-secondary);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.01em;
	white-space: nowrap;
}

.vsv-chip:first-child {
	color: var(--vsv-primary);
	background: rgba(var(--vsv-shadow-rgb), 0.08);
	border-color: transparent;
}

/* Action button — the theme's signature gradient */
.vsv-view-btn {
	background: var(--vsv-button);
	color: var(--vsv-button-contrast);
	text-decoration: none;
	padding: 11px 20px;
	border-radius: var(--vsv-radius);
	font-family: var(--vsv-font-display);
	font-weight: 600;
	font-size: 14px;
	letter-spacing: 0.01em;
	transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	display: inline-flex;
	align-items: center;
	gap: 8px;
	box-shadow: 0 4px 14px rgba(var(--vsv-shadow-rgb), 0.24);
	border: none;
	cursor: pointer;
	flex: none;
}

.vsv-view-btn::after {
	content: '→';
	font-size: 15px;
	font-weight: bold;
	transition: transform 0.2s ease;
}

.vsv-view-btn:hover {
	background: var(--vsv-button-hover);
	transform: translateY(-1px);
	box-shadow: 0 8px 20px rgba(var(--vsv-shadow-rgb), 0.32);
}

.vsv-view-btn:hover::after {
	transform: translateX(4px);
}

/* Subtle keyboard-only focus ring. Touch taps never show a thick border. */
@media (hover: hover) and (pointer: fine) {
	.vsv-view-btn:focus-visible,
	.vsv-scheme:focus-visible,
	.vsv-branch:focus-visible,
	.vsv-search:focus-visible,
	.vsv-btn-sm:focus-visible,
	.vsv-viewer-close:focus-visible {
		outline: 2px solid var(--vsv-accent);
		outline-offset: 2px;
	}
}

/* Empty states */
.vsv-no-results,
.vsv-select-branch {
	text-align: center;
	color: var(--vsv-secondary);
	padding: 48px 20px;
	font-size: 15px;
	font-weight: 500;
	background: var(--vsv-highlight);
	border-radius: var(--vsv-radius-lg);
	border: 1px dashed var(--vsv-border);
	margin: 14px 0 0;
}

.vsv-select-branch::before {
	content: '';
	display: block;
	width: 44px;
	height: 44px;
	margin: 0 auto 14px;
	background: rgba(var(--vsv-shadow-rgb), 0.12);
	border-radius: 12px;
	-webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23000"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.6" d="M12 21s-7-4.6-9.5-9A5.8 5.8 0 0112 6a5.8 5.8 0 019.5 6C19 16.4 12 21 12 21z"/><circle cx="12" cy="11" r="2.2" stroke-width="1.6"/></svg>') center / 22px 22px no-repeat;
	mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23000"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.6" d="M12 21s-7-4.6-9.5-9A5.8 5.8 0 0112 6a5.8 5.8 0 019.5 6C19 16.4 12 21 12 21z"/><circle cx="12" cy="11" r="2.2" stroke-width="1.6"/></svg>') center / 22px 22px no-repeat;
}

.vsv-no-results::before {
	content: '';
	display: block;
	width: 44px;
	height: 44px;
	margin: 0 auto 14px;
	background: rgba(var(--vsv-shadow-rgb), 0.12);
	border-radius: 12px;
	-webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23000"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.6" d="m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>') center / 22px 22px no-repeat;
	mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23000"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.6" d="m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>') center / 22px 22px no-repeat;
}

/* Spinner */
.vsv-spinner {
	width: 26px;
	height: 26px;
	margin: 20px auto;
	border: 3px solid var(--vsv-border);
	border-top-color: var(--vsv-accent);
	border-radius: 50%;
	animation: vsv-spin 0.8s linear infinite;
	display: none;
	position: relative;
}

.vsv-spinner.vsv-show {
	display: block;
}

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

@keyframes vsv-fade-in-up {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Viewer modal — native <dialog> */
.vsv-viewer {
	border: none;
	padding: 0;
	background: transparent;
	color: var(--vsv-primary);
	width: min(1100px, calc(100vw - 48px));
	max-width: none;
	height: calc(100vh - 48px);
	height: calc(100dvh - 48px);
	border-radius: var(--vsv-radius-lg);
	overflow: hidden;
	box-shadow: 0 20px 60px rgba(var(--vsv-shadow-rgb), 0.3);
}

.vsv-viewer[open] {
	display: flex;
}

.vsv-viewer::backdrop {
	background: rgba(15, 23, 42, 0.72);
	backdrop-filter: blur(3px);
}

.vsv-viewer-panel {
	display: flex;
	flex-direction: column;
	flex: 1;
	background: var(--vsv-surface);
	min-height: 0;
	position: relative;
}

.vsv-viewer-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	padding: 10px 14px;
	padding-right: 56px;
	background: var(--vsv-highlight);
	border-bottom: 1px solid var(--vsv-border);
}

.vsv-viewer-title {
	font-size: 13px;
	font-family: var(--vsv-font-display);
	font-weight: 600;
	color: var(--vsv-primary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1 1 auto;
	min-width: 0;
}

.vsv-viewer-actions {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.vsv-btn-sm {
	font-size: 12px;
	padding: 6px 12px;
	background: var(--vsv-surface);
	border: 1px solid var(--vsv-border);
	border-radius: var(--vsv-radius);
	color: var(--vsv-primary);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	font-family: var(--vsv-font-body);
	transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.vsv-btn-sm:hover {
	border-color: var(--vsv-accent);
	color: var(--vsv-accent);
	background: var(--vsv-highlight);
}

.vsv-viewer-close {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 6;
	font-size: 26px;
	line-height: 1;
	width: 40px;
	height: 40px;
	border: none;
	background: #b91c1c;
	color: #fff;
	cursor: pointer;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease, transform 0.2s ease;
}

.vsv-viewer-close:hover {
	background: #991b1b;
	transform: rotate(90deg);
}

.vsv-viewer-frame-wrap {
	position: relative;
	flex: 1;
	background: var(--vsv-highlight);
	min-height: 0;
}

.vsv-viewer-frame-wrap iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: var(--vsv-surface);
}

.vsv-viewer-loading {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	color: var(--vsv-secondary);
	font-size: 14px;
	background: var(--vsv-highlight);
}

.vsv-viewer-loading::before {
	content: '';
	width: 34px;
	height: 34px;
	border: 3px solid var(--vsv-border);
	border-top-color: var(--vsv-accent);
	border-radius: 50%;
	animation: vsv-loading-spin 0.8s linear infinite;
}

@keyframes vsv-loading-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.vsv-subject-item,
	.vsv-view-btn,
	.vsv-view-btn::after,
	.vsv-scheme,
	.vsv-branch,
	.vsv-search {
		animation: none !important;
		transition: none !important;
	}
	.vsv-view-btn:hover,
	.vsv-subject-item:hover {
		transform: none;
	}
}

@media (max-width: 768px) {
	.vsv-finder {
		margin: 10px;
		border-radius: var(--vsv-radius);
	}

	.vsv-finder-head {
		padding: 24px 20px 20px;
	}

	.vsv-finder-head::after {
		left: 20px;
	}

	.vsv-controls {
		padding: 18px 20px;
		flex-direction: column;
		align-items: stretch;
		gap: 13px;
	}

	.vsv-control-scheme,
	.vsv-control-branch,
	.vsv-control-search {
		flex: none;
	}

	.vsv-results-head {
		padding: 0 20px 2px;
		flex-direction: column;
		gap: 2px;
	}

	.vsv-results {
		padding: 10px 20px 22px;
		max-height: none;
	}

	.vsv-subject-item {
		flex-direction: column;
		align-items: stretch;
		gap: 12px;
	}

	.vsv-subject-info {
		text-align: left;
	}

	.vsv-view-btn {
		width: 100%;
		justify-content: center;
		padding: 14px 24px;
		font-size: 15px;
	}

	.vsv-viewer-bar {
		padding: 8px 12px;
		padding-right: 56px;
		gap: 8px;
	}

	.vsv-viewer-title {
		flex: 1 1 100%;
		white-space: normal;
	}
}

/* Viewer dialog on phones and tablets: near-fullscreen card with a small
   margin, instead of an edge-to-edge takeover. */
@media (max-width: 1024px) {
	.vsv-viewer {
		width: calc(100vw - 24px);
		height: calc(100vh - 24px);
		height: calc(100dvh - 24px);
		max-width: none;
		border-radius: var(--vsv-radius-lg);
	}
}

@media (max-width: 480px) {
	.vsv-controls {
		padding: 16px;
	}

	.vsv-results-head {
		padding: 0 16px 2px;
	}

	.vsv-results {
		padding: 8px 16px 18px;
	}

	.vsv-scheme,
	.vsv-branch,
	.vsv-search {
		padding: 11px 13px;
		font-size: 14px;
	}

	.vsv-subject-info h4 {
		font-size: 15px;
	}

	.vsv-no-results,
	.vsv-select-branch {
		padding: 32px 14px;
		font-size: 14px;
	}
}
