/*
 * Cart + Checkout are intentionally NOT template-overridden (see inc/ —
 * we lean on WooCommerce's own form-checkout.php / cart.php for the parts
 * that touch payment/tax/shipping logic) — restyled here via WooCommerce's
 * long-stable class names instead, which is the safe way to reskin the
 * pages that must never silently break checkout.
 */

/* ---- Cart page ---- */
.woocommerce-cart-form table.cart,
.woocommerce-cart-form table.cart thead,
.woocommerce-cart-form table.cart tbody { display: block; width: 100%; }
.woocommerce-cart-form table.cart thead tr { display: none; }
.woocommerce-cart-form table.cart tr {
	display: grid;
	grid-template-columns: 32px 64px 1fr auto;
	grid-template-areas: "remove thumb name name" ". thumb qty subtotal";
	gap: 8px 12px;
	align-items: center;
	padding: 16px 0;
	border-bottom: 1px solid var(--color-line);
}
.woocommerce-cart-form table.cart td { padding: 0; border: none; }
.product-remove { grid-area: remove; }
.product-remove a.remove { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; color: var(--color-ink-soft); font-size: 20px; line-height: 1; text-decoration: none; }
.product-remove a.remove:hover { color: var(--color-red); background: var(--color-cream); }
.product-thumbnail { grid-area: thumb; }
.product-thumbnail img { width: 64px; height: 80px; object-fit: cover; border-radius: 10px; background: var(--color-powder); }
.product-name { grid-area: name; font: var(--text-body-s); }
.product-name a { color: var(--text-primary); }
.product-price { display: none; }
.product-quantity { grid-area: qty; }
.product-quantity .quantity input.qty { width: 60px; text-align: center; border: 1px solid var(--color-line-strong); border-radius: 10px; min-height: 40px; }
.product-subtotal { grid-area: subtotal; font: 600 1rem/1 var(--font-display); color: var(--color-red); text-align: right; }

/* The actions <tr> falls under the ".cart tr" product-row grid above (it's
   still a row in table.cart), so without an explicit placement its lone
   <td class="actions"> gets auto-placed into that grid's narrow 32px
   "remove" column — crushing the coupon field/buttons and wrapping their
   text onto two lines. Span the full row width instead. */
.woocommerce-cart-form .actions { grid-column: 1 / -1; padding-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.coupon { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.coupon #coupon_code { flex: 1; border: 1px solid var(--color-line-strong); border-radius: 12px; padding: 10px 14px; min-height: 44px; font: var(--text-body-s); background: var(--color-paper); }
.coupon button, button[name="update_cart"] {
	flex: none; border: 1px solid var(--color-line-strong); background: transparent; color: var(--text-primary);
	border-radius: var(--radius-pill); padding: 10px 20px; min-height: 44px; font: var(--text-body-s); cursor: pointer;
}
.coupon button:hover, button[name="update_cart"]:hover { border-color: var(--color-red); color: var(--color-red); }

.cart-collaterals { margin-top: 24px; }
/* Two-column layout with a sticky order-summary card, matching cart.dc.html.
   Cart/checkout are the raw WooCommerce shortcode markup (see file header),
   so the grid is scoped to WC's own classes rather than a template override.
   The [woocommerce_cart] shortcode wraps its whole output in one extra
   <div class="woocommerce"> (WC_Shortcodes::shortcode_wrapper()) — that div,
   not .tt-container, is the direct parent of .woocommerce-cart-form and
   .cart-collaterals, so it's the one that needs to become the grid.
   Below 1100px .cart-collaterals stays a plain full-width block — no
   max-width/margin-left here, or the "Оформить заказ" button and the coupon/
   update-cart buttons above it end up capped at an arbitrary width instead
   of spanning the mobile viewport like every other control on the page. */
@media (min-width: 1100px) {
	body.woocommerce-cart #tt-main .woocommerce {
		display: grid;
		grid-template-columns: minmax(0, 1fr) 400px;
		column-gap: clamp(24px, 3vw, 48px);
		align-items: start;
	}
	body.woocommerce-cart #tt-main .woocommerce-cart-form { grid-column: 1; }
	/* WooCommerce nests BOTH .cross-sells and .cart_totals inside one
	   .cart-collaterals wrapper (woocommerce_cart_collaterals fires cross-sell
	   display, then cart totals, into the same container) — so pinning
	   .cart-collaterals itself to the 400px column trapped the cross-sells
	   slider inside that narrow sidebar instead of running full-width under
	   the cart items like cart.dc.html shows. `display: contents` removes
	   .cart-collaterals' own box and promotes its two children to direct
	   grid items, so each can be placed independently below. */
	body.woocommerce-cart #tt-main .cart-collaterals { display: contents; }
	body.woocommerce-cart #tt-main .cross-sells { grid-column: 1; }
	body.woocommerce-cart #tt-main .cart_totals { grid-column: 2; position: sticky; top: 132px; }
}
.cart_totals { background: var(--color-cream); border-radius: var(--radius-l); padding: 20px; }
.cart_totals h2 { font: var(--text-display-s); margin-bottom: 12px; }
.cart_totals table { width: 100%; border-collapse: collapse; }
.cart_totals table th, .cart_totals table td { text-align: left; padding: 10px 0; border-top: 1px solid var(--color-line); font: var(--text-body-s); }
.cart_totals table tr:first-child th, .cart_totals table tr:first-child td { border-top: none; }
.cart_totals .order-total td { font: 700 1.25rem/1 var(--font-display); color: var(--color-red); }

/* Shipping method options (cart totals + checkout review order table): stack
   them in their own full-width row instead of squeezed next to the
   "Доставка" label. */
.cart_totals table tr.woocommerce-shipping-totals th,
.cart_totals table tr.woocommerce-shipping-totals td { display: block; width: 100%; }
.cart_totals table tr.woocommerce-shipping-totals td { border-top: none; padding-top: 0; }

.woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals { flex-direction: column; align-items: stretch; }

.woocommerce-shipping-methods { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.woocommerce-shipping-methods li { display: flex; align-items: flex-start; gap: 8px; }
.woocommerce-shipping-methods li label { flex: 1; }
.woocommerce-shipping-methods li input[type="radio"] { flex: none; margin-top: 4px; }
.wc-proceed-to-checkout { margin-top: 12px; }
.wc-proceed-to-checkout .checkout-button {
	display: flex; align-items: center; justify-content: center; width: 100%;
	border: none; border-radius: var(--radius-pill); padding: 13px 0; min-height: 48px;
	background: var(--action-primary); color: #FFFDFB; font: var(--text-body-m-medium); text-align: center;
}
.wc-proceed-to-checkout .checkout-button:hover { background: var(--action-primary-hover); }

.cross-sells { margin-top: 32px; }
.cross-sells h2 { font: var(--text-display-s); margin-bottom: 16px; }
/* "Добавьте к заказу" slider: overrides the sitewide ul.products grid
   (components.css, !important) with a horizontally-scrollable row of the
   same product-card partial (image included) — matching the scroll-strip
   pattern used elsewhere in the theme (tt-noscroll) instead of a static grid. */
.cross-sells ul.products {
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: 16px;
	overflow-x: auto;
	scroll-snap-type: x proximity;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	padding-bottom: 4px;
	margin: 0 -1px;
}
.cross-sells ul.products::-webkit-scrollbar { display: none; }
.cross-sells ul.products li.product {
	flex: 0 0 clamp(150px, 22vw, 200px);
	scroll-snap-align: start;
}

/* "Добавьте к букету" on the cart page (ttf_cart_addons_display() in
   inc/woocommerce.php) reuses the same .tt-addons card grid as the product
   page and popup, but here it needs the cross-sells slider treatment above
   instead of a multi-row grid — one scrollable row, ~4 cards visible. */
.cross-sells.tt-addons { margin-top: 32px; }
.cross-sells.tt-addons .tt-addons__grid {
	display: flex;
	flex-wrap: nowrap;
	overflow-x: auto;
	scroll-snap-type: x proximity;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	gap: 16px;
	padding-bottom: 4px;
}
.cross-sells.tt-addons .tt-addons__grid::-webkit-scrollbar { display: none; }
.cross-sells.tt-addons .tt-addon-card {
	flex: 0 0 clamp(160px, 22vw, 220px);
	scroll-snap-align: start;
}

/* Generic slider chrome (assets/js/main.js, [data-slider]) — arrow buttons
   either side of a horizontally-scrolling track, hidden on touch/mobile
   where swiping is the natural gesture. */
.tt-slider { position: relative; }
.tt-slider__arrow {
	position: absolute; top: 50%; transform: translateY(-50%);
	width: 36px; height: 36px; flex: none; border-radius: 50%;
	border: 1px solid var(--color-line-strong); background: var(--color-paper); color: var(--text-primary);
	display: flex; align-items: center; justify-content: center; cursor: pointer;
	box-shadow: var(--shadow-raised); z-index: 2;
}
.tt-slider__arrow:hover { border-color: var(--color-red); color: var(--color-red); }
.tt-slider__arrow[hidden] { display: none; }
.tt-slider__arrow--prev { left: 4px; }
.tt-slider__arrow--next { right: 4px; transform: translateY(-50%) rotate(180deg); }
@media (max-width: 640px) { .tt-slider__arrow { display: none; } }

/* ---- Checkout page ---- */
.woocommerce-checkout { display: block; }
.woocommerce-checkout #customer_details { max-width: 640px; }
/* #customer_details IS .col2-set (WC's own form-checkout.php puts both
   classes on the same <div> — billing in .col-1, the "ship to a different
   address?" toggle in .col-2). It must NOT share the page-level 2-column
   grid rule below: that grid was meant for [form fields] vs [sticky order
   summary], but applying it to .col2-set as well turned the *billing form
   itself* into a second nested grid — squeezing every field into a narrow
   left track and reserving a wide near-empty track for the shipping toggle,
   which is what produced the "three columns / order summary pushed down"
   layout. .col-1/.col-2 just stack normally (shipping fields already show/
   hide themselves via WC's own JS on the checkbox). */
@media (min-width: 1000px) {
	form.checkout.woocommerce-checkout {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
		/* #customer_details (col 1) spans both rows of col 2 ("Your order"
		   heading + #order_review). With two `auto` rows, browsers are free to
		   dump most of that spanning item's height into row 1 instead of row 2
		   (both rows are equally eligible under the auto-track distribution
		   algorithm) — which pushed #order_review's sticky box down the page
		   instead of letting it stick right under the short heading. Making
		   row 2 an explicit `1fr` track means it absorbs the leftover height
		   instead of row 1, so the sticky box starts right after the heading. */
		grid-template-rows: auto 1fr;
		gap: 40px;
		align-items: start;
	}
	/* form.checkout's direct children: #customer_details (col1), the "Your
	   order" heading and #order_review (both col2, so they stack together
	   above the sticky summary card). */
	.woocommerce-checkout #customer_details { max-width: none; grid-column: 1; grid-row: 1 / span 2; }
	.woocommerce-checkout #order_review_heading { grid-column: 2; grid-row: 1; }
	.woocommerce-checkout #order_review { grid-column: 2; grid-row: 2; position: sticky; top: 110px; }
}

.woocommerce-billing-fields h3, #ship-to-different-address { font: 600 1.125rem/1.2 var(--font-display); margin: 0 0 12px; }
.woocommerce-additional-fields h3 { font: 600 1.125rem/1.2 var(--font-display); margin: 24px 0 12px; }

.form-row { margin-bottom: 12px; }
.form-row label { display: block; font: var(--text-detail); color: var(--color-ink-soft); margin-bottom: 6px; }
.form-row .required { color: var(--color-red); text-decoration: none; }
.form-row input.input-text,
.form-row textarea,
.form-row select,
.woocommerce-checkout select,
.woocommerce-checkout input.input-text {
	width: 100%; box-sizing: border-box;
	border: 1px solid var(--color-line-strong); border-radius: 12px;
	padding: 12px 14px; min-height: 46px; font: var(--text-body-s);
	font-family: var(--font-body); color: var(--text-primary); background: var(--color-paper); outline: none;
}
.form-row textarea { min-height: 88px; }
.woocommerce-invalid input.input-text { border-color: var(--color-red); }

.tt-time-range { display: flex; align-items: center; gap: 10px; }
.tt-time-range input.input-text { width: auto; flex: 1; }
.tt-time-range__dash { color: var(--color-ink-soft); flex: none; }
.tt-time-range__end {
	flex: 1; box-sizing: border-box;
	border: 1px solid var(--color-line); border-radius: 12px;
	padding: 12px 14px; min-height: 46px; font: var(--text-body-s);
	font-family: var(--font-body); color: var(--color-ink-soft); background: var(--color-cream);
	display: flex; align-items: center;
}

.tt-checkout-fieldset { border: none; padding: 0; margin: 0 0 24px; }
.tt-checkout-fieldset__title { font: 600 1.125rem/1.2 var(--font-display); padding: 0; margin-bottom: 12px; }
.tt-checkout-fieldset .tt-chip-row { margin-bottom: 12px; }
.tt-checkout-fieldset__conditional { margin-bottom: 12px; }
.tt-checkout-fieldset__conditional[hidden] { display: none; }
.tt-field-hint { display: block; font: var(--text-detail); color: var(--color-ink-soft); margin-top: 4px; }

.woocommerce-checkout-review-order-table { width: 100%; border-collapse: collapse; background: var(--color-cream); border-radius: var(--radius-l); padding: 20px; box-sizing: border-box; display: block; }
.woocommerce-checkout-review-order-table thead { display: none; }
.woocommerce-checkout-review-order-table tbody, .woocommerce-checkout-review-order-table tfoot { display: block; }
.woocommerce-checkout-review-order-table tr { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--color-line); font: var(--text-body-s); }
.woocommerce-checkout-review-order-table tr:first-child { border-top: none; }
.woocommerce-checkout-review-order-table .order-total { font: 700 1.25rem/1 var(--font-display); color: var(--color-red); }
.woocommerce-checkout-review-order-table .product-name { text-align: left; }

.woocommerce-checkout-payment { background: var(--color-cream); border-radius: var(--radius-l); padding: 16px 20px; margin-top: 16px; }
ul.wc_payment_methods { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
ul.wc_payment_methods li.wc_payment_method { border-bottom: 1px solid var(--color-line); padding: 12px 0; }
ul.wc_payment_methods li.wc_payment_method:last-of-type { border-bottom: none; }
.payment_box { font: var(--text-body-s); color: var(--color-ink-soft); padding: 10px 0 0 28px; }

#place_order {
	width: 100%; border: none; border-radius: var(--radius-pill); padding: 14px 0; min-height: 50px;
	background: var(--action-primary); color: #FFFDFB; font: var(--text-body-m-medium); cursor: pointer; margin-top: 16px;
}
#place_order:hover { background: var(--action-primary-hover); }

.woocommerce-form-coupon-toggle .woocommerce-info,
.woocommerce-form-login-toggle .woocommerce-info { background: var(--color-pink); border-radius: var(--radius-m); padding: 14px 18px; font: var(--text-body-s); }

/* ---- Order received / thank-you ---- */
.woocommerce-order { max-width: 640px; margin: 0 auto; }
.woocommerce-order .woocommerce-thankyou-order-received { font: 600 1.25rem/1.3 var(--font-display); text-align: center; margin: 8px 0 24px; }
ul.woocommerce-order-overview { list-style: none; margin: 0 0 24px; padding: 16px 0; border-top: 1px solid var(--color-line); border-bottom: 1px solid var(--color-line); display: flex; flex-wrap: wrap; gap: 16px 32px; }
ul.woocommerce-order-overview li { font: var(--text-body-s); }
ul.woocommerce-order-overview strong { display: block; font: 600 1rem/1.2 var(--font-display); }
.woocommerce-order-details, .woocommerce-customer-details { margin-bottom: 24px; }
.woocommerce-order-details table, .woocommerce-table--order-details { width: 100%; border-collapse: collapse; }
.woocommerce-order-details table th, .woocommerce-order-details table td { text-align: left; padding: 10px 0; border-top: 1px solid var(--color-line); font: var(--text-body-s); }
.tt-order-delivery-summary { list-style: none; margin: 0 0 24px; padding: 16px; background: var(--color-cream); border-radius: var(--radius-m); display: flex; flex-direction: column; gap: 6px; font: var(--text-body-s); }
