/* Listing video player (markup: Media and Videos in src/views/detail.tsx, behaviour: public/js/player.js).
   Phone videos are vertical, so everything starts from a 9:16 frame; player.js sets --vp-ratio once the poster or the video gives the real shape.

   Where it sits:
   - wide screens (900 px and more): a tall tile in the same row as the photos, at the same height (.media);
   - phones and tablets: under the photos, first as a compact card (a small moving preview and "play"), then, once pressed, as the full vertical player;
   - on its own: a centred player.
   Without JavaScript the browser's own controls stay inside the same frame. Tokens and logical properties only (docs/design-system.md).

   What tells the video from the photos is that it moves: player.js plays it without sound while it is on screen. The frame itself is
   quiet: round corners and a hairline of light (--vb wide: white to azure to honey) with a soft shadow, plus a small "video tour" tag
   and, during the silent preview, a "sound on" chip. Every size below counts --vb in, so the tile still lines up with the photos. */

/* --vh is the height of the picture: three quarters of the screen at most (--screen), so a vertical video never fills it. */
.videos{--vp-ratio:.5625;--cap:640px;--screen:100vh;--vh:min(calc(var(--screen) * .72),var(--cap));--vb:2px;--ring:#fff;display:flex;flex-direction:column;gap:1rem;width:min(100%,calc(var(--vh) * var(--vp-ratio) + 2 * var(--vb)));margin-inline:auto;border:var(--vb) solid transparent;border-radius:calc(var(--r-lg) + var(--vb));background:linear-gradient(var(--nuit),var(--nuit)) padding-box,linear-gradient(140deg,rgba(255,255,255,.95),rgba(16,151,219,.7) 38%,rgba(232,168,26,.85)) border-box;box-shadow:0 20px 46px -26px rgba(10,53,88,.6)}
@supports (height:1svh){.videos{--screen:100svh}}
.videos.is-tabs{gap:0}
.videos [hidden]{display:none !important}
.videos button:focus-visible,.videos input:focus-visible{outline-offset:-4px}

.vp{overflow:hidden;border-radius:var(--r-lg);background:linear-gradient(160deg,#0F4A78,var(--nuit) 60%);color:#fff}
.vp-stage{position:relative;aspect-ratio:var(--vp-ratio);background:var(--encre)}
.vp-stage video{display:block;width:100%;height:100%;object-fit:contain;background:var(--encre)}

/* Several videos: one frame, tabs on top */
.vp-tabs{display:flex;gap:.25rem;padding:.3rem;border-start-start-radius:var(--r-lg);border-start-end-radius:var(--r-lg);background:var(--nuit)}
.vp-tabs button{flex:1;min-height:38px;padding:0 .5rem;border:0;border-radius:var(--pill);background:transparent;color:var(--nuit-t);font:600 var(--fs-sm) / 1.2 var(--f-text);cursor:pointer}
.vp-tabs button:hover{color:#fff}
.vp-tabs button[aria-selected="true"]{background:rgba(255,255,255,.16);color:#fff;font-weight:700}
.videos.is-tabs .vp{border-start-start-radius:0;border-start-end-radius:0}

/* On the picture: the tag (top, start side) and, during the silent preview, the "sound on" chip (top, end side). Both are dark glass. */
.vp-tag,.vp-sound{position:absolute;inset-block-start:.6rem;z-index:1;display:none;align-items:center;gap:.4rem;min-height:32px;padding:0 .8rem;border:1px solid rgba(255,255,255,.3);border-radius:var(--pill);background:rgba(10,30,50,.5);color:#fff;font:700 var(--fs-xs) / 1 var(--f-text);-webkit-backdrop-filter:blur(14px) saturate(160%);backdrop-filter:blur(14px) saturate(160%)}
.vp-tag{inset-inline-start:.6rem;letter-spacing:var(--track);text-transform:var(--caps);pointer-events:none}
.vp-sound{inset-inline-end:.6rem;min-height:44px;padding-inline:.9rem;font-size:var(--fs-sm);cursor:pointer}
.vp-sound:hover{background:rgba(10,30,50,.75)}
.videos.is-ready .vp-tag{display:inline-flex}
.videos.is-ready .vp.is-preview.is-playing .vp-sound{display:inline-flex}
.vp.is-playing:not(.is-preview) .vp-tag,.vp.is-full .vp-tag{display:none}
/* narrow tiles (a vertical video beside the photos): the chip moves under the tag instead of running into it */
@container (max-width:20rem){.vp-sound{inset-block-start:3rem;inset-inline:.6rem auto}}
.vp-stage{container-type:inline-size}

/* Big play button, centred whatever the direction (inset + auto margins, no left/translate). */
.vp-big{position:absolute;inset:0;display:grid;place-items:center;width:76px;height:76px;margin:auto;padding:0;border:1px solid rgba(255,255,255,.7);border-radius:50%;background:rgba(10,30,50,.45);color:#fff;cursor:pointer;-webkit-backdrop-filter:blur(14px) saturate(160%);backdrop-filter:blur(14px) saturate(160%);transition:background .2s,transform .2s var(--ease)}
.vp-big:hover{background:rgba(6,102,185,.85);transform:scale(1.05)}
.vp-big .icon{width:30px;height:30px}
.vp-big-text{display:none}
.vp.is-playing .vp-big,.vp.is-waiting .vp-big{display:none}
.vp-i{display:contents}
.vp-i-play .icon,.vp-i-pause .icon{fill:currentColor}

/* Loading ring: between pressing play and the first picture */
.vp.is-waiting .vp-stage::after{content:"";position:absolute;inset:0;width:44px;height:44px;margin:auto;border:4px solid rgba(255,255,255,.35);border-block-start-color:#fff;border-radius:50%;pointer-events:none}
@media (prefers-reduced-motion:no-preference){.vp.is-waiting .vp-stage::after{animation:vp-spin .9s linear infinite}}
@keyframes vp-spin{to{transform:rotate(360deg)}}

.vp-err{position:absolute;inset:0;z-index:2;display:grid;place-items:center;margin:0;padding:1.5rem;background:var(--encre);color:#fff;font:600 var(--fs-sm) / 1.5 var(--f-text);text-align:center}

/* Controls under the picture, never over it: the whole frame stays visible, and there is nothing to auto-hide. Two rows, 92 px in all. */
.vp-bar{display:flex;flex-wrap:wrap;align-items:center;padding:0 .35rem .25rem}
.vp-btn{display:grid;flex:none;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:50%;background:transparent;color:#fff;cursor:pointer}
.vp-btn:hover{background:rgba(255,255,255,.14)}
.vp-btn .icon{width:22px;height:22px}
.vp-time{flex:1 1 0;min-width:0;margin-inline-start:.25rem;overflow:hidden;font:600 var(--fs-sm) / 1 var(--f-text);font-variant-numeric:tabular-nums;white-space:nowrap}

/* Which icon shows */
.vp-i-pause,.vp-i-mute,.vp-i-collapse{display:none}
.vp.is-playing .vp-bar .vp-i-play,.vp.is-muted .vp-i-volume,.vp.is-full .vp-i-expand{display:none}
.vp.is-playing .vp-bar .vp-i-pause,.vp.is-muted .vp-i-mute,.vp.is-full .vp-i-collapse{display:contents}

/* The timeline always runs left to right (as in every player, also in Arabic), hence dir="ltr" on the input and the physical keyword below. */
.vp-seek{--p:0%;flex:0 0 calc(100% - 1rem);min-width:0;height:44px;margin-block:0;margin-inline:.5rem;padding:0;background:transparent;cursor:pointer;-webkit-appearance:none;appearance:none}
.vp-seek:disabled{opacity:.5;cursor:default}
.vp-seek::-webkit-slider-runnable-track{height:6px;border-radius:3px;background:linear-gradient(to right,var(--miel) var(--p),rgba(255,255,255,.3) var(--p))}
.vp-seek::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;margin-block-start:-5px;border:0;border-radius:50%;background:#fff}
.vp-seek::-moz-range-track{height:6px;border-radius:3px;background:rgba(255,255,255,.3)}
.vp-seek::-moz-range-progress{height:6px;border-radius:3px;background:var(--miel)}
.vp-seek::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:#fff}

/* ---- Beside the photos (wide screens). --mh is the height of the row: the photos take it, and so does the video tile
   (picture + 92 px of controls, + 44 px of tabs when there are several videos, + the frame). The picture's width follows its shape; a landscape
   video is held to a share of the row and letterboxed, so the photos keep most of the room. */
.media>.videos{margin-block-start:10px}
@media (min-width:900px){
.media{--mh:clamp(300px,54vw,640px);display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px}
.media>.gallery .gallery-track,.media>.gallery-empty{height:var(--mh)}
.media>.videos{--sh:calc(var(--mh) - 92px - 2 * var(--vb));justify-content:center;width:max(240px,min(calc(var(--sh) * var(--vp-ratio) + 2 * var(--vb)),42vw,560px));margin:0;gap:6px}
.media>.videos.is-tabs{--sh:calc(var(--mh) - 136px - 2 * var(--vb));gap:0}
.media .vp-stage{height:var(--sh);aspect-ratio:auto}
}

/* ---- Phones and tablets, before the first press: a compact card. At the start side the video itself, small and whole, playing without
   sound; beside it the words and a play disc. The whole card is one button (.vp-big covers it); pressing it opens the player at its real,
   vertical shape, from the start and with sound. Only once the script runs: without it the native player shows. */
@media (max-width:899.98px){
/* Opened, the whole player must fit between the fixed header and the floating contact bar: the picture gives up what its own controls
   (92 px), the frame (4 px), the contact bar (76 px), the gap under the header (1rem, the site's scroll-padding) and, with several
   videos, the tabs (44 px) need. player.js scrolls it under the header. */
.videos{--chrome:188px;--vh:min(calc(var(--screen) * .72),var(--cap),calc(var(--screen) - var(--header-h,76px) - var(--chrome) - env(safe-area-inset-bottom,0px)))}
.videos.is-tabs{--chrome:232px}
.videos.is-ready:not(.is-open){--mini:clamp(4.4rem,calc(8.25rem * var(--vp-ratio)),10.5rem);width:100%}
.videos.is-ready:not(.is-open) .vp-tabs,.videos.is-ready:not(.is-open) .vp-bar,.videos.is-ready:not(.is-open) .vp-tag,.videos.is-ready:not(.is-open) .vp.is-preview .vp-sound{display:none}
.videos.is-ready:not(.is-open) .vp{border-radius:var(--r-lg)}
.videos.is-ready:not(.is-open) .vp-stage{display:flex;align-items:center;height:auto;aspect-ratio:auto;padding:.55rem;background:none}
.videos.is-ready:not(.is-open) .vp-stage video{flex:none;width:var(--mini);height:8.25rem;border-radius:calc(var(--r-lg) - .45rem);object-fit:cover}
.videos.is-ready:not(.is-open) .vp-big{display:flex;align-items:center;justify-content:space-between;gap:.9rem;width:100%;height:100%;margin:0;padding-inline:calc(var(--mini) + 1.5rem) 1.1rem;border:0;border-radius:0;background:none;-webkit-backdrop-filter:none;backdrop-filter:none;font:700 1.125rem / 1.25 var(--f-text);text-align:start;transform:none}
.videos.is-ready:not(.is-open) .vp-big .vp-i{order:2;display:grid;flex:none;place-items:center;width:52px;height:52px;border-radius:50%;background:#fff;color:var(--nuit);box-shadow:0 6px 18px -6px rgba(0,0,0,.5)}
.videos.is-ready:not(.is-open) .vp-big .icon{width:24px;height:24px}
.videos.is-ready:not(.is-open) .vp-big-text{display:grid;gap:.25rem;min-width:0}
.videos.is-ready:not(.is-open) .vp-big-text small{font:700 var(--fs-xs) / 1.2 var(--f-text);letter-spacing:var(--track);text-transform:var(--caps);color:var(--miel)}
}

/* Full screen: the frame fills the screen, the picture is centred, the controls stay at the bottom */
.vp:fullscreen{display:flex;flex-direction:column;width:100%;height:100%;border-radius:0}
.vp:fullscreen .vp-stage{flex:1;width:auto;height:auto;min-height:0;aspect-ratio:auto}
.vp:-webkit-full-screen{display:flex;flex-direction:column;width:100%;height:100%;border-radius:0}
.vp:-webkit-full-screen .vp-stage{flex:1;width:auto;height:auto;min-height:0;aspect-ratio:auto}
