/**
 * Comment Thread Styles
 *
 * Handles only what theme.json cannot express:
 * list resets, depth-based indentation, pill buttons,
 * the bypostauthor badge, the native comment form, and the
 * Webmention plugin's form, which borrows the comment form's look.
 *
 * @package Tufte_Blocks
 */

/* === Comments Container === */

.wp-block-comments {
	font-size: var(--wp--preset--font-size--small);
}

/* === List Reset === */

.wp-block-comment-template,
.wp-block-comment-template ol {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* === Spacing Between Comments === */

.wp-block-comment-template > li {
	padding: var(--wp--preset--spacing--50) 0;
}

.wp-block-comment-template > li + li {
	border-top: 1px solid var(--wp--preset--color--border);
}

/* === Threaded Reply Indentation === */

.wp-block-comment-template ol > li {
	padding: var(--wp--preset--spacing--50) 0 0;
	margin-left: var(--wp--preset--spacing--60);
}

.wp-block-comment-template ol ol > li {
	margin-left: var(--wp--preset--spacing--60);
}

/* === Avatar (rounded — done in CSS to avoid block-level border style) === */

.wp-block-avatar img {
	border-radius: 50%;
	display: block;
}

/* === Post Author Badge === */

.bypostauthor > .comment-item .wp-block-comment-author-name::after,
.bypostauthor > .wp-block-group .wp-block-comment-author-name::after {
	content: "author";
	font-family: var(--wp--preset--font-family--monospace);
	font-size: 0.6rem;
	letter-spacing: 0.08em;
	color: var(--wp--preset--color--primary);
	border: 1px solid var(--wp--preset--color--primary);
	padding: 1px 5px;
	border-radius: 2px;
	margin-left: 6px;
	vertical-align: middle;
	font-weight: 400;
	text-transform: lowercase;
}

/* === Reply / Edit Links (outline pill buttons) === */

.wp-block-comment-reply-link a,
.wp-block-comment-edit-link a {
	display: inline-block;
	color: var(--wp--preset--color--foreground);
	background: transparent;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	padding: 0.25rem 0.75rem;
	text-decoration: none;
	transition: border-color var(--wp--custom--transition),
	            color var(--wp--custom--transition),
	            background var(--wp--custom--transition);
}

.wp-block-comment-reply-link a:hover,
.wp-block-comment-edit-link a:hover {
	color: var(--wp--preset--color--background);
	background: var(--wp--preset--color--foreground);
	border-color: var(--wp--preset--color--foreground);
}

/* === Comment Form (native comment_form() output — not a block) === */

.wp-block-post-comments-form {
	margin-top: var(--wp--preset--spacing--70);
	padding-top: var(--wp--preset--spacing--50);
	border-top: 1px solid var(--wp--preset--color--border);
}

.comment-reply-title {
	font-family: var(--wp--preset--font-family--serif);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 400;
	color: var(--wp--preset--color--foreground);
	margin-bottom: var(--wp--preset--spacing--40);
}

.comment-form label,
#webmention-form label {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--foreground);
	display: block;
	margin-bottom: 0.4rem;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea,
#webmention-form input.webmention-source {
	width: 100%;
	max-width: none;
	background: transparent;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 6px;
	color: var(--wp--preset--color--foreground);
	font-family: var(--wp--preset--font-family--serif);
	font-size: var(--wp--preset--font-size--small);
	padding: 0.625rem 0.875rem;
	transition: border-color var(--wp--custom--transition);
	box-sizing: border-box;
}

.comment-form input:focus,
.comment-form textarea:focus,
#webmention-form input.webmention-source:focus {
	outline: none;
	border-color: var(--wp--preset--color--primary);
}

.comment-form textarea {
	min-height: 120px;
	line-height: 1.6;
	resize: vertical;
}

.comment-form input::placeholder,
#webmention-form input::placeholder,
.comment-form textarea::placeholder {
	color: var(--wp--preset--color--secondary);
}

.comment-form p,
#webmention-form p {
	margin-bottom: var(--wp--preset--spacing--40);
}

.comment-form .form-submit {
	margin-bottom: 0;
	margin-top: var(--wp--preset--spacing--50);
}

.comment-form input[type="submit"],
.comment-form .submit,
#webmention-form input[type="submit"] {
	font-size: 0.9rem;
	font-family: inherit;
	color: var(--wp--preset--color--background);
	background: var(--wp--preset--color--primary);
	border: 1px solid var(--wp--preset--color--primary);
	border-radius: 4px;
	padding: 0.5rem 1.25rem;
	cursor: pointer;
	transition: background var(--wp--custom--transition),
	            border-color var(--wp--custom--transition);
}

.comment-form input[type="submit"]:hover,
.comment-form input[type="submit"]:focus,
#webmention-form input[type="submit"]:hover,
#webmention-form input[type="submit"]:focus {
	background: var(--wp--preset--color--primary-hover);
	border-color: var(--wp--preset--color--primary-hover);
}

.comment-notes,
#webmention-source-description,
.comment-awaiting-moderation,
.logged-in-as {
	font-size: 0.75rem;
	color: var(--wp--preset--color--secondary);
}

/* === Checkboxes (subscribe-to-comments, mailing list opt-ins) === */

.comment-form input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	width: 1rem;
	height: 1rem;
	margin: 0 0.5rem 0 0;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 3px;
	background: transparent;
	cursor: pointer;
	vertical-align: -0.15em;
	position: relative;
	flex-shrink: 0;
	transition: border-color var(--wp--custom--transition),
	            background var(--wp--custom--transition);
}

.comment-form input[type="checkbox"]:hover {
	border-color: var(--wp--preset--color--primary);
}

.comment-form input[type="checkbox"]:checked {
	background: var(--wp--preset--color--primary);
	border-color: var(--wp--preset--color--primary);
}

.comment-form input[type="checkbox"]:checked::after {
	content: "";
	position: absolute;
	left: 4px;
	top: 0;
	width: 5px;
	height: 9px;
	border: solid var(--wp--preset--color--background);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.comment-form input[type="checkbox"]:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

/* Keep checkbox + label on the same line (Jetpack's subscribe row was breaking) */
.comment-form p:has(input[type="checkbox"]) {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
}

.comment-form p:has(input[type="checkbox"]) label {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	display: inline;
}

/* === Webmention Form (the plugin's form after #respond) === */

#webmention-form {
	margin: var(--wp--preset--spacing--50) 0 0;
}

#webmention-form p:last-of-type {
	margin-bottom: 0;
}

#cancel-comment-reply-link {
	font-size: 0.75rem;
	color: var(--wp--preset--color--secondary);
	margin-left: 0.5rem;
}

#cancel-comment-reply-link:hover {
	color: var(--wp--preset--color--primary);
}

/* === Mobile === */

@media (max-width: 600px) {
	.wp-block-comment-template ol > li,
	.wp-block-comment-template ol ol > li {
		margin-left: var(--wp--preset--spacing--50);
	}
}

/* === Reduced Motion === */

@media (prefers-reduced-motion: reduce) {
	.wp-block-comment-reply-link a,
	.wp-block-comment-edit-link a,
	.comment-form input,
	.comment-form textarea,
	.comment-form input[type="submit"],
	#webmention-form input {
		transition-duration: 0.01ms !important;
	}
}
