/*
Theme Name: Apteka Prima
Theme URI: http://apteka.local
Author: Apteka Prima
Author URI: http://apteka.local
Description: Dispensary-grade storefront for Apteka Prima. A calm, clinical pharmacy shop built as a child of Twenty Twenty-Five and tuned for WooCommerce browsing, search and checkout.
Template: twentytwentyfive
Version: 1.0.0
Requires at least: 6.7
Requires PHP: 7.2
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: apteka-prima
Tags: e-commerce, full-site-editing, block-patterns
*/

/* ---------------------------------------------------------------------------
   Prima Dispensary token layer.
   Mirrors the active DESIGN.md so CSS and theme.json never drift apart.
   --------------------------------------------------------------------------- */

:root {
	--ap-bg: #F1F4EF;
	--ap-surface: #FFFFFF;
	--ap-ink: #12211A;
	--ap-muted: #55665C;
	--ap-line: #D8E0D6;
	--ap-accent: #0E6E4A;
	--ap-accent-strong: #0A5638;
	--ap-accent-tint: #DCEBE2;
	--ap-signal: #B4491E;

	--ap-font-head: 'Fira Sans', system-ui, sans-serif;
	--ap-font-body: 'Manrope', system-ui, sans-serif;

	--ap-xs: 6px;
	--ap-sm: 10px;
	--ap-md: 18px;
	--ap-lg: 32px;
	--ap-xl: 56px;
	--ap-xxl: 96px;

	--ap-r-sm: 8px;
	--ap-r-md: 14px;
	--ap-r-pill: 999px;

	--ap-container: 1280px;
	--ap-measure: 720px;
	--ap-gutter: clamp(16px, 4vw, 40px);
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */

body {
	background: var(--ap-bg);
	color: var(--ap-ink);
	font-family: var(--ap-font-body);
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
}

:where(h1, h2, h3, h4, h5, h6) {
	font-family: var(--ap-font-head);
	font-weight: 600;
	line-height: 1.08;
	letter-spacing: -0.015em;
	color: var(--ap-ink);
}

:where(p, li) {
	max-width: var(--ap-measure);
}

a {
	color: var(--ap-accent);
	text-underline-offset: 0.18em;
}

a:hover {
	color: var(--ap-accent-strong);
}

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--ap-accent);
	outline-offset: 2px;
	border-radius: var(--ap-r-sm);
}

.ap-shell {
	width: 100%;
	max-width: var(--ap-container);
	margin-inline: auto;
	padding-inline: var(--ap-gutter);
}

/* ---------------------------------------------------------------------------
   Header: brand, product search, utilities. One line at desktop.
   --------------------------------------------------------------------------- */

/* The template part renders its own <header> wrapper, and a sticky child
   cannot escape that 77px box, so the wrapper carries the stickiness. */

header.wp-block-template-part:has(.ap-header) {
	position: sticky;
	top: 0;
	z-index: 40;
}

.admin-bar header.wp-block-template-part:has(.ap-header) {
	top: 32px;
}

.ap-header {
	background: var(--ap-surface);
	border-bottom: 1px solid var(--ap-line);
}

.ap-header__inner {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: var(--ap-lg);
	min-height: 76px;
	padding-block: var(--ap-sm);
}

.ap-header__inner > * {
	margin-block: 0;
}

.ap-brand {
	display: inline-flex;
	align-items: center;
	gap: var(--ap-sm);
	text-decoration: none;
	color: var(--ap-ink);
	font-family: var(--ap-font-head);
	font-weight: 700;
	font-size: 1.3rem;
	letter-spacing: -0.02em;
	line-height: 1;
	white-space: nowrap;
}

.ap-brand:hover {
	color: var(--ap-ink);
}

.ap-brand__mark {
	width: 26px;
	height: 26px;
	flex: 0 0 auto;
	color: var(--ap-accent);
}

.ap-brand__mark svg {
	display: block;
	width: 100%;
	height: 100%;
}

.ap-header__utils {
	display: inline-flex;
	align-items: center;
	gap: var(--ap-md);
	font-size: 0.9rem;
	white-space: nowrap;
}

.ap-header__utils .wc-block-customer-account__link {
	display: inline-flex;
	align-items: center;
	gap: var(--ap-xs);
	color: var(--ap-ink);
	text-decoration: none;
	font-weight: 500;
	font-size: 0.9rem;
}

.ap-header__utils .wc-block-customer-account__link:hover {
	color: var(--ap-accent);
}

.ap-header__utils .wc-block-mini-cart__button {
	color: var(--ap-ink);
	padding: 6px;
}

.ap-header__utils .wc-block-mini-cart__badge {
	background: var(--ap-accent);
	color: #fff;
	border-radius: var(--ap-r-pill);
	font-family: var(--ap-font-body);
	font-weight: 700;
}

/* ---------------------------------------------------------------------------
   Product search. The primary component of the site.
   --------------------------------------------------------------------------- */

.ap-search,
.ap-search > .wc-block-product-search {
	width: 100%;
}

.ap-search .wc-block-product-search__label {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

.ap-search .wc-block-product-search__fields {
	display: flex;
	align-items: stretch;
	gap: var(--ap-sm);
	width: 100%;
}

.ap-search .wc-block-product-search__field {
	flex: 1 1 auto;
	min-width: 0;
	height: 48px;
	padding: 0 var(--ap-md);
	background: var(--ap-surface);
	border: 1px solid var(--ap-line);
	border-radius: var(--ap-r-sm);
	font-family: var(--ap-font-body);
	font-size: 0.95rem;
	color: var(--ap-ink);
	appearance: none;
}

.ap-search .wc-block-product-search__field::placeholder {
	color: var(--ap-muted);
	opacity: 1;
}

.ap-search .wc-block-product-search__field:focus {
	border-color: var(--ap-accent);
	outline: 2px solid var(--ap-accent);
	outline-offset: 2px;
}

.ap-search .wc-block-product-search__button {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 48px;
	padding: 0 var(--ap-lg);
	background: var(--ap-accent);
	color: #fff;
	border: 1px solid var(--ap-accent);
	border-radius: var(--ap-r-sm);
	font-family: var(--ap-font-head);
	font-weight: 600;
	font-size: 0.95rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color 120ms ease;
}

.ap-search .wc-block-product-search__button:hover {
	background: var(--ap-accent-strong);
	border-color: var(--ap-accent-strong);
}

/* ---------------------------------------------------------------------------
   Shop counter band: heading, real catalogue facts, category rail.
   --------------------------------------------------------------------------- */

.ap-counter {
	padding-block: var(--ap-xl) var(--ap-lg);
}

.ap-counter__grid {
	display: grid;
	grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
	gap: var(--ap-xl);
	align-items: end;
}

.ap-counter__title {
	font-size: clamp(2.1rem, 4.4vw, 3.4rem);
	line-height: 1.04;
	margin: 0;
}

.ap-counter__lede {
	margin: var(--ap-md) 0 0;
	color: var(--ap-muted);
	font-size: 1.02rem;
	max-width: 46ch;
}

.ap-counter__facts {
	display: flex;
	flex-direction: column;
	gap: var(--ap-sm);
	padding-left: var(--ap-lg);
	border-left: 1px solid var(--ap-line);
}

.ap-counter__fact {
	margin: 0;
	font-size: 0.92rem;
	color: var(--ap-muted);
	max-width: none;
}

.ap-counter__fact strong {
	font-family: var(--ap-font-head);
	font-weight: 600;
	color: var(--ap-ink);
}

.ap-rail {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ap-sm);
	margin: var(--ap-lg) 0 0;
	padding: 0;
	list-style: none;
}

.ap-rail li {
	max-width: none;
	margin: 0;
}

.ap-rail a {
	display: inline-flex;
	align-items: baseline;
	gap: var(--ap-xs);
	padding: 8px 16px;
	background: var(--ap-surface);
	border: 1px solid var(--ap-line);
	border-radius: var(--ap-r-pill);
	color: var(--ap-ink);
	text-decoration: none;
	font-size: 0.88rem;
	font-weight: 500;
	transition: border-color 120ms ease, color 120ms ease;
}

.ap-rail a:hover,
.ap-rail a[aria-current='page'] {
	border-color: var(--ap-accent);
	color: var(--ap-accent);
}

.ap-rail a span {
	color: var(--ap-muted);
	font-size: 0.8rem;
}

.ap-rail a:hover span,
.ap-rail a[aria-current='page'] span {
	color: var(--ap-accent);
}

/* ---------------------------------------------------------------------------
   Shop toolbar and product grid (WooCommerce blockified templates)
   --------------------------------------------------------------------------- */

main.wp-block-group {
	padding-bottom: var(--ap-xxl);
}

.woocommerce-notices-wrapper:empty,
.wc-block-components-notices:empty {
	display: none;
}

.ap-shop-toolbar {
	align-items: center;
	gap: var(--ap-md);
	padding-block: var(--ap-md);
	border-top: 1px solid var(--ap-line);
	border-bottom: 1px solid var(--ap-line);
	margin-bottom: var(--ap-lg);
}

.wc-block-product-results-count,
.woocommerce-result-count {
	margin: 0;
	color: var(--ap-muted);
	font-size: 0.9rem;
	max-width: none;
}

.wc-block-catalog-sorting select,
.woocommerce-ordering select {
	height: 40px;
	padding: 0 var(--ap-md);
	background: var(--ap-surface);
	border: 1px solid var(--ap-line);
	border-radius: var(--ap-r-sm);
	font-family: var(--ap-font-body);
	font-size: 0.9rem;
	color: var(--ap-ink);
}

/* Secondary collections (Related products, up-sells) carry their own heading,
   which WooCommerce otherwise renders at body size. */

.wp-block-woocommerce-product-collection:has(> h2.wp-block-heading),
.wp-block-woocommerce-product-collection:has(> h3.wp-block-heading) {
	margin-top: var(--ap-xl);
}

.wp-block-woocommerce-product-collection > h2.wp-block-heading,
.wp-block-woocommerce-product-collection > h3.wp-block-heading {
	margin: 0 0 var(--ap-md);
	font-family: var(--ap-font-head);
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1.1;
	letter-spacing: -0.015em;
	color: var(--ap-ink);
}

.wp-block-woocommerce-product-collection ul.wc-block-product-template {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: var(--ap-lg) var(--ap-md);
	margin: 0;
	padding: 0;
	list-style: none;
}

.wp-block-woocommerce-product-collection li.wc-block-product {
	width: auto;
	max-width: none;
	min-width: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	background: var(--ap-surface);
	border: 1px solid var(--ap-line);
	border-radius: var(--ap-r-md);
	overflow: hidden;
	text-align: left;
	transition: border-color 140ms ease, transform 140ms ease;
}

/* Related products and up-sells ship as .is-flex-container.columns-N, and
   WooCommerce sizes those items for its own flex layout with a selector that
   outranks the card rule above, collapsing each card to about 45px inside the
   grid. Let the grid track be the only thing that sets card width. */

.wp-block-woocommerce-product-collection ul.wc-block-product-template.is-flex-container > li.wc-block-product {
	width: auto;
	max-width: none;
	min-width: 0;
	flex: 1 1 auto;
	box-sizing: border-box;
	margin: 0;
}

.wp-block-woocommerce-product-collection li.wc-block-product:hover {
	border-color: var(--ap-accent);
	transform: translateY(-2px);
}

/* One image ratio for every card, whether the product has real photography
   or is still falling back to the on-palette placeholder. */

li.wc-block-product .wc-block-components-product-image {
	margin: 0;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-bottom: 1px solid var(--ap-line);
	background: var(--ap-accent-tint);
}

li.wc-block-product .wc-block-components-product-image a {
	display: block;
	width: 100%;
	height: 100%;
}

li.wc-block-product .wc-block-components-product-image img,
li.wc-block-product .ap-thumb {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	aspect-ratio: auto;
	object-fit: cover;
	border-radius: 0;
}

li.wc-block-product .wp-block-post-title {
	padding: var(--ap-md) var(--ap-md) 0;
	margin: 0;
	font-family: var(--ap-font-head);
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: -0.01em;
	text-align: left;
	max-width: none;
}

li.wc-block-product .wp-block-post-title a {
	color: var(--ap-ink);
	text-decoration: none;
}

li.wc-block-product .wp-block-post-title a:hover {
	color: var(--ap-accent);
}

li.wc-block-product .ap-card-meta {
	padding: var(--ap-xs) var(--ap-md) 0;
	margin: 0;
	font-size: 0.82rem;
	line-height: 1.45;
	color: var(--ap-muted);
	max-width: none;
}

li.wc-block-product .wc-block-components-product-price {
	padding: var(--ap-sm) var(--ap-md) 0;
	margin: 0 0 auto;
	font-family: var(--ap-font-head);
	font-size: 1.08rem;
	font-weight: 600;
	color: var(--ap-ink);
	text-align: left;
}

li.wc-block-product .wc-block-components-product-price del {
	color: var(--ap-muted);
	font-weight: 400;
	font-size: 0.9rem;
	margin-right: var(--ap-xs);
	opacity: 1;
}

li.wc-block-product .wc-block-components-product-price ins {
	color: var(--ap-signal);
	text-decoration: none;
	background: transparent;
}

li.wc-block-product .wc-block-components-product-button {
	margin: var(--ap-md);
	text-align: left;
}

li.wc-block-product .wc-block-components-product-button .wp-block-button__link {
	width: 100%;
	justify-content: center;
}

.ap-stock {
	display: inline-flex;
	align-items: center;
	margin: var(--ap-sm) var(--ap-md) 0;
	padding: 3px 10px;
	border-radius: var(--ap-r-pill);
	background: var(--ap-accent-tint);
	color: var(--ap-accent-strong);
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	align-self: flex-start;
}

.ap-stock--out {
	background: rgba(180, 73, 31, 0.1);
	color: var(--ap-signal);
}

/* On-palette placeholder art, used until real product photography is chosen. */

.ap-thumb {
	position: relative;
	display: grid;
	place-items: center;
	background: linear-gradient(160deg, var(--ap-accent-tint) 0%, var(--ap-bg) 100%);
}

.ap-thumb svg {
	width: 34%;
	height: auto;
	color: var(--ap-accent);
	opacity: 0.62;
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.wp-element-button,
.wp-block-button__link,
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce a.button.alt,
.woocommerce button.button.alt {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 12px 22px;
	background: var(--ap-accent);
	color: #fff;
	border: 1px solid var(--ap-accent);
	border-radius: var(--ap-r-sm);
	font-family: var(--ap-font-head);
	font-weight: 600;
	font-size: 0.92rem;
	line-height: 1.2;
	text-decoration: none;
	text-shadow: none;
	cursor: pointer;
	transition: background-color 120ms ease, border-color 120ms ease;
}

.wp-element-button:hover,
.wp-block-button__link:hover,
.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover,
.woocommerce a.button.alt:hover,
.woocommerce button.button.alt:hover {
	background: var(--ap-accent-strong);
	border-color: var(--ap-accent-strong);
	color: #fff;
}

/* ---------------------------------------------------------------------------
   Pagination
   --------------------------------------------------------------------------- */

.wp-block-query-pagination {
	margin-top: var(--ap-xl);
	gap: var(--ap-xs);
}

.wp-block-query-pagination a,
.wp-block-query-pagination .page-numbers {
	min-width: 40px;
	height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 10px;
	border: 1px solid var(--ap-line);
	border-radius: var(--ap-r-sm);
	background: var(--ap-surface);
	color: var(--ap-ink);
	text-decoration: none;
	font-size: 0.9rem;
}

.wp-block-query-pagination .page-numbers.current {
	background: var(--ap-accent);
	border-color: var(--ap-accent);
	color: #fff;
}

/* ---------------------------------------------------------------------------
   Single product, cart, checkout, account
   --------------------------------------------------------------------------- */

.woocommerce div.product .product_title,
.wp-block-post-title {
	line-height: 1.06;
}

.woocommerce div.product p.price,
.wc-block-components-product-price {
	color: var(--ap-ink);
	font-family: var(--ap-font-head);
	font-weight: 600;
}

.woocommerce div.product .woocommerce-tabs ul.tabs::before {
	border-bottom-color: var(--ap-line);
}

.woocommerce div.product .woocommerce-tabs ul.tabs li {
	background: var(--ap-surface);
	border-color: var(--ap-line);
	border-radius: var(--ap-r-sm) var(--ap-r-sm) 0 0;
}

.woocommerce div.product .woocommerce-tabs ul.tabs li a {
	font-family: var(--ap-font-head);
	font-weight: 600;
	color: var(--ap-ink);
}

.woocommerce table.shop_table,
.woocommerce-cart table.cart {
	background: var(--ap-surface);
	border: 1px solid var(--ap-line);
	border-radius: var(--ap-r-md);
	border-collapse: separate;
	border-spacing: 0;
	overflow: hidden;
}

.woocommerce table.shop_table th {
	font-family: var(--ap-font-head);
	color: var(--ap-ink);
}

.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea,
.woocommerce form .form-row select,
.wc-block-components-text-input input,
.select2-container .select2-selection--single {
	min-height: 46px;
	padding: 10px var(--ap-md);
	background: var(--ap-surface);
	border: 1px solid var(--ap-line);
	border-radius: var(--ap-r-sm);
	font-family: var(--ap-font-body);
	color: var(--ap-ink);
}

.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
	background: var(--ap-surface);
	border-top: 3px solid var(--ap-accent);
	border-radius: var(--ap-r-sm);
	color: var(--ap-ink);
}

.woocommerce-error {
	border-top-color: var(--ap-signal);
}

.woocommerce-message::before,
.woocommerce-info::before {
	color: var(--ap-accent);
}

/* Composed empty state, shown when a search or filter returns nothing. */

.ap-empty {
	display: grid;
	gap: var(--ap-md);
	justify-items: start;
	padding: var(--ap-xl);
	background: var(--ap-surface);
	border: 1px dashed var(--ap-line);
	border-radius: var(--ap-r-md);
}

.ap-empty h2,
.ap-empty h2.wp-block-heading {
	margin: 0;
	font-size: 1.4rem;
	line-height: 1.12;
}

/* With no results there is nothing to count or sort, so the toolbar would
   otherwise render as two stray hairlines above the empty state. */

main:has(.ap-empty) .ap-shop-toolbar {
	display: none;
}

.ap-empty p {
	margin: 0;
	color: var(--ap-muted);
}

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */

.ap-footer {
	background: var(--ap-surface);
	border-top: 1px solid var(--ap-line);
	padding-block: var(--ap-xl);
	margin-top: var(--ap-xxl);
}

.ap-footer__grid {
	display: grid;
	grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr));
	gap: var(--ap-xl);
}

.ap-footer h2 {
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--ap-muted);
	font-weight: 600;
	margin: 0 0 var(--ap-md);
}

.ap-footer ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: var(--ap-sm);
}

.ap-footer li {
	max-width: none;
}

.ap-footer a {
	color: var(--ap-ink);
	text-decoration: none;
	font-size: 0.92rem;
}

.ap-footer a:hover {
	color: var(--ap-accent);
}

.ap-footer__about p {
	color: var(--ap-muted);
	font-size: 0.92rem;
	margin: var(--ap-md) 0 0;
	max-width: 42ch;
}

.ap-footer__legal {
	margin-top: var(--ap-xl);
	padding-top: var(--ap-md);
	border-top: 1px solid var(--ap-line);
	color: var(--ap-muted);
	font-size: 0.84rem;
}

.ap-footer__legal p {
	margin: 0;
	max-width: none;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 1100px) {
	.wp-block-woocommerce-product-collection ul.wc-block-product-template {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 900px) {
	.ap-header__inner {
		grid-template-columns: 1fr auto;
		grid-template-areas:
			'brand utils'
			'search search';
		gap: var(--ap-sm) var(--ap-md);
		padding-block: var(--ap-md);
	}

	.ap-brand {
		grid-area: brand;
	}

	.ap-header__utils {
		grid-area: utils;
	}

	.ap-search {
		grid-area: search;
	}

	.ap-counter {
		padding-block: var(--ap-lg) var(--ap-md);
	}

	.ap-counter__grid {
		grid-template-columns: 1fr;
		gap: var(--ap-lg);
		align-items: start;
	}

	.ap-counter__facts {
		padding-left: 0;
		padding-top: var(--ap-md);
		border-left: 0;
		border-top: 1px solid var(--ap-line);
	}

	.ap-footer__grid {
		grid-template-columns: 1fr 1fr;
		gap: var(--ap-lg);
	}

	.ap-footer__about {
		grid-column: 1 / -1;
	}
}

@media (max-width: 720px) {
	.wp-block-woocommerce-product-collection ul.wc-block-product-template {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.ap-search .wc-block-product-search__button {
		padding: 0 var(--ap-md);
	}
}

@media (max-width: 460px) {
	.wp-block-woocommerce-product-collection ul.wc-block-product-template {
		grid-template-columns: 1fr;
	}

	.ap-footer__grid {
		grid-template-columns: 1fr;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-woocommerce-product-collection li.wc-block-product,
	.ap-rail a,
	.ap-search .wc-block-product-search__button {
		transition: none;
	}

	.wp-block-woocommerce-product-collection li.wc-block-product:hover {
		transform: none;
	}
}
