/* Metal Craft Engineering: the dark mode (round D3, DARK-SPEC.md). Everything hangs on html[data-theme="dark"], which only
   boot.js sets (the stored choice, localStorage.mcTheme, or on a first visit the device's setting); no attribute is the light
   site exactly as before. All of it is inside @media screen, so print stays light. Linked after d1-matrix.css, so a dark
   rule of equal weight wins by order; each rule is one step more specific than the rule it replaces. */
@media screen{

/* 1. The gunmetal tokens (DARK-SPEC 2.2). */
html[data-theme="dark"]{
  color-scheme:dark;
  --bg:#16191d;--bg-2:#1d2025;--surface:#22262c;--surface-2:#2c3037;
  --line:rgba(227,229,232,.12);--line-2:rgba(227,229,232,.22);--line-3:#7c828b;--rule:#7c828b;
  --txt:#e3e5e8;--txt-2:#b8bdc4;--txt-3:#a2a8b0;--txt-hero:#ccd0d5;--txt-ph:#8f959d;
  --accent:#e0243d;--accent-2:#c41d34;--accent-txt:#eb7081;--red-txt:#eb7081;
  --accent-a05:rgba(224,36,61,.05);--accent-a08:rgba(224,36,61,.08);--red-a08:rgba(224,36,61,.08);
  --accent-a10:rgba(224,36,61,.1);--accent-a22:rgba(224,36,61,.22);
  --tone-engineering:#e0243d;--tone-bridges:#bd5a1a;
  --warm:#e8784f;--spark-core:#ffe4c0;
  --media-bg:#22262c;--field-bg:#121418;--menu-bg:#16191d;--ftr-bg:#1d2025;--wash:#222025;
  --field-edge-hover:rgba(227,229,232,.62);--ret-case:#16191d;
  --plate-ghost:transparent;--plate-ghost-hover:rgba(227,229,232,.07);--plate-hover:rgba(227,229,232,.07);--plate-dark:transparent;
  --paper:#16191d;
  --tex-grain:url(assets/textures/board-grain-dark-v2.svg);--tex-grid:none;--tex-grid-major:none;--tex-dots:none
}
html[data-theme="dark"][data-segment="bridges"]{
  --accent:#bd5a1a;--accent-2:#a54c16;--accent-txt:#d4946a;--red-txt:#d4946a;
  --accent-a05:rgba(189,90,26,.05);--accent-a08:rgba(189,90,26,.08);--red-a08:rgba(189,90,26,.08);
  --accent-a10:rgba(189,90,26,.1);--accent-a22:rgba(189,90,26,.22);
  --warm:#e0a050;--wash:#212125
}
/* Forced colours and "more contrast": no texture in dark either (theme.css 249 says so for :root; the dark tokens above
   outrank it, so it is said again here). */
@media (forced-colors:active),(prefers-contrast:more){html[data-theme="dark"]{--tex-grain:none}}

/* 2. Hard-coded colours (DARK-SPEC 2.4). */
/* D1: the kept 1 px lines take the mid steel grey, not the text colour (d1-clear.css 186). */
html[data-theme="dark"]:not([data-bg="live"]) body>.hdr,html[data-theme="dark"]:not([data-bg="live"]) main,html[data-theme="dark"]:not([data-bg="live"]) body>.ftr{--line:var(--rule);--line-2:var(--rule);--line-3:var(--rule)}
/* D2: the card carousel's controls keep a hot-metal hover edge that reads on the dark ground (theme.css 189-190). */
html[data-theme="dark"] .carousel--cards .icon-btn{--warm:#e8784f}
html[data-theme="dark"][data-segment="bridges"] .carousel--cards .icon-btn{--warm:#e0a050}
/* D3: the hero's fades end in the dark ground (theme.css 90). */
html[data-theme="dark"] .forge~main .hero{--fade-rgb:22,25,29}
/* D3-B: the Forge stage keeps the early all-dark site's ground #09090a (the engine's BG_DARK, B2-client's --bg), behind
   the canvas, its stills and the opening screen, so nothing changes tone as the canvas fades in. The hero's shade above,
   in the page ground, fades that ground into the page at the hero's top, text side and foot. */
html[data-theme="dark"]{--intro-bg:#09090a}
html[data-theme="dark"] .forge{--bg:#09090a;background:var(--bg)}
/* D4: the projects map (map.css 11, 12, 62): stronger tints on the dark land, state borders in the ground, the land inverted. */
html[data-theme="dark"] .pmap{--tint:#4a1f27;--tint-2:#7a2533}
@supports (color:color-mix(in srgb,red 50%,blue)){html[data-theme="dark"] .pmap{--tint:color-mix(in srgb,var(--accent) 30%,var(--bg));--tint-2:color-mix(in srgb,var(--accent) 50%,var(--bg))}}
html[data-theme="dark"] .pmap-st{stroke:var(--bg)}
html[data-theme="dark"] .pmap-land{filter:invert(1)}
/* D5: client logos (pure ink in an alpha shape) draw light (style.css 419). */
html[data-theme="dark"] .logos img{filter:brightness(0) invert(.86)}
/* D6: certificate scans and PDF pages stay white paper: no rule. D7 (still matrix) is in d1-matrix.css (B-GFX). */

/* 3. The switch (DARK-SPEC 6.3): shown in both themes, only with scripts on. */
.theme-btn{display:none}
html.js .theme-btn{display:grid;flex:none;width:2.5rem;height:2.5rem;--cut:var(--cut-sm);margin-left:-16px}
@media (max-width:1199px){html.js .theme-btn{margin-left:-8px}}
@media (max-width:1099px){html.js .theme-btn{margin-left:0}}
@media (max-width:960px){html.js .theme-btn{width:44px;height:44px;--cut:var(--cut-md);margin-left:auto}html.js .hdr-in>.theme-btn+.menu-btn{margin-left:-16px}}
@media (max-width:960px) and (orientation:landscape) and (max-height:500px){html.js .hdr-in>.theme-btn{margin-left:0}}
/* D3-C (G2 F3): the switch takes 56 px of a phone header, so below 375 px the wordmark had no room and broke onto two
   lines. There the bar's gap is 12 px (the switch keeps 12 px to the menu button, as above), and below 360 px the logo
   takes the desktop header's smallest step (style.css: 1.3rem, mark zoom 1.08), so logo, switch and menu fit one line. */
@media (max-width:374px){html.js .hdr-in{gap:12px}html.js .hdr-in>.theme-btn+.menu-btn{margin-left:0}}
@media (max-width:359px){html.js .hdr .logo{font-size:1.3rem;gap:14px}html.js .hdr .mark3d{zoom:1.08}}
html.theme-swap *,html.theme-swap *::before,html.theme-swap *::after{transition:none!important}

/* 4. Image swaps for the files B-GFX renders (DARK-SPEC 5.1, 4.3). Each copies a light rule with [data-theme="dark"] added to
   its html part and sets only the image; fit, fade and size come from the light rules. No-script rules are never dark. */
/* The header mark (style.css 198, 199, 202, 207, 948), in that order of weight, so the live, hover and paused rules still win. */
html[data-theme="dark"] .mark3d::before{background-image:url(assets/img/mark3d-still-dark-v1.webp)}
html.m3-live[data-theme="dark"] .mark3d::before{background-image:url(assets/img/mark3d-sway-dark-v1.webp)}
html[data-theme="dark"]:not(.save-data) .logo:hover .mark3d::before,html[data-theme="dark"]:not(.save-data) .logo:focus-visible .mark3d::before{background-image:url(assets/img/mark3d-spin-dark-v1.webp)}
@media (prefers-reduced-motion:reduce){:is(html.m3-live,html)[data-theme="dark"] :is(.mark3d,.logo:hover .mark3d,.logo:focus-visible .mark3d)::before{background-image:url(assets/img/mark3d-still-dark-v1.webp)}}
html.mc-paused[data-theme="dark"] :is(.mark3d,.logo:hover .mark3d,.logo:focus-visible .mark3d)::before{background-image:url(assets/img/mark3d-still-dark-v1.webp)}

/* The Forge stills: the home on the from-site path (style.css 880-884). */
html.js.from-site[data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-1600.webp)}
html.js.from-site[data-segment="bridges"][data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-1600.webp)}
html.js.from-site:not([data-segment])[data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-shared-1600.webp)}
@media (min-width:1700px){html.js.from-site[data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-2560.webp)}html.js.from-site[data-segment="bridges"][data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-2560.webp)}html.js.from-site:not([data-segment])[data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-shared-2560.webp)}}
@media (orientation:portrait){html.js.from-site[data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-p-1080.webp)}html.js.from-site[data-segment="bridges"][data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-p-1080.webp)}html.js.from-site:not([data-segment])[data-theme="dark"]:not(.forge-still):not(:has(.seg-sub)) .forge::before{background-image:url(assets/img/forge/still-v13-dark-shared-p-1080.webp)}}
/* The still path: reduced motion, no WebGL, a failed engine (style.css 892-896; with scripts only, so html.forge-still). */
html.forge-still[data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-1600.webp)}
html.forge-still[data-segment="bridges"][data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-1600.webp)}
html.js.forge-still:not([data-segment])[data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-shared-1600.webp)}
@media (min-width:1700px){html.forge-still[data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-2560.webp)}html.forge-still[data-segment="bridges"][data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-2560.webp)}html.js.forge-still:not([data-segment])[data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-shared-2560.webp)}}
@media (orientation:portrait){html.forge-still[data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-p-1080.webp)}html.forge-still[data-segment="bridges"][data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-p-1080.webp)}html.js.forge-still:not([data-segment])[data-theme="dark"] .forge::before{background-image:url(assets/img/forge/still-v13-dark-shared-p-1080.webp)}}
/* The division homes while their loop starts (tabs.css 179-182). */
html.js[data-theme="dark"]:has(.seg-sub):not(.forge-still) .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-1600.webp)}
html.js[data-segment="bridges"][data-theme="dark"]:has(.seg-sub):not(.forge-still) .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-1600.webp)}
@media (min-width:1700px){html.js[data-theme="dark"]:has(.seg-sub):not(.forge-still) .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-2560.webp)}html.js[data-segment="bridges"][data-theme="dark"]:has(.seg-sub):not(.forge-still) .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-2560.webp)}}
@media (orientation:portrait){html.js[data-theme="dark"]:has(.seg-sub):not(.forge-still) .forge::before{background-image:url(assets/img/forge/still-v13-dark-eng-p-1080.webp)}html.js[data-segment="bridges"][data-theme="dark"]:has(.seg-sub):not(.forge-still) .forge::before{background-image:url(assets/img/forge/still-v13-dark-bridges-p-1080.webp)}}

}
