/**
 * Comments area on single posts — Figma node 512:19865.
 *
 * Order: form on top, comment list below.
 * Numbered top-level rows; replies share the parent thread number and
 * render indented with an orange inline-start border.
 *
 * @package Hamechadesh
 */

/* ==========================================================================
   Section wrapper
   ========================================================================== */

.hm-comments-area {
	margin-block: 55px;
	padding-inline: 50px;
}

/* The shared .hm-section-heading already gives us the dot + Pompei Black 32px.
   Tighten the bottom margin so the form sits closer to the heading per Figma. */
.hm-comments__heading {
	margin-bottom: 16px;
}

/* ==========================================================================
   Comment form
   ========================================================================== */

.hm-comments__form {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-bottom: 30px;
}

.hm-comments__form-row {
	display: flex;
	gap: 16px;
}

.hm-comments__field {
	display: block;
	flex: 1 1 0;
	min-width: 0;
	margin: 0;
}

.hm-comments__field--textarea {
	width: 100%;
}

.hm-comments__input,
.hm-comments__textarea {
	display: block;
	width: 100%;
	background-color: #ffffff;
	border: 0;
	border-radius: 14px;
	color: var(--hm-color-text);
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 16px;
	line-height: 22px;
	text-align: start;
	unicode-bidi: isolate;
	box-sizing: border-box;
	transition: box-shadow var(--hm-transition-fast);
}

.hm-comments__input {
	height: 52px;
	padding: 14px 18px;
}

.hm-comments__textarea {
	min-height: 117px;
	padding: 18px;
	resize: vertical;
}

.hm-comments__input::placeholder,
.hm-comments__textarea::placeholder {
	color: #404040;
	opacity: 1; /* Firefox defaults to ~0.54 — keep Figma colour exact. */
}

.hm-comments__input:focus,
.hm-comments__textarea:focus {
	outline: none;
	box-shadow: 0 0 0 2px var(--hm-color-orange);
}

/* Invalid field state — red border + subtle shake-free outline so the user
   can see exactly which field failed validation. Cleared on input. */
.hm-comments__input.is-invalid,
.hm-comments__textarea.is-invalid {
	box-shadow: 0 0 0 2px var(--hm-color-accent);
}

/* Inline form message — same pattern as .hm-footer__form-message. The
   element is always in the DOM (for aria-live to work) but visually hidden
   when there's no text. */
.hm-comments__form-message {
	margin: 0;
	min-height: 0;
	padding: 0;
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 14px;
	line-height: 1.4;
	text-align: start;
	unicode-bidi: isolate;
}

.hm-comments__form-message:empty {
	display: none;
}

.hm-comments__form-message--error {
	color: var(--hm-color-accent);
}

.hm-comments__form-message--success {
	color: #1a7f37;
}

/* Submit button — full-width orange pill, Pompei Bold 16px, dark text. */
.hm-comments__submit {
	display: block;
	width: 100%;
	height: 52px;
	background-color: var(--hm-color-orange);
	border: 0;
	border-radius: 14px;
	color: var(--hm-color-text);
	font-family: var(--hm-font-primary);
	font-weight: 700;
	font-size: 16px;
	line-height: 22px;
	cursor: pointer;
	transition: opacity var(--hm-transition-fast);
}

.hm-comments__submit:hover,
.hm-comments__submit:focus-visible {
	opacity: 0.9;
	outline: none;
}

/* ==========================================================================
   Reply indicator (form)
   ========================================================================== */

.hm-comments__form-indicator {
	position: relative;
	padding: 12px 16px 12px 44px; /* extra inline-end padding for the × button */
	background-color: rgba(239, 144, 32, 0.1);
	border: 1px solid rgba(239, 144, 32, 0.4);
	border-radius: 14px;
	color: var(--hm-color-text);
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 14px;
	line-height: 1.4;
	text-align: start;
	unicode-bidi: isolate;
}

.hm-comments__form-indicator-cancel {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-end: 12px;
	transform: translateY(-50%);
	width: 24px;
	height: 24px;
	padding: 0;
	background: none;
	border: 0;
	color: var(--hm-color-text);
	font-family: inherit;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.6;
	transition: opacity var(--hm-transition-fast);
}

.hm-comments__form-indicator-cancel:hover {
	opacity: 1;
}

.hm-comments__form-indicator-text {
	margin: 0;
}

.hm-comments__form-indicator-prefix {
	margin-inline-end: 4px;
}

.hm-comments__form-indicator-author {
	font-weight: 700;
}

.hm-comments__form-indicator-snippet {
	margin-inline-start: 6px;
	opacity: 0.7;
}

/* ==========================================================================
   Comment list
   ========================================================================== */

.hm-comments__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hm-comments__list .children {
	margin: 0;
	padding-inline-start: 30px;
	list-style: none;
	border-inline-start: 2px solid var(--hm-color-orange);
}

/* Each comment <li> — only its inner article-row gets borders, so nested
   replies don't create double-borders next to the parent. */
.hm-comments__list .comment {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hm-comment__row {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	padding-block: 15px;
	border-block-start: 0.5px solid rgba(56, 56, 56, 0.25);
	border-block-end: 0.5px solid rgba(56, 56, 56, 0.25);
}

/* Avoid double-borders between adjacent comments — a sibling's top border
   collapses with the previous sibling's bottom border. Applies both to
   sibling top-level comments AND to consecutive replies inside .children. */
.hm-comments__list .comment + .comment .hm-comment__row {
	border-block-start: 0;
}

/* Avoid double-borders between a parent comment and its first reply: the
   parent's bottom border already separates them, so the reply skips its
   own top border. Without this, the two borders sit ~1px apart and read
   as a duplicated separator. */
.hm-comments__list .children > .comment:first-child .hm-comment__row {
	border-block-start: 0;
}

/* Right side (RTL = first DOM): badge + body */
.hm-comment__main {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	flex: 1 1 auto;
	min-width: 0;
}

.hm-comment__badge {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 8px 15px;
	background-color: #ffffff;
	border-radius: 20px;
	color: var(--hm-color-orange);
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 16px;
	line-height: 22px;
	box-sizing: border-box;
}

.hm-comment__badge-text {
	display: inline-block;
	white-space: nowrap;
}

.hm-comment__body {
	min-width: 0;
	color: var(--hm-color-text);
	font-family: var(--hm-font-primary);
	font-size: 16px;
	line-height: 22px;
	text-align: start;
	unicode-bidi: isolate;
}

.hm-comment__text {
	font-weight: 700;
	overflow-wrap: anywhere;
}

.hm-comment__text > p {
	margin: 0 0 4px 0;
}

.hm-comment__text > p:last-child {
	margin-bottom: 0;
}

.hm-comment__author {
	margin: 0;
	font-weight: 300;
	opacity: 0.7;
}

/* Left side (RTL = last DOM): votes + reply link */
.hm-comment__actions {
	display: flex;
	flex-direction: column;
	align-items: flex-end; /* RTL: flex-start = RIGHT inside this nested container */
	gap: 3px;
	flex-shrink: 0;
	width: 87px;
}

.hm-comment__votes {
	display: flex;
	align-items: flex-start;
	gap: 9px;
}

.hm-comment__vote {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	padding: 0;
	background: none;
	border: 0;
	color: var(--hm-color-text);
	cursor: pointer;
	transition: color var(--hm-transition-fast), opacity var(--hm-transition-fast);
}

.hm-comment__vote:hover {
	opacity: 0.75;
}

.hm-comment__vote:focus-visible {
	outline: 2px solid var(--hm-color-orange);
	outline-offset: 2px;
	border-radius: 2px;
}

.hm-comment__vote-icon {
	display: block;
	width: 15px;
	height: 15px;
}

.hm-comment__vote-count {
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 12px;
	line-height: 1;
	color: var(--hm-color-text);
}

.hm-comment__vote-count[hidden] {
	display: none !important;
}

/* Pressed state — colour the active vote button. */
.hm-comment__vote--up[aria-pressed="true"] {
	color: var(--hm-color-orange);
}

.hm-comment__vote--down[aria-pressed="true"] {
	color: var(--hm-color-accent);
}

.hm-comment__reply-link {
	padding: 0;
	background: none;
	border: 0;
	color: var(--hm-color-text);
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 16px;
	line-height: 22px;
	text-decoration: underline;
	text-align: start;
	cursor: pointer;
	opacity: 0.7;
	transition: color var(--hm-transition-fast), opacity var(--hm-transition-fast);
}

.hm-comment__reply-link:hover,
.hm-comment__reply-link:focus-visible {
	color: var(--hm-color-accent);
	opacity: 1;
	outline: none;
}

/* "Comments are closed" notice */
.hm-comments__closed {
	margin: 16px 0 0 0;
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 16px;
	color: var(--hm-color-text);
	opacity: 0.7;
	text-align: start;
}

/* Comments-navigation links — tight, inherits font from body. */
.comments-area .navigation {
	margin-block-start: 16px;
}

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 767px) {
	.hm-comments-area {
		margin-block: 32px;
		padding-inline: 0;
	}

	.hm-comments__form-row {
		flex-direction: column;
		gap: 12px;
	}

	.hm-comments__heading {
		font-size: 26px;
	}

	.hm-comment__row {
		flex-direction: column;
		align-items: stretch;
		gap: 12px;
	}

	.hm-comment__actions {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		gap: 16px;
	}

	.hm-comments__list .children {
		padding-inline-start: 16px;
	}
}
