/* ==========================================================================
   Tarhee — checkout.css
   One-page cart + checkout (inc/woocommerce/quick-checkout.php).
   Loaded only on the checkout page when the feature is on. No JavaScript.
   ========================================================================== */

/* ---------- White card ---------- */
.tarhee-qc-page .site-main .entry { max-width: 760px; margin-inline: auto; }
.tarhee-qc {
	margin: 0 0 24px;
	padding: 28px 28px 30px;
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
}
.tarhee-qc :where(.woocommerce-message, .woocommerce-info, .woocommerce-error) { margin: 0 0 16px; }

/* ---------- Layout (the real WooCommerce form, re-ordered with CSS only) ---------- */
.tarhee-qc--active form.checkout {
	display: flex;
	flex-direction: column;
	gap: 14px;
	counter-reset: tqc;
}
/* Order: 1 cart → 2 buyer fields → 3 gateways → amount → pay button. */
.tarhee-qc--active .tarhee-qc__cart { order: 1; }
.tarhee-qc--active #customer_details { order: 2; }
.tarhee-qc--active #order_review_heading { display: none; }
.tarhee-qc--active #order_review,
.tarhee-qc--active #payment { display: contents; }
.tarhee-qc--active .tarhee-qc__h--pay { order: 3; }
.tarhee-qc--active .wc_payment_methods { order: 4; }
.tarhee-qc--active .woocommerce-checkout-review-order-table { order: 5; }
.tarhee-qc--active .form-row.place-order { order: 6; }
.tarhee-qc--active .woocommerce-NoticeGroup { order: 0; }

/* Items are shown in section 1: the table keeps only discounts, fees and the total. */
.tarhee-qc--active .woocommerce-checkout-review-order-table thead,
.tarhee-qc--active .woocommerce-checkout-review-order-table tbody { display: none; }
.tarhee-qc--active #customer_details .col-2 { display: none; }
.tarhee-qc--active #customer_details .col-1 { width: 100%; float: none; }

/* ---------- Section titles with step numbers ---------- */
.tarhee-qc__h,
.tarhee-qc--active #customer_details h3 {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 12px;
	font-size: var(--tqc-title-fs, 1.1rem);
	font-weight: var(--fw-heading);
	line-height: 1.6;
	color: var(--navy);
}
.tarhee-qc__h::before,
.tarhee-qc--active #customer_details h3::before {
	content: counter(tqc);
	content: counter(tqc, persian);
	counter-increment: tqc;
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: var(--tqc-num-box, 28px);
	height: var(--tqc-num-box, 28px);
	border-radius: 50%;
	background: var(--gold-soft);
	color: var(--gold-dark);
	font-size: var(--tqc-num-fs, .85rem);
	font-weight: var(--fw-strong);
}
.tarhee-qc--empty .tarhee-qc__h::before { content: none; }

/* ---------- Cart items ---------- */
.tarhee-qc__proof {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 12px;
	padding: 8px 12px;
	background: var(--gold-soft);
	border-radius: var(--radius-sm);
	font-size: .84rem;
	font-weight: var(--fw-label);
	color: var(--gold-dark);
}
.tarhee-qc__items { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.tarhee-qc__item {
	position: relative;
	display: grid;
	grid-template-columns: 76px minmax(0, 1fr) auto;
	align-items: center;
	gap: 6px 14px;
	padding: 10px 40px 10px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
}
.tarhee-qc__thumb { display: block; width: 76px; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 8px; background: #fff; }
.tarhee-qc__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tarhee-qc__info { display: grid; gap: 4px; min-width: 0; }
.tarhee-qc__name { font-size: .95rem; font-weight: var(--fw-label); line-height: 1.7; color: var(--navy); overflow-wrap: anywhere; }
a.tarhee-qc__name:hover { color: var(--gold-dark); }
.entry-content .tarhee-qc a.tarhee-qc__name { text-decoration: none; }
.tarhee-qc__tag {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	justify-self: start;
	font-size: .74rem;
	font-weight: var(--fw-label);
	color: var(--success);
}
.tarhee-qc__info .variation { margin: 0; font-size: .78rem; color: var(--muted); }
.tarhee-qc__price { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 2px 8px; font-size: 1rem; font-weight: var(--fw-heading); color: var(--navy); }
.tarhee-qc__price ins { text-decoration: none; background: transparent; }
.tarhee-qc__price del { font-size: .8rem; font-weight: var(--fw-medium); color: #5b6472; }
.tarhee-qc__price del .woocommerce-Price-currencySymbol { color: inherit; }
.tarhee-qc__qty { font-size: .8rem; font-weight: var(--fw-label); color: var(--muted); }
.tarhee-qc__remove {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-end: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	margin-top: -14px;
	border-radius: 50%;
	color: var(--muted);
	transition: background-color .2s, color .2s;
}
.tarhee-qc__remove:hover { background: #fee2e2; color: var(--danger); }
.tarhee-qc__saved {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 12px 0 0;
	font-size: .86rem;
	font-weight: var(--fw-label);
	color: var(--success);
}

/* ---------- Buyer fields ---------- */
.tarhee-qc .woocommerce-billing-fields__field-wrapper {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 4px 14px;
}
.tarhee-qc .form-row { margin: 0 0 8px; padding: 0; float: none; width: auto; }
.tarhee-qc .form-row-wide { grid-column: 1 / -1; }
.tarhee-qc .form-row label { display: block; margin-bottom: 4px; font-size: .86rem; font-weight: var(--fw-label); color: var(--navy); }
.tarhee-qc .form-row .required { color: var(--danger); text-decoration: none; border: 0; }
.tarhee-qc .form-row .optional { font-weight: var(--fw-body); color: var(--muted); }
.tarhee-qc .form-row .description { display: block; margin-top: 4px; font-size: .78rem; color: var(--muted); }
.tarhee-qc .form-row input[dir='ltr']::placeholder { text-align: right; }
.tarhee-qc .woocommerce-invalid input.input-text,
.tarhee-qc .woocommerce-invalid textarea { border-color: var(--danger); }

/* ---------- Gateways ---------- */
.tarhee-qc .wc_payment_methods { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tarhee-qc .wc_payment_method {
	padding: 12px 14px;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	background: #fff;
	transition: border-color .2s, background-color .2s;
}
.tarhee-qc .wc_payment_method:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); }
.tarhee-qc .wc_payment_method > label { display: inline; margin-inline-start: 6px; font-weight: var(--fw-label); cursor: pointer; }
.tarhee-qc .wc_payment_method img { max-height: 28px; width: auto; vertical-align: middle; margin-inline-start: 8px; }
.tarhee-qc .payment_box { margin-top: 8px; font-size: .84rem; color: var(--muted); line-height: 1.9; }
.tarhee-qc .payment_box p { margin: 0; }

/* ---------- Amount payable ---------- */
.tarhee-qc .woocommerce-checkout-review-order-table { width: 100%; border-collapse: collapse; margin: 0; }
.tarhee-qc .woocommerce-checkout-review-order-table :is(th, td) { padding: 8px 0; border: 0; text-align: start; font-size: .92rem; }
.tarhee-qc .woocommerce-checkout-review-order-table td { text-align: end; }
.tarhee-qc .woocommerce-checkout-review-order-table tr + tr :is(th, td) { border-top: 1px dashed var(--border); }
.tarhee-qc .woocommerce-checkout-review-order-table .order-total :is(th, td) {
	padding-top: 14px;
	font-size: clamp(.95rem, 3.6vw, 1.05rem);
	font-weight: var(--fw-heading);
	color: var(--navy);
}
.tarhee-qc .woocommerce-checkout-review-order-table .order-total td .woocommerce-Price-amount { font-size: clamp(1.1rem, 4.6vw, 1.25rem); }
.tarhee-qc .woocommerce-checkout-review-order-table .woocommerce-Price-currencySymbol { margin-inline-start: .3em; font-size: .8rem; font-weight: var(--fw-medium); color: var(--muted); }

/* ---------- Pay button ---------- */
.tarhee-qc .form-row.place-order { display: grid; gap: 12px; margin: 0; }
.tarhee-qc .woocommerce-terms-and-conditions-wrapper { font-size: .82rem; color: var(--muted); }
.tarhee-qc #place_order {
	position: relative;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 19px;
	border: 0;
	border-radius: var(--radius);
	background: linear-gradient(135deg, var(--cta) 0%, var(--cta-2) 100%);
	color: #fff;
	font-size: 1.1rem;
	font-weight: var(--fw-strong);
	line-height: 1.5;
	box-shadow: 0 10px 30px rgba(13, 26, 56, .28);
	transition: transform .35s var(--ease), box-shadow .35s var(--ease), opacity .2s;
}
.tarhee-qc #place_order::before {
	content: '';
	position: absolute;
	top: 0;
	inset-inline-start: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .22) 50%, transparent 70%);
	transition: inset-inline-start .7s var(--ease);
	pointer-events: none;
}
.tarhee-qc #place_order:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(13, 26, 56, .4); }
.tarhee-qc #place_order:hover::before { inset-inline-start: 100%; }
.tarhee-qc #place_order:active { transform: translateY(-1px); }
.tarhee-qc #place_order:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.tarhee-qc .processing #place_order { opacity: .7; pointer-events: none; }

.tarhee-qc__note {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 0;
	font-size: .82rem;
	text-align: center;
	color: var(--muted);
}
.tarhee-qc__trust {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px 18px;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: .8rem;
	font-weight: var(--fw-label);
	color: var(--navy);
}
.tarhee-qc__trust li { display: inline-flex; align-items: center; gap: 6px; }
.tarhee-qc__trust .tarhee-icon { color: var(--gold-dark); }

/* ---------- Coupon (collapsed link above the form) ---------- */
.tarhee-qc .woocommerce-form-coupon-toggle .woocommerce-info { margin: 0 0 14px; padding: 10px 14px; font-size: .84rem; }
.tarhee-qc form.checkout_coupon { margin: 0 0 14px; padding: 14px; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.tarhee-qc form.checkout_coupon p { margin: 0 0 8px; }
.tarhee-qc form.checkout_coupon .form-row { display: inline-block; vertical-align: top; }
.tarhee-qc form.checkout_coupon .form-row-first { width: calc(100% - 140px); }
.tarhee-qc form.checkout_coupon .form-row-last { width: 128px; }
.tarhee-qc form.checkout_coupon .button,
.tarhee-qc form.checkout_coupon .button:hover {
	background: linear-gradient(135deg, var(--gold), var(--gold-light));
	color: var(--navy);
}

/* ---------- Empty cart ---------- */
.tarhee-qc__empty { display: grid; justify-items: center; gap: 14px; padding: 24px 0; text-align: center; color: var(--muted); }
.tarhee-qc__empty p { margin: 0; font-size: 1rem; color: var(--navy); font-weight: var(--fw-label); }

/* ---------- Order received / pay for order ---------- */
.tarhee-qc--plain,
.tarhee-qc:not(.tarhee-qc--active):not(.tarhee-qc--empty) { overflow-wrap: anywhere; }
.tarhee-qc table.shop_table { width: 100%; border-collapse: collapse; }
.tarhee-qc table.shop_table :is(th, td) { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: start; }
.tarhee-qc .woocommerce-order-downloads .button,
.tarhee-qc a.woocommerce-MyAccount-downloads-file { background: var(--tqd-bg, linear-gradient(135deg, var(--gold), var(--gold-light))); color: var(--tqd-color, var(--navy)); }

/* Downloads on the order confirmation: one tidy card per file. */
.tarhee-qc .woocommerce-order-downloads { margin: 0 0 24px; padding: 24px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* Custom box on the order confirmation (guide text). */
.tarhee-qc__box {
	margin: 0 0 20px;
	padding: 16px 20px;
	border: 1.5px solid var(--tqb-border, var(--gold));
	border-radius: var(--radius-sm);
	background: var(--tqb-bg, var(--gold-soft));
	color: var(--tqb-color, var(--navy));
	line-height: 1.9;
	overflow-wrap: anywhere;
}
.tarhee-qc__box p { margin: 0 0 .6em; }
.tarhee-qc__box > :last-child { margin-bottom: 0; }
.tarhee-qc .woocommerce-order-downloads__title { margin: 0 0 12px; font-size: 1.1rem; font-weight: var(--fw-heading); color: var(--navy); }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads { display: block; border: 0; }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads thead { display: none; }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads tbody { display: grid; gap: 10px; }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads tr {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 4px 14px;
	padding: 12px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
}
.tarhee-qc table.shop_table.woocommerce-table--order-downloads td { display: block; padding: 0; border: 0; text-align: start; }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads td.download-product { grid-column: 1; font-size: .95rem; font-weight: var(--fw-label); color: var(--navy); overflow-wrap: anywhere; }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads td.download-product a { text-decoration: none; }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads :is(td.download-remaining, td.download-expires) { grid-column: 1; font-size: .78rem; color: var(--muted); }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads :is(td.download-remaining, td.download-expires)::before { content: attr(data-title) ': '; }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads td.download-file { grid-column: 2; grid-row: 1 / span 3; }
.tarhee-qc table.shop_table.woocommerce-table--order-downloads td.download-file .button { max-width: 100%; padding: 10px 18px; font-size: .86rem; text-align: center; overflow-wrap: anywhere; }

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
	.tarhee-qc { padding: 18px 14px 20px; }
	.tarhee-qc .woocommerce-billing-fields__field-wrapper { grid-template-columns: minmax(0, 1fr); }
	.tarhee-qc__item { grid-template-columns: 64px minmax(0, 1fr); padding-inline-end: 40px; }
	.tarhee-qc__thumb { width: 64px; }
	.tarhee-qc table.shop_table.woocommerce-table--order-downloads tr { grid-template-columns: minmax(0, 1fr); }
	.tarhee-qc table.shop_table.woocommerce-table--order-downloads td.download-file { grid-column: 1; grid-row: auto; }
	.tarhee-qc table.shop_table.woocommerce-table--order-downloads td.download-file .button { display: flex; width: 100%; }
	.tarhee-qc__price { grid-column: 2; justify-content: flex-start; }
	.tarhee-qc form.checkout_coupon .form-row-first,
	.tarhee-qc form.checkout_coupon .form-row-last { display: block; width: 100%; }

	/* The pay block stays within reach while the form scrolls. */
	.tarhee-qc--sticky .form-row.place-order {
		position: sticky;
		bottom: 0;
		z-index: 5;
		margin-inline: -14px;
		padding: 10px 14px;
		background: var(--card);
		box-shadow: 0 -8px 20px rgba(13, 26, 56, .08);
	}
	.tarhee-qc--sticky .tarhee-qc__trust { display: none; }
}

/* ==========================================================================
   0.3.9: pay / download / coupon button fallbacks for older mobile browsers.
   ========================================================================== */
@supports not (color: color-mix(in srgb, red 50%, white)) {
	.tarhee-qc #place_order { background: var(--cta); }
	.tarhee-qc .woocommerce-order-downloads .button,
	.tarhee-qc a.woocommerce-MyAccount-downloads-file { background: var(--tqd-bg, var(--gold)); }
	.tarhee-qc form.checkout_coupon .button,
	.tarhee-qc form.checkout_coupon .button:hover { background: var(--gold); }
}

@supports not (inset-inline-start: 0) {
	html[dir='rtl'] .tarhee-qc #place_order::before { right: -100%; }
	html:not([dir='rtl']) .tarhee-qc #place_order::before { left: -100%; }
	html[dir='rtl'] .tarhee-qc #place_order:hover::before { right: 100%; }
	html:not([dir='rtl']) .tarhee-qc #place_order:hover::before { left: 100%; }
}
