/* ==========================================================================
   Dark mode for the classic artversion-child theme, keyed on
   <html data-theme="dark"> (set by the dock, or the AV Dark Mode plugin). Colours are staging's
   dark palette (new theme, inc/dark-mode.php and its scheme-dark rules):
     base #111214 · raised #1c1d20 · contrast #f2f2f2 · primary #ececec
     secondary #c4c4c4 · muted #9ba1a8 · sand, deep #2a241f
   Like staging, only the light surfaces and the text on them flip. Black
   sections (bg-dark-1, data-arts-theme-text="light") keep their own colours,
   so the theme's *-color-light text variables and --color-dark-* are untouched.
   Screen only, like the plugin: a printout stays light.
   ========================================================================== */

@media screen {
	html[data-theme="dark"],
	html[data-theme="dark"] body {
		color-scheme: dark;

		/* Light surfaces */
		--color-light-1: #111214;
		--color-light-2: #111214;
		--color-light-3: #1c1d20;
		--color-light-4: #1c1d20;
		--color-custom-1: #2a241f;
		--color-gray-4: #2a2b2f;
		--color-border-dark: rgba(255, 255, 255, .14);

		/* Text on light surfaces (the theme's "-dark" text set) */
		--h1-color-dark: #f2f2f2;
		--h2-color-dark: #f2f2f2;
		--h3-color-dark: #f2f2f2;
		--h4-color-dark: #f2f2f2;
		--h5-color-dark: #f2f2f2;
		--h6-color-dark: #f2f2f2;
		--xl-color-dark: #f2f2f2;
		--xxl-color-dark: #f2f2f2;
		--xxxl-color-dark: #f2f2f2;
		--subheading-color-dark: #f2f2f2;
		--paragraph-color-dark: #ececec;
		--link-color-dark: #ececec;
		--link-hover-color-dark: #ffffff;
		--small-color-dark: #c4c4c4;
		--blockquote-color-dark: #c4c4c4;
		--dropcap-color-dark: #f2f2f2;
	}

	/* The page behind everything; the theme's scroll switch writes an inline
	   white here. */
	html[data-theme="dark"] {
		background-color: #111214 !important;
	}

	/* Elementor's page settings paint <body> white per page
	   (body.elementor-page-N:not(...)), more specific than this; at desktop
	   widths that covered the whole page in white. */
	html[data-theme="dark"] body {
		background-color: #111214 !important;
		color: #ececec;
	}

	/* Elementor also paints these sections white per element, hence !important.
	   The theme's scroll switch swaps the class, so this follows it. */
	html[data-theme="dark"] :is(.bg-white, .bg-white-1, .bg-light-1, .bg-light-2) {
		background-color: #111214 !important;
	}

	html[data-theme="dark"] :is(.bg-light-3, .bg-light-4) {
		background-color: #1c1d20 !important;
	}

	html[data-theme="dark"] .bg-custom-1 {
		background-color: #2a241f !important;
	}

	/* ---- Set by av-dark-mode.js on colours Elementor hardcodes ---------- */
	html[data-theme="dark"] .av-dm-bg {
		background-color: var(--av-dm-bg) !important;
	}

	html[data-theme="dark"] .av-dm-fg {
		color: var(--av-dm-fg) !important;
	}

	html[data-theme="dark"] .av-dm-fix {
		color: var(--av-dm-fix) !important;
	}

	html[data-theme="dark"] .av-dm-line {
		border-color: var(--av-dm-line) !important;
	}

	/* Inside black sections, light surfaces (cards, buttons) stay light. */
	html[data-theme="dark"] :is(.bg-dark-1, .bg-dark-2, .bg-dark-3, .bg-dark-4, [data-arts-theme-text="light"]) {
		--color-light-1: #ffffff;
		--color-light-2: #fafafa;
		--color-light-3: #f8f8f8;
		--color-light-4: #f2f2ed;
		--color-gray-4: #e8e8e8;
	}

	/* ---- Focus (WCAG 2.4.7 / 2.4.11): whatever outline a control draws on
	   focus is light on the dark page. Elementor's buttons default to black. */
	html[data-theme="dark"] :is(a, button, [role="button"], input, select, textarea, summary, [tabindex]):focus-visible {
		outline-color: #f2f2f2;
	}

	html[data-theme="dark"] .elementor-button:focus-visible {
		outline: 2px solid #f2f2f2;
		outline-offset: 2px;
	}

	html[data-theme="dark"] iframe {
		color-scheme: normal;
	}

	/* Light page headers; Elementor's page setting paints them white with
	   body.elementor-page-N .section-masthead_post-N, hence the body here. */
	html[data-theme="dark"] body .section-masthead[data-arts-theme-text="dark"] {
		background-color: #111214;
	}

	/* ---- Header: single-colour marks go exactly white, on a dark pill
	   (staging's $pill-bg-dark) ------------------------------------------ */
	html[data-theme="dark"] .logo__img-primary,
	html[data-theme="dark"] .logo__wrapper-img::after {
		filter: brightness(0) invert(1);
	}

	/* Both header pills: the logo's on the left, the Menu + quote one on the
	   right (css/top.css .header__col:has(.header__burger)::before). Separate
	   rules: a browser without :has() would drop the whole selector list. */
	html[data-theme="dark"] .logo::before {
		background-color: rgba(28, 29, 32, .7);
	}

	html[data-theme="dark"] .header__col:has(.header__burger)::before {
		background-color: rgba(28, 29, 32, .7);
	}

	/* Menu burger lines (drawn in --color-dark-2) and the "Go to Quote" hand
	   icon (a dark animated SVG in the Header Area widget). Filtering the
	   image recolours it without touching its own animation. */
	html[data-theme="dark"] .header .header__burger-line::before,
	html[data-theme="dark"] .header .header__burger-line::after {
		background-color: #f2f2f2;
	}

	/* !important: some pages restyle this icon in their own Elementor page
	   settings (Branding, post-116765.css, forces filter: invert(0) on the
	   sticky header), which would otherwise win and leave it half light,
	   half dark. */
	html[data-theme="dark"] .header__col-right img {
		filter: brightness(0) invert(1) !important;
	}

	/* ---- Homepage hero --------------------------------------------------
	   Light: a white veil in `screen` mode, black letters let the video
	   through. Dark: the same knockout inverted, a dark veil in `multiply`
	   mode with white letters. */
	html[data-theme="dark"] .av-hm {
		--ink: #f2f2f2;
		--graphite: #c4c4c4; /* captions, light mode #3f4247 */
		--line: rgba(255, 255, 255, .16);
		--teal: #3fb6c8;
		background: #111214;
	}

	html[data-theme="dark"] .av-hm__veil {
		mix-blend-mode: multiply;
		background: linear-gradient(188deg, #2a2b2f 0%, #111214 55%);
	}

	html[data-theme="dark"] .av-hm__veil::before {
		background: #111214;
	}

	html[data-theme="dark"] .av-hm__veil .av-hm__ko {
		color: #fff;
	}

	html[data-theme="dark"] .av-hm .av-hm__h1 {
		color: #c4c4c4;
	}

	/* Inner-page hero ("HELLO" on /quote/), the same knockout. */
	html[data-theme="dark"] .av-ap {
		background: #111214;
		color: #f2f2f2;
	}

	html[data-theme="dark"] .av-ap__veil {
		mix-blend-mode: multiply;
		background: linear-gradient(188deg, #2a2b2f 0%, #111214 61%);
	}

	html[data-theme="dark"] .av-ap__veil .av-ap__ko {
		color: #fff;
	}

	html[data-theme="dark"] .av-ap__eyebrow {
		color: #c4c4c4;
	}

	/* Knockout letters in both heroes show the video through a dark multiply
	   veil, so they're only as bright as the footage. Lift and soften the
	   footage (a bright overlay, in effect): black frames now read as #868686
	   in the letters, ≥3.9:1 against the veil's lightest tone (WCAG 1.4.3,
	   large text), while the multiply veil keeps everything around the
	   letters dark. The light grey behind covers a video that hasn't loaded. */
	html[data-theme="dark"] :is(.av-hm__bg, .av-ap__bg) {
		background-color: #8a8d93;
	}

	html[data-theme="dark"] :is(.av-hm__video, .av-ap__video) {
		filter: contrast(.4) brightness(1.75);
	}

	/* custom.css paints every section paragraph black
	   (main.page-wrapper__content > section p); the hero's intro is solid text
	   on the dark veil, not a knockout. */
	html[data-theme="dark"] .av-ap__content p {
		color: #ececec;
	}

	/* Statement hero (template-parts/masthead/masthead-aperture-statement.php,
	   .ap2): a light gradient with a black headline. Flip both to staging's
	   dark tones; custom.css paints section paragraphs black, hence the
	   explicit colour on the statement. */
	html[data-theme="dark"] .ap2 {
		background: linear-gradient(188deg, #1c1d20 0%, #111214 58%);
		color: #f2f2f2;
	}

	html[data-theme="dark"] .ap2 .ap2__statement {
		color: #f2f2f2;
	}

	html[data-theme="dark"] .ap2 .ap2__eyebrow {
		color: #c4c4c4;
	}

	html[data-theme="dark"] .ap2 .section-masthead__scroll-down {
		color: #f2f2f2;
	}

	/* ---- Quote form (Formidable "quote2"; its inline CSS runs on these
	   variables). Raised surfaces as staging's quote cards. -------------- */
	html[data-theme="dark"] #form_quote2 {
		--f-paper: #1c1d20;
		--f-mist: #1c1d20;
		--f-ink: #ececec;
		--f-graphite: #c4c4c4;
		--f-line: #868b93; /* 3:1+ against the field and the page (WCAG 1.4.11) */
		--f-teal: #3fb6c8;
		--f-error: #ff8a80;
	}

	/* Formidable's own style gives the group label a white background. */
	html[data-theme="dark"] #form_quote2 .frm_primary_label {
		background: transparent !important;
	}

	/* ---- Images ----------------------------------------------------------
	   SVG images are logos and icons drawn dark on transparent: flip them on
	   light-turned-dark surfaces; hue-rotate keeps colour logos roughly their
	   own (the plugin's rule). av-dark-keep leaves one as drawn;
	   av-dark-invert flips a PNG/JPG too. */
	html[data-theme="dark"] main img[src*=".svg"],
	html[data-theme="dark"] .av-dark-invert img {
		filter: invert(1) hue-rotate(180deg);
	}

	/* ...but not where the surface was dark already. */
	html[data-theme="dark"] main :is(.bg-dark-1, .bg-dark-2, .bg-dark-3, .bg-dark-4, [data-arts-theme-text="light"], .av-dark-keep) img[src*=".svg"],
	html[data-theme="dark"] main img.av-dark-keep {
		filter: none;
	}
}

/* Windows High Contrast / forced colours: the system picks every colour, so
   the recolouring filters would only fight it (a white logo on a light
   system theme). */
@media (forced-colors: active) {
	html[data-theme="dark"] img,
	html[data-theme="dark"] .logo__wrapper-img::after {
		filter: none !important;
	}
}

/* The plugin's toggle stays in the page for its script; the AV Dock theme
   button presses it. Visually hidden, but its status region still speaks. */
#avdm-toggle {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
}
