/*
Theme Name: Duka Bora
Theme URI: https://habarichat.ai
Author: Habari Labs
Author URI: https://habarichat.ai
Description: A demo WooCommerce storefront used to exercise the HabariChat catalog sync. Block theme, no build step, no external requests — fonts and icons ship with the theme.
Version: 1.0.0
Requires at least: 6.5
Tested up to: 6.8
Requires PHP: 8.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: duka-bora
Tags: e-commerce, full-site-editing, block-patterns, wide-blocks, custom-colors, custom-menu
*/

/*
 * Everything expressible as a design token lives in theme.json. This file carries
 * only what theme.json has no key for: the WooCommerce classic-markup surfaces that
 * blocks do not style, hover/motion behaviour, and the icon sprite sizing.
 */

/* ------------------------------------------------------------------ tokens -- */

:root {
	--db-radius-sm: 4px;
	--db-radius-md: 6px;
	--db-radius-lg: 8px;
	--db-radius-xl: 12px;
	--db-radius-2xl: 16px;
	--db-radius-pill: 9999px;
	--db-transition: 200ms;
}

/* ------------------------------------------------------------------ motion -- */

/*
 * The design system asks for one transition duration on interactive surfaces and
 * explicitly rules out a press scale-down, so no :active transform anywhere.
 */
a,
button,
.wp-block-button__link,
.wp-element-button,
.wc-block-components-button,
.woocommerce a.button,
.woocommerce button.button {
	transition: background-color var(--db-transition) ease, color var(--db-transition) ease,
		border-color var(--db-transition) ease, box-shadow var(--db-transition) ease,
		opacity var(--db-transition) ease;
}

.wp-block-button__link:hover,
.wp-element-button:hover,
.woocommerce a.button:hover,
.woocommerce button.button:hover {
	opacity: 0.9;
}

@media ( prefers-reduced-motion: reduce ) {
	*,
	*::before,
	*::after {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}

/* -------------------------------------------------------------------- icons -- */

.db-icon {
	display: inline-block;
	width: 20px;
	height: 20px;
	stroke: currentColor;
	stroke-width: 1.5;
	fill: none;
	vertical-align: middle;
	flex: 0 0 auto;
}

.db-icon--sm {
	width: 16px;
	height: 16px;
}

/* --------------------------------------------------------------- utilities -- */

.db-eyebrow {
	font-family: var( --wp--preset--font-family--heading );
	font-size: var( --wp--preset--font-size--x-small );
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* One brand word per surface may carry the gradient fill. Used sparingly. */
.db-gradient-text {
	background: var( --wp--preset--gradient--primary );
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

/* Titles on the navy plates stay pure white, never tinted. */
.db-plate-navy,
.db-plate-navy :where( h1, h2, h3, h4, h5, h6 ) {
	color: #fff;
}

.db-plate-navy :where( p, li ) {
	color: hsl( 210 40% 88% );
}

/*
 * Outline buttons on the navy plates go 2px white rather than the 1px border used
 * everywhere else — the only place the design system permits a coloured border.
 */
.db-plate-navy .wp-block-button.is-style-outline .wp-block-button__link {
	border: 2px solid #fff;
	color: #fff;
	background: transparent;
}

.db-plate-navy .wp-block-button.is-style-outline .wp-block-button__link:hover {
	background: var( --wp--preset--color--primary );
	border-color: var( --wp--preset--color--primary );
	opacity: 1;
}

/* --------------------------------------------------------- category cards -- */

/*
 * WooCommerce ships a category *list* block but no grid, and these cards need an icon
 * and a description alongside the name — so the pattern emits them as plain anchors and
 * they are styled here rather than assembled out of a dozen nested group blocks.
 */
.db-category-card {
	display: flex;
	flex-direction: column;
	gap: 4px;
	height: 100%;
	padding: var( --wp--preset--spacing--45 );
	border: 1px solid var( --wp--preset--color--border );
	border-radius: var( --db-radius-xl );
	background: var( --wp--preset--color--background );
	box-shadow: var( --wp--preset--shadow--sm );
	color: var( --wp--preset--color--foreground );
	text-decoration: none;
	transition: box-shadow var( --db-transition ) ease, border-color var( --db-transition ) ease;
}

.db-category-card:hover {
	box-shadow: var( --wp--preset--shadow--md );
	border-color: var( --wp--preset--color--teal-300 );
	text-decoration: none;
}

.db-category-card__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin-bottom: 8px;
	border-radius: var( --db-radius-lg );
	background: var( --wp--preset--gradient--primary );
	color: #fff;
}

.db-category-card__title {
	font-family: var( --wp--preset--font-family--heading );
	font-size: var( --wp--preset--font-size--medium-large );
	font-weight: 600;
	letter-spacing: -0.01em;
}

.db-category-card__copy {
	font-size: var( --wp--preset--font-size--small );
	color: var( --wp--preset--color--muted-foreground );
}

/* ---------------------------------------------------- newsletter + reassurance -- */

.db-newsletter {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	max-width: 448px;
	margin: 0 auto;
}

.db-newsletter__input {
	flex: 1 1 220px;
	min-width: 0;
	padding: 11px 16px;
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--medium );
	color: var( --wp--preset--color--foreground );
	background: var( --wp--preset--color--background );
	border: 1px solid var( --wp--preset--color--border );
	border-radius: var( --db-radius-md );
}

.db-newsletter__input:focus {
	outline: 2px solid var( --wp--preset--color--primary );
	outline-offset: 1px;
	border-color: var( --wp--preset--color--primary );
}

.db-newsletter__button {
	flex: 0 0 auto;
	padding: 11px 20px;
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--small );
	font-weight: 600;
	color: var( --wp--preset--color--primary-foreground );
	background: var( --wp--preset--color--primary );
	border: 0;
	border-radius: var( --db-radius-md );
	cursor: pointer;
}

.db-newsletter__note {
	max-width: 448px;
	margin: 12px auto 0;
	font-size: var( --wp--preset--font-size--x-small );
	color: var( --wp--preset--color--muted-foreground );
	text-align: center;
}

.db-reassurance {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.db-reassurance__item {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: var( --wp--preset--font-size--small );
	color: var( --wp--preset--color--muted-foreground );
}

.db-reassurance__icon {
	display: inline-flex;
	color: var( --wp--preset--color--primary );
}

/* --------------------------------------------------------------- WooCommerce -- */

/*
 * WooCommerce still renders classic markup on a few surfaces (notices, the my-account
 * tables, the classic cart fallback, star ratings). Blocks do not reach these, so they
 * are matched by hand rather than left to inherit browser defaults.
 */

.woocommerce .woocommerce-message,
.woocommerce .woocommerce-info,
.woocommerce .woocommerce-error,
.wc-block-components-notice-banner {
	border-radius: var( --db-radius-lg );
	border-width: 1px;
	border-style: solid;
	font-size: var( --wp--preset--font-size--small );
}

.woocommerce .woocommerce-message,
.wc-block-components-notice-banner.is-success {
	background: rgb( 220 252 231 );
	border-color: rgb( 134 239 172 );
	color: rgb( 22 101 52 );
}

.woocommerce .woocommerce-info,
.wc-block-components-notice-banner.is-info {
	background: rgb( 254 243 199 );
	border-color: rgb( 253 224 71 );
	color: rgb( 120 53 15 );
}

.woocommerce .woocommerce-error,
.wc-block-components-notice-banner.is-error {
	background: rgb( 254 226 226 );
	border-color: rgb( 252 165 165 );
	color: rgb( 153 27 27 );
}

.woocommerce .star-rating span::before,
.woocommerce .star-rating::before {
	color: var( --wp--preset--color--teal-500 );
}

.woocommerce span.onsale,
.wc-block-components-product-badge {
	background: var( --wp--preset--gradient--primary );
	color: #fff;
	border: 0;
	border-radius: var( --db-radius-pill );
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--x-small );
	font-weight: 600;
	letter-spacing: 0;
	min-height: 0;
	min-width: 0;
	line-height: 1.35;
	padding: 4px 12px;
}

.woocommerce table.shop_table,
.woocommerce-cart table.cart {
	border-radius: var( --db-radius-lg );
	border-color: var( --wp--preset--color--border );
}

/* Selects are handled with the other form controls below, so they are not listed here. */
.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea,
.wc-block-components-text-input input {
	border-radius: var( --db-radius-md );
	border: 1px solid var( --wp--preset--color--border );
	padding: 10px 12px;
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--medium );
}

.woocommerce form .form-row input.input-text:focus,
.woocommerce form .form-row textarea:focus {
	outline: 2px solid var( --wp--preset--color--primary );
	outline-offset: 1px;
	border-color: var( --wp--preset--color--primary );
}

/* Product cards: 1px border, radius-lg, shadow-sm, lifting to shadow-md on hover. */
.wc-block-product-template .wc-block-product,
.woocommerce ul.products li.product {
	border: 1px solid var( --wp--preset--color--border );
	border-radius: var( --db-radius-lg );
	box-shadow: var( --wp--preset--shadow--sm );
	background: var( --wp--preset--color--background );
	padding: var( --wp--preset--spacing--30 );
	overflow: hidden;
}

@media ( min-width: 782px ) {
	.wc-block-product-template .wc-block-product,
	.woocommerce ul.products li.product {
		padding: var( --wp--preset--spacing--40 );
	}
}

.wc-block-product-template .wc-block-product:hover,
.woocommerce ul.products li.product:hover {
	box-shadow: var( --wp--preset--shadow--md );
}

.wc-block-product-template .wc-block-product img,
.woocommerce ul.products li.product img {
	border-radius: var( --db-radius-md );
}

/* ------------------------------------------------------------- form controls -- */

/*
 * Browsers do not let a <select> inherit the page font, and nothing in theme.json reaches
 * form controls — so the catalog sorting dropdown and the variation pickers were rendering
 * at 20px tall in Arial with square grey borders, right next to 40px branded buttons.
 *
 * Scoped to .wp-site-blocks so this covers the front end (header, content, footer, cart and
 * checkout) without touching the admin bar, which sits outside that wrapper.
 *
 * The chevron is an inline data-URI SVG rather than a pseudo-element, because a <select>
 * cannot render ::before/::after reliably across browsers. It is the Lucide chevron-down at
 * the muted-foreground colour — a data URI, so still no external request. Its stroke colour
 * has to be literal here, which is the one place in the theme that cannot use currentColor.
 */
.wp-site-blocks select:not( [multiple] ),
.woocommerce form .form-row select,
.woocommerce-ordering select.orderby,
.wc-block-components-select__select {
	appearance: none;
	-webkit-appearance: none;
	box-sizing: border-box;
	height: 40px;
	max-width: 100%;
	padding: 0 40px 0 12px;
	border: 1px solid var( --wp--preset--color--border );
	border-radius: var( --db-radius-md );
	background-color: var( --wp--preset--color--background );
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23556377' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E" );
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 16px 16px;
	color: var( --wp--preset--color--foreground );
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--small );
	font-weight: 400;
	line-height: 1.35;
	cursor: pointer;
	transition: border-color var( --db-transition ) ease, box-shadow var( --db-transition ) ease;
}

.wp-site-blocks select:not( [multiple] ):hover,
.woocommerce-ordering select.orderby:hover {
	border-color: var( --wp--preset--color--teal-300 );
}

.wp-site-blocks select:not( [multiple] ):focus-visible,
.woocommerce form .form-row select:focus-visible,
.wc-block-components-select__select:focus-visible {
	outline: 2px solid var( --wp--preset--color--primary );
	outline-offset: 1px;
	border-color: var( --wp--preset--color--primary );
}

.wp-site-blocks select:disabled {
	background-color: var( --wp--preset--color--muted );
	color: var( --wp--preset--color--muted-foreground );
	cursor: not-allowed;
}

/* A multi-select needs its own height, so only the shared chrome applies. */
.wp-site-blocks select[multiple] {
	border: 1px solid var( --wp--preset--color--border );
	border-radius: var( --db-radius-md );
	padding: 8px 12px;
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--small );
}

/*
 * The variation table is a layout table by default, which leaves the label and its select
 * cramped together. Give each row room and let it stack on a narrow screen.
 */
.woocommerce div.product form.cart table.variations {
	margin-bottom: var( --wp--preset--spacing--40 );
	border: 0;
}

.woocommerce div.product form.cart table.variations th,
.woocommerce div.product form.cart table.variations td {
	padding: 0 0 var( --wp--preset--spacing--30 );
	border: 0;
	vertical-align: middle;
}

/* Without this the attribute name sits flush against its dropdown. */
.woocommerce div.product form.cart table.variations th.label {
	padding-right: var( --wp--preset--spacing--40 );
	white-space: nowrap;
}

.woocommerce div.product form.cart table.variations th.label label {
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--small );
	font-weight: 600;
}

@media ( max-width: 600px ) {
	/* Stack the label above its dropdown rather than squeezing both onto one line. */
	.woocommerce div.product form.cart table.variations th.label,
	.woocommerce div.product form.cart table.variations td.value {
		display: block;
		width: 100%;
		padding-right: 0;
	}
}

/*
 * The quantity field is the same story as the select: a native control that inherits
 * nothing, so it was rendering with a 2px grey border and Arial next to a branded button.
 * Height is matched to the add-to-cart button it sits beside, since a mismatch between two
 * adjacent controls is the most visible kind.
 */
.woocommerce .quantity input.qty,
.wp-site-blocks input[type="number"] {
	box-sizing: border-box;
	height: 44px;
	padding: 0 8px;
	border: 1px solid var( --wp--preset--color--border );
	border-radius: var( --db-radius-md );
	background-color: var( --wp--preset--color--background );
	color: var( --wp--preset--color--foreground );
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--small );
	text-align: center;
	transition: border-color var( --db-transition ) ease;
}

.woocommerce .quantity input.qty:hover,
.wp-site-blocks input[type="number"]:hover {
	border-color: var( --wp--preset--color--teal-300 );
}

.woocommerce .quantity input.qty:focus-visible,
.wp-site-blocks input[type="number"]:focus-visible {
	outline: 2px solid var( --wp--preset--color--primary );
	outline-offset: 1px;
	border-color: var( --wp--preset--color--primary );
}

.woocommerce div.product form.cart .reset_variations {
	display: inline-block;
	margin-left: 12px;
	font-size: var( --wp--preset--font-size--x-small );
	color: var( --wp--preset--color--muted-foreground );
}

/* The sorting control and the result count should sit on one baseline. */
.wp-block-woocommerce-catalog-sorting .woocommerce-ordering {
	margin: 0;
}

/* --------------------------------------------------------------- pagination -- */

/*
 * WordPress emits pagination as bare inline text: the page numbers are separated only by
 * whitespace, have no hit area, and the current page is distinguished by a class with
 * almost no styling behind it. Next to the bordered product cards that reads as unstyled,
 * so the numbers become proper 40px controls here.
 *
 * Covers the block pagination (product archives, blog, search), the comments pagination,
 * and WooCommerce's classic `.woocommerce-pagination` in case a template falls back to it.
 */

/*
 * Selectors are qualified with `nav` on purpose. Core prints a
 * `.wp-container-core-query-pagination-is-layout-*` rule that sets `gap` on this same
 * element at one-class specificity, and the block-support styles can land after the theme
 * stylesheet — so a bare `.wp-block-query-pagination` would lose the coin toss. Adding the
 * element takes these to 0,1,1 and wins deterministically without reaching for !important.
 */
nav.wp-block-query-pagination,
nav.wp-block-comments-pagination,
nav.woocommerce-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: var( --wp--preset--spacing--70 );
}

/* The numbers arrive in their own wrapper, which is a plain block by default. */
nav.wp-block-query-pagination div.wp-block-query-pagination-numbers,
nav.wp-block-comments-pagination div.wp-block-comments-pagination-numbers,
nav.woocommerce-pagination ul {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
	border: 0;
}

nav.woocommerce-pagination ul li {
	margin: 0;
	border: 0;
}

/* Every control shares one shape: 40px tall, radius-md, 1px border. */
nav.wp-block-query-pagination a.page-numbers,
nav.wp-block-query-pagination span.page-numbers,
nav.wp-block-query-pagination a.wp-block-query-pagination-previous,
nav.wp-block-query-pagination a.wp-block-query-pagination-next,
nav.wp-block-comments-pagination a.page-numbers,
nav.wp-block-comments-pagination span.page-numbers,
nav.wp-block-comments-pagination a.wp-block-comments-pagination-previous,
nav.wp-block-comments-pagination a.wp-block-comments-pagination-next,
nav.woocommerce-pagination a.page-numbers,
nav.woocommerce-pagination span.page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	box-sizing: border-box;
	border: 1px solid var( --wp--preset--color--border );
	border-radius: var( --db-radius-md );
	background: var( --wp--preset--color--background );
	color: var( --wp--preset--color--foreground );
	font-family: var( --wp--preset--font-family--body );
	font-size: var( --wp--preset--font-size--small );
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	transition: background-color var( --db-transition ) ease, border-color var( --db-transition ) ease,
		box-shadow var( --db-transition ) ease, color var( --db-transition ) ease;
}

/* Prev and next carry a label, so they get horizontal room. */
nav.wp-block-query-pagination a.wp-block-query-pagination-previous,
nav.wp-block-query-pagination a.wp-block-query-pagination-next,
nav.wp-block-comments-pagination a.wp-block-comments-pagination-previous,
nav.wp-block-comments-pagination a.wp-block-comments-pagination-next {
	padding: 0 16px;
}

nav.wp-block-query-pagination a.page-numbers:hover,
nav.wp-block-query-pagination a.wp-block-query-pagination-previous:hover,
nav.wp-block-query-pagination a.wp-block-query-pagination-next:hover,
nav.wp-block-comments-pagination a.page-numbers:hover,
nav.wp-block-comments-pagination a.wp-block-comments-pagination-previous:hover,
nav.wp-block-comments-pagination a.wp-block-comments-pagination-next:hover,
nav.woocommerce-pagination a.page-numbers:hover {
	border-color: var( --wp--preset--color--teal-300 );
	box-shadow: var( --wp--preset--shadow--sm );
	text-decoration: none;
}

/* The page you are on: filled, not bordered, and not a link. */
nav.wp-block-query-pagination span.page-numbers.current,
nav.wp-block-comments-pagination span.page-numbers.current,
nav.woocommerce-pagination span.page-numbers.current {
	background: var( --wp--preset--gradient--primary );
	border-color: transparent;
	color: var( --wp--preset--color--primary-foreground );
	box-shadow: var( --wp--preset--shadow--sm );
}

/* The ellipsis is a label, not a control. */
nav.wp-block-query-pagination span.page-numbers.dots,
nav.wp-block-comments-pagination span.page-numbers.dots,
nav.woocommerce-pagination span.page-numbers.dots {
	min-width: 24px;
	padding: 0 4px;
	border: 0;
	background: none;
	box-shadow: none;
	color: var( --wp--preset--color--muted-foreground );
}

/*
 * Chevrons drawn from borders rather than an icon font or an inline SVG: this way they
 * inherit currentColor, so they flip to white with the text when a control is filled or
 * hovered, and the theme still makes no extra request.
 */
.wp-block-query-pagination-previous::before,
.wp-block-comments-pagination-previous::before,
.wp-block-query-pagination-next::after,
.wp-block-comments-pagination-next::after {
	content: "";
	width: 6px;
	height: 6px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	flex: 0 0 auto;
}

.wp-block-query-pagination-previous::before,
.wp-block-comments-pagination-previous::before {
	transform: rotate( 135deg );
}

.wp-block-query-pagination-next::after,
.wp-block-comments-pagination-next::after {
	transform: rotate( -45deg );
}

/*
 * On a narrow screen a 12-page catalog would wrap the numbers onto three rows. Prev and
 * next are the controls that matter on a phone, so the numbers step aside — the current
 * page stays, so you never lose your place.
 */
@media ( max-width: 600px ) {
	nav.wp-block-query-pagination a.page-numbers,
	nav.wp-block-query-pagination span.page-numbers.dots,
	nav.wp-block-comments-pagination a.page-numbers,
	nav.wp-block-comments-pagination span.page-numbers.dots {
		display: none;
	}

	nav.wp-block-query-pagination span.page-numbers.current,
	nav.wp-block-comments-pagination span.page-numbers.current {
		display: inline-flex;
	}
}

/* ------------------------------------------------------------ accessibility -- */

.skip-link:focus {
	background: var( --wp--preset--color--background );
	color: var( --wp--preset--color--primary );
	box-shadow: var( --wp--preset--shadow--md );
	border-radius: var( --db-radius-md );
	padding: 12px 20px;
	z-index: 100000;
	left: 16px;
	top: 16px;
}

:where( a, button, input, select, textarea, .wp-block-button__link ):focus-visible {
	outline: 2px solid var( --wp--preset--color--primary );
	outline-offset: 2px;
}
