/* The image viewer (public/js/image-viewer.js): a user's images over the page, in the intermission's colours
   (public/css/intermission.css): a dark, blurred plum, its pink gradient and glow, white rings, Poppins.
   Top bar, stage, caption and strip share one column (1100 px at most), so the arrows stand on the same lines as the
   avatar (left) and the close button (right). */
html.iv-locked { overflow: hidden; }
/* A touch screen: the page is not held by overflow (iOS Safari then grows or shrinks its bars, and the page changes
   size just before the picture moves); the viewer takes the touches itself, so nothing scrolls under it. */
@media (hover: none) {
  html.iv-locked { overflow: visible; }
  .iv { touch-action: none; overscroll-behavior: contain; }
}
/* What opens the viewer gets no tap flash on a phone (iOS greys a tapped link for a moment, just before the picture moves). */
.horizontalMasonry a, .p6-masonry-item, .p6-avatar-wrapper, .p6-act-clickable { -webkit-tap-highlight-color: transparent; } /* image-viewer.js puts the scrollbar's width back as padding (where it takes room), so nothing moves */
.iv { position: fixed; inset: 0 auto 0 0; width: 100vw; z-index: 10000; /* 100vw: over the scrollbar's place too (its room is kept while the page is held) */ display: grid; grid-template-rows: auto 1fr auto auto; gap: 10px; padding: 14px 18px 16px; box-sizing: border-box;
  font-family: Poppins, sans-serif; color: #fff;
  background: radial-gradient(120% 90% at 50% 40%, rgba(61, 26, 69, .9), rgba(20, 8, 24, .96)); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 0; transition: opacity .3s ease; }
.iv.in { opacity: 1; }
/* Without view transitions: the viewer fades in, the bar, caption, strip and arrows a moment after (in place: nothing
   moves under the mouse), and they go at once on closing. Until they are there ("ready") they take no clicks: a click
   where they are not seen yet closes, as on the dark. (With view transitions, see the end of this file.) */
.iv-top, .iv-foot, .iv-strip { transition: opacity .3s ease .14s; }
.iv:not(.in) :is(.iv-top, .iv-foot, .iv-strip) { opacity: 0; }
.iv:not(.in) :is(.iv-top, .iv-foot, .iv-strip, .iv-arrow) { transition-delay: 0s; transition-duration: .18s; }
.iv:not(.ready) :is(.iv-top, .iv-foot, .iv-strip, .iv-arrow) { pointer-events: none; }
.iv > * { width: 100%; max-width: 1100px; margin: 0 auto; box-sizing: border-box; }

/* Whose images: the avatar in a ring of their colour, the name, how many images. */
.iv-top { display: flex; align-items: center; gap: 12px; }
.iv-who { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.iv-avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; padding: 2px; box-sizing: border-box; background: var(--g); box-shadow: 0 0 14px color-mix(in srgb, var(--g) 70%, transparent); }
.iv-avatar img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #1a0a1f; box-sizing: border-box; background: #fff; }
.iv-id { display: flex; flex-direction: column; min-width: 0; }
.iv-name { font: 700 17px/1.2 Poppins, sans-serif; color: #fff; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iv-name:hover { text-decoration: underline; }
.iv-stats { font: 400 12.5px/1.3 Poppins, sans-serif; color: rgba(255, 255, 255, .68); white-space: nowrap; min-height: 1.3em; }
.iv-x { width: 40px; height: 40px; flex: none; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .12); color: #fff; transition: background .2s, transform .2s; }
.iv-x:hover { background: rgba(255, 255, 255, .22); transform: rotate(90deg); }
.iv-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* The stage: the picture's size is set by image-viewer.js (fit: a little larger than "contain", cut evenly at the edges). */
.iv-stage { position: relative; min-height: 0; }
.iv-pic { position: absolute; inset: 0 56px; display: grid; place-items: center; pointer-events: none; }
/* The frame is the part of the picture shown (its window: corners, shadow); the picture inside keeps its whole size,
   centred, the frame cutting what sticks out. Both sized by image-viewer.js. */
.iv-frame { display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); pointer-events: auto; background: #1a0a1f;
  transition: box-shadow .3s ease, background-color .3s ease; }
/* While a view transition runs the frame is part of the page's picture (only the picture inside moves): no shadow and
   no ground then, or they would show at the end place before the picture is there; they come back softly after. */
:root[data-iv-vt] .iv-frame { box-shadow: 0 24px 60px transparent; background-color: transparent; transition: none; }
.iv-img { display: block; flex: none; max-width: none; max-height: none; object-fit: fill; }
/* The arrows: the intermission's button (.cta-button) as a round one, white ring, pink glow; flush with the avatar's and
   the close button's outer edges. */
.iv-arrow { position: absolute; top: calc(50% - 20px); z-index: 2; width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 2px solid #fff; cursor: pointer;
  color: #fff; background: linear-gradient(135deg, #ff2d78 0%, #ff5a9d 100%); box-shadow: 0 8px 25px rgba(255, 45, 120, .5), 0 2px 6px rgba(0, 0, 0, .3);
  transition: transform .2s, box-shadow .2s, opacity .3s ease .14s; }
.iv:not(.in) .iv-arrow { opacity: 0; }
.iv-arrow::before { content: ''; position: absolute; inset: 0; margin: auto; box-sizing: border-box; width: 12px; height: 12px; border: solid currentColor; border-width: 3px 3px 0 0; border-radius: 1px; }
.iv-arrow.next::before { rotate: 45deg; translate: -3px 0; } .iv-arrow.prev::before { rotate: -135deg; translate: 3px 0; }
.iv-arrow:hover { transform: translateY(-2px); box-shadow: 0 12px 35px rgba(255, 45, 120, .5), 0 3px 8px rgba(0, 0, 0, .3); }
.iv-arrow:hover::after { content: ''; position: absolute; left: -2px; right: -2px; top: 100%; height: 4px; } /* keeps the lifted arrow under a mouse at its bottom edge */
.iv-arrow.prev { left: 0; } .iv-arrow.next { right: 0; }

/* The caption in the middle, the count at the right. */
.iv-foot { position: relative; min-height: 1.4em; padding: 0 70px; }
.iv-cap { margin: 0; text-align: center; font: 400 13.5px/1.4 Poppins, sans-serif; color: rgba(255, 255, 255, .82); }
.iv-count { position: absolute; right: 0; top: 0; font: 500 12px Poppins, sans-serif; color: rgba(255, 255, 255, .6); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* All the user's images. */
.iv-strip { display: flex; gap: 8px; justify-content: safe center; overflow-x: auto; scrollbar-width: none; padding: 6px 4px; }
.iv-strip::-webkit-scrollbar { display: none; }
.iv-thumb { position: relative; flex: none; display: block; width: 58px; height: 58px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: pointer; opacity: .6;
  background: #2d1233; outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .2s, opacity .2s, transform .2s; }
.iv-thumb img, .iv-thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.iv-thumb:hover { transform: translateY(-2px); opacity: 1; }
.iv-thumb.on { opacity: 1; outline-color: #ff5a9d; box-shadow: 0 0 14px rgba(255, 45, 120, .55); }
/* A video without a picture of its own: a play sign on top. */
.iv-thumb.vid::after { content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: rgba(0, 0, 0, .45); }
.iv-thumb.vid::before { content: ''; position: absolute; z-index: 1; left: 50%; top: 50%; width: 7px; height: 9px; margin: -4.5px 0 0 -2.5px; background: #fff; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.iv-x:focus-visible, .iv-thumb:focus-visible, .iv-arrow:focus-visible { outline: 2px solid #ff5a9d; outline-offset: 2px; }

/* One image only (an avatar, a single upload): no arrows, no strip. */
.iv.single .iv-arrow, .iv.single .iv-strip { display: none; }
.iv.single .iv-pic { inset: 0; }

/* A phone: the picture from edge to edge with all the height there is; a slimmer top, caption and strip; swipe for the arrows. */
@media (max-width: 600px), (hover: none) {
  .iv { backdrop-filter: none; -webkit-backdrop-filter: none; } /* behind 90-96 % plum it hardly shows, and a phone pays for it every frame */
  .iv-pic { inset: 0; }
  .iv-arrow { display: none; }
}
@media (max-width: 600px) {
  /* A phone: calm, the picture and little else. No strip of images (one swipes to the next; the count says where one
     is), the caption and the count on one quiet line, the picture from edge to edge. */
  .iv { grid-template-rows: auto 1fr auto; padding: 8px 0 14px; gap: 8px; background: radial-gradient(120% 90% at 50% 40%, #3d1a45, #140818); } /* whole: the page does not show through */
  .iv-strip { display: none; }
  .iv-top, .iv-foot { padding-left: 12px; padding-right: 12px; }
  .iv-avatar { width: 38px; height: 38px; }
  .iv-name { font-size: 15px; }
  .iv-x { width: 36px; height: 36px; }
  .iv-frame { border-radius: 0; box-shadow: none; }
  .iv-foot { padding: 0 64px; }
  .iv-cap { font-size: 13px; color: rgba(255, 255, 255, .75); }
  .iv-count { right: 12px; }
}
}

/* --- View transitions (image-viewer.js, document.startViewTransition) ----------------------------------------------
   The picture carries the name "iv-photo" from its tile to the stage, back, and from one image to the next: the browser
   moves and sizes it, both its pictures fill the moving box ("cover", so the crop changes along the way), and
   image-viewer.js clips the pair (a tile partly out of sight, the corners) and times it. The page under the viewer is
   the root, crossfading as the dark comes and goes. The bar, caption, strip and arrows have names of their own: they
   fade in a moment after the picture has set off, and go at once; between two images they stay, their words crossfade.
   html[data-iv-vt] is the kind: open, close or step. */
.iv-top { view-transition-name: iv-top; }
.iv-foot { view-transition-name: iv-foot; }
.iv-strip { view-transition-name: iv-strip; }
.iv-arrow.prev { view-transition-name: iv-prev; }
.iv-arrow.next { view-transition-name: iv-next; }
::view-transition-group(iv-photo) { animation-duration: .45s; animation-timing-function: cubic-bezier(.2, .85, .25, 1); }
:root[data-iv-vt="close"]::view-transition-group(iv-photo) { animation-duration: .4s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
:root[data-iv-vt="step"]::view-transition-group(iv-photo) { animation-duration: .35s; animation-timing-function: cubic-bezier(.3, .7, .2, 1); }
::view-transition-old(iv-photo), ::view-transition-new(iv-photo) { height: 100%; object-fit: cover; animation-duration: inherit; animation-timing-function: ease; }
/* Opening and closing it is one picture, whole and in the same proportions at both ends (image-viewer.js), so its two
   snapshots lie exactly on each other: they swap where it leaves (opening: the first 0.12 s) and where it lands
   (closing: the last 0.12 s), so each end shows exactly what the page does there (a border, a ring), and nothing shows
   twice on the way. Between two images the new one comes over the old one.
   Never two half-faded pictures at once: Safari does not add them up to a whole (no plus-lighter), so the page shows
   through and the screen blinks. So the one that comes fades in over the other, which stays whole under it and goes
   only once it is covered (on closing the old one is on top and fades off the new one). */
::view-transition-old(iv-photo), ::view-transition-new(iv-photo), ::view-transition-old(root), ::view-transition-new(root) { mix-blend-mode: normal; }
:root[data-iv-vt="open"]::view-transition-new(iv-photo) { animation: iv-in .12s ease both; }
:root[data-iv-vt="open"]::view-transition-old(iv-photo) { animation: iv-out .01s linear .12s both; }
:root[data-iv-vt="close"]::view-transition-old(iv-photo) { z-index: 1; animation: iv-out .12s ease .28s both; }
:root[data-iv-vt="close"]::view-transition-new(iv-photo) { animation: none; }
:root[data-iv-vt="step"]::view-transition-new(iv-photo) { animation: iv-in .3s ease both; }
:root[data-iv-vt="step"]::view-transition-old(iv-photo) { animation: iv-out .01s linear .3s both; }
/* The page (under the dark): the new state fades in over the old one; on closing the viewer fades off the page. */
::view-transition-old(root) { animation: none; }
::view-transition-new(root) { animation: iv-in .3s ease both; }
:root[data-iv-vt="close"]::view-transition-old(root) { z-index: 1; animation: iv-out .3s ease both; }
:root[data-iv-vt="close"]::view-transition-new(root) { animation: none; }
::view-transition-new(iv-top):only-child,
::view-transition-new(iv-foot):only-child,
::view-transition-new(iv-strip):only-child,
::view-transition-new(iv-prev):only-child,
::view-transition-new(iv-next):only-child { animation: iv-in .3s ease .14s both; }
::view-transition-old(iv-top):only-child,
::view-transition-old(iv-foot):only-child,
::view-transition-old(iv-strip):only-child,
::view-transition-old(iv-prev):only-child,
::view-transition-old(iv-next):only-child { animation: iv-out .18s ease both; }
::view-transition-group(iv-top), ::view-transition-group(iv-foot), ::view-transition-group(iv-strip), ::view-transition-group(iv-prev), ::view-transition-group(iv-next) { animation-duration: .3s; }
/* What lies over the picture in its place (the wall's name, the gallery's caption, the avatar's badges; class
   "iv-over", named by image-viewer.js) stays over the moving picture: what goes with the tile goes at once when the
   picture leaves, and comes just before it lands (0.4 s); what stays (the avatar's badges) just stays. */
::view-transition-group(*.iv-over) { z-index: 3; }
::view-transition-old(*.iv-over):only-child { animation: iv-out .12s ease both; }
::view-transition-new(*.iv-over):only-child { animation: iv-in .14s ease .27s both; }
@keyframes iv-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes iv-out { from { opacity: 1; } to { opacity: 0; } }
