/**
 * Balitalia Living - base + component styles.
 *
 * Tailwind (via the Play CDN, driven by inc/tailwind-config.php) does the bulk
 * of the work. Everything here is either impossible to express as a utility,
 * a behaviour the design's markup relies on, or a progressive-enhancement
 * fallback for when the CDN has not yet executed.
 */

/* ------------------------------------------------------------------ *
 * 1. CSS custom properties (mirror of the design tokens)
 * ------------------------------------------------------------------ */

:root {
	--ba-primary: #7e331a;
	--ba-terracotta-dark: #82381f;
	--ba-tertiary: #404e38;
	--ba-surface: #f6fbf5;
	--ba-surface-cream: #fdfbf7;
	--ba-surface-warm-linen: #f5efeb;
	--ba-on-surface: #181d1a;
	--ba-on-surface-variant: #55433d;
	--ba-border-warm: #e8e3dd;
	--ba-badge-promo: #9c4a2f;
	--ba-badge-benefit: #5c6b53;

	--ba-font-serif: "Playfair Display", Georgia, serif;
	--ba-font-sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;

	/* Header is 36px announcement + 80px bar + 41px nav on desktop. */
	--ba-header-height: 157px;
}

@media (max-width: 1023px) {
	:root {
		--ba-header-height: 72px;
	}
}

/* ------------------------------------------------------------------ *
 * 2. Base
 * ------------------------------------------------------------------ */

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
}

body {
	margin: 0;
	background-color: var(--ba-surface);
	color: var(--ba-on-surface);
	font-family: var(--ba-font-sans);
	overscroll-behavior-y: none;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

main > :first-child {
	margin-top: 0 !important;
}

main > :last-child {
	margin-bottom: 0 !important;
}

/* The design hides scrollbars on horizontal rail scrollers (category strips,
   tab bars). Keep that, but only where the markup opts in. */
.ba-hide-scrollbar {
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.ba-hide-scrollbar::-webkit-scrollbar,
.ba-horizontal-rail::-webkit-scrollbar {
	display: none;
}

.ba-horizontal-rail {
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
}

/* Focus visibility: Tailwind's reset removes outlines, and a furniture store
   has to stay keyboard navigable. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
	outline: 2px solid var(--ba-primary);
	outline-offset: 2px;
	border-radius: 0.125rem;
}

/* ------------------------------------------------------------------ *
 * 3. Material Symbols icon font
 * ------------------------------------------------------------------ */

.material-symbols-outlined {
	font-family: "Material Symbols Outlined";
	font-weight: normal;
	font-style: normal;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	display: inline-block;
	white-space: nowrap;
	word-wrap: normal;
	direction: ltr;
	font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
	-webkit-font-feature-settings: "liga";
	-webkit-font-smoothing: antialiased;
	user-select: none;
	vertical-align: middle;
}

/*
 * Icon sizing.
 *
 * The design sizes every icon with Tailwind `text-*` utilities, which set
 * `font-size` on the icon element itself. We therefore deliberately do NOT set
 * `font-size` here: doing so would either fight those utilities or collapse the
 * ligature to the surrounding text size. The `font-size` comes from the utility.
 */

/* ------------------------------------------------------------------ *
 * 4. Header
 * ------------------------------------------------------------------ */

.ba-site-header {
	position: sticky;
	top: 0;
	z-index: 50;
}

/* Offset anchors so sticky-nav jumps do not hide content underneath. */
:target {
	scroll-margin-top: calc(var(--ba-header-height) + 1rem);
}

.ba-nav-menu {
	display: flex;
	align-items: center;
	gap: 1.5rem;
}

.ba-nav-menu a {
	white-space: nowrap;
}

/* Mobile navigation drawer. */
.ba-mobile-nav {
	transform: translateX(-100%);
	transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
	will-change: transform;
}

.ba-mobile-nav[data-open="true"] {
	transform: translateX(0);
}

.ba-mobile-scrim {
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.28s ease;
}

.ba-mobile-scrim[data-open="true"] {
	opacity: 1;
	pointer-events: auto;
}

body.ba-nav-open,
body.ba-modal-open {
	overflow: hidden;
}

/* Modal dialogs. Visibility is driven by the `hidden` utility; the display
   value is swapped in JS because `hidden` and `flex` both set `display`. */
.ba-modal-open .ba-site-header {
	/* Keep the sticky header below the dialog scrim while a modal is open. */
	z-index: 1;
}

/* ------------------------------------------------------------------ *
 * 5. Product cards & badges
 * ------------------------------------------------------------------ */

.ba-card-media {
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.ba-group:hover .ba-card-media {
	transform: scale(1.05);
}

.ba-line-clamp-1,
.ba-line-clamp-2,
.ba-line-clamp-3 {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ba-line-clamp-1 { -webkit-line-clamp: 1; line-clamp: 1; }
.ba-line-clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.ba-line-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

/* Wishlist / compare toggle buttons on media. */
.ba-icon-toggle {
	transition: color 0.2s ease, background-color 0.2s ease;
}

.ba-icon-toggle[aria-pressed="true"] {
	color: var(--ba-primary);
}

.ba-icon-toggle[aria-pressed="true"] .material-symbols-outlined {
	font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* ------------------------------------------------------------------ *
 * 6. Carousels & rails (scroll-snap)
 * ------------------------------------------------------------------ */

.ba-snap-rail {
	display: flex;
	gap: 1rem;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	padding-bottom: 0.25rem;
}

.ba-snap-rail > * {
	scroll-snap-align: start;
	flex: 0 0 auto;
}

/* ------------------------------------------------------------------ *
 * 7. Forms
 * ------------------------------------------------------------------ */

.ba-field {
	width: 100%;
	border: 1px solid var(--ba-border-warm);
	background: #fff;
	border-radius: 0.25rem;
	padding: 0.625rem 0.75rem;
	font-family: var(--ba-font-sans);
	font-size: 14px;
	line-height: 22px;
	color: var(--ba-on-surface);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ba-field::placeholder {
	color: #88726c;
}

.ba-field:focus {
	outline: none;
	border-color: var(--ba-primary);
	box-shadow: 0 0 0 3px rgba(126, 51, 26, 0.12);
}

.ba-field[aria-invalid="true"] {
	border-color: #ba1a1a;
}

/* Radio/checkbox cards used on checkout shipping + payment selection. */
.ba-choice-card {
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ba-choice-card:has(input:checked) {
	border-color: var(--ba-primary);
	background: var(--ba-surface-warm-linen);
}

/* Quantity stepper. */
.ba-qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--ba-border-warm);
	border-radius: 0.25rem;
	overflow: hidden;
	background: #fff;
}

.ba-qty button {
	width: 2rem;
	height: 2rem;
	display: grid;
	place-items: center;
	background: transparent;
	border: 0;
	cursor: pointer;
	color: var(--ba-on-surface-variant);
	transition: background-color 0.15s ease, color 0.15s ease;
}

.ba-qty button:hover {
	background: var(--ba-surface-warm-linen);
	color: var(--ba-primary);
}

.ba-qty input {
	width: 2.75rem;
	border: 0;
	border-left: 1px solid var(--ba-border-warm);
	border-right: 1px solid var(--ba-border-warm);
	text-align: center;
	font-family: var(--ba-font-sans);
	font-size: 14px;
	font-weight: 600;
	padding: 0.375rem 0;
	background: transparent;
	color: var(--ba-on-surface);
}

.ba-qty input::-webkit-outer-spin-button,
.ba-qty input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.ba-qty input[type="number"] {
	-moz-appearance: textfield;
	appearance: textfield;
}

/* ------------------------------------------------------------------ *
 * 8. Accordions (FAQ, product spec tabs, footer policies)
 * ------------------------------------------------------------------ */

.ba-accordion-panel {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows 0.28s ease;
}

.ba-accordion-panel > div {
	overflow: hidden;
}

.ba-accordion[data-open="true"] .ba-accordion-panel {
	grid-template-rows: 1fr;
}

.ba-accordion[data-open="true"] .ba-accordion-chevron {
	transform: rotate(180deg);
}

.ba-accordion-chevron {
	transition: transform 0.28s ease;
}

/* ------------------------------------------------------------------ *
 * 9. Tabs
 * ------------------------------------------------------------------ */

.ba-tab-panel[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ *
 * 10. Countdown timer
 * ------------------------------------------------------------------ */

.ba-countdown-unit {
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

/* ------------------------------------------------------------------ *
 * 11. Ratings
 * ------------------------------------------------------------------ */

.ba-stars {
	display: inline-flex;
	gap: 0.0625rem;
	color: #c8863c;
}

/* ------------------------------------------------------------------ *
 * 12. Skip link
 * ------------------------------------------------------------------ */

.ba-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 100;
	padding: 0.75rem 1.25rem;
	background: var(--ba-primary);
	color: #fff;
	font-family: var(--ba-font-sans);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	border-radius: 0 0 0.25rem 0;
}

.ba-skip-link:focus {
	left: 0;
}

/* ------------------------------------------------------------------ *
 * 13. WordPress alignment + caption defaults
 * ------------------------------------------------------------------ */

.alignleft {
	float: left;
	margin: 0.5rem 1.5rem 1rem 0;
}

.alignright {
	float: right;
	margin: 0.5rem 0 1rem 1.5rem;
}

.aligncenter {
	display: block;
	margin-left: auto;
	margin-right: auto;
}

.wp-caption {
	max-width: 100%;
	margin-bottom: 1.5rem;
}

.wp-caption-text,
.wp-element-caption {
	font-size: 12px;
	line-height: 18px;
	color: var(--ba-on-surface-variant);
	text-align: center;
	padding-top: 0.5rem;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ------------------------------------------------------------------ *
 * 14. Print
 * ------------------------------------------------------------------ */

@media print {
	.ba-site-header,
	.ba-site-footer,
	.ba-mobile-nav,
	.ba-mobile-scrim {
		display: none !important;
	}

	main {
		padding-top: 0 !important;
	}

	body {
		background: #fff;
	}
}

/* ------------------------------------------------------------------ *
 * 15. Reduced motion
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	.ba-snap-rail {
		scroll-behavior: auto;
	}
}
