/**
 * [darkify_demo] — host page styles.
 *
 * Only the browser window around the preview lives here. The sample site inside
 * has its own stylesheet (darkify-demo-frame.css) because it is served into a
 * separate document.
 */

.dkfd {
	--dkfd-max: 900px;
	--dkfd-chrome-bg: #232a4e;
	--dkfd-chrome-text: #aeb6d4;
	--dkfd-window-bg: #ffffff;
	--dkfd-radius: 14px;
	--dkfd-height: 460px;

	box-sizing: border-box;
	width: 100%;
	max-width: var(--dkfd-max);
	margin-left: auto;
	margin-right: auto;
}

.dkfd *,
.dkfd *::before,
.dkfd *::after {
	box-sizing: border-box;
}

.dkfd__heading {
	margin: 0 0 10px;
	text-align: center;
	font-size: clamp(24px, 3.4vw, 34px);
	line-height: 1.25;
	font-weight: 700;
}

.dkfd__subtitle,
.dkfd__note {
	margin: 0 0 26px;
	text-align: center;
	font-size: 15px;
	line-height: 1.6;
	opacity: 0.85;
}

.dkfd__note {
	margin: 18px 0 0;
	font-size: 13px;
}

/*
 * The rounded corners, and why nothing here paints a background.
 *
 * A pale quarter-arc used to show at all four corners over a dark preview. The
 * cause was this element's white background, not the clip: along a rounded edge
 * the chrome bar and the iframe cover their pixels only fractionally — that is
 * what antialiasing is — so whatever was painted underneath showed through at
 * partial strength for the width of the curve, and white against a dark preview
 * reads as a light arc. `overflow: hidden` could never remove it, because the
 * white was inside the clip by design. Painting nothing blends the same edge
 * against the page instead, which is what a rounded corner should look like.
 *
 * The white placeholder that kept the window from flashing empty now lives on
 * the viewport, and only until the frame has booted (see .dkfd--ready below).
 *
 * The children round the corners they own as well (.dkfd__chrome the top two,
 * .dkfd__viewport and the iframe the bottom two). An iframe is its own document
 * and is not clipped by an ancestor's radius on every engine, so it has to be
 * rounded in its own right; the chrome follows for symmetry.
 */
.dkfd__window {
	position: relative;
	overflow: hidden;
	border-radius: var(--dkfd-radius);
	box-shadow: 0 30px 60px -24px rgba(4, 8, 32, 0.65), 0 2px 8px rgba(4, 8, 32, 0.25);
	/* Its own stacking context, so the corner clip is composited with the
	   children rather than against the page behind them — without this the
	   iframe's layer is rounded a pixel out of step and leaves a soft fringe. */
	isolation: isolate;
}


/* Browser chrome — the frame around the preview, not part of the sample site,
   so it keeps the same look whichever mode the preview is in. */
.dkfd__chrome {
	position: relative;
	display: flex;
	align-items: center;
	min-height: 38px;
	padding: 10px 16px;
	border-radius: var(--dkfd-radius) var(--dkfd-radius) 0 0;
	background: var(--dkfd-chrome-bg);
}

.dkfd__dots {
	display: flex;
	gap: 7px;
}

.dkfd__dots i {
	display: block;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #ff5f57;
}

.dkfd__dots i:nth-child(2) {
	background: #febc2e;
}

.dkfd__dots i:nth-child(3) {
	background: #28c840;
}

.dkfd__url {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	max-width: 60%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-size: 12px;
	letter-spacing: 0.04em;
	color: var(--dkfd-chrome-text);
}

/* Background-free for the same reason as the window above: it sits under the
   iframe's bottom corners, and anything it painted would blend into them. */
.dkfd__viewport {
	position: relative;
	overflow: hidden;
	border-radius: 0 0 var(--dkfd-radius) var(--dkfd-radius);
}

.dkfd__frame {
	display: block;
	width: 100%;
	height: var(--dkfd-height);
	border: 0;
	border-radius: inherit;
	background: transparent;
	/* The preview grows and shrinks with its own content (cards stack on narrow
	   screens); easing that keeps the window from snapping. */
	transition: height 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
	.dkfd__frame {
		transition: none;
	}
}

/* Until the script boots the preview there is nothing in the frame; keep the
   window from collapsing to a bare chrome bar. */
.dkfd:not(.dkfd--ready) .dkfd__viewport {
	min-height: 260px;
	background: var(--dkfd-window-bg);
}

@media (max-width: 600px) {
	.dkfd__chrome {
		padding: 8px 12px;
	}

	.dkfd__url {
		font-size: 11px;
	}
}

/* Demo controls -----------------------------------------------------------
   Styled for the dark section the demo lives in. The tokens below are the
   whole palette — override them on `.dkfd` to drop the panel onto a lighter
   background. */

.dkfd {
	--dkfd-panel-bg: rgba(255, 255, 255, 0.02);
	--dkfd-panel-border: rgba(255, 255, 255, 0.08);
	--dkfd-panel-label: #64748b;
	--dkfd-panel-text: #94a3b8;
	--dkfd-panel-strong: #ffffff;
	--dkfd-panel-strong-text: #0f172a;
}

.dkfd__controls {
	display: flex;
	flex-wrap: wrap;
	gap: 14px 34px;
	margin-top: 14px;
	padding: 16px 22px;
	border: 1px solid var(--dkfd-panel-border);
	border-radius: 14px;
	background: var(--dkfd-panel-bg);
}

.dkfd-ctrl {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

/* The divider between groups, drawn on the group itself so it disappears
   automatically when the groups wrap onto their own rows. */
.dkfd-ctrl + .dkfd-ctrl {
	padding-left: 20px;
	border-left: 1px solid var(--dkfd-panel-border);
	margin-left: -20px;
}

.dkfd-ctrl__label {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--dkfd-panel-label);
	line-height: 1;
}

.dkfd-ctrl__options {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.dkfd__controls button {
	appearance: none;
	cursor: pointer;
	font-family: inherit;
	transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.dkfd__controls button:focus-visible {
	outline: 2px solid var(--dkfd-panel-strong);
	outline-offset: 2px;
}

/* Colour swatches */

/* A preset chip: its page background against its link colour — the pair that
   tells Darkify's presets apart at a glance. */
.dkfd-swatch {
	position: relative;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(
		135deg,
		var(--dkfd-swatch, #0f0f0f) 0 50%,
		var(--dkfd-swatch-2, var(--dkfd-swatch, #e7e7e7)) 50% 100%
	);
	box-shadow: 0 0 0 0 var(--dkfd-panel-strong);
}

.dkfd-swatch:hover {
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.dkfd-swatch.is-selected {
	box-shadow: 0 0 0 2px var(--dkfd-panel-strong);
}

/* Size and position pills */

.dkfd-pill {
	min-width: 38px;
	padding: 7px 12px;
	border: 1px solid var(--dkfd-panel-border);
	border-radius: 8px;
	background: transparent;
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	color: var(--dkfd-panel-text);
}

.dkfd-pill:hover {
	border-color: rgba(255, 255, 255, 0.3);
	color: var(--dkfd-panel-strong);
}

.dkfd-pill.is-selected {
	border-color: rgba(255, 255, 255, 0.55);
	color: var(--dkfd-panel-strong);
}

/* Position select

   Styled to sit level with the pills beside it — same height, radius, border
   and type — so the row still reads as one panel. The arrow is an inline SVG
   data URI rather than a pseudo-element: `appearance: none` removes the native
   one, and a <select> cannot carry ::after. It is drawn with `currentColor`
   through the stroke, so it follows the light-surface flip for free. */
.dkfd-select {
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	min-width: 150px;
	padding: 7px 30px 7px 12px;
	border: 1px solid var(--dkfd-panel-border);
	border-radius: 8px;
	background-color: transparent;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 11px center;
	font-family: inherit;
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	color: var(--dkfd-panel-text);
	transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.dkfd-select:hover {
	border-color: rgba(255, 255, 255, 0.3);
	color: var(--dkfd-panel-strong);
}

.dkfd-select:focus-visible {
	outline: 2px solid var(--dkfd-panel-strong);
	outline-offset: 2px;
}

/* The dropdown list itself is painted by the OS, not the panel: on a dark
   surface the inherited light text would land on the browser's white list.
   These two are the only properties that reach it. */
.dkfd-select option {
	background: #0f172a;
	color: #e2e8f0;
}

.dkfd__controls .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 782px) {
	.dkfd__controls {
		gap: 16px;
		padding: 16px 18px;
	}

	/* Stacked groups don't need the divider — or the pull-in that goes with it. */
	.dkfd-ctrl {
		flex-basis: 100%;
	}

	.dkfd-ctrl + .dkfd-ctrl {
		padding-left: 0;
		margin-left: 0;
		border-left: 0;
	}
}

/* The same panel on a light surface. Applied by the script, which measures the
   background actually behind the demo. */
.dkfd.dkfd--on-light {
	--dkfd-panel-bg: rgba(15, 23, 42, 0.02);
	--dkfd-panel-border: rgba(15, 23, 42, 0.12);
	--dkfd-panel-label: #64748b;
	--dkfd-panel-text: #475569;
	--dkfd-panel-strong: #0f172a;
	--dkfd-panel-strong-text: #ffffff;
}

.dkfd--on-light .dkfd-swatch:hover {
	box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.3);
}

.dkfd--on-light .dkfd-pill:hover,
.dkfd--on-light .dkfd-pill.is-selected,
.dkfd--on-light .dkfd-select:hover {
	border-color: rgba(15, 23, 42, 0.45);
}

.dkfd--on-light .dkfd-select {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.dkfd--on-light .dkfd-select option {
	background: #ffffff;
	color: #0f172a;
}

/* Hero preview ------------------------------------------------------------
   The auto-playing variant. Same window, no controls, and a cross-fade that
   covers the moment the engine repaints. */

.dkfd--hero {
	--dkfd-fade: 260ms;
	--dkfd-height: 420px;
}

/* Set through the token rather than on .dkfd__window directly: the chrome and
   the viewport round their own corners from --dkfd-radius, so overriding the
   window alone would leave them 2px out of step and re-open the corner seam. */
.dkfd--hero.dkfd--bare {
	--dkfd-radius: 12px;
}

/* Bare drops the chrome bar, so the viewport is the window's only child and
   owns all four corners rather than just the bottom two. */
.dkfd--bare .dkfd__viewport {
	border-radius: var(--dkfd-radius);
}

/*
 * The flip itself is masked from inside the frame (see darkify-hero-frame.css):
 * the sample *page* dips while the engine repaints it, and the switcher and the
 * cursor stay crisp on top of it — which is what the moment is about. Only the
 * height eases out here.
 */
.dkfd--hero .dkfd__frame {
	transition: height 0.25s ease;
}

/* The cursor ------------------------------------------------------------- */

.dkfd--hero .dkfd__window {
	position: relative;
}

/* The transform is driven by the Web Animations API (curved paths, and a drift
   while it waits), so only the fade is a CSS transition. */
.dkfd__cursor {
	position: absolute;
	left: 0;
	top: 0;
	z-index: 6;
	width: 24px;
	height: 24px;
	opacity: 0;
	pointer-events: none;
	transform: translate3d(0, 0, 0);
	transition: opacity 360ms ease;
	will-change: transform, opacity;
}

.dkfd--hero.is-pointing .dkfd__cursor {
	opacity: 1;
}

.dkfd__cursor svg {
	display: block;
	filter: drop-shadow(0 2px 5px rgba(4, 8, 32, 0.45));
	transform-origin: 4px 3px;
	transition: transform 150ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* The press: the pointer dips into the switch and a ring leaves from its tip. */
.dkfd--hero.is-clicking .dkfd__cursor svg {
	transform: scale(0.84);
}

/* The click ring leaves from the pointer's tip and opens out past the switch,
   so it reads on a white switcher and a black one alike. */
.dkfd__ripple {
	position: absolute;
	left: 4px;
	top: 3px;
	width: 46px;
	height: 46px;
	margin: -23px 0 0 -23px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.92);
	box-shadow: 0 0 0 1.5px rgba(15, 23, 42, 0.35), inset 0 0 0 1.5px rgba(15, 23, 42, 0.25);
	opacity: 0;
	transform: scale(0.18);
}

.dkfd--hero.is-clicking .dkfd__ripple {
	animation: dkfd-ripple 560ms cubic-bezier(0.2, 0.6, 0.3, 1);
}

@keyframes dkfd-ripple {
	0% {
		opacity: 0.95;
		transform: scale(0.18);
	}
	65% {
		opacity: 0.4;
	}
	100% {
		opacity: 0;
		transform: scale(1.65);
	}
}

/* The mode badge in the window chrome. */

.dkfd__mode {
	margin-left: auto;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	line-height: 1.6;
	background: rgba(255, 255, 255, 0.12);
	color: #e8ecf8;
	transition: background-color var(--dkfd-fade) ease, color var(--dkfd-fade) ease;
}

.dkfd__mode[data-dkfd-mode="dark"] {
	background: #ffffff;
	color: #0f172a;
}

/* The badge sits at the right end, so the centred address needs the room. */
.dkfd--hero .dkfd__url {
	max-width: 45%;
	transition: opacity 180ms ease;
}

/* The address changes when the preview walks to wp-admin and back. It is swapped
   while the frame is behind its veil, and dipped as it changes so the new one
   arrives rather than appearing. */
.dkfd__url.is-changing {
	opacity: 0;
}

/* A page load's tell: a bar that crosses the chrome while the preview moves
   between the front end and the admin. Decorative — it is timed to the walk,
   not to anything being fetched. */
.dkfd__progress {
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 2px;
	transform: scaleX(0);
	transform-origin: 0 50%;
	opacity: 0;
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.85));
}

.dkfd--hero.is-loading .dkfd__progress {
	animation: dkfd-load 900ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

@keyframes dkfd-load {
	0% {
		opacity: 1;
		transform: scaleX(0);
	}
	70% {
		opacity: 1;
		transform: scaleX(0.82);
	}
	100% {
		opacity: 0;
		transform: scaleX(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.dkfd--hero .dkfd__frame,
	.dkfd__mode,
	.dkfd__url,
	.dkfd__cursor,
	.dkfd__cursor svg {
		transition: none;
	}

	.dkfd--hero.is-loading .dkfd__progress {
		animation: none;
	}

	/* The loop does not run at all under reduced motion (the script checks the
	   same query); this only guards a sequence that was already in flight. */
	.dkfd__cursor {
		display: none;
	}

	.dkfd--hero.is-clicking .dkfd__ripple {
		animation: none;
	}
}
