/*
Theme Name: RaMarket
Template: marketplace-shop
Author: ramarket
Description: Child theme of Marketplace Shop. All ramarket frontend work lives here.
Version: 0.2.0
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Text Domain: ramarket-child
*/

/* ==========================================================================
   ramarket — white ground, serif headings, hairline rules, blue logo.
   Palette and fonts come from theme.json; this file handles layout, chrome
   and the parent theme's leftovers.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Ground
   -------------------------------------------------------------------------- */

body {
	background: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--secondary-one);
	-webkit-font-smoothing: antialiased;
}

/* The parent theme paints sections in its own near-white (#FFFFFE), which on
   a true white ground shows as a faint rectangle. Let them inherit. */
.wp-block-group.has-background[style*="#FFFFFE"],
.wp-block-group.has-accent-text-background-color {
	background-color: transparent !important;
}

/* A small caps label, used for footer headings and field names. */
.rm-label {
	font-family: var(--wp--preset--font-family--public-sans);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--wp--preset--color--secondary-two);
}

/* Content that is deliberately unfinished — reads as a slot, not as data. */
.rm-placeholder {
	font-size: 15px;
	color: var(--wp--preset--color--secondary-two);
	font-style: italic;
	border-bottom: 1px dashed var(--wp--preset--color--secondary-accent);
	display: inline-block;
	padding-bottom: 2px;
}

/* --------------------------------------------------------------------------
   2. Header
   -------------------------------------------------------------------------- */

/* The bar and the nav row must share one measure, or the nav sits 24px left
   of the logo. Same max-width, same padding, same box model on both. */
.rm-header__bar,
.rm-header__nav > .wp-block-navigation {
	max-width: 1168px;   /* 1120 content + 24 padding each side */
	margin-inline: auto;
	box-sizing: border-box;
	padding-inline: 24px;
}

.rm-header__bar {
	gap: 28px;
}

.rm-header__nav {
	padding-inline: 0 !important;
}

/* Logo keeps the original brand blue. */
.rm-logo a,
.rm-logo,
.rm-footer .wp-block-site-title a {
	color: #214FC8 !important;
	text-decoration: none;
}

.rm-logo a:hover,
.rm-footer .wp-block-site-title a:hover {
	color: #1A3F9E !important;
}

/* Search lives in the shop sidebar, above the filters — not in the header,
   where it was the widest thing on the page and searched the whole site. */
.rm-shop-search {
	margin: 0 0 20px;
	padding: 0 0 20px;
	border-bottom: 1px solid var(--wp--preset--color--secondary-accent);
}

.rm-shop-search .wp-block-search__inside-wrapper {
	border: 1px solid var(--wp--preset--color--secondary-accent);
	border-radius: 3px;
	background: #fff;
	padding: 0;
	overflow: hidden;
}

.rm-shop-search .wp-block-search__input {
	border: 0;
	background: transparent;
	padding: 10px 14px;
	font-size: 15px;
	color: var(--wp--preset--color--secondary-one);
}

.rm-shop-search .wp-block-search__input::placeholder {
	color: var(--wp--preset--color--secondary-two);
}

.rm-shop-search .wp-block-search__input:focus {
	outline: none;
}

.rm-shop-search .wp-block-search__inside-wrapper:focus-within {
	border-color: var(--wp--preset--color--secondary-one);
}

.rm-shop-search .wp-block-search__button {
	background: var(--wp--preset--color--secondary-one);
	color: var(--wp--preset--color--accent-text);
	border: 0;
	border-radius: 0;
	margin: 0;
	padding: 10px 20px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.rm-shop-search .wp-block-search__button:hover {
	background: var(--wp--preset--color--primary);
}

/* Account + cart.
   The parent theme rendered the account link as a bare 16px icon with no
   label — an invisible hit target sitting next to a decorative heart that
   did nothing at all. Both now have real text and a real box. */
.rm-header__actions {
	gap: 20px;
	align-items: center;
}

.rm-header__actions a,
.rm-header__actions button {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	font-size: 14px;
	font-weight: 500;
	color: var(--wp--preset--color--secondary-one);
	text-decoration: none;
	padding: 8px 4px;
	background: none;
	border: 0;
	cursor: pointer;
	white-space: nowrap;
}

.rm-header__actions a:hover,
.rm-header__actions button:hover {
	color: var(--wp--preset--color--primary);
}

.rm-header__actions svg {
	width: 19px;
	height: 19px;
	fill: currentColor;
}

.wc-block-mini-cart__badge {
	background: var(--wp--preset--color--primary);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	border-radius: 999px;
	min-width: 18px;
	padding: 0 5px;
	line-height: 18px;
	text-align: center;
}

/* The account link is a paragraph, so it needs the same treatment as the
   cart button to sit on the same baseline. */
.rm-account,
.rm-account a {
	margin: 0;
	font-size: 14px;
	font-weight: 500;
	color: var(--wp--preset--color--secondary-one);
	text-decoration: none;
}

.rm-account a:hover {
	color: var(--wp--preset--color--primary);
}

/* Nav */
.rm-nav a {
	display: inline-block;
	padding: 13px 0;
	color: var(--wp--preset--color--secondary-one);
	text-decoration: none;
	border-bottom: 2px solid transparent;
}

.rm-nav a:hover {
	color: var(--wp--preset--color--primary);
	border-bottom-color: var(--wp--preset--color--primary);
}

.rm-nav .rm-nav__cta a,
.rm-nav__cta a {
	color: var(--wp--preset--color--primary);
	font-weight: 600;
}

/* --------------------------------------------------------------------------
   3. Product cards (front page + shop)
   -------------------------------------------------------------------------- */

.wc-block-product-template li.wc-block-product {
	display: flex;
}

.wc-block-product-template li.wc-block-product > .wp-block-group {
	display: flex;
	flex-direction: column;
	width: 100%;
	background: #fff;
	border: 1px solid var(--wp--preset--color--secondary-accent) !important;
	border-radius: 4px !important;
}

/* Button to the bottom, whatever the title length. */
.wc-block-product-template li.wc-block-product .wc-block-components-product-button {
	margin-top: auto;
	margin-bottom: 0;
}

/* One image box for every thumbnail — real photos and placeholders alike,
   so the grid doesn't stagger. box-sizing matters: without it the padding
   below is added to the width and the image bleeds past the card edge. */
.wc-block-product-template li.wc-block-product img {
	aspect-ratio: 1 / 1;
	object-fit: cover;
	width: 100%;
	border-radius: 3px;
	box-sizing: border-box;
}

.wc-block-product-template li.wc-block-product img.woocommerce-placeholder {
	object-fit: contain;
	background: var(--wp--preset--color--accent);
	padding: 16%;
}

.wc-block-product-template li.wc-block-product .wp-block-post-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-family: var(--wp--preset--font-family--public-sans) !important;
	font-weight: 500 !important;
}

/* Add to cart. The parent theme styled this pale grey on pale grey, which
   reads as disabled — on the one control that has to look clickable. */
.wc-block-product-template li.wc-block-product .wc-block-components-product-button .wp-block-button__link {
	display: block;
	width: 100%;
	text-align: center;
	background-color: var(--wp--preset--color--secondary-one);
	color: var(--wp--preset--color--accent-text);
	border: 0;
	border-radius: 3px;
	padding: 10px 14px;
	font-weight: 600;
	font-size: 14px;
	line-height: 1.2;
	transition: background-color .15s ease;
}

.wc-block-product-template li.wc-block-product .wc-block-components-product-button .wp-block-button__link:hover,
.wc-block-product-template li.wc-block-product .wc-block-components-product-button .wp-block-button__link:focus-visible {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--accent-text);
}

/* --------------------------------------------------------------------------
   3b. Shop archive — filters + toolbar
   -------------------------------------------------------------------------- */

.rm-shop__layout {
	align-items: flex-start;
}

.rm-filter {
	padding: 0 0 20px;
	margin: 0 0 20px;
	border-bottom: 1px solid var(--wp--preset--color--secondary-accent);
}

.rm-filter:last-child {
	border-bottom: 0;
}

.rm-filter__title {
	font-family: var(--wp--preset--font-family--public-sans) !important;
	font-size: 11px !important;
	font-weight: 700 !important;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--wp--preset--color--secondary-two) !important;
	margin: 0 0 12px !important;
}

/* Long facet lists (17 categories, 17 brands) scroll rather than pushing the
   grid metres down the page. */
.rm-filter .wc-block-product-filter-checkbox-list {
	max-height: 236px;
	overflow-y: auto;
	padding-right: 4px;
}

.rm-filter label,
.rm-filter .wc-block-product-filter-checkbox-list__label {
	font-size: 14px;
	line-height: 1.5;
	cursor: pointer;
}

.rm-filter input[type="checkbox"] {
	accent-color: var(--wp--preset--color--primary);
}

/* Toolbar: results count left, sorting right. */
.rm-shop__toolbar {
	gap: 16px;
}

.rm-shop__toolbar .woocommerce-result-count {
	margin: 0;
	font-size: 14px;
	color: var(--wp--preset--color--secondary-two);
}

/* Sorting. The stock control is a raw browser <select> — the single cheapest
   looking thing on the page. Give it the same border, type and padding as the
   search field, and draw our own caret. */
.rm-sorting select,
.rm-shop__toolbar select,
.woocommerce-ordering select {
	appearance: none;
	-webkit-appearance: none;
	background-color: #fff;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236B6459' stroke-width='1.6' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	border: 1px solid var(--wp--preset--color--secondary-accent);
	border-radius: 3px;
	padding: 9px 36px 9px 13px;
	font-family: var(--wp--preset--font-family--public-sans);
	font-size: 14px;
	color: var(--wp--preset--color--secondary-one);
	line-height: 1.3;
	cursor: pointer;
	max-width: 100%;
}

.rm-sorting select:hover,
.woocommerce-ordering select:hover {
	border-color: var(--wp--preset--color--secondary-two);
}

.rm-sorting select:focus-visible,
.woocommerce-ordering select:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

/* WooCommerce ships mobile overlay controls ("Filter products" / "Close")
   with the filters block and leaves them in the markup on desktop, where the
   sidebar is already open. Hide them above the breakpoint; show them below,
   where they are the only way to reach the filters. */
@media (min-width: 801px) {
	.wc-block-product-filters__open-overlay,
	.wc-block-product-filters__close-overlay,
	.rm-filters .wp-block-button.wc-block-product-filters__open-overlay,
	.rm-filters button[class*="open-overlay"],
	.rm-filters button[class*="close-overlay"] {
		display: none !important;
	}
}

/* Price slider.
   Inline mode lays out [min input][track][max input] in one row: 170 + 170px
   of inputs alone, which overflows a 250px sidebar by ~114px and collapses
   the track to zero width. Stack instead: track on its own line, the two
   inputs side by side under it. */
.rm-filter .wc-block-product-filter-price-slider__content {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-bottom: 4px;
}

.rm-filter .wc-block-product-filter-price-slider__range {
	grid-column: 1 / -1;
	width: 100% !important;
	min-width: 0;
}

.rm-filter .wc-block-product-filter-price-slider__left,
.rm-filter .wc-block-product-filter-price-slider__right {
	width: auto !important;
	min-width: 0;
	font-size: 13px;
}

.rm-filter .wc-block-product-filter-price-slider input[type="text"],
.rm-filter .wc-block-product-filter-price-slider input[type="number"] {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid var(--wp--preset--color--secondary-accent);
	border-radius: 3px;
	padding: 7px 9px;
	font-size: 13px;
	background: #fff;
}

/* The apply button renders disabled-grey until something changes; give it
   the same weight as the other controls so it doesn't read as broken. */
.rm-filters button[class*="apply"],
.rm-filters .wc-block-product-filters__apply {
	background: var(--wp--preset--color--secondary-one);
	color: var(--wp--preset--color--accent-text);
	border: 0;
	border-radius: 3px;
	padding: 9px 18px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

/* Active filter chips */
.wc-block-product-filter-removable-chips__item {
	background: var(--wp--preset--color--accent);
	border: 1px solid var(--wp--preset--color--secondary-accent);
	border-radius: 999px;
	padding: 4px 10px;
	font-size: 13px;
}

@media (max-width: 800px) {
	.rm-shop__layout {
		display: block;
	}
	.rm-shop__filters {
		margin-bottom: 32px;
	}
}

/* --------------------------------------------------------------------------
   4. Single product
   -------------------------------------------------------------------------- */

.rm-crumbs {
	color: var(--wp--preset--color--secondary-two);
}

.rm-crumbs a {
	color: var(--wp--preset--color--secondary-two);
	text-decoration: none;
}

.rm-crumbs a:hover {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* Gallery.
   WooCommerce sizes the thumbnail rail off --wc-block-product-gallery-thumbnails-size,
   but every one of those rules is scoped to .wc-block-product-gallery — a class the
   block does not add itself, it comes from the saved markup. It is set in
   templates/single-product.html; without it the rail has no flex-basis and eats
   more width than the photo. The gap is ours: the block ships none. */
.rm-product__media .wc-block-product-gallery {
	gap: 14px;
	align-items: flex-start;
}

.rm-product__media .wc-block-product-gallery-large-image {
	border: 1px solid var(--wp--preset--color--secondary-accent);
	border-radius: 4px;
	overflow: hidden;
	background: #fff;
}

.rm-product__media .wc-block-product-gallery-thumbnails__thumbnail__image {
	border: 1px solid var(--wp--preset--color--secondary-accent);
	border-radius: 3px;
	box-sizing: border-box;
}

.rm-product__media .wc-block-product-gallery-thumbnails__thumbnail__image--is-active {
	border-color: var(--wp--preset--color--secondary-one);
}

/* Next/previous. The block renders them flush to the image edges with no
   surface of their own, which on a light photo leaves two invisible arrows. */
.rm-product__media .wc-block-next-previous-buttons__button {
	background: rgba(255, 255, 255, .92);
	border: 1px solid var(--wp--preset--color--secondary-accent);
	border-radius: 999px;
	width: 34px;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	color: var(--wp--preset--color--secondary-one);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
	transition: background-color .15s ease;
}

.rm-product__media .wc-block-next-previous-buttons__button:hover {
	background: #fff;
}

.rm-product__media .wc-block-next-previous-buttons__button[aria-disabled="true"] {
	opacity: .35;
}

/* Say that the photo opens. */
.rm-product__media .wc-block-woocommerce-product-gallery-large-image__image--full-screen-on-click {
	cursor: zoom-in;
}

/* Fullscreen viewer (the <dialog> the gallery injects).
   WooCommerce sets the images to width:100%;max-width:1600px, which upscales
   anything narrower than the screen — a 900px phone photo is stretched to
   1500px and goes soft. width:auto lets each image stop at its own size. */
.wc-block-product-gallery-dialog__content img {
	width: auto;
	max-width: min(100%, 1100px);
	border-radius: 4px;
}

.wc-block-product-gallery-dialog__close-button {
	background: #fff;
	border: 1px solid var(--wp--preset--color--secondary-accent);
	border-radius: 999px;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wc-block-product-gallery-dialog__close-button:hover {
	background: var(--wp--preset--color--accent);
}

/* Buy column. */
.rm-product__title {
	font-weight: 600;
}

/* Price is the number the page is answering — it should not read as body copy.
   .woocommerce-Price-amount catches both the plain price and the sale pair. */
.rm-product__price .wc-block-components-product-price__value,
.rm-product__price .woocommerce-Price-amount {
	font-size: 27px;
	font-weight: 700;
	line-height: 1.1;
	color: var(--wp--preset--color--secondary-one);
}

/* The struck-out original stays small and quiet, so the payable figure wins. */
.rm-product__price del,
.rm-product__price del .woocommerce-Price-amount {
	font-size: 16px;
	font-weight: 400;
	color: var(--wp--preset--color--secondary-two);
	margin-right: 8px;
}

.rm-product__price ins,
.rm-product__price ins .woocommerce-Price-amount {
	text-decoration: none;
	color: var(--wp--preset--color--primary);
}

.rm-product__stock {
	color: var(--wp--preset--color--secaccent);
	font-weight: 600;
}

.rm-product__stock .wc-block-components-product-stock-indicator--out-of-stock {
	color: var(--wp--preset--color--secondary-two);
}

.rm-product__summary {
	color: var(--wp--preset--color--secondary-one);
	max-width: 52ch;
}

/* Quantity. Every listing is sold individually (see functions.php), so
   WooCommerce emits the field as type="hidden" — but it keeps the wrapper,
   which stays a flex item and pushes the button over by one gap. Drop the
   wrapper, not the input: the form still posts quantity=1.

   The long selector is deliberate. WooCommerce ships
   `.woocommerce .wp-block-add-to-cart-form form.cart div.quantity` at (0,4,2)
   and `:has()` only contributes its argument's specificity, so the obvious
   `.rm-product__cart .quantity:has(...)` lands at (0,3,1) and loses. */
.rm-product__buy .rm-product__cart form.cart div.quantity:has(input[type="hidden"]) {
	display: none;
}

/* Left as a block, deliberately. Making this a flex row to sit a quantity box
   next to the button backfires: WooCommerce clears the float-era form with
   content:" " pseudo-elements, and in a flex container those become zero-width
   flex items that each eat a gap — indenting the button past the title and
   price it lines up with. Overriding them is a specificity fight nobody wins
   (.woocommerce div.product form.cart::before is (0,3,3)). There is only ever
   one visible control here anyway, since quantity is always 1. */
.rm-product__cart form.cart {
	margin: 0 0 22px;
}

/* The parent theme paints this pale grey on pale grey — on the one control
   that has to look pressable. Same treatment as the cards. */
.rm-product__cart .single_add_to_cart_button {
	background-color: var(--wp--preset--color--secondary-one);
	color: var(--wp--preset--color--accent-text);
	border: 0;
	border-radius: 3px;
	padding: 14px 30px;
	font-family: var(--wp--preset--font-family--public-sans);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color .15s ease;
}

.rm-product__cart .single_add_to_cart_button:hover,
.rm-product__cart .single_add_to_cart_button:focus-visible {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--accent-text);
}

.rm-product__meta {
	font-size: 14px;
	color: var(--wp--preset--color--secondary-two);
	padding-top: 18px;
	border-top: 1px solid var(--wp--preset--color--secondary-accent);
}

.rm-product__meta a {
	color: var(--wp--preset--color--secondary-two);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.rm-product__meta a:hover {
	color: var(--wp--preset--color--primary);
}

.rm-product__desc-body p:last-child {
	margin-bottom: 0;
}

@media (max-width: 781px) {
	.rm-product__top {
		gap: 28px;
	}
	.rm-product__cart .single_add_to_cart_button {
		width: 100%;
	}
}

/* --------------------------------------------------------------------------
   5. Buttons, site-wide
   -------------------------------------------------------------------------- */

.wp-block-button__link {
	border-radius: 3px;
	font-family: var(--wp--preset--font-family--public-sans);
	letter-spacing: 0.01em;
}

.wp-block-button.is-style-outline .wp-block-button__link {
	border-width: 1px;
}

/* Visible keyboard focus everywhere — the parent theme removes it. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   6. Footer
   -------------------------------------------------------------------------- */

.rm-footer__links {
	list-style: none;
	margin: 0;
	padding: 0;
}

.rm-footer__links li {
	margin: 0 0 9px;
}

.rm-footer__links a {
	color: var(--wp--preset--color--secondary-one);
	text-decoration: none;
	font-size: 15px;
}

.rm-footer__links a:hover {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* --------------------------------------------------------------------------
   7. Typography rhythm
   -------------------------------------------------------------------------- */

h1, h2, h3, h4 {
	font-family: var(--wp--preset--font-family--display);
}

/* Long body text stays readable — roughly 70 characters. */
.wp-block-post-content p,
.entry-content p {
	max-width: 68ch;
}

/* --------------------------------------------------------------------------
   8. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
	.rm-header__bar {
		gap: 16px;
	}
	.rm-shop-search {
		order: 3;
		flex-basis: 100%;
		max-width: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: .01ms !important;
		transition-duration: .01ms !important;
	}
}
