/*
 * RahkarTheme — اطلاع از موجودی (back-in-stock) button + modal.
 *
 * Loaded only on single-product pages with an OOS state. All values come
 * from theme.json tokens. The button is a primary CTA (brand blue), per the
 * brand rule — never the accent red.
 */

/* -------------------------------------------------------------------------
 *  The notify button — drops into the cart bar where the add-to-cart /
 *  disabled «ناموجود» button would be. Matches the add-btn footprint so the
 *  bar height never shifts (CLS = 0).
 * ------------------------------------------------------------------------- */
.rh-product__notify-btn {
	flex: 1;
	min-height: var(--wp--custom--button--h--lg, 52px);
	border: 0;
	border-radius: var(--wp--custom--button--radius, 10px);
	background: var(--wp--preset--color--primary, #0a66c2);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--wp--custom--button--gap, 8px);
	cursor: pointer;
	padding: 0 var(--wp--custom--button--px--lg, 22px);
	font-weight: var(--wp--custom--button--fw, 600);
	font-size: var(--wp--custom--button--fs--lg, 1rem);
	font-family: inherit;
	transition: background-color 120ms linear, transform 80ms linear;
}
/* The explicit display above outranks the UA [hidden] rule, so a button shipped
 * `hidden` (variable parent that's in stock but has OOS variations — revealed by
 * product-single.js only when an OOS variation is picked) would otherwise show
 * on first paint. Re-assert hidden at class+attribute specificity. */
.rh-product__notify-btn[hidden] {
	display: none;
}
.rh-product__notify-btn:hover {
	background: var(--wp--preset--color--primary-dark, #074a8d);
}
.rh-product__notify-btn:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary, #0a66c2);
	outline-offset: 2px;
}
.rh-product__notify-btn:active {
	transform: translateY(1px);
}
.rh-product__notify-icon {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
}

/* -------------------------------------------------------------------------
 *  The subscribe modal (native <dialog>).
 *  Desktop: centered card. Mobile: bottom sheet.
 * ------------------------------------------------------------------------- */
/* The JS toggles views/icons via the [hidden] attribute, but several of them
   (.rh-sn-tick, .rh-sn-bell, .rh-sn-input) carry an explicit display, which
   would otherwise win over [hidden]'s display:none and leave them visible.
   Force [hidden] to win inside the modal. */
.rh-sn-modal [hidden] {
	display: none !important;
}

.rh-sn-modal {
	/* Canonical viewport centering. JS relocates the dialog to <body> so this
	   fixed positioning is viewport-relative even when an ancestor on the
	   product page has a transform. */
	position: fixed;
	inset: 0;
	margin: auto;
	border: 0;
	padding: 0;
	width: min(420px, calc(100vw - 2rem));
	max-width: calc(100vw - 2rem);
	max-height: calc(100vh - 2rem);
	border-radius: var(--wp--custom--radius--lg, 0.75rem);
	box-shadow: var(--wp--preset--shadow--lg, 0 16px 40px rgba(15, 17, 21, 0.14));
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--text, #1a1d23);
}
.rh-sn-modal::backdrop {
	background: rgba(15, 17, 21, 0.45);
}
.rh-sn-modal__inner {
	position: relative;
	padding: 1.5rem 1.25rem 1.25rem;
}
.rh-sn-modal__close {
	position: absolute;
	inset-inline-end: 0.5rem;
	inset-block-start: 0.5rem;
	width: 36px;
	height: 36px;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--text-muted, #5b6271);
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
	border-radius: var(--wp--custom--radius--sm, 0.25rem);
}
.rh-sn-modal__close:hover {
	background: var(--wp--preset--color--surface, #f7f7f8);
}
.rh-sn-modal__title {
	margin: 0 0 0.35rem;
	font-size: var(--wp--preset--font-size--lg, 1.25rem);
	font-weight: 700;
}
.rh-sn-modal__intro {
	margin: 0 0 1rem;
	color: var(--wp--preset--color--text-muted, #5b6271);
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	line-height: 1.8;
}

/* known (logged-in) confirm view */
.rh-sn-known__line {
	margin: 0 0 0.75rem;
	font-size: var(--wp--preset--font-size--base, 1rem);
}
.rh-sn-known__line strong {
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.5px;
}
.rh-sn-known__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

/* free phone entry view */
.rh-sn-input {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}
.rh-sn-field {
	width: 100%;
	min-height: var(--wp--custom--button--h--md, 44px);
	padding: 0 0.85rem;
	border: 1px solid var(--wp--preset--color--border, #e2e4e9);
	border-radius: var(--wp--custom--radius--md, 0.5rem);
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--text, #1a1d23);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--base, 1rem);
	text-align: center;
}
.rh-sn-field:focus {
	outline: 0;
	border-color: var(--wp--preset--color--primary, #0a66c2);
	box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.15);
}
.rh-sn-field.is-error {
	border-color: var(--wp--preset--color--danger, #dc2626);
}

/* shared button styles inside the modal */
.rh-sn-btn {
	min-height: var(--wp--custom--button--h--md, 44px);
	padding: 0 var(--wp--custom--button--px--md, 20px);
	border: 0;
	border-radius: var(--wp--custom--button--radius, 10px);
	font-family: inherit;
	font-weight: var(--wp--custom--button--fw, 600);
	font-size: var(--wp--custom--button--fs--md, 0.9375rem);
	cursor: pointer;
}
.rh-sn-btn--primary {
	background: var(--wp--preset--color--primary, #0a66c2);
	color: #fff;
}
.rh-sn-btn--primary:hover {
	background: var(--wp--preset--color--primary-dark, #074a8d);
}
.rh-sn-btn--primary:disabled {
	opacity: 0.6;
	cursor: progress;
}
.rh-sn-btn--link {
	background: transparent;
	color: var(--wp--preset--color--primary, #0a66c2);
	padding-inline: 0.25rem;
	min-height: auto;
}
.rh-sn-btn--link:hover {
	text-decoration: underline;
}

/* status line */
.rh-sn-msg {
	margin-top: 0.85rem;
	min-height: 1.2em;
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	line-height: 1.7;
}
.rh-sn-msg[data-tone="error"]   { color: var(--wp--preset--color--danger, #dc2626); }
.rh-sn-msg[data-tone="success"] { color: var(--wp--preset--color--success, #198754); }

/* -------------------------------------------------------------------------
 *  Success step — animated green tick, mirroring the review-submit screen.
 * ------------------------------------------------------------------------- */
.rh-sn-success {
	text-align: center;
	padding: 0.5rem 0 0.25rem;
}
.rh-sn-tick {
	display: inline-flex;
	margin-block-end: 0.75rem;
	color: var(--wp--preset--color--success, #198754);
}
/* Repeat-submit state: neutral brand-blue bell with a gentle pop — clearly
   "you're already on the list", not a fresh green success. */
.rh-sn-bell {
	display: inline-flex;
	margin-block-end: 0.75rem;
	color: var(--wp--preset--color--primary, #0a66c2);
	animation: rh-sn-bell-pop 320ms ease;
}
@keyframes rh-sn-bell-pop {
	0%   { transform: scale(0.6); opacity: 0; }
	60%  { transform: scale(1.08); opacity: 1; }
	100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
	.rh-sn-bell { animation: none; }
}
.rh-sn-tick__circle,
.rh-sn-tick__check {
	stroke-dasharray: 200;
	stroke-dashoffset: 200;
	animation: rh-sn-tick-draw 600ms ease forwards;
}
.rh-sn-tick__check { animation-delay: 250ms; }
@keyframes rh-sn-tick-draw {
	to { stroke-dashoffset: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.rh-sn-tick__circle,
	.rh-sn-tick__check { animation: none; stroke-dashoffset: 0; }
}
.rh-sn-success__title {
	margin: 0 0 0.5rem;
	font-size: var(--wp--preset--font-size--lg, 1.25rem);
	font-weight: 700;
	color: var(--wp--preset--color--contrast, #0f1115);
}
.rh-sn-success__text {
	margin: 0 0 1.1rem;
	color: var(--wp--preset--color--text-muted, #5b6271);
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	line-height: 1.8;
}
.rh-sn-success .rh-sn-btn--primary {
	min-width: 140px;
}

/* Mobile: bottom sheet (overrides the centered desktop positioning). */
@media (max-width: 600px) {
	.rh-sn-modal {
		inset: auto 0 0 0;
		margin: 0;
		width: 100%;
		max-width: 100%;
		max-height: 90vh;
		border-end-end-radius: 0;
		border-end-start-radius: 0;
		padding-bottom: env(safe-area-inset-bottom);
	}
}
