/* 作品投票系統 — 前端樣式 */

:root {
	--vs-bg: #f3f0ea;
	--vs-surface: #fffdf8;
	--vs-ink: #1c1a17;
	--vs-muted: #6b645b;
	--vs-line: #ddd5c8;
	--vs-accent: #0f6b5c;
	--vs-accent-hover: #0a5247;
	--vs-accent-soft: #e4f2ef;
	--vs-danger: #a33b2d;
	--vs-radius: 10px;
	--vs-shadow: 0 10px 30px rgba(28, 26, 23, 0.06);
	--vs-font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

.vs-works-page,
.vs-single-work {
	font-family: var(--vs-font);
	color: var(--vs-ink);
	background:
		radial-gradient(circle at top left, rgba(15, 107, 92, 0.08), transparent 40%),
		linear-gradient(180deg, #f7f4ee 0%, var(--vs-bg) 100%);
	padding: 40px 0 80px;
	min-height: 60vh;
}

.vs-container {
	width: min(1180px, calc(100% - 32px));
	margin: 0 auto;
}

.vs-page-content {
	margin-bottom: 28px;
	line-height: 1.8;
	color: var(--vs-ink);
}

.vs-page-content > *:first-child {
	margin-top: 0;
}

.vs-page-content > *:last-child {
	margin-bottom: 0;
}

/* Category tabs */
.vs-category-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 28px;
}

.vs-tab {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 18px;
	border: 1px solid var(--vs-line);
	background: var(--vs-surface);
	border-radius: 999px;
	cursor: pointer;
	color: var(--vs-ink);
	transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.vs-tab:hover,
.vs-tab.is-active {
	background: var(--vs-accent);
	border-color: var(--vs-accent);
	color: #fff;
}

.vs-tab-icon {
	width: 24px;
	height: 24px;
	object-fit: contain;
	border-radius: 4px;
}

.vs-tab-name {
	font-weight: 700;
}

.vs-tab-count {
	font-size: 0.85rem;
	opacity: 0.85;
}

/* Layout 70 / 30 */
.vs-layout {
	display: grid;
	grid-template-columns: 7fr 3fr;
	gap: 28px;
	align-items: start;
}

.vs-main,
.vs-sidebar,
.vs-panel {
	background: var(--vs-surface);
	border: 1px solid var(--vs-line);
	border-radius: var(--vs-radius);
	box-shadow: var(--vs-shadow);
}

.vs-main {
	padding: 22px;
}

.vs-sidebar {
	padding: 0;
	overflow: hidden;
}

.vs-toolbar {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 10px;
	margin-bottom: 18px;
}

.vs-sort-label {
	font-size: 0.9rem;
	color: var(--vs-muted);
}

.vs-sort {
	border: 1px solid var(--vs-line);
	border-radius: 8px;
	padding: 8px 12px;
	background: #fff;
	color: var(--vs-ink);
}

.vs-works-list {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 18px;
}

.vs-work-item {
	border: 1px solid var(--vs-line);
	border-radius: var(--vs-radius);
	overflow: hidden;
	background: #fff;
	display: flex;
	flex-direction: column;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.vs-work-item:hover {
	transform: translateY(-2px);
	box-shadow: var(--vs-shadow);
}

.vs-work-link {
	color: inherit;
	text-decoration: none;
	display: block;
	flex: 1;
}

.vs-work-thumb {
	aspect-ratio: 16 / 10;
	background: #ebe6dc;
	overflow: hidden;
}

.vs-work-thumb img,
.vs-single-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.vs-work-thumb-placeholder {
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #ebe6dc, #d9d2c4);
}

.vs-work-body {
	padding: 14px 16px 8px;
}

.vs-work-title {
	margin: 0 0 8px;
	font-size: 1.05rem;
	line-height: 1.35;
}

.vs-work-excerpt {
	margin: 0;
	color: var(--vs-muted);
	font-size: 0.9rem;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.vs-work-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px 16px 16px;
	border-top: 1px solid var(--vs-line);
}

.vs-work-votes {
	font-size: 0.9rem;
	color: var(--vs-muted);
}

.vs-work-votes strong {
	color: var(--vs-ink);
	margin-left: 4px;
}

.vs-load-more-wrap {
	display: flex;
	justify-content: center;
	margin-top: 24px;
}

.vs-empty {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--vs-muted);
	padding: 40px 10px;
}

/* Buttons */
.vs-btn {
	appearance: none;
	border: none;
	border-radius: 8px;
	padding: 10px 16px;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.2s ease, opacity 0.2s ease;
}

.vs-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.vs-btn-primary {
	background: var(--vs-accent);
	color: #fff;
}

.vs-btn-primary:hover:not(:disabled) {
	background: var(--vs-accent-hover);
}

.vs-btn-secondary {
	background: var(--vs-accent-soft);
	color: var(--vs-accent);
}

.vs-btn-block {
	width: 100%;
}

.vs-link-btn {
	appearance: none;
	border: none;
	background: none;
	padding: 0;
	color: var(--vs-accent);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	text-decoration: underline;
}

/* Sidebar panels */
.vs-panel {
	border: none;
	border-radius: 0;
	box-shadow: none;
	padding: 22px;
	border-bottom: 1px solid var(--vs-line);
}

.vs-panel:last-child {
	border-bottom: none;
}

.vs-panel-title {
	margin: 0 0 14px;
	font-size: 1.1rem;
}

.vs-rules-content {
	color: var(--vs-muted);
	line-height: 1.7;
	font-size: 0.95rem;
}

.vs-rules-content p:first-child {
	margin-top: 0;
}

.vs-auth-tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 14px;
}

.vs-auth-tab {
	flex: 1;
	border: 1px solid var(--vs-line);
	background: #fff;
	border-radius: 8px;
	padding: 8px;
	cursor: pointer;
	font: inherit;
}

.vs-auth-tab.is-active {
	background: var(--vs-accent);
	border-color: var(--vs-accent);
	color: #fff;
}

.vs-form {
	display: none;
}

.vs-form.is-active {
	display: block;
}

.vs-field {
	margin: 0 0 12px;
}

.vs-field label {
	display: block;
	margin-bottom: 6px;
	font-size: 0.88rem;
	color: var(--vs-muted);
}

.vs-field input {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid var(--vs-line);
	border-radius: 8px;
	padding: 10px 12px;
	font: inherit;
	background: #fff;
}

.vs-code-inputs {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
}

.vs-auth-switch {
	margin: 14px 0 0;
	font-size: 0.9rem;
	color: var(--vs-muted);
}

.vs-msg {
	margin: 12px 0 0;
	padding: 10px 12px;
	border-radius: 8px;
	font-size: 0.9rem;
}

.vs-msg.is-success {
	background: var(--vs-accent-soft);
	color: var(--vs-accent);
}

.vs-msg.is-error {
	background: #f8e8e5;
	color: var(--vs-danger);
}

/* 投票結果 Popup */
body.vs-popup-open {
	overflow: hidden;
}

.vs-popup-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(28, 26, 23, 0.55);
	backdrop-filter: blur(2px);
}

.vs-popup-overlay.is-visible {
	display: flex !important;
}

.vs-popup-overlay[hidden]:not(.is-visible) {
	display: none !important;
}

.vs-popup {
	width: min(420px, 100%);
	background: var(--vs-surface);
	border: 1px solid var(--vs-line);
	border-radius: var(--vs-radius);
	box-shadow: 0 20px 50px rgba(28, 26, 23, 0.2);
	padding: 28px 24px 22px;
	text-align: center;
	animation: vs-popup-in 0.22s ease;
}

@keyframes vs-popup-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.vs-popup-icon {
	width: 52px;
	height: 52px;
	margin: 0 auto 14px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1;
}

.vs-popup.is-success .vs-popup-icon {
	background: var(--vs-accent-soft);
	color: var(--vs-accent);
}

.vs-popup.is-success .vs-popup-icon::before {
	content: '✓';
}

.vs-popup.is-error .vs-popup-icon {
	background: #f8e8e5;
	color: var(--vs-danger);
}

.vs-popup.is-error .vs-popup-icon::before {
	content: '!';
}

.vs-popup-message {
	margin: 0 0 20px;
	font-size: 1.05rem;
	line-height: 1.6;
	color: var(--vs-ink);
}

.vs-popup-close {
	min-width: 120px;
}

.vs-status-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.vs-status-list li {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 0;
	border-bottom: 1px dashed var(--vs-line);
	font-size: 0.92rem;
}

.vs-status-list li:last-child {
	border-bottom: none;
}

.vs-status-name {
	font-weight: 700;
}

.vs-status-count {
	color: var(--vs-muted);
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.vs-status-check {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--vs-accent);
	color: #fff;
	font-size: 0.7rem;
	line-height: 1;
	flex-shrink: 0;
}

.vs-status-list li.is-full .vs-status-count {
	color: var(--vs-accent);
	font-weight: 700;
}

.vs-status-done {
	margin: 12px 0 0;
	padding: 12px 14px;
	background: var(--vs-accent-soft);
	color: var(--vs-accent);
	border-radius: 8px;
	font-size: 0.9rem;
	font-weight: 700;
	line-height: 1.5;
	text-align: center;
}

.vs-user-greeting {
	margin: 0 0 12px;
}

.vs-auth-actions {
	margin: 0 0 12px;
}

/* Single work */
.vs-single-work .vs-container {
	background: var(--vs-surface);
	border: 1px solid var(--vs-line);
	border-radius: var(--vs-radius);
	box-shadow: var(--vs-shadow);
	padding: 32px;
}

.vs-single-header {
	margin-bottom: 24px;
}

.vs-single-title {
	margin: 0 0 10px;
	font-size: clamp(1.6rem, 3vw, 2.2rem);
	line-height: 1.25;
}

.vs-single-votes {
	margin: 0;
	color: var(--vs-muted);
}

.vs-single-thumb {
	margin-bottom: 24px;
	border-radius: var(--vs-radius);
	overflow: hidden;
}

.vs-single-content {
	line-height: 1.8;
	color: var(--vs-ink);
	margin-bottom: 28px;
}

.vs-single-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 16px;
	padding-top: 20px;
	border-top: 1px solid var(--vs-line);
}

@media (max-width: 960px) {
	.vs-layout {
		grid-template-columns: 1fr;
	}

	.vs-works-list {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 640px) {
	.vs-history-table-head,
	.vs-history-item {
		grid-template-columns: 1fr;
		gap: 4px;
	}

	.vs-history-table-head {
		display: none;
	}

	.vs-works-page,
	.vs-single-work {
		padding: 24px 0 48px;
	}

	.vs-single-work .vs-container,
	.vs-main {
		padding: 18px;
	}

	.vs-category-tabs {
		flex-wrap: nowrap;
		overflow-x: auto;
		padding-bottom: 4px;
	}

	.vs-code-inputs {
		grid-template-columns: 1fr;
	}

	.vs-single-actions {
		flex-direction: column;
		align-items: stretch;
	}
}
