/* SmartCompare design tokens. Each falls back to the active theme's preset
   (theme.json) when it exists, otherwise to a neutral default. Override any
   --sc-* property in your theme to restyle the plugin. */
:root {
	--sc-c-main: var(--wp--preset--color--contrast, #1c1b19);
	--sc-c-main-accent: #c9c6bf;
	--sc-c-base: var(--wp--preset--color--base, #fafaf7);
	--sc-c-white: #ffffff;
	--sc-c-primary: #b4462e;
	--sc-c-secondary: #66635d;
	--sc-c-tertiary: #f1f0eb;
	--sc-c-border-light: #e3e1db;
	--sc-c-border-dark: #3a3834;
	--sc-c-success: #2e6b4a;
	--sc-fs-x-small: 0.8125rem;
	--sc-fs-small: 0.875rem;
	--sc-fs-base: 1rem;
	--sc-fs-medium: 1.25rem;
	--sc-ff-display: inherit;
	--sc-sh-soft: 0 1px 2px rgba(28, 27, 25, .04), 0 8px 24px rgba(28, 27, 25, .06);
	--sc-sh-lifted: 0 2px 4px rgba(28, 27, 25, .05), 0 16px 40px rgba(28, 27, 25, .10);
}
.sc-sr {
	position: absolute !important;
	width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   SmartCompare — 商品比較: 「比較する」 toggle, bottom tray, toast (every page).
   The compare table is in compare-page.css (compare page only).
   ========================================================================== */

.sc-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* --------------------------------------------------------------------------
   Toggle (cards and product page)
   -------------------------------------------------------------------------- */

.sc-compare-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	min-height: 32px;
	margin: 0.35rem 0 0 !important;
	padding: 0.25rem 0.5rem 0.25rem 0;
	border: 0;
	border-radius: var(--wp--custom--radius--control);
	background: none;
	color: var(--sc-c-secondary);
	font-family: inherit;
	font-size: 0.75rem;
	font-weight: 500;
	letter-spacing: 0.06em;
	line-height: 1.4;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: color var(--wp--custom--transition);
}

.sc-compare-toggle:hover,
.sc-compare-toggle[aria-pressed="true"] {
	color: var(--sc-c-main);
}

.sc-compare-toggle:focus-visible {
	outline: 2px solid var(--sc-c-main);
	outline-offset: 2px;
}

.sc-compare-toggle__box {
	position: relative;
	flex: none;
	width: 16px;
	height: 16px;
	border: 1px solid #8C887F; /* 3.4:1 on the page background */
	border-radius: 3px;
	background: var(--sc-c-white);
	transition: background-color var(--wp--custom--transition), border-color var(--wp--custom--transition);
}

.sc-compare-toggle:hover .sc-compare-toggle__box {
	border-color: var(--sc-c-main);
}

.sc-compare-toggle[aria-pressed="true"] .sc-compare-toggle__box {
	border-color: var(--sc-c-main);
	background: var(--sc-c-main);
}

/* Check mark */
.sc-compare-toggle[aria-pressed="true"] .sc-compare-toggle__box::after {
	content: "";
	position: absolute;
	left: 4.5px;
	top: 1.5px;
	width: 5px;
	height: 9px;
	border: solid var(--sc-c-white);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

/* Product page: under the add-to-cart button. */
.sc-compare-single {
	margin-top: 0.75rem;
}

.sc-compare-toggle--single {
	margin: 0 !important;
	font-size: var(--sc-fs-small);
	letter-spacing: 0.04em;
}

.sc-compare-toggle--single .sc-compare-toggle__box {
	width: 18px;
	height: 18px;
}

.sc-compare-toggle--single[aria-pressed="true"] .sc-compare-toggle__box::after {
	left: 5.5px;
	top: 2px;
}

/* --------------------------------------------------------------------------
   Tray
   -------------------------------------------------------------------------- */

.sc-tray {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 90;
	padding: 0.75rem clamp(16px, 4vw, 40px) max(0.75rem, env(safe-area-inset-bottom));
	border-top: 1px solid var(--sc-c-border-light);
	background: var(--sc-c-white);
	box-shadow: 0 -10px 30px rgba(28, 27, 25, 0.08);
	color: var(--sc-c-main);
	font-size: var(--sc-fs-x-small);
	line-height: 1.5;
	transition: transform 0.25s ease, visibility 0.25s;
	animation: sc-tray-in 0.25s ease;
}

.sc-tray[hidden] {
	display: none;
}

@keyframes sc-tray-in {
	from { transform: translateY(100%); }
}

/* Product page: out of the way while it would cover the add-to-cart form. */
.sc-tray.is-yielding {
	transform: translateY(calc(100% + 12px));
	visibility: hidden;
}

/* Never over the mobile menu (core navigation sets .has-modal-open on <html>)
   or the mini cart (WooCommerce 11 adds no body class; its drawer overlay
   loses --is-hidden while it is open). */
.has-modal-open .sc-tray,
.has-modal-open .sc-toast,
body:has(.wc-block-components-drawer__screen-overlay:not(.wc-block-components-drawer__screen-overlay--is-hidden)) .sc-tray,
body:has(.wc-block-components-drawer__screen-overlay:not(.wc-block-components-drawer__screen-overlay--is-hidden)) .sc-toast {
	display: none;
}

.sc-tray__inner {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	grid-template-areas: "head list actions";
	align-items: center;
	gap: 0.75rem 1.75rem;
	max-width: var(--wp--style--global--wide-size, 1280px);
	margin: 0 auto;
}

.sc-tray__head {
	grid-area: head;
	min-width: 0;
}

.sc-tray__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 40px;
	padding: 0.25rem 0.25rem 0.25rem 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.sc-tray__toggle:focus-visible,
.sc-tray__clear:focus-visible,
.sc-tray__remove:focus-visible,
.sc-tray__link:focus-visible,
.sc-tray__go:focus-visible {
	outline: 2px solid var(--sc-c-main);
	outline-offset: 2px;
}

.sc-tray__title {
	font-size: var(--sc-fs-small);
	font-weight: 700;
	letter-spacing: 0.06em;
	white-space: nowrap;
}

.sc-tray__count {
	display: inline-block;
	flex: none;
	white-space: nowrap;
	min-width: 2.6em;
	padding: 0.1em 0.6em;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--sc-c-tertiary);
	font-family: var(--sc-ff-display);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-align: center;
	font-feature-settings: "tnum" 1;
}

.sc-tray__chev {
	display: inline-flex;
	color: var(--sc-c-secondary);
	transform: rotate(180deg);
	transition: transform var(--wp--custom--transition);
}

.sc-tray.is-collapsed .sc-tray__chev {
	transform: none;
}

.sc-tray__mini {
	display: none;
}

.sc-tray__hint {
	margin: 0.1rem 0 0;
	color: var(--sc-c-secondary);
	font-size: 0.75rem;
	white-space: nowrap;
}

.sc-tray__hint[hidden] {
	display: none;
}

/* Slots */
.sc-tray__list {
	grid-area: list;
	display: grid;
	grid-template-columns: repeat(var(--sc-tray-max, 4), minmax(0, 1fr));
	gap: 0.625rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.sc-tray__item,
.sc-tray__slot {
	position: relative;
	display: flex;
	align-items: center;
	min-width: 0;
	min-height: 62px;
	margin: 0;
	border-radius: var(--wp--custom--radius--card);
}

.sc-tray__item {
	border: 1px solid var(--sc-c-border-light);
	background: var(--sc-c-base);
}

.sc-tray__slot {
	justify-content: center;
	border: 1px dashed var(--sc-c-border-light);
	color: var(--sc-c-main-accent);
}

.sc-tray__slot-plus {
	font-size: 1rem;
	line-height: 1;
}

.sc-tray__link {
	display: flex;
	flex: 1;
	align-items: center;
	gap: 0.625rem;
	min-width: 0;
	padding: 6px 2.25rem 6px 6px;
	border-radius: var(--wp--custom--radius--card);
	color: var(--sc-c-main);
	text-decoration: none;
}

.sc-tray__link:hover .sc-tray__name {
	text-decoration: underline;
}

.sc-tray__img {
	flex: none;
	width: 48px;
	height: 48px;
	border-radius: var(--wp--custom--radius--control);
	background: var(--sc-c-tertiary);
	object-fit: cover;
}

.sc-tray__name {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 0.75rem;
	font-weight: 500;
	line-height: 1.5;
	letter-spacing: 0.04em;
}

.sc-tray__remove {
	position: absolute;
	top: 50%;
	right: 4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin-top: -16px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--sc-c-secondary);
	cursor: pointer;
}

.sc-tray__remove:hover {
	background: var(--sc-c-tertiary);
	color: var(--sc-c-main);
}

/* Actions */
.sc-tray__actions {
	grid-area: actions;
	display: flex;
	align-items: center;
	gap: 1.25rem;
}

.sc-tray__clear {
	padding: 0.5rem 0;
	border: 0;
	background: none;
	color: var(--sc-c-secondary);
	font: inherit;
	font-size: 0.75rem;
	letter-spacing: 0.04em;
	text-decoration: underline;
	text-underline-offset: 3px;
	white-space: nowrap;
	cursor: pointer;
}

.sc-tray__clear:hover {
	color: var(--sc-c-main);
}

.sc-tray .sc-tray__go {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 0.75em 1.6em;
	border-radius: var(--wp--custom--radius--control);
	font-size: var(--sc-fs-small);
	white-space: nowrap;
	text-decoration: none;
	cursor: pointer;
}

.sc-tray .sc-tray__go[aria-disabled="true"] {
	background: var(--sc-c-tertiary);
	color: #6F6B64;
	cursor: not-allowed;
}

/* Collapsed: one slim row. */
.sc-tray.is-collapsed .sc-tray__list,
.sc-tray.is-collapsed .sc-tray__clear {
	display: none;
}

.sc-tray.is-collapsed .sc-tray__inner {
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas: "head actions";
}

.sc-tray.is-collapsed .sc-tray__head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	column-gap: 1rem;
}

.sc-tray.is-collapsed .sc-tray__mini {
	display: inline-flex;
	padding-left: 0.25rem;
}

.sc-tray__mini img {
	width: 26px;
	height: 26px;
	margin-left: -6px;
	border: 2px solid var(--sc-c-white);
	border-radius: 50%;
	background: var(--sc-c-tertiary);
	object-fit: cover;
}

.sc-tray.is-collapsed .sc-tray .sc-tray__go,
.sc-tray.is-collapsed .sc-tray__go {
	min-height: 42px;
}

/* Desktop: the × sits on the thumbnail's corner (as on phones), so the name
   gets the whole remaining width (「ベーシックTシャツ」 on one line). */
@media (min-width: 782px) {
	.sc-tray__link {
		padding-right: 6px;
	}

	.sc-tray__remove {
		top: -7px;
		left: 42px;
		right: auto;
		width: 24px;
		height: 24px;
		margin: 0;
		border: 1px solid var(--sc-c-border-light);
		background: var(--sc-c-white);
		box-shadow: 0 1px 3px rgba(28, 27, 25, 0.12);
		color: var(--sc-c-main);
	}

	.sc-tray__remove:hover {
		border-color: var(--sc-c-main);
		background: var(--sc-c-main);
		color: var(--sc-c-white);
	}

	.sc-tray__remove svg {
		width: 12px;
		height: 12px;
	}
}

/* Phones and small tablets */
@media (max-width: 781px) {
	.sc-tray {
		padding-top: 0.5rem;
		padding-bottom: max(0.625rem, env(safe-area-inset-bottom));
	}

	.sc-tray__inner {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas:
			"head clear"
			"list list"
			"actions actions";
		gap: 0.5rem 1rem;
	}

	.sc-tray__actions {
		display: contents;
	}

	.sc-tray__clear {
		grid-area: clear;
		justify-self: end;
	}

	.sc-tray .sc-tray__go {
		grid-area: actions;
		width: 100%;
		min-height: 46px;
	}

	.sc-tray__head {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		column-gap: 0.75rem;
	}

	.sc-tray__hint {
		margin: 0;
	}

	.sc-tray__list {
		gap: 0.5rem;
	}

	.sc-tray__item,
	.sc-tray__slot {
		flex-direction: column;
		align-items: stretch;
		min-height: 0;
	}

	.sc-tray__slot {
		aspect-ratio: 1 / 1;
		align-items: center;
	}

	.sc-tray__item {
		border: 0;
		background: none;
	}

	.sc-tray__link {
		flex-direction: column;
		align-items: stretch;
		gap: 0.25rem;
		padding: 0;
	}

	.sc-tray__img {
		width: 100%;
		height: auto;
		aspect-ratio: 1 / 1;
		border-radius: var(--wp--custom--radius--card);
	}

	.sc-tray__name {
		display: block;
		font-size: 0.6875rem;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.sc-tray__remove {
		top: 4px;
		right: 4px;
		width: 28px;
		height: 28px;
		margin: 0;
		background: rgba(255, 255, 255, 0.92);
		box-shadow: 0 1px 3px rgba(28, 27, 25, 0.15);
		color: var(--sc-c-main);
	}

	.sc-tray.is-collapsed .sc-tray__inner {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas: "head actions";
	}

	.sc-tray.is-collapsed .sc-tray__go {
		width: auto;
		padding-left: 1.1em;
		padding-right: 1.1em;
	}

	.sc-tray.is-collapsed .sc-tray__hint {
		flex-basis: 100%;
	}

	.sc-tray.is-collapsed .sc-tray__toggle {
		gap: 0.4rem;
		min-width: 0;
	}

	.sc-tray__title {
		font-size: 0.875rem;
	}

	.sc-tray__mini img {
		width: 24px;
		height: 24px;
		margin-left: -9px;
	}
}

/* Keyboard focus never ends up behind the tray (WCAG 2.4.11): scrolling a
   focused element into view keeps it above the tray. */
html.sc-has-tray {
	scroll-padding-bottom: calc(var(--sc-tray-h, 0px) + 16px);
}

/* Room for the tray at the end of the page (ink, like the footer it extends). */
html.sc-has-tray body::after {
	content: "";
	display: block;
	height: var(--sc-tray-h, 0);
	background: var(--sc-c-main);
}

/* WooCommerce snackbars sit above the tray. */
html.sc-has-tray .wc-block-components-notice-snackbar-list {
	bottom: calc(var(--sc-tray-h, 0px) + 16px);
}

/* --------------------------------------------------------------------------
   Toast (limit, cleared, copied)
   -------------------------------------------------------------------------- */

.sc-toast {
	position: fixed;
	left: 50%;
	bottom: calc(var(--sc-tray-h, 0px) + 16px);
	z-index: 95;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	width: max-content;
	max-width: min(560px, calc(100vw - 32px));
	padding: 0.7rem 0.6rem 0.7rem 1.1rem;
	/* a light edge, so the ink toast never melts into the ink footer */
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: var(--wp--custom--radius--card);
	background: var(--sc-c-main);
	color: var(--sc-c-white);
	box-shadow: 0 0 0 1px rgba(28, 27, 25, 0.35), var(--sc-sh-lifted);
	font-size: var(--sc-fs-x-small);
	line-height: 1.6;
	letter-spacing: 0.04em;
	opacity: 0;
	visibility: hidden;
	transform: translate(-50%, 8px);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.sc-toast.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translate(-50%, 0);
	/* visible at once (no visibility transition), so its button can take focus right away */
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
}

.sc-toast__text {
	flex: 1;
}

.sc-toast__action {
	flex: none;
	padding: 0.4rem 0.7rem;
	border: 1px solid rgba(255, 255, 255, 0.5);
	border-radius: var(--wp--custom--radius--control);
	background: none;
	color: var(--sc-c-white);
	font: inherit;
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
}

.sc-toast__close {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--sc-c-main-accent);
	cursor: pointer;
}

.sc-toast__action:hover,
.sc-toast__close:hover {
	background: rgba(255, 255, 255, 0.12);
	color: var(--sc-c-white);
}

.sc-toast button:focus-visible {
	outline: 2px solid var(--sc-c-white);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.sc-tray,
	.sc-toast,
	.sc-tray__chev {
		animation: none;
		transition: none;
	}
}

/* --------------------------------------------------------------------------
   Button styles (Settings → Compare button → Style)
   -------------------------------------------------------------------------- */

.sc-compare-toggle--style-button,
.sc-compare-toggle--style-link {
	gap: 0.4em;
}

.sc-compare-toggle--style-button .sc-compare-toggle__box,
.sc-compare-toggle--style-link .sc-compare-toggle__box {
	display: none;
}

.sc-compare-toggle--style-button {
	justify-content: center;
	padding: 0.5em 1em;
	border: 1px solid var(--sc-c-main);
	border-radius: 4px;
	color: var(--sc-c-main);
	background: var(--sc-c-white);
}

.sc-compare-toggle--style-button:hover,
.sc-compare-toggle--style-button[aria-pressed="true"] {
	color: var(--sc-c-white);
	background: var(--sc-c-main);
}

.sc-compare-toggle--style-link {
	padding: 0.25rem 0;
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* "Added" label swap for the button and link styles. */
.sc-compare-toggle__added {
	display: none;
}

.sc-compare-toggle[aria-pressed="true"] .sc-compare-toggle__added {
	display: inline;
}

.sc-compare-toggle[aria-pressed="true"]:has(.sc-compare-toggle__added) .sc-compare-toggle__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}
