/* Container and layout */
.comments-container {
	width: 100%;
	scroll-behavior: smooth;
	scroll-snap-type: proximity;
}

.comments-inner {
	margin-left: auto;
	margin-right: auto;
}

.comments-card {
	border-radius: 0.5rem;
	overflow: hidden;
}

.comments-header {
	padding: 1.5rem 1rem;
	padding-top: 1.5rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid rgba(39, 39, 42, 0.8);
}

@media (min-width: 578px) {
	.comments-header {
		padding-left: 2rem;
		padding-right: 2rem;
	}
}

.comments-title-container {
	text-align: center;
	margin-bottom: 1rem;
}

.comments-title {
	font-size: 1rem;
	font-weight: 500;
	color: rgb(212, 212, 216);
	margin-bottom: 0.25rem;
}

.comments-subtitle {
	font-size: 0.875rem !important;
	color: rgb(161, 161, 170);
	text-align: center !important;
}

/* Reactions section */
.reactions-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1rem;
}

@media (min-width: 578px) {
	.reactions-grid {
		display: flex;
		justify-content: center;
		align-items: flex-start;
	}
}

.reaction-button {
	display: flex;
	flex-direction: column;
	align-items: center;
	transition-property: all;
	transition-duration: 0.2s;
	position: relative;
	opacity: 0.9;
	background-color: transparent;
	border: 1px solid transparent;
	outline: 1px solid transparent;
	box-shadow: none;
	cursor: pointer;
	width: 76px;
	height: 98px;
	border-radius: 0.375rem;
	justify-self: center;
}
.reaction-button.active {
	background-color: rgba(62, 100, 207, 0.35);
	border: 1px solid rgba(62, 100, 207, 0.8);
}

.reaction-button:hover {
	opacity: 1;
	transform: scale(1.05);
}

.reaction-emoji-container {
	display: flex;
	position: relative;
}

.reaction-emoji {
	font-size: 2.25rem;
	margin-bottom: 0.5rem;
	filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.1));
}

.reaction-count {
	font-size: 1rem;
	font-weight: 500;
	color: rgb(228, 228, 231);
	margin-bottom: 0.125rem;
}
.reaction-button.active .reaction-label {
	color: rgb(228, 228, 231);
}

.reaction-label {
	font-size: 0.75rem;
	color: rgb(161, 161, 170);
}

/* Comments content section */
.comments-content {
	padding-left: 1rem;
	padding-right: 1rem;
}

@media (min-width: 578px) {
	.comments-content {
		padding-left: 1.5rem;
		padding-right: 1.5rem;
	}
}

.comments-header-row {
	padding-top: 1rem;
	padding-bottom: 1rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 1rem;
}

.comments-count {
	font-size: 1rem;
	font-weight: 500;
	color: rgb(228, 228, 231);
}

/* Sort controls */
.sort-controls {
	display: flex;
	font-size: 0.75rem;
	background-color: rgba(39, 39, 42, 0.8);
	border-radius: 9999px;
	padding: 0.25rem;
	width: 100%;
}

.sort-button {
	padding: 0.375rem 1rem;
	text-transform: capitalize;
	border-radius: 9999px;
	transition-property: all;
	transition-duration: 0.2s;
	outline: none;
	border: none;
	background-color: transparent;
	cursor: pointer;
	width: 100%;
}

@media (min-width: 578px) {
	.sort-controls {
		width: auto;
	}
	.sort-button {
		width: auto;
	}
}

.sort-button-default.active {
	background-color: var(--main-color);
	color: white;
	font-weight: 500;
}

.sort-button-default {
	color: rgb(212, 212, 216);
}

.sort-button-default:hover {
	color: white;
	background-color: rgb(63, 63, 70);
}

/* Comment form */
.comment-form-container {
	padding-top: 1rem;
	padding-bottom: 1rem;
}

.comment-form {
	background-color: rgba(24, 24, 27, 0.5);
	border-radius: 0.5rem;
	border: 1px solid rgba(39, 39, 42, 0.5);
	transition-property: all;
	transition-duration: 0.2s;
}

.comment-form-header {
	background-color: rgba(24, 24, 27, 0.5);
	border-radius: 0.5rem;
	border: 1px solid rgb(39, 39, 42);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.5rem 1rem;
	border-bottom: 1px solid rgba(39, 39, 42, 0.5);
}

.login-prompt {
	font-size: 0.875rem;
	color: rgb(161, 161, 170);
}

.login-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	white-space: nowrap;
	font-size: 0.875rem;
	font-weight: 500;
	height: 2.25rem;
	border-radius: 0.375rem;
	padding: 0 0.75rem;
	color: var(--main-color);
	transition-property: color, background-color;
	transition-duration: 0.15s;
	background-color: transparent;
	outline: 1px solid transparent;
	border: 1px solid transparent;
	cursor: pointer;
}

.login-button:hover {
	color: var(--main-color);
	background-color: rgba(51, 103, 214, 0.1);
}

.login-icon {
	width: 1rem;
	height: 1rem;
	margin-right: 0.375rem;
}

.comment-editor {
	min-height: 100px;
	border-radius: 5px;
	background-color: #18181b;
	border: 1px solid rgba(39, 39, 42, 0.8);
	padding: 10px;
	color: #e4e4e7;
	font-size: 0.875rem;
	line-height: 1.5;
	outline: none;
	width: 100%;
	max-height: 300px;
	overflow-y: auto;
}

.comment-editor:empty:before {
	content: attr(data-placeholder);
	color: #71717a;
}

.comment-controls {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px 8px;
	border-top: 1px solid rgba(39, 39, 42, 0.3);
	flex-direction: column;
}

.comment-controls-left {
	display: flex;
	gap: 8px;
	width: 100%;
}

.comment-controls-right {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
}

.formatting-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 4px;
	background-color: transparent;
	color: #a1a1aa;
	border: none;
	padding: 0;
	cursor: pointer;
	transition: all 0.2s ease;
}

.formatting-button.active {
	background-color: rgba(39, 39, 42, 0.5);
	color: var(--main-color);
}

.formatting-button:hover {
	background-color: rgba(39, 39, 42, 0.5);
	color: var(--main-color);
}

.formatting-button:active {
	transform: scale(0.95);
}

.character-count {
	font-size: 0.75rem;
	color: #a1a1aa;
}

.submit-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	white-space: nowrap;
	font-size: 0.875rem;
	font-weight: 500;
	height: 2rem;
	background-color: var(--main-color);
	color: white;
	padding: 0 0.75rem;
	border-radius: 0.375rem;
	border: none;
	transition: background-color 0.2s;
	cursor: pointer;
	margin-left: auto;
}

.submit-button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.submit-button:not(:disabled):hover {
	background-color: #2563eb;
}

@media (min-width: 578px) {
	.comment-controls {
		flex-direction: row;
	}

	.comment-controls-left,
	.comment-controls-right {
		width: auto;
	}

	.comment-controls-right .submit-button {
		margin-left: 0;
	}
}

/* Hide the placeholder when editor is focused */
.comment-placeholder {
	position: absolute;
	padding: 10px;
	color: #71717a;
	font-size: 0.875rem;
	pointer-events: none;
	transition: opacity 0.2s;
}

.comment-input {
	position: relative;
}

.comment-placeholder {
	padding: 0.5rem 0.75rem;
	color: rgb(161, 161, 170);
	font-size: 0.875rem;
	cursor: text;
	border-radius: 0.375rem;
}

/* Comments list */
.comments-list {
	margin-top: 0;
	margin-bottom: 0;
	border-top-width: 0;
}

.comment-item {
	padding-top: 1rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid rgba(39, 39, 42, 0.3);
}

.comment-container {
	display: flex;
}

.comment-avatar-container {
	flex-shrink: 0;
	margin-right: 0.75rem;
}

.avatar-wrapper {
	position: relative;
}

.avatar {
	border-radius: 9999px;
	overflow: hidden;
	width: 2rem;
	height: 2rem;
	color: white;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	font-weight: 800;
	font-family: Roboto, monospace, sans-serif;
	user-select: none;
	text-transform: uppercase;
}

.comment-item:nth-child(2n + 1) .avatar {
	background-color: rgb(62, 100, 207);
}
.comment-item:nth-child(3n + 1) .avatar {
	background-color: rgb(234, 179, 8);
}
.comment-item:nth-child(3n + 2) .avatar {
	background-color: rgb(244, 63, 94);
}
.comment-item:nth-child(4n + 1) .avatar {
	background-color: rgb(34, 197, 94);
}
.comment-item:nth-child(5n + 1) .avatar {
	background-color: rgb(99, 102, 241);
}
.comment-item:nth-child(6n + 1) .avatar {
	background-color: rgb(249, 115, 22);
}

@media (min-width: 578px) {
	.avatar {
		width: 2.5rem;
		height: 2.5rem;
	}
}

.comment-content {
	flex: 1;
	min-width: 0;
}

.comment-header {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 0.25rem;
}

.comment-author {
	font-weight: 600;
	transition-property: color;
	color: white;
}

.comment-author:hover {
	color: var(--main-color);
}

.comment-timestamp {
	font-size: 0.75rem;
	color: rgb(161, 161, 170);
}

.delete-comment {
	background: rgba(255, 64, 121, 0.1);
	border: none;
	outline: 1px solid rgb(255, 64, 121);
	outline-offset: 1px;
	color: rgb(255, 64, 121);
	border-radius: 0.3rem;
	cursor: pointer;
}

.comment-body {
	font-size: 0.875rem;
	line-height: 1.625;
	margin-bottom: 0.75rem;
}

.comment-text-wrapper {
	margin-bottom: 0.5rem;
	position: relative;
}

.comment-text {
	overflow: hidden;
	overflow-wrap: anywhere;
	word-break: normal;
	hyphens: none;
	color: rgb(228, 228, 231);
	font-size: 0.875rem;
	line-height: 1.625;
	margin-bottom: 0.5rem;
	display: inline-block;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	transition: all 0.2s ease;
}

.comment-text.expanded {
	-webkit-line-clamp: unset;
	overflow: visible;
}

.comment-text.spoiler {
	filter: blur(12px);
	user-select: none;
	cursor: not-allowed;
	display: -webkit-box;
}

.comment-text p {
	margin: 0;
	padding: 0 !important;
	overflow-wrap: anywhere;
	text-align: start !important;
}

.comment-text-wrapper .tool-buttons {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 1rem;
	margin-top: 0.5rem;
}

.read-more-button,
.spoiler-button {
	font-size: 0.75rem;
	display: flex;
	align-items: center;
	gap: 0.25rem;
	color: var(--main-color);
	position: relative;
	z-index: 2;
	border: none;
	outline: none;
	background: transparent;
	cursor: pointer;
	transition: all 0.2s ease;
	padding-inline-start: 0;
}

.read-more-button:hover,
.spoiler-button:hover {
	color: var(--main-color);
}

.chevron-icon,
.spoiler-button svg {
	width: 0.875rem;
	height: 0.875rem;
}

/* Comment actions */
.comment-actions {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	font-size: 0.75rem;
	margin-bottom: 0.75rem;
	flex-wrap: wrap;
}

.comment-action-button {
	display: flex;
	align-items: center;
	gap: 0.375rem;
	transition-property: color;
	color: rgb(161, 161, 170);
	background-color: transparent;
	border: none !important;
	outline: none !important;
	cursor: pointer;
}

.comment-action-button.active {
	color: var(--main-color);
	font-weight: 500;
}

.comment-action-button:hover {
	color: var(--main-color);
}

.action-icon {
	width: 0.875rem;
	height: 0.875rem;
}

/* Reply threads */
.reply-thread {
	padding-top: 1rem;
	padding-bottom: 1rem;
	margin-top: 0.75rem;
	border-left: 2px solid rgba(39, 39, 42, 0.3);
	margin-left: 1.25rem;
}

.reply-item {
	padding-left: 2rem;
}

@media (min-width: 578px) {
	.reply-item {
		padding-left: 3rem;
	}
}

/* Load more button */
.load-more-container {
	padding-top: 1.5rem;
	padding-bottom: 1.5rem;
	text-align: center;
}

.load-more-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	white-space: nowrap;
	font-size: 0.875rem;
	height: 2.5rem;
	background-color: var(--main-color);
	color: white;
	font-weight: 500;
	padding: 0 1.5rem;
	border-radius: 0.5rem;
	opacity: 0.8;
	transition: all 0.2s ease;
	border: none;
	outline: 1px solid var(--main-color);
	outline-offset: 0px;
	cursor: pointer;
}

.load-more-button:hover,
.load-more-button:focus {
	opacity: 1;
	scale: 1.05;
	outline-offset: 2px;
}

.emoji-picker {
	width: 100svw;
	max-width: 320px;
	margin: 0;
	background-color: rgb(37 36 42);
	border-radius: 0.25rem;
}

.emoji-tabs {
	display: flex;
	align-items: center;
	justify-content: space-around;
}
.emoji-tab {
	padding: 0.5rem;
	width: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	height: auto;
	aspect-ratio: 1/1;
	font-size: 1.25rem;
}
.emoji-tab[aria-selected='true'] {
	background-color: rgb(29, 27, 38);
	border-radius: 0.25rem;
}
.emoji-container {
	background-color: rgb(29, 27, 38);
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	place-content: center;
	justify-content: center;
}
.emoji-container .emoji {
	padding: 0.25rem;
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.25rem;
	cursor: pointer;
	height: auto;
	aspect-ratio: 1/1;
	line-height: 100%;
	transition: all 0.2s ease;
}
.emoji-container .emoji:hover {
	background-color: rgb(37 36 42);
	scale: 1.2;
}

.reply-form {
	background-color: rgba(24, 24, 27, 0.5);
	border-radius: 0.5rem;
	border: 1px solid rgba(39, 39, 42, 0.5);
	transition-property: all;
	transition-duration: 0.2s;
}

.reply-to {
	font-size: 0.875rem;
	color: #2563eb !important;
}
[contenteditable='true']:empty:before {
	content: attr(data-placeholder);
	color: #888;
	font-style: italic;
	pointer-events: none;
}

.comment-replies,
.comment-replies[aria-expanded] {
	animation: scroll-in 0.3s ease-in-out forwards;
}

.comment-replies[aria-expanded='true'] {
	animation: alternate-scroll-in 0.3s ease-in-out forwards;
}

@keyframes scroll-in {
	from {
		height: calc(var(--reply-count) * 9.25rem);
		opacity: 0.8;
	}
	to {
		height: 0;
		opacity: 0;
		overflow: hidden;
	}
}

@keyframes alternate-scroll-in {
	from {
		height: 0;
		opacity: 0;
	}
	to {
		height: calc(var(--reply-count) * 9.25rem);
		opacity: 1;
		overflow: auto;
		min-height: fit-content;
	}
}
.load-more-reply {
	display: block;
	background: var(--main-color);
	border: none;
	outline: none;
	color: white;
	font-weight: 500;
	margin-left: 3rem;
	cursor: pointer;
	position: relative;
	overflow: visible;
	transition: all 0.2s ease;
	opacity: 0.8;
	border-radius: 0.375rem;
	padding-block: 0.25rem;
	margin-top: 0.75rem;
	border-left: 2px solid rgba(39, 39, 42, 0.3);
	margin-left: 3.25rem;
}

.load-more-reply::before {
	content: '';
	position: absolute;
	top: 0;
	left: -2rem;
	bottom: 0;
	width: 2px;
	height: 100%;
	background-color: rgba(39, 39, 42, 0.3);
	border-radius: 0.375rem;
}

@media (min-width: 1024px) {
	.load-more-reply {
		margin-left: 4.25rem;
	}
	.load-more-reply::before {
		left: -3.125rem;
	}
}

.load-more-reply:hover {
	opacity: 1;
	transform: scale(1.05);
}
