/* The video player and the article's photo viewer in the new design (APEX; redesign P5b, release 5b-2): templates/video-dialog.php
   and photo-viewer.php, driven by youtube.js and article-gallery.js unchanged, with dialogs-next.js keeping the keyboard inside.
   Loaded by header.php on every new-design page that can open one (the homepage, a section page, Trackdays, the model page and an
   article), after site-next.css. Nothing here reads site.css: the classes are the new design's own, so the current design's
   .video-dialog and .photo-viewer rules never match, and the dialogs keep their look once a page stops loading site.css.

   Rules kept (dev plan P2/P3): every colour is a token from site-next.css, in both themes, except the two ::backdrop rules (a backdrop
   inherits no custom property before Chrome 122, Firefox 120 and Safari 17.4, the rule release 2-5 kept); no text under 12 px; no
   variable-font settings; no inline image URI; the close button is visible, with its words, and at least 44 px tall; the opening
   fade only when the reader has not asked for reduced motion. The photo viewer is dark in both themes, as the current one is. */

html.photo-viewer-open,body.video-modal-open{overflow:hidden}
.ar-dialog{padding:0;border:0;color:var(--text);overscroll-behavior:contain}
.ar-dialog:not([open]){display:none}
/* A dialog sits in the page's flow until it opens, so a page's own spacing rule for its children reached it: the article column's
   ".ar-art-main > * + *{margin-top:32px}" pushed the photo viewer 32 px down and left the site visible above it (owner, 1 December).
   Its margins are its own, at a weight no such rule reaches: the player centred, the viewer at the edges. */
.ar-dialog.ar-video{margin:auto}
.ar-dialog.ar-viewer{margin:0}
.ar-dialog__bar{display:flex;align-items:center;justify-content:space-between;gap:var(--s4);min-height:64px;padding:var(--s2) var(--s3) var(--s2) var(--s5)}
.ar-dialog__eyebrow{font:600 var(--fs-label)/1.3 var(--font-text);letter-spacing:.07em;text-transform:uppercase;color:var(--text-muted)}
.ar-dialog__close{display:inline-flex;align-items:center;gap:var(--s2);flex-shrink:0;min-width:44px;min-height:44px;padding:0 var(--s3) 0 var(--s4);border-radius:var(--r-pill);border:1px solid var(--line-control);background:var(--surface-2);font:650 var(--fs-small)/1.2 var(--font-text);color:var(--text-strong)}
.ar-dialog__close:hover{border-color:var(--text-muted);background:var(--surface-hover)}
.ar-dialog__close svg{width:20px;height:20px;flex-shrink:0}

/* ------------------------------------------------------------------ the video player */
.ar-video{width:min(1040px,calc(100% - 40px));max-width:none;max-height:calc(100dvh - 40px);overflow:auto;border-radius:var(--r-lg);border:1px solid var(--line-strong);background:var(--surface);box-shadow:var(--shadow-pop)}
.ar-video::backdrop{background:rgb(5 5 8 / .86)}
.ar-video__mount{width:100%;aspect-ratio:16/9;background:var(--viewer-bg-dim)}
.ar-video__mount iframe{display:block;width:100%;height:100%;border:0}
.ar-video__foot{display:flex;align-items:center;justify-content:space-between;gap:var(--s4) var(--s5);padding:var(--s5)}
.ar-video__foot h2{min-width:0;font:var(--weight-title) var(--fs-h4)/1.35 var(--font-title);color:var(--text-strong);overflow-wrap:anywhere}
.ar-video__actions{display:flex;flex-wrap:wrap;align-items:center;gap:var(--s1) var(--s5);flex-shrink:0;max-width:100%}
.ar-video__action{display:inline-flex;align-items:center;min-height:44px;padding:0;border:0;background:none;font:650 var(--fs-small)/1.3 var(--font-text);color:var(--text-strong);text-decoration:underline;text-decoration-color:var(--line-control);text-underline-offset:5px}
.ar-video__action:hover{color:var(--accent-ink);text-decoration-color:var(--accent)}

/* ------------------------------------------------------------------ the photo viewer: the whole screen, every photograph whole */
/* The whole viewport, exactly: pinned to its four edges with no size of its own (not 100vw/100dvh, which differ from the visible
   viewport by a scrollbar or a browser bar), in the top layer, so nothing of the page, the sticky header included, is drawn above it
   (owner, 1 December). The controls keep clear of a phone's notch and home bar (safe areas, below). */
.ar-viewer{--viewer-chrome:150px;position:fixed;inset:0;width:auto;max-width:none;height:auto;max-height:none;margin:0;padding:max(var(--s4),env(safe-area-inset-top,0px)) max(var(--s5),env(safe-area-inset-right,0px)) max(var(--s4),env(safe-area-inset-bottom,0px)) max(var(--s5),env(safe-area-inset-left,0px));background:var(--viewer-bg-dim);color:var(--viewer-ink)}
.ar-viewer::backdrop{background:rgb(0 0 0 / .73)}
.ar-viewer[open]{display:grid;grid-template-rows:auto minmax(0,1fr);gap:var(--s4)}
.ar-viewer__bar{width:min(100%,1200px);margin:0 auto;padding:0}
.ar-viewer__counter{font:650 var(--fs-small)/1.4 var(--font-text);font-variant-numeric:tabular-nums;color:var(--viewer-status-ink)}
.ar-viewer .ar-dialog__close,.ar-viewer__step{border-color:var(--viewer-button-line);background:var(--viewer-button-bg);color:var(--viewer-button-ink)}
.ar-viewer .ar-dialog__close:hover,.ar-viewer__step:hover{background:var(--viewer-button-hover)}
.ar-viewer .ar-dialog__close:focus-visible,.ar-viewer__step:focus-visible{outline:2px solid var(--viewer-focus);outline-offset:3px}
.ar-viewer__stage{display:flex;align-items:center;justify-content:center;min-width:0;min-height:0;touch-action:pan-y}
.ar-viewer__figure{display:flex;flex-direction:column;align-items:center;gap:var(--s2);min-width:0;max-width:100%;margin:0}
.ar-viewer__image{display:block;width:auto;height:auto;max-width:min(100%,1200px);max-height:calc(100dvh - var(--viewer-chrome));border-radius:var(--r-md);object-fit:contain}
.ar-viewer__credit{font-size:var(--fs-label);line-height:1.5;color:var(--viewer-status-ink);text-align:center}
.ar-viewer__status{font-size:var(--fs-small);color:var(--viewer-status-ink);text-align:center}
.ar-viewer__steps{position:absolute;top:50%;right:var(--s5);left:var(--s5);display:flex;justify-content:space-between;pointer-events:none;transform:translateY(-50%)}
.ar-viewer__step{display:grid;place-items:center;width:52px;height:52px;padding:0;border:1px solid;border-radius:50%;pointer-events:auto;cursor:pointer}
.ar-viewer__step:disabled{opacity:.3;cursor:default}
.ar-viewer__step svg{width:22px;height:22px}

@media (prefers-reduced-motion:no-preference){
  .ar-video[open]{animation:ar-dialog-rise .18s ease-out}
  .ar-viewer[open]{animation:ar-dialog-fade .16s ease-out}
}
@keyframes ar-dialog-rise{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
@keyframes ar-dialog-fade{from{opacity:0}to{opacity:1}}

@media (max-width:760px){
  .ar-viewer{--viewer-chrome:200px;padding-left:max(var(--s4),env(safe-area-inset-left,0px));padding-right:max(var(--s4),env(safe-area-inset-right,0px))}
  .ar-viewer[open]{grid-template-rows:auto minmax(0,1fr) auto}
  .ar-viewer__steps{position:static;justify-content:center;gap:var(--s5);transform:none}
  .ar-viewer__step{width:48px;height:48px}
}
@media (max-width:640px){
  .ar-video{width:calc(100% - 20px);max-height:calc(100dvh - 20px);border-radius:var(--r-md)}
  .ar-dialog__bar{padding-left:var(--s4)}
  .ar-video__foot{flex-direction:column;align-items:flex-start;padding:var(--s4)}
}
@media (max-height:550px) and (min-width:641px){
  .ar-video{width:min(640px,calc(100% - 40px))}
  .ar-video__mount{max-height:calc(100dvh - 170px)}
  .ar-video__foot{padding:var(--s3) var(--s4)}
}
