/* Nocturne cover (approved by Art 2026-10-11): a Fraktur title woven into one painted branch —
   the title lies over the painting and a registered front copy brings chosen leaves, buds and petals over the letters.
   Night swaps the painting for its registered oxblood companion through a short "failing projector" reel. */
@font-face { font-family: 'Mysterra Fraktur'; src: url('assets/unifraktur-maguntia-modern.woff2') format('woff2'); font-display: block; }

.cover--nocturne { --t: min(12.4vw, 19.5svh); --title-top: max(108px, calc(48svh - var(--t) * 1.62)); --title-day: #ddc38c; --title-night: #eadbc0; --night-filter: brightness(.8) saturate(.92) contrast(1.06); }

/* The painting and its front copy share one parallax plane; folio-motion.js drives every .cover-bouquet. */
.cover--nocturne .cover-plates { position: absolute; z-index: 2; left: 50%; top: calc(var(--title-top) - var(--t) * .62); height: calc(var(--t) * 4.35); width: auto; max-width: none; aspect-ratio: 1536 / 1024; filter: none; pointer-events: none; }
.cover--nocturne .cover-plate { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; }
.cover--nocturne .cover-plate--day { filter: saturate(.96) brightness(.68) contrast(.95); }
.cover--nocturne .cover-plate--night { opacity: 0; filter: var(--night-filter); }
body[data-theme=night] .cover--nocturne .cover-plate--day { opacity: 0; }
body[data-theme=night] .cover--nocturne .cover-plate--night { opacity: 1; }
/* Never an empty cover (beyond a night visit's 200 ms hold below): the day plate stays until a night plate has
   decoded (is-awaiting-night, also kept after a failed load) and whenever no night plate is present at all. */
body .cover--nocturne.is-awaiting-night .cover-plate--day { opacity: 1; }
body .cover--nocturne.is-awaiting-night .cover-plate--night { opacity: 0; }
body .cover--nocturne.is-awaiting-night .cover-plate { animation: none; }
/* A night visit whose plate is still on its way from the cache holds the bare ground for 200 ms instead of the
   day painting, so a plate that arrives in that time is never preceded by the pink day bloom; a slower one is
   preceded by the day plate, faded in (the index.html inline script sets is-night-visit, cover-nocturne.js clears it). */
body .cover--nocturne.is-awaiting-night.is-night-visit .cover-plate--day { animation: night-visit-hold .45s linear both !important; } /* opacity only: kept under reduced motion too */
@keyframes night-visit-hold { 0%, 44% { opacity: 0; } 100% { opacity: 1; } }
body[data-theme=night] .cover--nocturne .cover-plates:not(:has(.cover-plate--night)) .cover-plate--day { opacity: 1; }

/* Painting (z2) < title (z3) < front copy (z4), which shows only the soft-edged overlap spots below. */
.nocturne-title { position: absolute; top: var(--title-top); left: 0; width: 100%; z-index: 3; margin: 0; font-family: 'Mysterra Fraktur', 'UnifrakturMaguntia', serif; font-feature-settings: "cv03" 1; font-weight: 400; font-size: var(--t); line-height: 1.02; letter-spacing: 0; text-align: center; color: var(--title-day); text-shadow: 0 2px 3px #090d17c4, 0 0 .5em #090d1755; }
body.theme-ready .nocturne-title { transition: color .9s ease; }
.nocturne-title .ln { display: block; white-space: nowrap; }
.nocturne-title .ln:nth-child(1) { font-size: 1.04em; }
.nocturne-title .ln:nth-child(3) { font-size: 1.12em; margin-top: .02em; }
body[data-theme=night] .nocturne-title { color: var(--title-night); text-shadow: 0 2px 3px #050308d0, 0 0 .55em #3a0a14aa; }

/* Weave over the letters (V34.1, Art 2026-10-12). Over each letter, every connected patch of painting is either
   entirely in front of it or entirely behind it, so the edge seen on a letter is always a painted contour against the
   ground or the letter's own outline — never a cut through a petal or leaf. The painting is one surface: a registered
   front copy (.cover-front, z4) lies over the title's plane, so even with the text highlighted the highlight shows
   only where the painting leaves the ground bare, and a non-selectable copy of the title (.nocturne-title--front,
   aria-hidden) is drawn over it everywhere except on the patches that lie in front of the letters. Masks by
   assets/v36/build-weave-masks.py, mapped onto the painting's box: title-* (the painting minus those patches) for the
   copy, title-* plus front-* (the patches) for the front copy, so the front copy covers the title only where both
   loaded — a missing mask leaves the plain title over the painting, never hidden letters. Mask layers combine
   source-over (a + b(1 - a)), so front-* stays full across title-*'s soft edge and a few px beyond: the front copy is
   never partly transparent along a patch boundary (no highlight ring tracing a hidden letter). title-* also leaves out
   the reach of the copy's text-shadow from hidden ink, so a hidden letter part draws no shadow line on its petal. The letters' own edges
   come from the live text, so they are exact at every size. As the painting recedes on scroll (folio-motion.js
   --bouquet-depth) the whole front layer fades out by depth .3, before the painting starts moving against the type;
   at rest, under reduced motion and without JS the weave is complete. */
.cover--nocturne { --mask-title-day: url('assets/v36/title-day-wide.png'); --mask-front-day: url('assets/v36/front-day-wide.png'); --mask-title-night: url('assets/v36/title-night-wide.png'); --mask-front-night: url('assets/v36/front-night-wide.png'); --plate-h: calc(var(--t) * 4.35); --plate-x: 50%; --plate-y: calc(var(--t) * -.62); }
.cover--nocturne .cover-front { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: clamp(0, calc(1 - var(--bouquet-depth, 0) / .3), 1); }
.cover--nocturne .cover-plates--front { z-index: 4; }
.cover--nocturne .cover-plates--front .cover-plate { -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
.cover--nocturne .cover-plates--front .cover-plate--day { -webkit-mask-image: var(--mask-title-day), var(--mask-front-day); mask-image: var(--mask-title-day), var(--mask-front-day); }
.cover--nocturne .cover-plates--front .cover-plate--night { -webkit-mask-image: var(--mask-title-night), var(--mask-front-night); mask-image: var(--mask-title-night), var(--mask-front-night); }
.cover--nocturne .nocturne-title--front { z-index: 5; pointer-events: none; -webkit-user-select: none; user-select: none; text-shadow: 0 2px 3px #090d17c4;
  -webkit-mask-image: var(--mask-title-day); mask-image: var(--mask-title-day); -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-size: calc(var(--plate-h) * 1.5) var(--plate-h); mask-size: calc(var(--plate-h) * 1.5) var(--plate-h);
  -webkit-mask-position: var(--plate-x) var(--plate-y); mask-position: var(--plate-x) var(--plate-y); }
.cover--nocturne .nocturne-title--front [data-t]::before { content: attr(data-t); }
body[data-theme=night] .cover--nocturne .nocturne-title--front { text-shadow: 0 2px 3px #050308d0; }
/* The night mask follows the night plate only once it is shown (a night visit keeps the day plate until then). */
body[data-theme=night] .cover--nocturne:not(.is-awaiting-night):has(.cover-plate--night) .nocturne-title--front { -webkit-mask-image: var(--mask-title-night); mask-image: var(--mask-title-night); }
/* The highlighted title keeps its ink colour, so the selected letters match their copy over the painting. */
.cover--nocturne .nocturne-title::selection, .cover--nocturne .nocturne-title *::selection { color: var(--title-day); }
body[data-theme=night] .cover--nocturne .nocturne-title::selection, body[data-theme=night] .cover--nocturne .nocturne-title *::selection { color: var(--title-night); }

/* Portrait phones: five lines — Woven from / Light & / Wonder / Mysterra / Art. */
@media (max-width: 650px) and (orientation: portrait) {
  .cover--nocturne { --t: 17vw; --title-top: max(96px, 17svh); }
  .cover--nocturne .cover-plates { top: calc(var(--title-top) + 4svh); height: min(76svh, 132vw); left: 46%; }
  .nocturne-title { line-height: .98; }
  .nocturne-title .ln:nth-child(1) { font-size: 1em; }
  .nocturne-title .ln:nth-child(n+2) { display: contents; font-size: 1em; }
  .nocturne-title .wd { display: block; white-space: nowrap; }
  .nocturne-title .wd--light { font-size: 1.42em; }
  .nocturne-title .wd--wonder { font-size: 1.3em; }
  .nocturne-title .wd--mysterra { font-size: 1.05em; }
  .nocturne-title .wd--art { font-size: 1.6em; }
  /* The painting box relative to the title: min(76svh, 132vw) tall, 4svh lower, centred at 46% with a -43% anchor. */
  .cover--nocturne { --mask-title-day: url('assets/v36/title-day-phone.png'); --mask-front-day: url('assets/v36/front-day-phone.png'); --mask-title-night: url('assets/v36/title-night-phone.png'); --mask-front-night: url('assets/v36/front-night-phone.png'); --plate-h: min(76svh, 132vw); --plate-x: calc(46% + var(--plate-h) * .045); --plate-y: 4svh; }
}
/* Portrait tablets: a larger composition fills the taller cover. */
@media (min-width: 651px) and (orientation: portrait) {
  .cover--nocturne { --t: min(13.6vw, 19.5svh); --title-top: max(120px, calc(46svh - var(--t) * 1.62)); }
}
/* Short landscape windows and 200% zoom keep the three-line desktop composition below the header. */
@media (min-width: 651px) and (max-height: 520px) {
  .cover--nocturne { --t: min(10.5vw, 17svh); --title-top: max(92px, calc(54svh - var(--t) * 1.6)); }
  /* V36: a smaller monogram and no header rule, so the chrome clears 'Woven from'. The title and its masks do not move. */
  .home-page .brand { width: 60px; height: 60px; }
  .home-page .brand img { width: 56px; height: 56px; }
  .home-page .site-header::after { display: none; }
}
@media (max-width: 650px) and (orientation: landscape) {
  .cover--nocturne { --t: min(10.5vw, 17svh); --title-top: max(92px, calc(54svh - var(--t) * 1.6)); }
}

/* Reel: scratches, vignette and an oxblood wash. Silent by day, a quiet vignette by night. No film grain anywhere
   on the cover (client feedback 2026-10-11). */
.cover--nocturne .cover-reel { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.cover--nocturne .cover-reel i { position: absolute; inset: 0; opacity: 0; }
.cover--nocturne .reel-scratch { background-image: linear-gradient(90deg, transparent 0 22.9%, #eadfc999 22.9% 23%, transparent 23%), linear-gradient(90deg, transparent 0 61.2%, #eadfc966 61.2% 61.27%, transparent 61.27%), linear-gradient(90deg, transparent 0 83.6%, #00000099 83.6% 83.78%, transparent 83.78%); background-repeat: repeat-x; }
.cover--nocturne .reel-shade { background: radial-gradient(ellipse 75% 70% at 50% 46%, transparent 38%, #000000d9 100%); }
.cover--nocturne .reel-blood { background: #6a1222; mix-blend-mode: multiply; }
body[data-theme=night] .cover--nocturne .reel-shade { opacity: .62; }
.cover--nocturne .cover-caption { z-index: 4; }

/* To night: gate weave, two flicker cuts, a double exposure, red/cyan fringe and an oxblood wash.
   At most three luminance flashes in the first second (WCAG 2.3.1 general flash threshold). */
.cover--nocturne.is-reeling-in .cover-composition { animation: reel-weave 1.8s steps(1, end) both; }
.cover--nocturne.is-reeling-in .cover-plate--day { animation: reel-day-in 1.8s steps(1, end) both; }
.cover--nocturne.is-reeling-in .cover-plate--night { animation: reel-night-in 1.8s steps(1, end) both; }
.cover--nocturne.is-reeling-in .nocturne-title { animation: reel-type 1.8s steps(1, end) both; }
.cover--nocturne.is-reeling-in .nocturne-title--front { animation-name: reel-type-front; }
.cover--nocturne.is-reeling-in .reel-scratch { animation: reel-scratch 1.8s steps(1, end) both; }
.cover--nocturne.is-reeling-in .reel-shade { animation: reel-shade-in 1.8s steps(1, end) both; }
.cover--nocturne.is-reeling-in .reel-blood { animation: reel-blood 1.8s ease-out both; }

@keyframes reel-weave { 0% { translate: 0 0; } 4% { translate: -3px 2px; } 9% { translate: 2px -1px; } 14% { translate: 0 3px; } 20% { translate: -2px -2px; } 26% { translate: 4px 1px; } 32% { translate: -1px -3px; } 40% { translate: 2px 2px; } 48% { translate: -2px 0; } 58% { translate: 1px -1px; } 70% { translate: 0 1px; } 80%, 100% { translate: 0 0; } }
@keyframes reel-day-in { 0% { opacity: 1; } 7% { opacity: .35; } 11% { opacity: 1; } 23% { opacity: 0; } 29% { opacity: .5; } 35%, 100% { opacity: 0; } }
@keyframes reel-night-in {
  0% { opacity: 0; filter: var(--night-filter); }
  23% { opacity: 1; filter: var(--night-filter) drop-shadow(7px 0 0 #96102399) drop-shadow(-5px 0 0 #3caabe40); }
  29% { opacity: .55; filter: var(--night-filter) drop-shadow(-6px 1px 0 #96102399) drop-shadow(4px 0 0 #3caabe40); }
  35% { opacity: 1; filter: var(--night-filter) drop-shadow(4px 0 0 #96102380); }
  50% { opacity: .6; filter: var(--night-filter) drop-shadow(-3px 0 0 #96102366); }
  54% { opacity: 1; filter: var(--night-filter) drop-shadow(2px 0 0 #9610234d); }
  64%, 100% { opacity: 1; filter: var(--night-filter); }
}
@keyframes reel-type {
  0% { color: var(--title-day); }
  23% { color: var(--title-night); text-shadow: 3px 0 0 #8c0a1eb3, -2px 0 0 #46aabe59, 0 2px 3px #050308d0; }
  29% { text-shadow: -3px 0 0 #8c0a1eb3, 2px 0 0 #46aabe4d, 0 2px 3px #050308d0; }
  35% { text-shadow: 2px 0 0 #8c0a1e80, 0 2px 3px #050308d0, 0 0 .55em #3a0a14aa; }
  54%, 100% { color: var(--title-night); text-shadow: 0 2px 3px #050308d0, 0 0 .55em #3a0a14aa; }
}
@keyframes reel-type-front {
  0% { color: var(--title-day); }
  23% { color: var(--title-night); text-shadow: 3px 0 0 #8c0a1eb3, -2px 0 0 #46aabe59, 0 2px 3px #050308d0; }
  29% { text-shadow: -3px 0 0 #8c0a1eb3, 2px 0 0 #46aabe4d, 0 2px 3px #050308d0; }
  35% { text-shadow: 2px 0 0 #8c0a1e80, 0 2px 3px #050308d0; }
  54%, 100% { color: var(--title-night); text-shadow: 0 2px 3px #050308d0; }
}
@keyframes reel-scratch { 0% { opacity: 0; } 9% { opacity: .8; background-position: 0 0; } 14% { opacity: 0; } 20% { opacity: .7; background-position: -140px 0; } 26% { opacity: .2; } 32% { opacity: .75; background-position: 95px 0; } 40% { opacity: 0; } 48% { opacity: .5; background-position: -60px 0; } 58%, 100% { opacity: 0; } }
@keyframes reel-shade-in { 0% { opacity: 0; } 7% { opacity: .55; } 11% { opacity: .2; } 23% { opacity: .9; } 35% { opacity: .75; } 50% { opacity: .9; } 54%, 100% { opacity: .62; } }
@keyframes reel-blood { 0%, 34% { opacity: 0; } 36% { opacity: .7; } 46% { opacity: .3; } 58% { opacity: .1; } 70%, 100% { opacity: 0; } }

/* Back to day: a shorter flicker, the bloom returns, the reel quiets. */
.cover--nocturne.is-reeling-out .cover-composition { animation: reel-weave 1s steps(1, end) both; }
.cover--nocturne.is-reeling-out .cover-plate--night { animation: reel-night-out 1s steps(1, end) both; }
.cover--nocturne.is-reeling-out .cover-plate--day { animation: reel-day-out 1s steps(1, end) both; }
.cover--nocturne.is-reeling-out .reel-shade { animation: reel-shade-out 1s steps(1, end) both; }
@keyframes reel-night-out { 0% { opacity: 1; } 15% { opacity: .4; } 22% { opacity: 1; } 40%, 100% { opacity: 0; } }
@keyframes reel-day-out { 0%, 39% { opacity: 0; } 40% { opacity: 1; } 48% { opacity: .6; } 55%, 100% { opacity: 1; } }
@keyframes reel-shade-out { 0% { opacity: .62; } 15% { opacity: .85; } 40% { opacity: .4; } 60%, 100% { opacity: 0; } }

/* After the first paint the plates and reel ease between themes when no reel runs (e.g. reduced motion). */
body.theme-ready .cover--nocturne .cover-plate, body.theme-ready .cover--nocturne .reel-shade { transition: opacity .5s ease; }
/* An interrupted reel (a quick second theme change) lets its oxblood wash ease out instead of cutting it. */
body.theme-ready .cover--nocturne .reel-blood { transition: opacity .35s ease; }
/* Reduced motion: only that quiet crossfade — no weave, flicker, scratches or flashes. */
@media (prefers-reduced-motion: reduce) {
  body.theme-ready .cover--nocturne .cover-plate, body.theme-ready .cover--nocturne .reel-shade { transition: opacity .5s ease !important; }
  .cover--nocturne .cover-front { opacity: 1; }
}
/* A night visit whose plate is already cached opens on the night painting without a day-to-night crossfade. */
body .hero.cover--nocturne.is-settling .cover-plate { transition: none !important; }
