/* ==========================================================================
   Fynode child theme — WooCommerce single product page enhancements
   Loaded only on is_product() (see functions.php). Layered on top of the
   parent theme's style.css / base.css; nothing here overrides parent rules
   destructively, it only adds a 3rd column and restyles .single-product-tabs-wrapper.
   ========================================================================== */

/* ---- 1. Linked products: 3-column desktop layout ---------------------- */

#product-overview {
	scroll-margin-top: calc(var(--fynode-sticky-nav-top, 0px) + var(--fynode-sticky-nav-height, 0px) + 1rem);
}

.single-product-wrapper.has-linked-products {
	-webkit-box-align: start;
	-ms-flex-align: start;
	align-items: flex-start;
}

@media screen and (min-width: 1024.02px) {
	.single-product-wrapper.has-linked-products .column.single-product-gallery,
	.single-product-wrapper.has-linked-products .column.single-product-detail {
		-webkit-box-flex: 0;
		-ms-flex: 0 0 calc((100% - 2.5rem) * 0.4);
		flex: 0 0 calc((100% - 2.5rem) * 0.4);
		width: calc((100% - 2.5rem) * 0.4);
	}

	.single-product-wrapper .column.single-product-linked {
		-webkit-box-flex: 0;
		-ms-flex: 0 0 calc((100% - 2.5rem) * 0.2);
		flex: 0 0 calc((100% - 2.5rem) * 0.2);
		width: calc((100% - 2.5rem) * 0.2);
	}
}

@media screen and (min-width: 768.02px) and (max-width: 1023.98px) {
	.single-product-wrapper.has-linked-products .column.single-product-gallery,
	.single-product-wrapper.has-linked-products .column.single-product-detail {
		-webkit-box-flex: 0;
		-ms-flex: 0 0 calc((100% - 1.25rem) * 0.5);
		flex: 0 0 calc((100% - 1.25rem) * 0.5);
		width: calc((100% - 1.25rem) * 0.5);
	}

	.single-product-wrapper .column.single-product-linked {
		-webkit-box-flex: 0;
		-ms-flex: 0 0 100%;
		flex: 0 0 100%;
		width: 100%;
	}
}

.column.single-product-linked {
	width: 100%;
}

.linked-products-wrapper {
	position: sticky;
	top: calc(var(--fynode-sticky-nav-top, 0px) + 1.25rem);
	background-color: var(--color-body-background, #fff);
	border: 1px solid var(--color-gray-200, #e5e7eb);
	border-radius: 12px;
	padding: 1.25rem 1rem;
}

@media screen and (max-width: 1024px) {
	.linked-products-wrapper {
		position: static;
	}
}

.linked-products-title {
	font-size: 1rem;
	font-weight: 700;
	margin-bottom: 1rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
}

.linked-products-list {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-orient: vertical;
	-webkit-box-direction: normal;
	-ms-flex-direction: column;
	flex-direction: column;
	gap: 0.25rem;
}

.linked-product-card {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	gap: 0.75rem;
	padding: 0.625rem 0.375rem;
	border-radius: 8px;
	color: inherit;
	text-decoration: none;
	-webkit-transition: background-color 0.15s ease;
	transition: background-color 0.15s ease;
}

.linked-product-card:hover,
.linked-product-card:focus-visible {
	background-color: var(--color-gray-100, #f3f4f6);
	color: inherit;
}

.linked-product-thumbnail {
	-webkit-box-flex: 0;
	-ms-flex: 0 0 3.5rem;
	flex: 0 0 3.5rem;
	width: 3.5rem;
	height: 3.5rem;
	overflow: hidden;
	border-radius: 6px;
	background-color: var(--color-gray-100, #f3f4f6);
}

.linked-product-thumbnail img {
	display: block;
	width: 100%;
	height: 100%;
	-o-object-fit: cover;
	object-fit: cover;
}

.linked-product-info {
	-webkit-box-flex: 1;
	-ms-flex: 1 1 auto;
	flex: 1 1 auto;
	min-width: 0;
}

.linked-product-name {
	display: block;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.3;
	margin-bottom: 0.25rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.linked-product-price {
	display: block;
	font-size: 0.8125rem;
	color: var(--color-gray-500, #6b7280);
}

.linked-product-price ins {
	color: inherit;
	text-decoration: none;
}

.linked-product-price del {
	margin-right: 0.375rem;
	opacity: 0.6;
}

/* ---- 2. Tabs → accordion ------------------------------------------------ */

.single-product-tabs-wrapper .woocommerce-tabs .tabs[hidden] {
	display: none;
}

.fynode-accordion {
	border-top: 1px solid var(--color-gray-200, #e5e7eb);
}

.fynode-accordion-item {
	border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
}

.fynode-accordion-header {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	-webkit-box-pack: justify;
	-ms-flex-pack: justify;
	justify-content: space-between;
	width: 100%;
	padding: 1.125rem 0.25rem;
	background: none;
	border: 0;
	cursor: pointer;
	font-size: 1rem;
	font-weight: 700;
	text-align: left;
	color: inherit;
}

.fynode-accordion-header-icon {
	position: relative;
	-webkit-box-flex: 0;
	-ms-flex: 0 0 auto;
	flex: 0 0 auto;
	width: 0.875rem;
	height: 0.875rem;
	margin-left: 1rem;
}

.fynode-accordion-header-icon::before,
.fynode-accordion-header-icon::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	background-color: currentColor;
	-webkit-transition: -webkit-transform 0.2s ease;
	transition: transform 0.2s ease;
}

.fynode-accordion-header-icon::before {
	width: 100%;
	height: 2px;
	-webkit-transform: translate(-50%, -50%);
	transform: translate(-50%, -50%);
}

.fynode-accordion-header-icon::after {
	width: 2px;
	height: 100%;
	-webkit-transform: translate(-50%, -50%);
	transform: translate(-50%, -50%);
}

.fynode-accordion-item.is-open .fynode-accordion-header-icon::after {
	-webkit-transform: translate(-50%, -50%) rotate(90deg) scaleX(0);
	transform: translate(-50%, -50%) rotate(90deg) scaleX(0);
}

.fynode-accordion-panel {
	padding: 0 0.25rem 1.5rem;
	scroll-margin-top: calc(var(--fynode-sticky-nav-top, 0px) + var(--fynode-sticky-nav-height, 0px) + 1rem);
}

.fynode-accordion-content {
	position: relative;
	overflow: hidden;
}

.fynode-accordion-panel:not(.has-more) .fynode-accordion-content {
	max-height: none;
}

.fynode-accordion-panel.has-more .fynode-accordion-content {
	max-height: 300px;
}

.fynode-accordion-panel.has-more:not(.is-expanded) .fynode-accordion-content::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 4.5rem;
	background: -webkit-gradient(linear, left bottom, left top, from(var(--color-body-background, #fff)), to(rgba(255, 255, 255, 0)));
	background: linear-gradient(to top, var(--color-body-background, #fff), rgba(255, 255, 255, 0));
	pointer-events: none;
}

.fynode-accordion-panel.has-more.is-expanded .fynode-accordion-content {
	max-height: none;
}

.fynode-show-more {
	display: none;
	margin-top: 1rem;
	padding: 0;
	background: none;
	border: 0;
	border-bottom: 1px solid currentColor;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	color: var(--color-body-foreground, #111827);
}

.fynode-accordion-panel.has-more .fynode-show-more {
	display: inline-block;
}

/* ---- 3. Sticky internal navigation -------------------------------------- */

.product-sticky-nav {
	position: -webkit-sticky;
	position: sticky;
	top: var(--fynode-sticky-nav-top, 0px);
	z-index: 15;
	background-color: var(--color-body-background, #fff);
	border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
	margin-bottom: 1.5rem;
}

.product-sticky-nav-list {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	gap: 0.5rem;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.product-sticky-nav-list::-webkit-scrollbar {
	display: none;
}

.product-sticky-nav-list a {
	-webkit-box-flex: 0;
	-ms-flex: 0 0 auto;
	flex: 0 0 auto;
	padding: 0.875rem 0.875rem;
	font-size: 0.875rem;
	font-weight: 600;
	white-space: nowrap;
	color: var(--color-gray-500, #6b7280);
	text-decoration: none;
	border-bottom: 2px solid transparent;
}

.product-sticky-nav-list a.is-active {
	color: inherit;
	border-bottom-color: currentColor;
}

/* ---- 4. Mobile stacking order -------------------------------------------
   Gallery -> Info -> Linked products -> sticky nav -> accordions, per spec.
   The sticky nav/accordion are siblings inserted after .single-product-wrapper
   in source order already, so only the linked-products column needs a flex
   order tweak on narrow widths where the wrapper has already stacked to 100%. */

@media screen and (max-width: 767.98px) {
	.single-product-wrapper {
		display: -webkit-box;
		display: -ms-flexbox;
		display: flex;
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		-ms-flex-direction: column;
		flex-direction: column;
	}

	.single-product-wrapper .column.single-product-gallery {
		-webkit-box-ordinal-group: 1;
		-ms-flex-order: 0;
		order: 0;
	}

	.single-product-wrapper .column.single-product-detail {
		-webkit-box-ordinal-group: 2;
		-ms-flex-order: 1;
		order: 1;
	}

	.single-product-wrapper .column.single-product-linked {
		-webkit-box-ordinal-group: 3;
		-ms-flex-order: 2;
		order: 2;
	}

	.product-sticky-nav-list a {
		padding: 0.75rem 0.625rem;
		font-size: 0.8125rem;
	}
}
