/* Template preview overlay. Colours come from the active Style. */
html.hw-ov-open { overflow: hidden; }

.hw-ov {
	width: min(1400px, calc(100vw - 2.5rem));
	height: calc(100dvh - 2.5rem);
	max-width: none;
	max-height: none;
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 16px;
	overflow: hidden;
	display: none;
	flex-direction: column;
	background: #E9E5DE;
	color: var(--wp--preset--color--ink, #33302B);
	font-family: var(--wp--preset--font-family--body, system-ui, sans-serif);
	box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
}
.hw-ov[open] { display: flex; animation: hw-ov-in 0.22s ease-out; }
.hw-ov::backdrop { background: rgba(28, 26, 23, 0.6); backdrop-filter: blur(3px); }
@keyframes hw-ov-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } }

.hw-ov__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem 1rem;
	flex-wrap: wrap;
	padding: 0.6rem 0.75rem 0.6rem 1rem;
	background: var(--wp--preset--color--base, #FAF7F2);
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.hw-ov__nav, .hw-ov__actions { display: flex; align-items: center; gap: 0.6rem; }
.hw-ov__name { display: flex; flex-direction: column; line-height: 1.2; min-width: 9rem; }
.hw-ov__name strong { font-family: var(--wp--preset--font-family--heading, Georgia, serif); font-weight: 600; font-size: 1.1rem; }
.hw-ov__name span { font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--wp--preset--color--muted, #6D6960); }

.hw-ov button { font: inherit; color: inherit; cursor: pointer; }
.hw-ov__arrow, .hw-ov__close {
	display: inline-grid;
	place-items: center;
	flex: none;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.15);
	background: none;
	font-size: 1.15rem;
	line-height: 1;
}
.hw-ov__close { font-size: 1.5rem; margin-left: 0.25rem; }
.hw-ov__arrow:hover, .hw-ov__close:hover { background: #fff; }

.hw-ov__sizes { display: flex; background: rgba(0, 0, 0, 0.06); border-radius: 99px; padding: 3px; }
.hw-ov__sizes button { border: 0; background: none; padding: 0.4rem 0.8rem; border-radius: 99px; font-size: 0.82rem; font-weight: 600; }
.hw-ov__sizes button[aria-pressed="true"] { background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

.hw-ov__full, .hw-ov__choose {
	font-size: 0.88rem;
	font-weight: 700;
	white-space: nowrap;
	text-decoration: none;
	padding: 0.6rem 1.1rem;
	border-radius: 99px;
}
.hw-ov__full { color: inherit; border: 1px solid rgba(0, 0, 0, 0.18); }
.hw-ov__full:hover { background: #fff; }
.hw-ov__choose { background: var(--wp--preset--color--accent-strong, #965E47); color: var(--wp--preset--color--on-accent, #fff); }
.hw-ov__choose:hover { filter: brightness(0.92); }

.hw-ov__stage { position: relative; flex: 1; min-height: 0; display: flex; justify-content: center; overflow: auto; }
.hw-ov__loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font-size: 0.95rem; color: var(--wp--preset--color--muted, #6D6960); }
.hw-ov.is-loaded .hw-ov__loading { display: none; }
.hw-ov__frame { position: relative; display: block; width: 100%; height: 100%; border: 0; background: #fff; opacity: 0; transition: opacity 0.2s ease, width 0.25s ease; }
.hw-ov.is-loaded .hw-ov__frame { opacity: 1; }
.hw-ov[data-size="tablet"] .hw-ov__stage, .hw-ov[data-size="phone"] .hw-ov__stage { padding: 1.25rem; }
.hw-ov[data-size="tablet"] .hw-ov__frame { width: 834px; border-radius: 18px; box-shadow: 0 0 0 10px #1d1d1f, 0 20px 50px rgba(0, 0, 0, 0.25); }
.hw-ov[data-size="phone"] .hw-ov__frame { width: 390px; border-radius: 28px; box-shadow: 0 0 0 10px #1d1d1f, 0 20px 50px rgba(0, 0, 0, 0.25); }

.hw-ov :focus-visible { outline: 2px solid var(--wp--preset--color--accent-strong, #965E47); outline-offset: 2px; }

/* Narrower screens: the preview fills the screen and the size switch goes (the screen is the size). */
@media (max-width: 1080px) {
	.hw-ov__sizes { display: none; }
	.hw-ov[data-size] .hw-ov__stage { padding: 0; }
	.hw-ov[data-size] .hw-ov__frame { width: 100%; border-radius: 0; box-shadow: none; }
}
@media (max-width: 720px) {
	.hw-ov { width: 100vw; height: 100dvh; border-radius: 0; }
	.hw-ov__bar { padding: 0.5rem 0.6rem; }
	.hw-ov__nav { order: 2; flex-basis: 100%; justify-content: space-between; }
	.hw-ov__actions { order: 1; flex: 1; justify-content: flex-end; }
	.hw-ov__full, .hw-ov__choose { padding: 0.5rem 0.85rem; font-size: 0.82rem; }
	.hw-ov__name { align-items: center; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
	.hw-ov[open] { animation: none; }
	.hw-ov__frame { transition: none; }
}
