/* Cose Theme - single product page (single-product.php) */

/* Only the logo is fixed on this page, same as everywhere else on the site
   (header.php's sitewide .site-logo, styled in main.css) - the sidebar
   itself scrolls normally with the rest of the page. */

/* The whole page is exactly one screen tall (header + this row), so it
   never scrolls - the photo is sized to fit the room left, not the other
   way round. --site-header-height is measured in single-product.js. */
.pdp {
	display: flex;
	height: calc(100vh - var(--site-header-height, 92px));
}

.pdp-sidebar {
	/* As wide as the logo above it (main.css's .site-logo img) plus the 40px
	   insets: Sold out!, the description and the price all end on the logo's
	   right edge. */
	flex: 0 0 calc(clamp(220px, 22vw, 320px) + 80px);
	width: calc(clamp(220px, 22vw, 320px) + 80px);
	/* Not fixed (scrolls away with the page). Its content starts right
	   under the fixed logo: the box itself begins below the header, so the
	   top padding is the logo's bottom edge (measured in
	   single-product.js; the fallback is the logo's usual height centered
	   at 50%) plus a gap, minus the header. It must not stretch to the
	   whole row: the gallery row is one screen tall, and so is this. */
	align-self: flex-start;
	height: calc(100vh - var(--site-header-height, 92px));
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	padding: calc(var(--site-logo-bottom, calc(50vh + 50px)) + 40px - var(--site-header-height, 92px)) 40px 40px;
}

.pdp-sidebar__body {
	display: flex;
	flex-direction: column;
}

/* Title on the left, Sold out! on the column's right edge - the same edge
   the price ends on. The subtitle follows tight under the title. */
.pdp-sidebar__heading {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	line-height: 1.15;
	text-transform: uppercase;
}

/* Tracking 100 in the layouts. */
.pdp-sidebar__title,
.pdp-sidebar__soldout {
	margin: 0;
	font-size: 1rem;
	font-weight: 500;
	letter-spacing: 0.1em;
}

.pdp-sidebar__soldout {
	/* Minus the tracking after the last letter, so the text itself ends on the edge. */
	margin-right: -0.1em;
	white-space: nowrap;
}

.pdp-sidebar__subtitle {
	margin: 0;
	font-style: italic;
	font-weight: 400;
	line-height: 1.15;
}

/* --- Add to cart / variations form (mostly WooCommerce's own markup) --- */

/* With a description in between, the gap above Add to cart shrinks, so the
   page still fits the window on smaller screens. */
.pdp-sidebar__form .pdp-description ~ .single_variation_wrap,
.pdp-sidebar__form .pdp-description ~ .pdp-buy {
	margin-top: 20px;
}

/* Product description, between the cover picker and Add to cart. */
.pdp-description {
	margin: 0;
}

.pdp-description__text {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
}

.pdp-description.is-expanded .pdp-description__text {
	display: block;
	overflow: visible;
}

/* Desktop: single-product.js caps the opened text to the room left in the
   window; past that it scrolls inside itself, with a thin black line for a
   scrollbar instead of the browser's. */
@media (min-width: 901px) {
	.pdp-description.is-expanded .pdp-description__text {
		overflow-y: auto;
		scrollbar-width: thin;
		scrollbar-color: #000 transparent;
	}

	/* Room for the scrollbar - only when there is one. */
	.pdp-description.has-scroll .pdp-description__text {
		padding-right: 12px;
	}

	.pdp-description__text::-webkit-scrollbar {
		width: 3px;
	}

	.pdp-description__text::-webkit-scrollbar-track {
		background: transparent;
		border-left: 1px solid #d8d8d8;
	}

	.pdp-description__text::-webkit-scrollbar-thumb {
		background: #000;
	}
}

.pdp-description__text p {
	margin: 0 0 6px;
}

.pdp-description__toggle {
	display: block;
	min-width: 5.5em;
	margin: 4px 0 0 auto;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-style: italic;
	text-align: right;
	cursor: pointer;
}

.pdp-description__toggle[hidden] {
	display: none;
}

.pdp-sidebar__form {
	margin-top: 20px;
}

.pdp-sidebar__form .variations_form,
.pdp-sidebar__form .cart {
	display: flex;
	flex-direction: column;
	gap: 30px;
}

/* 30px (gap) + 60px = the 90px between the cover picker and Add to cart; the
   description, when there is one, sits in the first 30. */
.pdp-sidebar__form .single_variation_wrap,
.pdp-sidebar__form .cart > .pdp-buy {
	margin-top: 60px;
}

.pdp-sidebar__form table.variations {
	border: none;
	margin: 0;
}

.pdp-sidebar__form table.variations tr,
.pdp-sidebar__form table.variations td,
.pdp-sidebar__form table.variations th {
	display: block;
	padding: 0;
	border: none;
}

.pdp-sidebar__form table.variations label {
	display: none;
}

/* The real <select> stays in the DOM (single-product.js relies on it and on
   WooCommerce's own variation JS both reading/writing its value) but is
   visually replaced by the custom listbox built next to it. */
.pdp-sidebar__form select {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
}

/* The "Svuota"/clear link: WooCommerce's variation JS shows it once a
   choice is made by writing an inline style="display:inline-block", which
   beats a plain stylesheet rule - !important is the only way to keep it
   hidden. Not wanted in this design. */
.pdp-sidebar__form .reset_variations {
	display: none !important;
}

.pdp-sidebar__form .woocommerce-variation-price,
.pdp-sidebar__form .woocommerce-variation-availability {
	display: none;
}

/* The cover picker, as in the layouts. Closed: plain text with a small
   chevron right after it, no box. Open: a light grey rounded panel laid over
   the picker, the chosen cover checkmarked. */
.pdp-select {
	position: relative;
	/* One fixed line, like the Add to cart row: whatever weight the trigger is
	   in (Regular, or Medium on hover), nothing below it - the description - can
	   be nudged by a fraction of a pixel. */
	height: 1rem;
}

.pdp-select__trigger {
	display: flex;
	align-items: center;
	padding: 0;
	background: none;
	border: 0;
	font: inherit;
	color: inherit;
	text-align: left;
	cursor: pointer;
}

.pdp-select__trigger::after {
	content: "";
	flex: none;
	margin: -3px 0 0 9px;
	width: 5px;
	height: 5px;
	border-right: 1px solid currentColor;
	border-bottom: 1px solid currentColor;
	transform: rotate(45deg);
}

/* The panel's text lines up with the picker's own: the checkmark column
   hangs to its left. */
.pdp-select__list {
	position: absolute;
	left: -18px;
	right: -4px;
	top: -8px;
	margin: 0;
	padding: 5px 0;
	list-style: none;
	background: #e6e6e6;
	border-radius: 5px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
	display: none;
	z-index: 3;
}

.pdp-select.is-open .pdp-select__list {
	display: block;
}

.pdp-select__option {
	display: flex;
	align-items: baseline;
	gap: 0;
	width: 100%;
	padding: 2px 10px 2px 5px;
	background: none;
	border: none;
	font: inherit;
	color: inherit;
	text-align: left;
	cursor: pointer;
}

.pdp-select__option-check {
	flex: none;
	width: 13px;
	visibility: hidden;
}

.pdp-select__option.is-selected .pdp-select__option-check {
	visibility: visible;
}

/* WooCommerce's own quantity stepper isn't part of this design.
   WooCommerce's variation-form JS toggles this with an inline
   style="display:block" when a variation is selected, which - being
   inline - beats any plain stylesheet rule regardless of specificity;
   !important is the only way to keep it hidden through that. */
/* Label (the button) on the left, price on the right; only the button clicks. */
.pdp-buy {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	width: 100%;
}

.pdp-buy .pdp-price {
	cursor: default;
}

.pdp-buy .single_add_to_cart_button.disabled ~ .pdp-price {
	opacity: 0.5;
}

.pdp-sidebar__form .quantity {
	display: none !important;
}

/* WooCommerce's own product-page button styles (woocommerce.css, loaded
   for every page with a product form) target this exact element with
   several rules of their own, all more specific than a plain
   .single_add_to_cart_button selector, plus a few properties (background,
   border) set with !important. Matching that specificity/!important here
   is the only reliable way to replace WooCommerce's default button chrome
   with the plain text+price row the design calls for. */
.pdp-sidebar__form .single_add_to_cart_button,
.woocommerce div.product .pdp-sidebar__form .single_add_to_cart_button {
	display: inline-flex !important;
	justify-content: space-between;
	align-items: flex-start;
	gap: 16px;
	width: auto;
	padding: 0 !important;
	/* Fixed row height: baseline-aligning the label (Medium on hover) and the
	   price (Regular) made the button 1px taller on hover. */
	height: 1rem;
	vertical-align: top;
	background: none !important;
	border: none !important;
	border-radius: 0 !important;
	color: inherit !important;
	/* Not the `font` shorthand: it resets font-weight too, which would
	   wipe out the global hover rule's regular->medium change (main.css). */
	font-family: inherit !important;
	font-size: inherit !important;
	text-transform: uppercase;
	cursor: pointer;
}

.pdp-sidebar__form .pdp-price {
	font-weight: 400;
}

/* --- Gallery --- */

.pdp-gallery {
	flex: 1;
	min-width: 0;
	position: relative;
	display: flex;
	justify-content: center;
	align-items: stretch;
	padding: 20px;
	padding-bottom: 10px;
}

/* Portrait 3:4, but sized from the HEIGHT available (the row minus the
   gallery's padding) with the width following from the ratio - so the
   photo always fits the window instead of overflowing it. */
.pdp-gallery__main {
	position: relative;
	flex: 0 0 auto;
	height: 100%;
	aspect-ratio: 3 / 4;
	overflow: hidden;
}

.swiper-slide-active {
	aspect-ratio: 3 / 4;
}

.pdp-gallery__main .swiper-slide img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.pdp-gallery__thumbs {
	/* Flush with the top of the main image, not vertically centered -
	   top matches .pdp-gallery's own padding so both start at the same edge. */
	position: absolute;
	right: 40px;
	top: 20px;
	/* Down to the photo's bottom edge (the gallery's 10px bottom padding), no
	   further: with many photos the rail scrolls inside itself instead of making
	   the whole page scroll. */
	bottom: 10px;
	display: flex;
	flex-direction: column;
	gap: 5px;
	overflow-y: auto;
	/* No visible scrollbar: it scrolls with the wheel / trackpad, and the
	   active thumbnail is kept in view by single-product.js. */
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.pdp-gallery__thumbs::-webkit-scrollbar {
	display: none;
}

.pdp-gallery__thumb {
	flex: 0 0 auto;
	width: 64px;
	aspect-ratio: 3 / 4;
	height: auto;
	padding: 0;
	border: none;
	background: #fff;
	cursor: pointer;
}

/* The browser's default keyboard-focus ring (a dark outline) showed up
   on the thumbs when tabbing/arrowing through the page; not wanted. The
   active thumb is already marked by being the only unblurred one. */
.pdp-gallery__thumb:focus,
.pdp-gallery__thumb:focus-visible {
	outline: none;
}

.pdp-gallery__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: blur(2px);
	transition: filter 0.2s ease;
	display: block;
}

.pdp-gallery__thumb.is-active img {
	filter: none;
}

.pdp-gallery__counter {
	display: none;
	position: absolute;
	top: 20px;
	left: 20px;
	z-index: 2;
}

@media (max-width: 900px) {
	/* Stacked on small screens: photo on top, info below, so the page
	   scrolls here and the photo takes the full width instead. */
	.pdp {
		flex-direction: column;
		height: auto;
	}

	.pdp-sidebar {
		flex-basis: auto;
		width: auto;
		align-self: auto;
		height: auto;
		justify-content: flex-start;
		padding: 24px 20px 200px;
	}

	.pdp-sidebar__heading {
		justify-content: space-between;
	}

	.pdp-gallery {
		order: -1;
		padding: 0;
	}

	.pdp-gallery__main {
		width: 100%;
		height: auto;
		aspect-ratio: 4 / 5;
	}

	.pdp-gallery__thumbs {
		display: none;
	}

	.pdp-gallery__counter {
		display: block;
	}

	/* The open panel stays inside the screen's 20px inset. */
	.pdp-select__list {
		left: -10px;
		right: 0;
	}

	.pdp-select__option {
		padding: 5px 10px;
	}

	.pdp-select__option-check {
		display: none;
	}

	/* No room for a checkmark column here: the chosen cover is Medium. */
	.pdp-select__option.is-selected {
		font-weight: 500;
	}
}

/* Mobile: on the product page the logo closes the page (Mobile/PDP_.png)
   instead of floating over it, so it can never cover the cover picker or
   the Add to cart row. */
@media (max-width: 900px) {
	body.single-product {
		position: relative;
	}

	body.single-product .site-logo {
		position: absolute;
	}
}

/* --- Desktop: the description's slot ---
   The description gets a fixed slot (label + about eight lines of text + the
   toggle) between the cover picker and Add to cart, open or closed, so
   opening "See more" never moves Add to cart; the text scrolls inside the
   slot when it is longer. Add to cart simply follows the slot - it is NOT
   pinned to the bottom. Only when the window is too short for the slot does
   the slot shrink (flex), so that Add to cart never ends up lower than the
   bottom edge of the gallery photo. The gallery photo ends 10px above its
   column's bottom, and so does the sidebar's content. */
@media (min-width: 901px) {
	/* Above the gallery, so the open cover picker's panel is never under it. */
	.pdp-sidebar {
		position: relative;
		z-index: 2;
		padding-bottom: 10px;
	}

	.pdp-gallery {
		padding-bottom: 10px;
	}

	.pdp-sidebar__body,
	.pdp-sidebar__form,
	.pdp-sidebar__form .variations_form,
	.pdp-sidebar__form .cart {
		flex: 1 1 auto;
		min-height: 0;
	}

	.pdp-sidebar__form {
		display: flex;
		flex-direction: column;
	}

	.pdp-sidebar__form .variations_form,
	.pdp-sidebar__form .cart {
		flex: 0 1 auto;
	}

	.pdp-description {
		display: flex;
		flex-direction: column;
		flex: 0 1 132px;
		height: 132px;
		min-height: 44px;
		margin: 0;
	}

	/* Sized to its text (not stretched over the whole slot), so See less sits
	   right under the last line; it only shrinks, and scrolls, when the slot is
	   too small for the text. */
	.pdp-description.is-expanded .pdp-description__text {
		flex: 0 1 auto;
		min-height: 0;
		overflow-y: auto;
	}
}

/* Short desktop windows: the description's slot is what gets squeezed, so
   take the room from the gaps above it first (the space under the logo, the
   spacing around the cover picker) to leave the text a usable height. */
@media (min-width: 901px) and (max-height: 800px) {
	.pdp-sidebar {
		padding-top: calc(var(--site-logo-bottom, calc(50vh + 50px)) + 25px - var(--site-header-height, 92px));
	}

	.pdp-sidebar__form .variations_form,
	.pdp-sidebar__form .cart {
		gap: 20px;
	}

	.pdp-sidebar__form .pdp-description ~ .single_variation_wrap,
	.pdp-sidebar__form .pdp-description ~ .pdp-buy {
		margin-top: 10px;
	}
}

/* --- Description shown in full (for now) ---
   No two-line clamp, no "See more", no scrollbar inside the text: the whole
   description is printed and Add to cart simply follows it. A long text pushes
   Add to cart down instead of scrolling. To bring the clamp, the toggle and the
   inner scroll back, delete this block. */
.pdp-description__text {
	display: block;
	-webkit-line-clamp: unset;
	line-clamp: unset;
	overflow: visible;
}

.pdp-description__toggle {
	display: none;
}

@media (min-width: 901px) {
	.pdp-description {
		flex: 0 0 auto;
		height: auto;
		min-height: 0;
	}

	.pdp-description.is-expanded .pdp-description__text,
	.pdp-description .pdp-description__text {
		overflow: visible;
	}
}
