/* Image viewer opened by the links marked "data-lightbox" (script: src/assets/lightbox.js).
   The background takes the colours of the site (ocean, peacock, plum, olivine). A thin bar at the top holds
   the logo (centre) and the close button (right), a thin bar at the bottom the counter (centre); the image
   takes all the room left. Up to 1100px wide, the previous / next post buttons are at the bottom, on each side of
   the counter; phones (up to 700px wide) show the image and its text in one column, centred. */

/* The viewer covers the whole screen, under the browser's bars too: the iPhone's Safari draws the page under its
   bottom bar, even lower than "100lvh" when the bar is small, so the viewer goes 6rem further down (nothing to see
   there, it is only its background). Its contents (.lightbox-frame) stay in the part really visible:
   --lightbox-height, the window's height measured by lightbox.js ("100dvh" until then). The colours are on the
   viewer itself, the blur of the page on its backdrop. */
.lightbox {
  box-sizing: border-box;
  top: 0;
  bottom: auto;
  width: 100vw;
  max-width: 100vw;
  height: calc(100vh + 6rem);
  height: calc(100lvh + 6rem);
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background:
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(24, 96, 107, 0.6), transparent 70%),
    radial-gradient(ellipse 70% 60% at 100% 100%, rgba(72, 49, 102, 0.6), transparent 70%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(160, 186, 149, 0.2), transparent 70%),
    rgba(14, 33, 58, 0.8);
  color: #fff;
  overflow: hidden;
}

.lightbox::backdrop {
  background: transparent;
  backdrop-filter: blur(3px);
}

html:has(.lightbox[open]) {
  overflow: hidden;
}

.lightbox [hidden] {
  display: none !important;
}

.lightbox button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.lightbox button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* The top bar (logo, close button; 3rem + 6px high) and the bottom bar (counter; 3rem high). */
.lightbox-post-status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  font-size: 0.85rem;
  line-height: 3rem;
  text-align: center;
  opacity: 0.75;
  pointer-events: none;
}

.lightbox-logo {
  position: absolute;
  top: calc((3rem + 6px - 1.9rem) / 2); /* as much room under the logo as above it */
  left: 50%;
  width: 1.9rem;
  height: 1.9rem;
  margin: 0 0 0 -0.95rem;
  opacity: 0.85;
  pointer-events: none;
}

.lightbox-close {
  position: absolute;
  top: calc((3rem + 6px - 2.25rem) / 2);
  right: calc((3rem + 6px - 2.25rem) / 2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

/* No circle around the cross: it lights up on hover and when it has the focus. */
.lightbox .lightbox-close:hover,
.lightbox .lightbox-close:focus-visible {
  opacity: 1;
  outline: none;
}

.lightbox-close svg {
  display: block;
}

.lightbox-frame {
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: var(--lightbox-height, 100dvh);
  padding: calc(3rem + 6px) 4.75rem 3rem;
}

.lightbox-panel {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: rgb(22, 53, 87);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.4);
}

.lightbox-media {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  background: rgba(0, 0, 0, 0.25);
}

/* The image's height: the screen minus the top and bottom bars (6rem + 6px), and minus some room for the text
   (lightbox.js then fits the image and the text under it exactly). */
.lightbox-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(var(--lightbox-height, 100dvh) - 6rem - 6px - 5rem);
  margin: 0;
  object-fit: contain;
  transition: opacity 0.2s;
}

.lightbox.no-text .lightbox-image {
  max-height: calc(var(--lightbox-height, 100dvh) - 6rem - 6px);
}

.lightbox-image.is-loading {
  opacity: 0.3;
}

/* A video: shown like an image. In a post, its own buttons (lightbox.js): a big "play" button while it is paused,
   the sound in a corner, and a thin progress bar along the bottom. Elsewhere, the player's usual buttons, so the dots
   (which would cover them) are not shown. */
.lightbox-video {
  background: #000;
}

.lightbox.is-post .lightbox-video {
  cursor: pointer;
}

.lightbox.is-video:not(.is-post) .lightbox-dots {
  display: none;
}

.lightbox-play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  margin: -2rem 0 0 -2rem !important;
  border-radius: 50%;
  background: rgba(9, 22, 42, 0.6) !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.lightbox.is-paused .lightbox-play {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-sound {
  position: absolute;
  right: 0.75rem;
  bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(9, 22, 42, 0.6) !important;
  transition: background 0.2s;
}

.lightbox-sound:hover {
  background: rgba(9, 22, 42, 0.9) !important;
}

.lightbox-sound .lightbox-sound-off,
.lightbox-sound.is-off .lightbox-sound-on {
  display: none;
}

.lightbox-sound.is-off .lightbox-sound-off {
  display: inline;
}

/* The bar is 3px high, and 16px to touch: a click or a drag on it moves in the video. */
.lightbox-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  cursor: pointer;
  touch-action: none;
}

.lightbox-progress::before,
.lightbox-progress-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  content: '';
}

.lightbox-progress::before {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-progress-bar {
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
}

.lightbox-progress:hover::before,
.lightbox-progress:hover .lightbox-progress-bar,
.lightbox-progress:focus-visible::before,
.lightbox-progress:focus-visible .lightbox-progress-bar {
  height: 5px;
}

.lightbox-progress:focus-visible {
  outline: none;
}

/* The dots stay above the progress bar. */
.lightbox.is-post.is-video .lightbox-dots {
  bottom: 1.6rem;
}

/* Previous / next image of a post: the same round outlined icons as the post buttons (white, lavender on hover), on
   the image itself, over a semi-transparent navy disc like the dots, so they stand out on any image, light or dark.
   Smaller than the previous / next post buttons, so the two are never mistaken for each other. (Outside the posts,
   the images of a series change with the big buttons at the edges of the screen.) */
.lightbox-arrow {
  position: absolute;
  z-index: 1;
  top: 50%;
  width: 2.5rem;
  height: 2.5rem;
  margin-top: -1.25rem !important;
  border-radius: 50%;
  background: rgba(22, 53, 87, 0.55) !important; /* the frame's blue, semi-transparent */
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: color 0.2s;
}

.lightbox-arrow > span {
  display: none;
}

/* The site's own "previous / next" icon, as on the post buttons. */
.lightbox-arrow::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: currentColor;
  -webkit-mask: url("images/btn-next.svg") center / contain no-repeat;
  mask: url("images/btn-next.svg") center / contain no-repeat;
}

.lightbox-prev::before {
  -webkit-mask-image: url("images/btn-prev.svg");
  mask-image: url("images/btn-prev.svg");
}

.lightbox-arrow:hover,
.lightbox-arrow:focus-visible {
  color: #cbb6e7 !important; /* lavande */
}

.lightbox-prev {
  left: 0.75rem;
}

.lightbox-next {
  right: 0.75rem;
}

/* Sliding to the next image (lightbox.js): the box of the image has a set size and hides what goes past its sides
   (nothing passes over the text); the images in it are placed by the script. */
.lightbox-media.is-sliding {
  flex: none;
  overflow: hidden;
}

.lightbox-media.is-sliding > .lightbox-image {
  position: absolute;
  max-width: none;
  max-height: none;
}

/* The image leaving, while the next image slides in against it (lightbox.js). */
.lightbox-ghost {
  position: absolute;
  max-width: none;
  max-height: none;
  margin: 0;
  object-fit: contain;
  pointer-events: none;
}

/* The images move by a transform while they slide: the browser moves them without laying the viewer out again. */
.lightbox-media.is-sliding > .lightbox-image,
.lightbox-media.is-sliding > .lightbox-ghost {
  will-change: transform;
}

/* While the viewer is open, the stars of the page behind it stop twinkling: the blurred page under the viewer does
   not have to be drawn again at every image of an animation. */
html:has(.lightbox[open]) .galaxies-vivantes .etoile {
  animation-play-state: paused;
}

/* Which image of the post: dots in a small dark pill, readable on a white image too. */
.lightbox-dots {
  position: absolute;
  z-index: 1;
  bottom: 0.75rem;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0 auto;
  padding: 0.4rem 0.65rem;
  border-radius: 1rem;
  background: rgba(22, 53, 87, 0.55); /* navy, as the image arrows */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.lightbox-dots:empty {
  display: none;
}

.lightbox-dots span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transition:
    width 0.2s,
    background 0.2s;
}

.lightbox-dots span.is-current {
  width: 1.1rem;
  border-radius: 0.25rem;
  background: #fff;
}

/* Caption or post description. */
.lightbox-text {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
  padding: 0.7rem 1rem;
  /* Never under 17px, also on phones (whose rem is smaller); its strokes as the text's (style.css, Typography):
     about 1.2px at this size. */
  font-size: max(1.125rem, 17px);
  font-variation-settings: 'wdth' 120, 'XOPQ' 67, 'YOPQ' 66;
  line-height: 140%;
}

/* Bold: thicker strokes (the site's bold keeps the weight of the text, style.css). */
.lightbox-text strong,
.lightbox-text b {
  font-variation-settings: 'wdth' 120, 'XOPQ' 120, 'YOPQ' 100;
}

.lightbox-text p {
  margin: 0;
}

.lightbox-caption {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.lightbox-caption::-webkit-scrollbar {
  width: 6px;
}

.lightbox-caption::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.35);
}

/* A post's text: no scroll bar, the bouncing arrow (below) shows there is more to read. */
.lightbox.is-post .lightbox-caption {
  scrollbar-width: none;
}

.lightbox.is-post .lightbox-caption::-webkit-scrollbar {
  display: none;
}

/* More text to read below: the last lines fade out (set by lightbox.js while scrolling). */
.lightbox-caption.has-more {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 3rem), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 3rem), transparent);
}

/* ...and an arrow bouncing at the bottom of the text, as on the scrolling "Écran" images (style.css). */
.lightbox-text.has-more::after {
  content: "";
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  width: 22px;
  height: 19px;
  margin-left: -11px;
  background: url("images/arrow-down.svg") center / contain no-repeat;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.5));
  pointer-events: none;
  animation: lightbox-more 1.6s ease-in-out infinite;
}

@keyframes lightbox-more {
  0%,
  100% {
    translate: 0 -3px;
  }
  50% {
    translate: 0 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-text.has-more::after {
    animation: none;
  }
}

.lightbox-caption p + p {
  margin-top: 0.6em;
}

.lightbox-caption a {
  color: inherit;
  text-decoration: underline;
}

/* A post: the image on the left, its description on the right. The image gets as much room as it can: the text
   column narrows first (20rem at most), down to a third of the width (--post-room: the width between the post
   buttons), so the image always keeps at least two thirds. */
.lightbox.is-post {
  --post-room: calc(100vw - 9.5rem);
  --post-text: min(20rem, calc(var(--post-room) / 3));
}

.lightbox.is-post .lightbox-panel {
  flex-direction: row;
}

.lightbox.is-post .lightbox-image {
  max-width: calc(var(--post-room) - var(--post-text));
  max-height: calc(var(--lightbox-height, 100dvh) - 6rem - 6px);
}

.lightbox.is-post .lightbox-text {
  width: var(--post-text);
  max-height: calc(var(--lightbox-height, 100dvh) - 6rem - 6px);
  padding: 1rem 1.2rem;
}

.lightbox.is-post.no-text .lightbox-image {
  max-width: 100%;
}

/* Previous / next post: at the edges of the screen, outside the frame, so they never look like the image arrows. */
.lightbox-post {
  position: absolute;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-top: -1.625rem !important;
  border-radius: 50%;
  transition: color 0.2s;
}

/* The site's own "previous / next" icons (as on the article links), white, lavender on hover. */
.lightbox-post-icon {
  width: 100%;
  height: 100%;
  background-color: currentColor;
  -webkit-mask: url("images/btn-prev.svg") center / contain no-repeat;
  mask: url("images/btn-prev.svg") center / contain no-repeat;
}

.lightbox-post-next .lightbox-post-icon {
  -webkit-mask-image: url("images/btn-next.svg");
  mask-image: url("images/btn-next.svg");
}

.lightbox-post:hover,
.lightbox-post:focus-visible {
  color: #cbb6e7; /* lavande */
}

.lightbox-post-prev {
  left: 1rem;
}

.lightbox-post-next {
  right: 1rem;
}

.lightbox-post-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Changing post slides the frame, so that the change is visible. */
.lightbox-panel.slide-next {
  animation: lightbox-from-right 0.3s ease-out;
}

.lightbox-panel.slide-prev {
  animation: lightbox-from-left 0.3s ease-out;
}

@keyframes lightbox-from-right {
  from {
    transform: translateX(3rem);
    opacity: 0;
  }
}

@keyframes lightbox-from-left {
  from {
    transform: translateX(-3rem);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-panel.slide-next,
  .lightbox-panel.slide-prev {
    animation: none;
  }
}

/* Tablets and narrow windows: the post buttons go to the bottom, as on phones, so the image and its text take the
   whole width (still two thirds for the image, one third for the text). */
@media (min-width: 701px) and (max-width: 1100px) {
  .lightbox-frame {
    padding: calc(3rem + 6px) 1rem 3.5rem;
  }

  .lightbox-post-status {
    line-height: 3.5rem;
  }

  .lightbox.is-post {
    --post-room: calc(100vw - 2rem);
  }

  .lightbox.is-post .lightbox-image,
  .lightbox.is-post .lightbox-text {
    max-height: calc(var(--lightbox-height, 100dvh) - 6.5rem - 6px);
  }

  .lightbox-post {
    top: auto;
    bottom: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    margin-top: 0 !important;
  }
}

/* Phones: everything in one column, centred; the post buttons, with their names, at the bottom. */
@media (max-width: 700px) {
  .lightbox {
    background:
      radial-gradient(ellipse 120% 50% at 0% 0%, rgba(24, 96, 107, 0.6), transparent 70%),
      radial-gradient(ellipse 120% 50% at 100% 100%, rgba(72, 49, 102, 0.6), transparent 70%),
      rgba(14, 33, 58, 0.86);
  }

  .lightbox-frame {
    padding: calc(3rem + 6px) 0 3.5rem;
  }

  .lightbox-post-status {
    line-height: 3.5rem;
  }

  .lightbox-panel,
  .lightbox.is-post .lightbox-panel {
    flex-direction: column;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .lightbox-image,
  .lightbox.is-post .lightbox-image {
    max-width: 100%;
    max-height: calc(var(--lightbox-height, 100dvh) - 12rem);
  }

  .lightbox.no-text .lightbox-image,
  .lightbox.is-post.no-text .lightbox-image {
    max-height: calc(var(--lightbox-height, 100dvh) - 6.5rem - 6px);
  }

  .lightbox-text,
  .lightbox.is-post .lightbox-text {
    width: 100%;
    max-height: none;
    padding: 0.8rem 1rem;
    overflow-y: auto;
  }

  .lightbox-post {
    top: auto;
    bottom: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    margin-top: 0 !important;
  }

  .lightbox-post-prev {
    left: 1rem;
  }

  .lightbox-post-next {
    right: 1rem;
  }
}
