/* The portrait (spec 7.1.2), drawn by tools/portrait_art.py: three one-colour drawings used as masks,
   so the theme colours them. The page gives each its addresses as custom properties:
     --portrait-squares       the squares, for light themes
     --portrait-squares-dark  the squares where the picture is light, for dark themes
     --portrait-lines         the lines along the strongest edges
   and marks it up as
     <figure class="portrait" role="img" aria-label="Portrait of …" data-slug="…">
       <span class="portrait-cover" aria-hidden="true"></span><span class="portrait-line" aria-hidden="true"></span>
     </figure>
   The squares are Primary, the lines Primary mixed half into the page's ground: every colour opaque.
   A square frame, 4:5; no ground of its own, so the page shows through. */
.portrait { position: relative; margin: 0; width: 100%; aspect-ratio: 4 / 5; }
.portrait::before, .portrait::after { content: ""; position: absolute; inset: 0;
  -webkit-mask: var(--pm) center / 100% 100% no-repeat; mask: var(--pm) center / 100% 100% no-repeat; }
.portrait::before { --pm: var(--portrait-squares); background: var(--bluewell-primary); }
.portrait::after { --pm: var(--portrait-lines); background: color-mix(in srgb, var(--bluewell-primary) 50%, var(--bluewell-paper)); }
html[data-theme$="-dark"] .portrait::before { --pm: var(--portrait-squares-dark); }

/* Drawn in by a scan (web/portrait.js starts it): top to bottom in 0.7 s, once, a faint Primary
   hairline at its edge (1 px, under half strength) that fades before the foot. The drawing never
   moves or clips: a cover in the page's ground hides it while it loads and is painted, then shrinks
   toward the foot, the hairline riding its top edge. Both are transforms, which a browser moves
   without drawing the portrait again (a drawing of twenty thousand squares cannot be redrawn every
   frame). With reduced motion the portrait is simply there. */
.portrait-cover, .portrait-line { position: absolute; pointer-events: none; }
.portrait-cover { inset: -1px; z-index: 2; background: var(--bluewell-paper); transform-origin: 50% 100%; transform: scaleY(0); }
.portrait-line { inset: 0; z-index: 3; border-top: 1px solid var(--bluewell-primary); opacity: 0; }
.portrait.portrait-wait .portrait-cover { transform: scaleY(1); }
.portrait.scan .portrait-cover { animation: portrait-cover 700ms cubic-bezier(0.3, 0.15, 0.35, 1) both; }
.portrait.scan .portrait-line { animation: portrait-line 700ms cubic-bezier(0.3, 0.15, 0.35, 1) both; }
@keyframes portrait-cover { from { transform: scaleY(1); } to { transform: scaleY(0); } }
@keyframes portrait-line { 0% { transform: translateY(0); opacity: 0.45; } 60% { opacity: 0.45; }
  100% { transform: translateY(100%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .portrait.scan .portrait-cover, .portrait.scan .portrait-line { animation: none; }
}
