/* 좋은얼굴신종연치과의원 — the paper-cut vignette in a treatment page head (only pages with a vignette link this file).
   Contract: art/vignettes/CONTRACT.md. Runtime: js/vignette.js. Markup (tools/build-pages.cjs):
     <header class="sheet page-head has-vg"><div class="ph-text">crumbs, h1, lead, avail</div>
       <figure class="vg vg-open|vg-window" data-vg="<id>" style="--vg-ar: W / H; --vg-ar-p: W / H; --vg-hw-p: H / W">
         <div class="vg-stage" data-alt="…"></div><figcaption class="vg-cap">…</figcaption></figure>
       <nav class="toc">…</nav></header>
   (the runtime adds the pause button before the figcaption, and role="img" + aria-label to the stage once it is drawn)
   Desk (>= 1100 px): the figure beside the title, up to 560 px wide, in the desk aspect (--vg-ar). Stacked under the text
   (< 1100 px) it takes the phone composition and its aspect (--vg-ar-p), so the art fills its stage: the text's width up
   to 700 px on tablets and landscape phones (never taller than the screen leaves room for); on portrait phones
   (<= 600 px) the sheet's full width less 8 px a side. */

.vg { position: relative; margin: 0; }
html:not(.js) .vg { display: none; }           /* without the runtime the stage would stay empty */
.vg-stage { position: relative; overflow: hidden; width: 100%; aspect-ratio: var(--vg-ar, 560 / 340); contain: layout paint; }
.vg-in { position: absolute; inset: 0; opacity: 0; transition: opacity .6s ease; }
.vg-ready .vg-in { opacity: 1; }
.vg-stage img { position: absolute; left: 0; top: 0; max-width: none; height: auto; display: block; margin: 0;
  user-select: none; -webkit-user-select: none; pointer-events: none; }
.vg-a, .vg-b { position: absolute; inset: 0; pointer-events: none; }
.vg-p { visibility: hidden; will-change: transform; }
.vg-sh { position: absolute; left: 0; top: 0; opacity: 0; border-radius: 50%; transform-origin: 50% 50%;
  background: radial-gradient(closest-side, rgba(14, 9, 6, .6), rgba(14, 9, 6, 0)); }

/* open: the cut-outs sit straight on the page's own hanji sheet. window: a torn-edged window into the same world, with
   its own sky and a little shade inside the cut edge (the light is upper left) */
.vg-window .vg-stage { isolation: isolate;
  -webkit-mask: url(../art/sheet-mask.png?v=612134b9) center / 100% 100% no-repeat; mask: url(../art/sheet-mask.png?v=612134b9) center / 100% 100% no-repeat;
  background: radial-gradient(70% 90% at 16% 0%, rgba(255, 244, 214, .9), rgba(255, 244, 214, 0) 70%),
    linear-gradient(180deg, #EDE2CF 0%, #F4E6CB 42%, #F7E2BF 66%, #F2D9B4 100%); }
.vg-window .vg-stage::before { content: ""; position: absolute; inset: 0; background: url(../art/hanji-tile.jpg?v=e6b31083) 0 0 / 420px auto repeat;
  mix-blend-mode: multiply; opacity: .35; }
.vg-sky { position: absolute; inset: 0; }
.vg-window .vg-stage::after { content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  box-shadow: inset 7px 9px 16px -6px rgba(70, 45, 20, .32), inset -2px -3px 8px -4px rgba(70, 45, 20, .16); }

/* the caption is page text (a song line, a saying); the pause button sits at the end of its line, off the picture */
.sub .sheet .vg-cap { margin: 10px 0 0; min-height: 44px; padding: 7px 52px 0 0; font: 500 17px/1.6 var(--display); color: var(--ink-2);
  letter-spacing: -.005em; word-break: keep-all; overflow-wrap: break-word; text-wrap: balance; }
/* a 44 px target; the paper disc drawn inside it is 32 px */
.vg-toggle { position: absolute; right: 0; bottom: 0; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink); background: none; cursor: pointer; }
.vg-toggle::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: rgba(255, 255, 255, .5);
  box-shadow: inset 0 0 0 1.5px rgba(43, 38, 34, .22); }
.vg-toggle:hover::before { background: rgba(255, 255, 255, .75); box-shadow: inset 0 0 0 1.5px rgba(43, 38, 34, .45); }
.vg-toggle svg { position: relative; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.vg-toggle .vg-i-play { display: none; fill: currentColor; stroke-width: 1.4; }
.vg-toggle.is-paused .vg-i-play { display: block; }
.vg-toggle.is-paused .vg-i-pause { display: none; }
.sub main .vg-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; border-radius: 50%; }
.vg:not(.vg-ready) .vg-toggle { visibility: hidden; }
/* the still (reduced motion, at load or switched on while it plays): nothing moves, so no button. The runtime sets the
   class when it stops the loop, so the button can never vanish while frames still run */
.vg-still .vg-toggle { display: none; }
/* switched to the still while the button had the focus, the figure holds it (js/vignette.js) */
.vg:focus { outline: none; }
.sub main .vg:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .vg-in { transition: none; } .vg-p { will-change: auto; } }
.vg-shoot .vg-toggle { display: none; }
/* a vignette that cannot load (or a browser that cannot run it) shows no empty frame claiming to be a picture */
.vg.vg-failed { display: none; }

/* the page head with a vignette */
@media (min-width: 1100px) {
  .page-head.has-vg { display: grid; grid-template-columns: minmax(0, 1fr) min(560px, calc(100% - 470px)); column-gap: 40px; align-items: start; }
  .page-head.has-vg > .ph-text { grid-column: 1; grid-row: 1; }
  .page-head.has-vg > .vg { grid-column: 2; grid-row: 1; margin-top: 6px; }
  .page-head.has-vg > .toc { grid-column: 1 / -1; }
  html:not(.js) .page-head.has-vg { display: block; }   /* no runtime, no figure: no empty column beside the title */
}
/* stacked under the text (tablets, landscape phones, phones): the phone composition, in its own aspect
   (js/vignette.js: STACK), as wide as the text up to 700 px, and short enough to sit inside a landscape phone's screen */
@media (max-width: 1099.98px) {
  .vg-stage { aspect-ratio: var(--vg-ar-p, var(--vg-ar, 560 / 340)); }
  .page-head.has-vg > .vg { margin-top: 24px; max-width: min(700px, calc((100vh - 110px) / var(--vg-hw-p, .6)));
    max-width: min(700px, calc((100svh - 110px) / var(--vg-hw-p, .6))); }
}
/* portrait phones (js/vignette.js: SMALL): the sheet's full width less 8 px a side */
@media (max-width: 600px) {
  .page-head.has-vg > .vg { --vg-in: calc(clamp(24px, 4.6vw, 60px) - 8px); max-width: none; margin: 22px calc(-1 * var(--vg-in)) 0; }
  .sub .sheet .vg-cap { padding-left: var(--vg-in); padding-right: calc(var(--vg-in) + 46px); }
  .vg-toggle { right: calc(var(--vg-in) - 10px); }
}
@media print { .vg-toggle { display: none; } .vg-in { opacity: 1; transition: none; } }
