/**
 * Wedding Moodboard — front-end styles.
 * Namespaced under .wm- to avoid collisions with theme styles.
 *
 * Every colour, radius, button and form token below is derived from the
 * active theme's CSS custom properties (Blocksy `--theme-*` variables), so
 * the Moodboard follows the site palette/typography automatically. Each
 * var() carries a literal fallback for the case where the theme vars are
 * not present (e.g. the plugin used on another theme).
 */

:root {
	/* Brand / accent — theme palette colour 1. */
	--wm-accent: var(--theme-palette-color-1, #b37e70);
	--wm-accent-hover: var(--theme-button-background-hover-color, #b38578);
	--wm-accent-strong: #8f6053;
	--wm-accent-soft: rgba(179, 126, 112, 0.14);

	/* Text */
	--wm-ink: var(--theme-text-color, var(--theme-palette-color-4, #000));
	--wm-heading: var(--theme-headings-color, var(--theme-palette-color-4, #000));
	--wm-muted: var(--theme-palette-color-3, #415161);

	/* Surfaces */
	--wm-surface: var(--theme-palette-color-8, #ffffff);
	--wm-surface-alt: var(--theme-palette-color-2, #f9f3f1);
	--wm-border: rgba(179, 126, 112, 0.25);

	/* Shape */
	--wm-shadow: 0 12px 18px -6px rgba(34, 56, 101, 0.12);

	/* Buttons — mirrors the theme button design tokens. */
	--wm-btn-text: var(--theme-button-text-initial-color, #ffffff);
	--wm-btn-text-hover: var(--theme-button-text-hover-color, #ffffff);
	--wm-btn-bg: var(--theme-button-background-initial-color, var(--theme-palette-color-1, #b37e70));
	--wm-btn-bg-hover: var(--theme-button-background-hover-color, #b38578);
	--wm-btn-min-height: var(--theme-button-min-height, 48px);
	--wm-btn-padding: var(--theme-button-padding, 5px 24px);
	--wm-btn-font-size: var(--theme-button-font-size, 16px);
	--wm-btn-font-weight: var(--theme-button-font-weight, 700);

	/* Forms — mirrors the theme form field tokens. */
	--wm-field-border: var(--theme-form-field-border-initial-color, var(--wm-border));
	--wm-field-border-focus: var(--theme-form-field-border-focus-color, var(--wm-accent));

	/* Spacing */
	--wm-spacing: var(--theme-content-spacing, 1.5em);
}

/* Soft tints derived from the live palette where color-mix() is supported. */
@supports (color: color-mix(in srgb, red, blue)) {
	:root {
		--wm-accent-strong: color-mix(in srgb, var(--theme-palette-color-1, #b37e70) 78%, #000);
		--wm-accent-soft: color-mix(in srgb, var(--theme-palette-color-1, #b37e70) 14%, transparent);
		--wm-border: color-mix(in srgb, var(--theme-palette-color-1, #b37e70) 25%, transparent);
	}
}

/*
 * Capture the theme's *body* typography here, on non-heading elements:
 * custom properties are substituted on the element that declares them, so
 * inside a heading — where the theme redefines --theme-font-family /
 * --theme-font-size / --theme-font-weight to the display face and heading
 * scale — these still resolve to the body values.
 */
.wm-moodboard,
.wm-empty-state,
.wm-toast-container {
	--wm-body-font: var(--theme-font-family, Inter, Sans-Serif);
	--wm-body-size: var(--theme-font-size, 16px);
	--wm-body-weight: var(--theme-font-weight, 300);
}

.wm-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Heart button */
.wm-heart {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	background: rgba(255, 255, 255, 0.9);
	border: 1px solid var(--wm-border);
	border-radius: 999px;
	cursor: pointer;
	color: var(--wm-ink);
	transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.wm-heart:hover {
	background: var(--wm-surface);
}

.wm-heart:focus-visible {
	outline: 2px solid var(--wm-accent);
	outline-offset: 2px;
}

.wm-heart-icon {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	transition: fill 0.15s ease, stroke 0.15s ease;
}

.wm-heart.is-active {
	color: var(--wm-accent);
}

.wm-heart.is-active .wm-heart-icon {
	fill: var(--wm-accent);
	stroke: var(--wm-accent);
}

.wm-heart.wm-animate {
	animation: wm-heart-pop 0.35s ease;
}

@keyframes wm-heart-pop {
	0% {
		transform: scale(1);
	}
	35% {
		transform: scale(1.25);
	}
	60% {
		transform: scale(0.95);
	}
	100% {
		transform: scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.wm-heart.wm-animate {
		animation: none;
	}
}

/* Counter */
.wm-counter {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 14px;
	color: var(--wm-ink);
}

/* Moodboard page */
.wm-moodboard {
	max-width: var(--theme-normal-container-max-width, 1170px);
	margin: 0 auto;
	color: var(--wm-ink);
}

.wm-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 24px;
}

/* Left to the theme's h2 rules (family / size / weight); colour only. */
.wm-toolbar-title {
	display: flex;
	align-items: baseline;
	gap: 10px;
	margin: 0;
	color: var(--wm-heading);
}

/* Body typography, not the heading's display face / heading scale. */
.wm-toolbar-count {
	font-family: var(--wm-body-font);
	font-size: var(--wm-body-size);
	font-weight: var(--wm-body-weight);
	line-height: 1.2;
	letter-spacing: normal;
	color: var(--wm-muted);
}

.wm-toolbar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.wm-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 20px;
	margin-bottom: 40px;
}

.wm-item {
	position: relative;
	background: var(--wm-surface);
	border: 1px solid var(--wm-border);
	border-radius: var(--theme-button-border-radius, 12px);
	overflow: hidden;
	transition: box-shadow 0.2s ease, opacity 0.25s ease, transform 0.25s ease;
}

.wm-item:hover {
	box-shadow: var(--wm-shadow);
}

.wm-item.wm-removing {
	opacity: 0;
	transform: scale(0.92);
}

.wm-item-media {
	aspect-ratio: 4 / 3;
	background: var(--wm-surface-alt);
	overflow: hidden;
	position: relative;
}

.wm-item-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.wm-item-image-base,
.wm-item-image-swap {
	position: absolute;
	inset: 0;
	transition: opacity 0.45s ease;
}

.wm-item-image-swap {
	opacity: 0;
}

.wm-item--has-swap:hover .wm-item-image-swap,
.wm-item--has-swap:focus-within .wm-item-image-swap {
	opacity: 1;
}

.wm-item-media-placeholder {
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, var(--wm-surface-alt), var(--wm-border));
}

.wm-item-body {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 10px 12px;
}

.wm-item-title {
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	color: var(--wm-ink);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wm-item-remove {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	background: transparent;
	border: 1px solid var(--wm-border);
	border-radius: 999px;
	color: var(--wm-muted);
	cursor: pointer;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.wm-item-remove:hover {
	color: var(--wm-accent);
	border-color: var(--wm-accent);
}

.wm-item-remove:focus-visible {
	outline: 2px solid var(--wm-accent);
	outline-offset: 2px;
}

.wm-item-remove svg {
	width: 14px;
	height: 14px;
}

/* Empty state */
.wm-empty-wrap {
	margin-bottom: 32px;
}

.wm-empty-state {
	text-align: center;
	padding: 56px 24px;
	border: 1px dashed var(--wm-border);
	border-radius: var(--theme-button-border-radius, 12px);
	background: var(--wm-surface);
}

.wm-empty-icon {
	width: 56px;
	height: 56px;
	color: var(--wm-accent);
	margin-bottom: 16px;
}

/* Left to the theme's h4 rules (family / size / weight); colour only. */
.wm-empty-title {
	margin: 0 0 6px;
	color: var(--wm-heading);
}

.wm-empty-text {
	margin: 0 0 20px;
	color: var(--wm-muted);
}

/* Buttons — sized and coloured like the theme's own .ct-button. */
.wm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: var(--wm-btn-min-height);
	padding: var(--wm-btn-padding);
	font-family: var(--wm-body-font, inherit);
	font-size: var(--wm-btn-font-size);
	font-weight: var(--wm-btn-font-weight);
	line-height: var(--theme-button-line-height, 1);
	text-transform: var(--theme-button-transform, none);
	border-radius: var(--theme-button-border-radius, 12px);
	border: 1px solid transparent;
	box-shadow: var(--theme-button-shadow, none);
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.wm-btn:focus-visible {
	outline: 2px solid var(--wm-accent);
	outline-offset: 2px;
}

.wm-btn-primary {
	background: var(--wm-btn-bg);
	color: var(--wm-btn-text);
}

.wm-btn-primary:hover,
.wm-btn-primary:focus {
	background: var(--wm-btn-bg-hover);
	color: var(--wm-btn-text-hover);
}

.wm-btn-primary:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Contact form */
.wm-contact {
	border-top: 1px solid var(--wm-border);
	padding-top: 32px;
}

/* Left to the theme's h3 rules (family / size / weight); colour only. */
.wm-contact-title {
	margin: 0 0 16px;
	color: var(--wm-heading);
}

.wm-contact-form {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}

.wm-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.wm-field-full {
	grid-column: 1 / -1;
}

.wm-field label {
	font-size: 14px;
	font-weight: 600;
	color: var(--wm-ink);
}

.wm-field input,
.wm-field textarea {
	min-height: var(--theme-form-field-height, 55px);
	padding: 10px 16px;
	font-family: var(--wm-body-font, inherit);
	font-size: var(--theme-font-size, 16px);
	border: 1px solid var(--wm-field-border);
	border-radius: var(--theme-button-border-radius, 12px);
	background: var(--wm-surface);
	color: var(--wm-ink);
}

.wm-field textarea {
	padding-top: 14px;
	padding-bottom: 14px;
	resize: vertical;
}

.wm-field input:focus,
.wm-field textarea:focus {
	outline: none;
	border-color: var(--wm-field-border-focus);
	box-shadow: 0 0 0 3px var(--wm-accent-soft);
}

.wm-field-submit {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	gap: 16px;
}

.wm-form-message {
	margin: 0;
	font-size: 14px;
}

.wm-form-message.is-success {
	color: #2f6e3f;
}

.wm-form-message.is-error {
	color: var(--wm-accent-strong);
}

@media (max-width: 640px) {
	.wm-contact-form {
		grid-template-columns: 1fr;
	}
}

/* Shared read-only moodboard */
.wm-shared-notice {
	margin: 0 0 20px;
	padding: 12px 16px;
	background: var(--wm-surface);
	border-left: 3px solid var(--wm-accent);
	border-radius: var(--theme-button-border-radius, 12px);
	color: var(--wm-muted);
	font-size: 14px;
}

/* Toasts */
.wm-toast-container {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 100000;
	display: flex;
	flex-direction: column;
	gap: 8px;
	pointer-events: none;
}

.wm-toast {
	pointer-events: auto;
	padding: 10px 18px;
	font-family: var(--wm-body-font, inherit);
	background: var(--wm-ink);
	color: var(--theme-palette-color-8, #ffffff);
	border-radius: var(--theme-button-border-radius, 12px);
	font-size: 14px;
	box-shadow: var(--wm-shadow);
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.wm-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}
