/**
 * DinnerlyHub - Comments & Recipe Ratings
 * Branded comment list, comment form, star-rating selector and read-only stars.
 */

:root {
	--dh-star-empty: #e0ddd6;
	--dh-star-active: var(--dh-orange);
	/* Star silhouette used as a CSS mask so a plain box becomes a star. */
	--dh-star-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2.95 5.98 6.6.96-4.78 4.66 1.13 6.57L12 17.02 6.1 20.13l1.13-6.57L2.45 8.9l6.6-.96L12 2z'/%3E%3C/svg%3E");
}

/* ==========================================================================
   READ-ONLY STARS (summary + per-comment)
   ========================================================================== */

.dh-stars {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	line-height: 0;
}

.dh-stars__star {
	width: 17px;
	height: 17px;
	display: inline-block;
	background-color: var(--dh-star-empty);
	-webkit-mask: var(--dh-star-mask) center / contain no-repeat;
	mask: var(--dh-star-mask) center / contain no-repeat;
}

.dh-stars__star--full {
	background-color: var(--dh-star-active);
}

.dh-stars__star--half {
	background-image: linear-gradient(90deg, var(--dh-star-active) 50%, var(--dh-star-empty) 50%);
}

.dh-stars--sm .dh-stars__star {
	width: 14px;
	height: 14px;
}

/* ==========================================================================
   RATING SUMMARY (near the recipe title)
   ========================================================================== */

/* Sits on its own full-width row at the top of the meta block. */
.dh-single__meta .dh-rating-summary {
	flex-basis: 100%;
	order: -1;
	margin-bottom: 4px;
}

.dh-rating-summary {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	padding: 7px 8px 7px 14px;
	font-family: var(--dh-font-body);
	background: var(--dh-green-subtle);
	border: 1px solid var(--dh-green-border);
	border-radius: var(--dh-radius-pill);
	text-decoration: none;
	cursor: pointer;
	transition: background var(--dh-ease), border-color var(--dh-ease), transform var(--dh-ease), box-shadow var(--dh-ease);
}

button.dh-rating-summary {
	-webkit-appearance: none;
	appearance: none;
}

button.dh-rating-summary:hover {
	background: rgba(74, 124, 89, 0.14);
	border-color: rgba(74, 124, 89, 0.35);
	transform: translateY(-1px);
	box-shadow: var(--dh-shadow-sm);
}

.dh-rating-summary--static {
	cursor: default;
}

.dh-rating-summary__value {
	font-family: var(--dh-font-heading);
	font-weight: 700;
	font-size: 0.95rem;
	color: var(--dh-text-heading);
}

.dh-rating-summary__count {
	font-size: var(--dh-text-sm);
	color: var(--dh-gray-meta);
	font-weight: 500;
}

/* "Rate This Recipe" call-to-action pill on the right of the trigger. */
.dh-rating-summary__cta {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	margin-left: 2px;
	padding: 5px 13px;
	font-family: var(--dh-font-heading);
	font-size: var(--dh-text-sm);
	font-weight: 700;
	color: var(--dh-white);
	background: var(--dh-orange);
	border-radius: var(--dh-radius-pill);
	white-space: nowrap;
	transition: background var(--dh-ease);
}

button.dh-rating-summary:hover .dh-rating-summary__cta {
	background: var(--dh-orange-dark);
}

.dh-rating-summary__cta-icon {
	width: 13px;
	height: 13px;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.dh-rating-summary--empty .dh-stars {
	/* Invite the first rating with a warmer empty state. */
	opacity: 0.85;
}

/* ==========================================================================
   COMMENT LIST
   ========================================================================== */

.dh-comments__inner {
	margin-top: 8px;
}

.dh-comment-list {
	list-style: none;
	margin: 0 0 40px;
	padding: 0;
}

.dh-comment-list ol.children {
	list-style: none;
	margin: 18px 0 0;
	padding: 18px 0 0 clamp(16px, 4vw, 40px);
	border-left: 2px solid var(--dh-green-border);
}

.dh-comment {
	margin: 0 0 18px;
}

.dh-comment:last-child {
	margin-bottom: 0;
}

.dh-comment__body {
	display: flex;
	gap: 16px;
	padding: 20px 22px;
	background: var(--dh-white);
	border: 1px solid rgba(74, 124, 89, 0.12);
	border-radius: var(--dh-radius-md);
	box-shadow: var(--dh-shadow-sm);
}

.dh-comment__avatar {
	flex-shrink: 0;
}

.dh-comment__avatar-img {
	width: 52px;
	height: 52px;
	border-radius: 50%;
	border: 2px solid var(--dh-green-subtle);
	object-fit: cover;
}

.dh-comment__main {
	flex: 1;
	min-width: 0;
}

.dh-comment__header {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px 12px;
	margin-bottom: 8px;
}

.dh-comment__author {
	font-family: var(--dh-font-heading);
	font-weight: 700;
	font-size: 1rem;
	color: var(--dh-text-heading);
}

.dh-comment__date {
	font-size: var(--dh-text-xs);
	color: var(--dh-gray-meta);
	margin-left: auto;
}

.dh-comment__moderation {
	margin: 0 0 8px;
	font-size: var(--dh-text-sm);
	font-style: italic;
	color: var(--dh-orange-text);
}

.dh-comment__content {
	color: var(--dh-text-paragraph);
	font-size: var(--dh-text-body);
	line-height: var(--dh-leading-relaxed);
}

.dh-comment__content p {
	margin: 0 0 10px;
}

.dh-comment__content p:last-child {
	margin-bottom: 0;
}

.dh-comment__actions {
	margin-top: 10px;
	display: flex;
	gap: 16px;
	font-size: var(--dh-text-sm);
	font-weight: 600;
}

.dh-comment__actions a {
	color: var(--dh-green);
	text-decoration: none;
	transition: color var(--dh-ease);
}

.dh-comment__actions a:hover {
	color: var(--dh-orange);
}

.dh-comments__closed {
	color: var(--dh-gray-meta);
	font-style: italic;
	margin: 0 0 28px;
}

/* ==========================================================================
   COMMENT FORM
   ========================================================================== */

.dh-comment-form {
	background: linear-gradient(180deg, var(--dh-green-subtle), rgba(74, 124, 89, 0.02));
	border: 1px solid var(--dh-green-border);
	border-radius: var(--dh-radius-lg);
	padding: clamp(22px, 4vw, 36px);
}

.dh-comment-form__title {
	font-family: var(--dh-font-heading);
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--dh-text-heading);
	margin: 0 0 6px;
}

.dh-comment-form__notes,
.comment-form .comment-notes {
	font-size: var(--dh-text-sm);
	color: var(--dh-gray-meta);
	margin: 0 0 22px;
}

.comment-form .required {
	color: var(--dh-orange-text);
}

/* Field rows: author + email side by side on wider screens */
.dh-comment-form .comment-form-author,
.dh-comment-form .comment-form-email,
.dh-comment-form .comment-form-comment {
	margin: 0 0 18px;
}

@media (min-width: 600px) {
	.dh-comment-form .comment-form-author,
	.dh-comment-form .comment-form-email {
		display: inline-block;
		width: calc(50% - 8px);
		vertical-align: top;
	}

	.dh-comment-form .comment-form-author {
		margin-right: 14px;
	}
}

.dh-comment-form label {
	display: block;
	font-family: var(--dh-font-heading);
	font-weight: 600;
	font-size: var(--dh-text-sm);
	color: var(--dh-text-heading);
	margin-bottom: 7px;
}

.dh-comment-form input[type="text"],
.dh-comment-form input[type="email"],
.dh-comment-form textarea {
	width: 100%;
	font-family: var(--dh-font-body);
	font-size: var(--dh-text-body);
	color: var(--dh-text);
	background: var(--dh-white);
	border: 1.5px solid rgba(74, 124, 89, 0.20);
	border-radius: var(--dh-radius-sm);
	padding: 12px 14px;
	transition: border-color var(--dh-ease), box-shadow var(--dh-ease);
}

.dh-comment-form textarea {
	resize: vertical;
	min-height: 130px;
	line-height: var(--dh-leading-normal);
}

.dh-comment-form input::placeholder,
.dh-comment-form textarea::placeholder {
	color: #9a9a9a;
}

.dh-comment-form input[type="text"]:focus,
.dh-comment-form input[type="email"]:focus,
.dh-comment-form textarea:focus {
	outline: none;
	border-color: var(--dh-green);
	box-shadow: 0 0 0 3px var(--dh-green-subtle);
}

/* Cookie consent row */
.comment-form-cookies-consent {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 4px 0 22px;
}

.comment-form-cookies-consent input {
	margin-top: 3px;
	accent-color: var(--dh-green);
}

.comment-form-cookies-consent label {
	margin: 0;
	font-weight: 500;
	font-family: var(--dh-font-body);
	color: var(--dh-text-light);
	font-size: var(--dh-text-sm);
}

/* Submit button */
.dh-comment-form .form-submit {
	margin: 6px 0 0;
}

.dh-comment-form__submit,
.dh-comment-form input[type="submit"] {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: var(--dh-font-heading);
	font-weight: 700;
	font-size: var(--dh-text-body);
	color: var(--dh-white);
	background: var(--dh-green);
	border: none;
	border-radius: var(--dh-radius-pill);
	padding: 13px 30px;
	cursor: pointer;
	box-shadow: var(--dh-shadow-btn-green);
	transition: background var(--dh-ease), transform var(--dh-ease), box-shadow var(--dh-ease);
}

.dh-comment-form__submit:hover,
.dh-comment-form input[type="submit"]:hover {
	background: var(--dh-green-dark);
	transform: translateY(-2px);
	box-shadow: var(--dh-shadow-btn-green-hover);
}

.dh-comment-form__submit:active,
.dh-comment-form input[type="submit"]:active {
	transform: translateY(0);
}

/* Reply context: "Cancel reply" link + logged-in / log-out lines */
.comment-reply-title small {
	margin-left: 10px;
	font-weight: 500;
}

.comment-reply-title small a {
	color: var(--dh-orange-text);
}

.logged-in-as,
.must-log-in {
	font-size: var(--dh-text-sm);
	color: var(--dh-gray-meta);
	margin: 0 0 18px;
}

.logged-in-as a,
.must-log-in a {
	color: var(--dh-green);
	font-weight: 600;
}

/* ==========================================================================
   STAR-RATING SELECTOR (in the comment form)
   ========================================================================== */

.dh-rating-input {
	border: none;
	margin: 0 0 22px;
	padding: 0;
}

.dh-rating-input__legend {
	font-family: var(--dh-font-heading);
	font-weight: 700;
	font-size: 1.05rem;
	color: var(--dh-text-heading);
	padding: 0;
	margin-bottom: 4px;
}

.dh-rating-input__optional {
	font-family: var(--dh-font-body);
	font-weight: 500;
	font-size: var(--dh-text-sm);
	color: var(--dh-gray-meta);
	margin-left: 4px;
}

/* Reverse row so adjacent-sibling CSS can fill stars to the left of the
   hovered/checked one. Visual order remains 1 → 5 (left → right). */
.dh-rating-input__stars {
	position: relative;
	display: inline-flex;
	flex-direction: row-reverse;
	justify-content: flex-end;
	gap: 4px;
	margin: 6px 0 8px;
}

/* Hide the native radios in place (NOT with .screen-reader-text, which the
   theme un-hides on :focus and would scroll the page to the top). Keeping them
   anchored inside the visible star row means focusing one never jumps the page. */
.dh-rating-input__radio {
	position: absolute;
	top: 0;
	left: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	opacity: 0;
	pointer-events: none;
}

.dh-rating-input__star {
	cursor: pointer;
	color: var(--dh-star-empty);
	transition: color 0.12s ease, transform 0.12s ease;
	line-height: 0;
}

.dh-rating-input__star svg {
	width: 34px;
	height: 34px;
	fill: currentColor;
	pointer-events: none;
}

/* Checked state: this star + all earlier (lower-value) ones. */
.dh-rating-input__radio:checked ~ .dh-rating-input__star {
	color: var(--dh-star-active);
}

/* Hover preview overrides the checked state while the pointer is over. */
.dh-rating-input__stars:hover .dh-rating-input__star {
	color: var(--dh-star-empty);
}

.dh-rating-input__star:hover,
.dh-rating-input__star:hover ~ .dh-rating-input__star {
	color: var(--dh-star-active);
	transform: scale(1.08);
}

/* Keyboard focus on the (visually hidden) radios. */
.dh-rating-input__radio:focus-visible + .dh-rating-input__star {
	outline: 2px solid var(--dh-green);
	outline-offset: 3px;
	border-radius: var(--dh-radius-sm);
}

.dh-rating-input__help {
	font-size: var(--dh-text-sm);
	color: var(--dh-gray-meta);
	margin: 0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 600px) {
	.dh-comment__body {
		gap: 12px;
		padding: 16px;
	}

	.dh-comment__avatar-img {
		width: 42px;
		height: 42px;
	}

	.dh-comment__date {
		margin-left: 0;
		flex-basis: 100%;
	}

	.dh-rating-input__star svg {
		width: 38px;
		height: 38px;
	}

	.dh-rating-summary {
		flex-wrap: wrap;
	}
}

/* ==========================================================================
   RATE THIS RECIPE — MODAL
   ========================================================================== */

.dh-rate-modal {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.dh-rate-modal[hidden] {
	display: none;
}

.dh-rate-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(26, 26, 26, 0.55);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
	animation: dh-rate-fade 0.2s ease;
}

.dh-rate-modal__dialog {
	position: relative;
	width: 100%;
	max-width: 460px;
	max-height: calc(100vh - 40px);
	overflow-y: auto;
	background: var(--dh-white);
	border-radius: var(--dh-radius-lg);
	box-shadow: var(--dh-shadow-lg);
	padding: clamp(24px, 5vw, 38px);
	text-align: center;
	animation: dh-rate-pop 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dh-rate-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes dh-rate-pop {
	from { opacity: 0; transform: translateY(12px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.dh-rate-modal__overlay,
	.dh-rate-modal__dialog {
		animation: none;
	}
}

.dh-rate-modal__close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--dh-text-muted);
	background: transparent;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	transition: background var(--dh-ease), color var(--dh-ease);
}

.dh-rate-modal__close:hover {
	background: var(--dh-green-subtle);
	color: var(--dh-text-heading);
}

.dh-rate-modal__close svg {
	width: 20px;
	height: 20px;
}

.dh-rate-modal__title {
	font-family: var(--dh-font-heading);
	font-size: 1.6rem;
	font-weight: 700;
	color: var(--dh-text-heading);
	margin: 0 0 4px;
}

.dh-rate-modal__recipe {
	font-size: var(--dh-text-body);
	font-weight: 600;
	color: var(--dh-green);
	margin: 0 0 18px;
}

/* Centered, larger stars inside the modal. */
.dh-rating-input--modal {
	margin: 0 0 18px;
}

.dh-rating-input--modal .dh-rating-input__legend {
	display: none;
}

.dh-rating-input--modal .dh-rating-input__stars {
	justify-content: center;
	gap: 8px;
	margin: 0;
}

.dh-rating-input--modal .dh-rating-input__star svg {
	width: 42px;
	height: 42px;
}

.dh-rate-modal__field {
	margin: 0 0 14px;
	text-align: left;
}

.dh-rate-modal__field label {
	display: block;
	font-family: var(--dh-font-heading);
	font-weight: 600;
	font-size: var(--dh-text-sm);
	color: var(--dh-text-heading);
	margin-bottom: 6px;
}

.dh-rate-modal__field textarea,
.dh-rate-modal__field input {
	width: 100%;
	font-family: var(--dh-font-body);
	font-size: var(--dh-text-body);
	color: var(--dh-text);
	background: var(--dh-white);
	border: 1.5px solid rgba(74, 124, 89, 0.20);
	border-radius: var(--dh-radius-sm);
	padding: 12px 14px;
	transition: border-color var(--dh-ease), box-shadow var(--dh-ease);
}

.dh-rate-modal__field textarea {
	resize: vertical;
	min-height: 88px;
	line-height: var(--dh-leading-normal);
}

.dh-rate-modal__field textarea:focus,
.dh-rate-modal__field input:focus {
	outline: none;
	border-color: var(--dh-green);
	box-shadow: 0 0 0 3px var(--dh-green-subtle);
}

.dh-rate-modal__field input::placeholder,
.dh-rate-modal__field textarea::placeholder {
	color: #9a9a9a;
}

.dh-rate-modal__loggedin {
	text-align: left;
	font-size: var(--dh-text-sm);
	color: var(--dh-gray-meta);
	margin: 0 0 14px;
}

.dh-rate-modal__submit {
	width: 100%;
	font-family: var(--dh-font-heading);
	font-weight: 700;
	font-size: var(--dh-text-body);
	color: var(--dh-white);
	background: var(--dh-green);
	border: none;
	border-radius: var(--dh-radius-sm);
	padding: 14px 24px;
	margin-top: 4px;
	cursor: pointer;
	box-shadow: var(--dh-shadow-btn-green);
	transition: background var(--dh-ease), transform var(--dh-ease), box-shadow var(--dh-ease);
}

.dh-rate-modal__submit:hover {
	background: var(--dh-green-dark);
	transform: translateY(-2px);
	box-shadow: var(--dh-shadow-btn-green-hover);
}

.dh-rate-modal__submit:active {
	transform: translateY(0);
}

/* Lock background scroll while the modal is open. */
body.dh-rate-modal-open {
	overflow: hidden;
}
