/*
Theme Name: Handcraft
Description: Block theme for the Handcraft Shop. Presentation only; business logic lives in the Handcraft Shop plugin.
Version:           0.8.2
Requires at least: 6.7
Requires PHP: 8.3
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: handcraft
*/

/*
 * Design tokens live in theme.json. This file holds what theme.json can't express: per-language
 * typography, the motif treatments, and WooCommerce details.
 *
 * Layout uses logical properties only, so every rule mirrors between Persian (RTL) and English (LTR).
 */

/* Persian reads best in Vazirmatn throughout, with more generous leading than Latin text. */
html:lang(fa),
html:lang(fa) body {
	--wp--custom--font--heading: var(--wp--preset--font-family--vazirmatn);
	--wp--custom--line-height--body: 1.9;
	--wp--custom--line-height--heading: 1.45;
}

:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 3px solid var(--wp--preset--color--ochre);
	outline-offset: 2px;
}

/* Motifs are single-colour SVG masks, so they take the colour of the text around them. */

.wp-block-separator.is-style-girih {
	block-size: var(--wp--custom--motif-band);
	border: 0;
	background-color: var(--wp--preset--color--rose);
	mask: url(assets/motifs/girih.svg) repeat-x center / auto 100%;
	opacity: 1;
}

.wp-block-separator.is-style-botteh {
	--botteh-gap: 1.75rem;
	block-size: 2.5rem;
	border: 0;
	background-color: var(--wp--preset--color--ochre);
	mask:
		url(assets/motifs/botteh.svg) center / auto 100% no-repeat,
		linear-gradient(#000 0 0) 0 50% / calc(50% - var(--botteh-gap)) 1px no-repeat,
		linear-gradient(#000 0 0) 100% 50% / calc(50% - var(--botteh-gap)) 1px no-repeat;
	opacity: 1;
}

/* A carpet's border: an outer ochre guard, then a thin madder-red line inside it. */
.wp-block-group.is-style-carpet-frame {
	border: 3px solid var(--wp--preset--color--ochre);
	outline: 1px solid var(--wp--preset--color--carpet-red);
	outline-offset: -9px;
	padding: var(--wp--preset--spacing--50);
}

.wp-block-group.is-style-medallion {
	position: relative;
	isolation: isolate;
	overflow: hidden;
}

.wp-block-group.is-style-medallion::before {
	content: "";
	position: absolute;
	inset-block-start: 50%;
	inset-inline-end: -4rem;
	z-index: -1;
	inline-size: 22rem;
	aspect-ratio: 120 / 136;
	translate: 0 -50%;
	background-color: var(--wp--preset--color--rose);
	mask: url(assets/motifs/medallion.svg) center / contain no-repeat;
	opacity: 0.18;
	pointer-events: none;
}

/* Header: a Shiraz-wine band finished like a carpet edge, with a girih strip and an ochre guard line. */

.handcraft-header {
	position: relative;
	border-block-end: 3px solid var(--wp--preset--color--ochre);
	margin-block-end: var(--wp--custom--motif-band);
}

.handcraft-header::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	inset-block-start: calc(100% + 3px);
	block-size: var(--wp--custom--motif-band);
	background-color: var(--wp--preset--color--rose);
	mask: url(assets/motifs/girih.svg) repeat-x center / auto 100%;
}

.handcraft-header a {
	color: inherit;
	text-decoration: none;
}

.handcraft-header a:hover {
	color: var(--wp--preset--color--ochre);
}

.handcraft-header .wp-block-navigation-item__content {
	padding-block: 0.25em;
	border-block-end: 2px solid transparent;
}

.handcraft-header .current-menu-item > .wp-block-navigation-item__content,
.handcraft-header .wp-block-navigation-item__content[aria-current] {
	border-block-end-color: var(--wp--preset--color--ochre);
}

.handcraft-language-switcher {
	display: flex;
	gap: var(--wp--preset--spacing--20);
}

.handcraft-language-switcher a {
	padding-block: 0.3em;
	padding-inline: 0.9em;
	border: 1px solid color-mix(in srgb, currentColor 45%, transparent);
	border-radius: 999px;
	font-size: var(--wp--preset--font-size--small);
}

.handcraft-language-switcher a:lang(en) {
	font-family: var(--wp--preset--font-family--fraunces);
}

.handcraft-language-switcher a:lang(fa) {
	font-family: var(--wp--preset--font-family--vazirmatn);
}

/*
 * The footer stands on the hero's Persepolis stair: the same procession of Immortals runs along its
 * top edge, drawn into a transparent border so the block's own padding stays as the editor set it.
 */
.handcraft-footer {
	border-block-start: 4.5rem solid transparent;
	background-image: url(assets/images/hero-immortals.svg);
	background-repeat: repeat-x;
	background-size: auto 4.5rem;
	background-origin: border-box;
	background-position: 0 0;
}

.handcraft-footer a {
	color: inherit;
}

/* The Enamad seal in the footer, at the size a trust mark reads at. */
.handcraft-footer .handcraft-enamad-badge {
	margin-block-start: var(--wp--preset--spacing--30);
}

.handcraft-footer .handcraft-enamad__seal {
	display: block;
	width: 4.5rem;
	height: auto;
}

/*
 * The brand is Hoopoe (هدهد). Its mark stands before the site title wherever the title appears,
 * in the title's own colour, and turns to face the name in Persian.
 */
.wp-block-site-title a {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	text-decoration: none;
}

.wp-block-site-title a::before {
	content: "";
	flex: 0 0 auto;
	inline-size: 1.65em;
	block-size: 1.57em;
	background-color: currentColor;
	mask: url(assets/motifs/hoopoe.svg) center / contain no-repeat;
}

[dir="rtl"] .wp-block-site-title a::before {
	scale: -1 1;
}

/* The 404 page's hoopoe, the guide bird that lost the way for once, faces the words. */
.handcraft-lost-hoopoe {
	margin-block-end: 0;
}

[dir="rtl"] .handcraft-lost-hoopoe img {
	scale: -1 1;
}

/* Header and footer sit flush against the main content. */
.wp-site-blocks > * + * {
	margin-block-start: 0;
}

/* Product page. */

.handcraft-product__gallery img {
	outline: 1px solid color-mix(in srgb, var(--wp--preset--color--ochre) 80%, transparent);
	outline-offset: -12px;
}

.handcraft-product__summary > * + * {
	margin-block-start: var(--wp--preset--spacing--30);
}

.handcraft-product__summary .wp-block-separator.is-style-girih {
	max-inline-size: 11rem;
	margin-inline: 0;
}

.handcraft-product .wp-block-woocommerce-product-meta {
	color: var(--wp--preset--color--umber);
}

.handcraft-product .quantity .qty,
.handcraft-catalog select {
	padding-block: 0.6em;
	padding-inline: 0.75em;
	border: 1px solid var(--wp--preset--color--sand);
	border-radius: 0.25rem;
	background-color: #fffaf1;
	font: inherit;
	color: inherit;
}

.handcraft-product .wp-block-woocommerce-product-details .wc-tabs {
	padding-inline-start: 0;
}

/*
 * Customization options above the add-to-cart button: each option is a chip, its radio button
 * hidden but still focusable, and the chosen one inked in garnet.
 */

.handcraft-options {
	flex-basis: 100%;
	margin-block-end: var(--wp--preset--spacing--30);
}

.handcraft-options__group {
	margin-block: 0 var(--wp--preset--spacing--30);
	margin-inline: 0;
	padding: 0;
	border: 0;
}

.handcraft-options__legend {
	margin-block-end: var(--wp--preset--spacing--20);
	padding: 0;
	font-weight: 600;
}

.handcraft-options__optional {
	color: var(--wp--preset--color--umber);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
}

.handcraft-options__choices {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.handcraft-option {
	position: relative;
	display: inline-flex;
	align-items: baseline;
	gap: 0.5em;
	padding-block: 0.5em;
	padding-inline: 0.95em;
	border: 1px solid var(--wp--preset--color--sand);
	border-radius: 999px;
	background-color: #fffaf1;
	cursor: pointer;
	transition: border-color 0.15s, background-color 0.15s;
}

.handcraft-option:hover {
	border-color: var(--wp--preset--color--ochre);
}

.handcraft-option__input {
	position: absolute;
	inset: 0;
	margin-block: 0;
	margin-inline: 0;
	opacity: 0;
	cursor: pointer;
}

.handcraft-option:has(:checked) {
	border-color: var(--wp--preset--color--garnet);
	background-color: color-mix(in srgb, var(--wp--preset--color--garnet) 8%, #fffaf1);
	box-shadow: inset 0 0 0 1px var(--wp--preset--color--garnet);
}

.handcraft-option:has(:focus-visible) {
	outline: 2px solid var(--wp--preset--color--ochre);
	outline-offset: 2px;
}

.handcraft-option__price {
	color: var(--wp--preset--color--umber);
	font-size: var(--wp--preset--font-size--small);
}

/*
 * The Customer's own text for the Maker: one full-width line to type in, under a warning that
 * makes the piece Final Sale.
 */

.handcraft-options__text {
	padding-block-end: var(--wp--preset--spacing--30);
}

.handcraft-options__text-input {
	display: block;
	width: min(100%, 32rem);
	max-width: 100%;
}

.handcraft-options__final-sale {
	margin-block: var(--wp--preset--spacing--20) 0;
	margin-inline: 0;
	color: var(--wp--preset--color--carpet-red);
	font-size: var(--wp--preset--font-size--small);
}

.handcraft-options__total {
	margin-block: 0;
	margin-inline: 0;
	padding-block-start: var(--wp--preset--spacing--20);
	border-block-start: 1px dashed var(--wp--preset--color--sand);
}

.handcraft-options__total output {
	font-weight: 600;
	color: var(--wp--preset--color--shiraz);
}

@media (prefers-reduced-motion: reduce) {
	.handcraft-option {
		transition: none;
	}
}

/* Maker credit: each Maker's photo in a small arch beside their name and bio. */

.handcraft-maker-credit__label {
	margin: 0 0 var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--umber);
	font-size: var(--wp--preset--font-size--small);
}

.handcraft-maker-credit__makers {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--30);
	margin: 0;
	padding: 0;
	list-style: none;
}

.handcraft-maker-credit__maker {
	display: flex;
	align-items: flex-start;
	gap: 0.85em;
}

.handcraft-maker-credit__photo {
	flex: 0 0 auto;
}

.handcraft-maker-credit__photo img {
	display: block;
	inline-size: 3.25rem;
	block-size: 4rem;
	object-fit: cover;
	border-start-start-radius: 100vmax;
	border-start-end-radius: 100vmax;
}

.handcraft-maker-credit__name {
	border-block-end: 1px solid var(--wp--preset--color--ochre);
	color: inherit;
	font-weight: 600;
	text-decoration: none;
}

.handcraft-maker-credit__name:is(:hover, :focus-visible) {
	color: var(--wp--preset--color--carpet-red);
	border-block-end-color: currentColor;
}

.handcraft-maker-credit__bio {
	margin: 0.25em 0 0;
	color: var(--wp--preset--color--umber);
	font-size: var(--wp--preset--font-size--small);
}

/* International Visitors order by chat: the two doors, side by side under the price. */

.handcraft-contact {
	margin-block-start: var(--wp--preset--spacing--40);
}

.handcraft-contact__label {
	margin: 0 0 var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--umber);
	font-size: var(--wp--preset--font-size--small);
}

.handcraft-contact__buttons {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--20);
	margin: 0;
	padding: 0;
	list-style: none;
}

.handcraft-contact__button {
	display: inline-block;
	padding: 0.6em 1.4em;
	border-radius: 0.25rem;
	color: var(--wp--preset--color--parchment);
	background-color: var(--wp--preset--color--rose-deep);
	font-weight: 600;
}

.handcraft-contact__button--instagram {
	background-color: var(--wp--preset--color--carpet-red);
}

.handcraft-contact__button:is(:hover, :focus-visible) {
	background-color: var(--wp--preset--color--shiraz);
	color: var(--wp--preset--color--parchment);
}

/* Maker page: the Maker's photo in an arch beside their name and bio, then their products. */

.handcraft-maker-page__profile {
	gap: var(--wp--preset--spacing--50);
	margin-block: var(--wp--preset--spacing--40);
}

.handcraft-maker-page__photo {
	flex: 0 0 auto;
	inline-size: min(16rem, 60vw);
	margin: 0;
	padding: 0.45rem 0.45rem 0;
	background-color: var(--wp--preset--color--ochre);
	border-start-start-radius: 100vmax;
	border-start-end-radius: 100vmax;
}

.handcraft-maker-page__photo img {
	display: block;
	inline-size: 100%;
	block-size: auto;
	aspect-ratio: 3 / 4;
	object-fit: cover;
	border-start-start-radius: 100vmax;
	border-start-end-radius: 100vmax;
}

.handcraft-maker-page__about {
	flex: 1 1 20rem;
	max-inline-size: 40rem;
}

.handcraft-maker-page__about > * {
	margin-block: 0;
}

.handcraft-maker-page__about > * + * {
	margin-block-start: var(--wp--preset--spacing--30);
}

.handcraft-maker-page__eyebrow {
	color: var(--wp--preset--color--carpet-red);
	letter-spacing: 0.08em;
}

.handcraft-maker-page__eyebrow:lang(en) {
	text-transform: uppercase;
}

/* Catalog. */

.handcraft-product-grid .wc-block-components-product-image img {
	border-radius: 0.25rem;
}

.handcraft-product-grid .wp-block-post-title {
	margin-block: var(--wp--preset--spacing--20) 0;
}

.handcraft-product-grid .wp-block-post-title a {
	text-decoration: none;
}

.handcraft-product-grid .wc-block-components-product-sale-badge {
	inset-inline-end: 0.5rem;
	inset-inline-start: auto;
}

/*
 * Item hover: light rakes across the piece the way late sun crosses carved sandstone. The card
 * rises a little, the picture settles closer, a band of warm light sweeps over it once, and an
 * ochre hairline frames it like the guard on a relief panel. Keyboard focus gets the same.
 */
.handcraft-product-grid > li,
.handcraft-arcade__tile,
.handcraft-maker {
	--rake: 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
	transition: translate 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.handcraft-product-grid .wc-block-components-product-image,
.handcraft-arch {
	position: relative;
	overflow: hidden;
	isolation: isolate;
}

.handcraft-product-grid .wc-block-components-product-image img,
.handcraft-arch img {
	transition: scale var(--rake, 0.9s ease), filter var(--rake, 0.9s ease);
}

.handcraft-product-grid .wc-block-components-product-image::after,
.handcraft-arch::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: inherit;
	background: linear-gradient(115deg, transparent 38%, rgb(255 240 212 / 0.42) 50%, transparent 62%) no-repeat;
	background-size: 260% 100%;
	background-position: 130% 0;
	pointer-events: none;
}

[dir="rtl"] :is(.handcraft-product-grid .wc-block-components-product-image, .handcraft-arch)::after {
	background-image: linear-gradient(245deg, transparent 38%, rgb(255 240 212 / 0.42) 50%, transparent 62%);
	background-position: -30% 0;
}

.handcraft-product-grid .wc-block-components-product-image::before {
	content: "";
	position: absolute;
	inset: 0.6rem;
	z-index: 1;
	border: 1px solid var(--wp--preset--color--ochre);
	border-radius: 0.2rem;
	opacity: 0;
	scale: 1.03;
	transition: opacity 0.45s ease, scale 0.45s ease;
	pointer-events: none;
}

.handcraft-product-grid .wp-block-post-title a {
	transition: color 0.3s ease;
}

@media (hover: hover) {
	:is(.handcraft-product-grid > li, .handcraft-arcade__tile, .handcraft-maker):hover,
	:is(.handcraft-product-grid > li, .handcraft-arcade__tile, .handcraft-maker):focus-within {
		translate: 0 -0.35rem;
	}

	:is(.handcraft-product-grid > li, .handcraft-arcade__tile, .handcraft-maker):is(:hover, :focus-within) :is(.wc-block-components-product-image, .handcraft-arch) img {
		scale: 1.045;
		filter: saturate(1.08) brightness(1.03);
	}

	:is(.handcraft-product-grid > li, .handcraft-arcade__tile, .handcraft-maker):is(:hover, :focus-within) :is(.wc-block-components-product-image, .handcraft-arch)::after {
		background-position: -30% 0;
		transition: background-position var(--rake);
	}

	[dir="rtl"] :is(.handcraft-product-grid > li, .handcraft-arcade__tile, .handcraft-maker):is(:hover, :focus-within) :is(.wc-block-components-product-image, .handcraft-arch)::after {
		background-position: 130% 0;
	}

	.handcraft-product-grid > li:is(:hover, :focus-within) .wc-block-components-product-image::before {
		opacity: 0.9;
		scale: 1;
	}

	.handcraft-product-grid > li:is(:hover, :focus-within) .wp-block-post-title a {
		color: var(--wp--preset--color--rose);
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}
}

/* Catalog sidebar: categories and filters. */

.handcraft-catalog__sidebar {
	gap: var(--wp--preset--spacing--50);
}

.handcraft-catalog__sidebar h2,
.handcraft-catalog__sidebar h3 {
	margin-block: 0 var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--garnet);
}

.handcraft-catalog__categories .wc-block-product-categories-list {
	margin: 0;
	padding-inline-start: 0;
	list-style: none;
}

.handcraft-catalog__categories .wc-block-product-categories-list-item {
	padding-block: 0.35em;
	border-block-end: 1px solid var(--wp--preset--color--sand);
}

.handcraft-catalog__categories a {
	color: inherit;
	text-decoration: none;
}

.handcraft-catalog__categories a:hover,
.handcraft-catalog__categories a:focus-visible {
	color: var(--wp--preset--color--carpet-red);
}

.handcraft-catalog__categories .wc-block-product-categories-list-item.current-cat > a,
.handcraft-catalog__categories a[aria-current] {
	font-weight: 700;
	color: var(--wp--preset--color--garnet);
}

.handcraft-product-grid .wc-block-components-product-stock-indicator {
	margin-block-start: var(--wp--preset--spacing--10);
	color: var(--wp--preset--color--rose-deep);
}

.wc-block-components-product-stock-indicator--out-of-stock {
	color: var(--wp--preset--color--carpet-red);
}
