/* Comment Area Styles */
.comment-area {
	background-color: var(--bg-primary);
	color: var(--text-primary);
	padding: 0;
	border-radius: 8px;
	margin: 0.5rem 0;
	transition: all 0.3s ease;
}

* {
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	* {
		scroll-behavior: auto;
		transition: none !important;
	}
}

/* Dark Mode (Default) */
:root {
	--bg-primary: #222;
	--bg-secondary: #2a2a2a;
	--text-primary: #ffffff;
	--text-secondary: #b0b0b0;
	--text-muted: #808080;
	--border-color: #333333;
	--reaction-bg: #2a2a2a;
	--reaction-hover: #3a3a3a;
	--accent-color: var(--theme-box-color);
}

/* Light Mode */
.lightmode {
	--bg-primary: #ffffff;
	--bg-secondary: #f8f9fa;
	--text-primary: #333333;
	--text-secondary: #666666;
	--text-muted: #999999;
	--border-color: #e0e0e0;
	--reaction-bg: #f8f9fa;
	--reaction-hover: #e9ecef;
	--accent-color: var(--theme-box-color);
}

/* Reaction Section */
.reaction-section {
	text-align: center;
	margin-bottom: 2rem;
}

.reaction-title {
	font-size: 1.5rem;
	font-weight: 600;
	margin-bottom: 0.5rem;
	color: var(--text-primary);
}

.response-count {
	font-size: 1rem;
	color: var(--text-secondary);
	margin-bottom: 1.5rem;
}

.reaction-buttons {
	display: flex;
	justify-content: center;
	gap: 1rem;
	flex-wrap: wrap;
}

.reaction-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 1rem;
	background-color: var(--bg-primary);
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.3s ease;
	min-width: 80px;
	border: 1px solid var(--bg-primary);
}

.reaction-item[data-selected='true'] {
	background-color: var(--reaction-bg);
	border-color: var(--accent-color);
	box-shadow: 0 0 8px var(--accent-color);
}

.reaction-item:hover {
	background-color: var(--reaction-bg);
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	border-color: var(--border-color);
}

.lightmode .reaction-item:hover {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0);
}

.lightmode .reaction-item[data-selected='true'] {
	box-shadow: 0 0 0px var(--accent-color);
}

.reaction-icon {
	width: 2.5rem;
	height: 2.5rem;
	margin-bottom: 0.5rem;
	transition: transform 0.3s ease;
}

.reaction-item:hover .reaction-icon {
	transform: scale(1.1);
}

.reaction-label {
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--text-primary);
	margin-bottom: 0.25rem;
}

.reaction-count {
	font-size: 0.75rem;
	color: var(--text-secondary);
	font-weight: 600;
}

.comments-header {
	display: flex;
	justify-content: flex-end;
	margin-bottom: 1rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--border-color);
}

.comments-header .login-link {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	color: var(--accent-color);
	font-weight: 600;
	cursor: pointer;
	transition: color 0.3s ease;
}

/* Comments Section */
.comments-section {
	padding-top: 2rem;
}

.login-prompt {
	text-align: center;
	margin-bottom: 2rem;
}

.login-prompt p {
	color: var(--text-secondary);
	font-size: 1rem;
	padding: 1rem;
	background-color: var(--bg-secondary);
	border-radius: 6px;
	border: 1px solid var(--border-color);
}

.comment-form {
	margin-bottom: 1.25rem;
}

.comment-form textarea {
	width: 100%;
	padding: 0.75rem;
	border: 1px solid var(--border-color);
	border-radius: 6px;
	resize: vertical;
	min-height: 100px;
	background-color: var(--bg-secondary);
	color: var(--text-secondary);
	font-size: 0.875rem;
	transition:
		border-color 0.3s ease,
		background-color 0.3s ease,
		color 0.3s ease;
}

.comment-form .input-tools {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.5rem;
	flex-wrap: wrap;
	gap: 1.25rem;
}

.tools-icon {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	color: var(--text-muted);
	font-size: 12px;
}

.comment-form .action-buttons {
	display: flex;
	align-items: center;
	gap: 1.25rem;
	width: 100%;
	justify-content: space-between;
}

.comment-form .action-buttons input[type='checkbox'] {
	background: var(--bg-secondary);
	border: none;
	color: var(--text-secondary);
	cursor: pointer;
	font-size: 0.875rem;
	transition: color 0.3s ease;
	margin: 0;
}

.spoiler-checkbox {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	color: var(--text-secondary);
}

.spoiler-checkbox {
	display: flex;
	align-items: center;
	gap: 8px;
}

.spoiler-checkbox input[type='checkbox'] {
	display: none;
}

.spoiler-checkbox label {
	position: relative;
	display: flex;
	align-items: center;
	cursor: pointer;
	user-select: none;
}

.spoiler-checkbox label::before {
	content: '';
	width: 40px;
	height: 20px;
	background-color: var(--bg-secondary);
	border-radius: 20px;
	margin-right: 8px;
	position: relative;
	transition: background-color 0.3s ease;
}

.spoiler-checkbox label::after {
	content: '';
	width: 16px;
	height: 16px;
	background-color: var(--text-muted);
	border-radius: 50%;
	position: absolute;
	left: 2px;
	top: 50%;
	transform: translateY(-50%);
	transition: transform 0.3s ease;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.lightmode .spoiler-checkbox label::after {
	background-color: var(--bg-secondary);
}

.spoiler-checkbox input[type='checkbox']:checked + label::before {
	background-color: var(--accent-color);
}

.spoiler-checkbox input[type='checkbox']:checked + label::after {
	transform: translateY(-50%) translateX(20px);
}

.spoiler-checkbox label:hover::before {
	opacity: 0.8;
}

.image-upload-button {
	background: transparent;
	border: none;
	outline: none;
	cursor: pointer;
	color: var(--text-muted);
}

.image-upload-button:hover {
	color: var(--accent-color);
}

.action-buttons button {
	background-color: var(--accent-color);
	color: #fff;
	border: none;
	padding: 0.5rem 1rem;
	border-radius: 4px;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.3s ease;
}

.action-buttons button#cancel-comment {
	background-color: var(--bg-secondary);
	color: var(--text-secondary);
}

.comments-utils {
	margin-bottom: 1.5rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: nowrap;
	gap: 1rem;
	border-bottom: 1.5px solid var(--border-color);
	padding-bottom: 0.5rem;
	color: var(--text-muted);
}

.comments-utils label {
	display: none;
}

@media (min-width: 600px) {
	.comments-utils label {
		display: block;
		font-size: 0.875rem;
	}
}

.comments-sort {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.comments-utils select {
	padding: 0.25rem 0.5rem;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	background-color: var(--bg-primary);
	color: var(--text-primary);
	font-size: 0.875rem;
	cursor: pointer;
	transition:
		border-color 0.3s ease,
		background-color 0.3s ease,
		color 0.3s ease;
}

.comments-count {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.comments-list {
	min-height: 100px;
	display: flex;
	flex-direction: column;
}

.comment-item {
	display: flex;
	gap: 1rem;
	padding-block: 1rem;
	border-radius: 8px;
	margin-bottom: 0.25rem;
	transition: all 0.3s ease;
}

.comment-item *:is(.comment-item):last-child {
	margin-bottom: 0;
}

.comment-avatar {
	flex-shrink: 0;
}

.comment-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background-color: var(--bg-primary);
	border: 2px solid var(--border-color);
	overflow: hidden;
}
.comment-avatar img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
}

.comment-content {
	flex: 1;
	min-width: 0;
}

.comment-content img {
	max-width: 20rem;
	margin-block: 0.5rem;
}

.comment-content a.replied-to {
	color: var(--accent-color);
	font-weight: 600;
	text-decoration: none;
}

.comment-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 0.5rem;
}

.comment-author {
	font-weight: 600;
	color: var(--text-primary);
	font-size: 0.875rem;
}

.comment-time {
	color: var(--text-muted);
	font-size: 0.75rem;
	position: relative;
}

.comment-time::before {
	content: '•';
	margin-right: 0.5rem;
	color: var(--text-muted);
}

.comment-text {
	color: var(--text-secondary);
	font-size: 0.875rem;
	line-height: 1.5;
	margin-bottom: 0.75rem;
	word-wrap: break-word;
}

.comment-text.spoiler {
	filter: blur(8px);
	cursor: not-allowed;
	user-select: none;
}

.comment-text > p {
	display: flex;
	flex-direction: column;
}

.comment-actions {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin-bottom: 0.75rem;
}

.comment-like,
.comment-dislike,
.comment-reply,
.pin-action,
.spoiler-action {
	font-size: 0.75rem;
	color: var(--text-muted);
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
	transition: all 0.3s ease;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	display: flex;
	align-items: center;
}

.comment-like span,
.comment-dislike span {
	font-weight: 600;
	font-size: 0.85rem;
}

.comment-like svg,
.comment-dislike svg,
.comment-reply svg,
.pin-action svg,
.spoiler-action svg {
	width: 1rem;
	height: 1rem;
	margin-right: 4px;
	vertical-align: middle;
	fill: none;
}

.comment-like:hover,
.comment-dislike:hover,
.comment-reply:hover,
.pin-action:hover,
.spoiler-action:hover {
	color: var(--accent-color);
	background-color: var(--bg-primary);
}

.comment-form.hidden {
	display: none;
}

.spoiler-action:not(.active) svg[data-spoiler-closed] {
	animation: fadeIn 0.3s ease;
}
.spoiler-action:not(.active) svg[data-spoiler-open] {
	display: none;
}

.spoiler-action:is(.active) svg[data-spoiler-closed] {
	display: none;
}
.spoiler-action:is(.active) svg[data-spoiler-open] {
	animation: fadeIn 0.3s ease;
}

.comment-like.active {
	color: #4caf50;
}

.comment-like.active svg,
.comment-dislike.active svg {
	fill: currentColor;
}

.comment-dislike.active {
	color: #f44336;
}

.comment-reply:hover {
	color: var(--text-primary);
}

/* Guest Badge */
.guest-badge {
	background-color: var(--text-muted);
	color: var(--bg-primary);
	font-size: 0.6rem;
	padding: 0.125rem 0.375rem;
	border-radius: 12px;
	text-transform: uppercase;
	font-weight: 600;
	letter-spacing: 0.5px;
}

/* Responsive Design for Comments */
@media (max-width: 600px) {
	.comment-item {
		gap: 0.75rem;
	}

	.comment-avatar img {
		width: 32px;
		height: 32px;
	}

	.comment-actions {
		gap: 0.5rem;
	}

	.comment-like,
	.comment-dislike,
	.comment-reply {
		font-size: 0.7rem;
		padding: 0.2rem 0.4rem;
	}

	.comment-reply span,
	.pin-action span,
	.spoiler-action span {
		display: none;
	}
	.comment-reply svg,
	.pin-action svg,
	.spoiler-action svg {
		width: 1.25rem;
		height: 1.25rem;
	}
}

/* Responsive Design */
@media (min-width: 768px) {
	.comment-area {
		padding: 1.5rem;
		margin: 1rem 0;
	}

	.reaction-item {
		min-width: 70px;
		padding: 0.75rem;
	}

	.reaction-title {
		font-size: 1.25rem;
	}
	.comment-form .action-buttons {
		width: auto;
	}
}

@media (max-width: 480px) {
	.reaction-buttons {
		grid-template-columns: repeat(3, 1fr);
		display: grid;
		gap: 0.75rem;
	}

	.reaction-item {
		min-width: auto;
	}

	.replies-container {
		margin-left: -1rem;
	}

	.comment-form .action-buttons {
		gap: 0.5rem;
	}
}

/* Animation for mode switching */
* {
	transition:
		background-color 0.3s ease,
		color 0.3s ease,
		border-color 0.3s ease;
}

.pinned-badge {
	line-height: 1;
	margin-inline-end: -0.5rem;
}
.pinned-badge svg {
	width: 1rem;
	height: 1rem;
	vertical-align: middle;
	fill: currentColor;
}
.load-more-comments.hidden {
	display: none;
}

.load-more-comments {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	border: none;
	outline: none;
	width: 100%;
	background-color: transparent;
	cursor: pointer;
	color: var(--text-muted);
}
.load-more-comments svg {
	transition: all 0.25s ease-in-out;
}

.load-more-comments:hover {
	color: var(--accent-color);
}
.load-more-comments:hover > svg {
	scale: 1.05;
	margin-top: 0.5rem;
}
.loader {
	width: 8px;
	height: 28px;
	border-radius: 4px;
	display: block;
	margin: 20px auto;
	position: relative;
	background: currentColor;
	color: var(--accent-color);
	box-sizing: border-box;
	animation: animloader 0.3s 0.3s linear infinite alternate;
}

.loader::after,
.loader::before {
	content: '';
	width: 8px;
	height: 28px;
	border-radius: 4px;
	background: currentColor;
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	left: 20px;
	box-sizing: border-box;
	animation: animloader 0.3s 0.45s linear infinite alternate;
}
.loader::before {
	left: -20px;
	animation-delay: 0s;
}

@keyframes animloader {
	0% {
		height: 32px;
	}
	100% {
		height: 4px;
	}
}
