/* Styles for photo-interactions.js: photos that lift, play their Live Photo, and open a
   details card. Shared by index.html and the experiment page. */

.interactive-photo {
  cursor: pointer;
  /* Independent scale/translate preserve the heart collage's existing rotations. */
  transition:
    scale 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    translate 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 220ms ease;
}
.interactive-photo:focus-visible {
  outline: 3px solid #d2042d;
  outline-offset: 5px;
}
.interactive-photo.photo-emphasis {
  scale: 1.012;
  translate: 0 -3px;
  box-shadow:
    0 10px 28px #32282a25,
    0 0 0 2px #d2042d25;
}

/* The Live Photo clip sits over its still and fades in once it is playing. */
.interactive-photo video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}
.interactive-photo video.playing {
  opacity: 1;
}

/* Prints that turn over. The page gives a print a back by adding a <figcaption>; without
   one, or without scripts, the print simply never turns. photo-interactions.js sets the
   custom properties when a print is picked up. */

.turnable {
  transform-style: preserve-3d;
  transform: perspective(1400px) translate(0, 0) rotate(var(--tilt, 0deg)) rotateY(0deg) scale(1);
  transition:
    transform 640ms cubic-bezier(0.3, 0.7, 0.2, 1),
    scale 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    translate 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 220ms ease;
}
.turnable.turned {
  z-index: 30;
  transform: perspective(1400px) translate(var(--carry-x, 0), var(--carry-y, 0)) rotate(0deg)
    rotateY(180deg) scale(var(--pick-up, 1));
  box-shadow: 0 14px 34px #32282a3d;
}
.turnable img,
.turnable video,
.turnable figcaption {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
/* The back is laid out at the size the print is held at and shrunk to fit the print, so
   its writing is drawn at full size rather than magnified. */
.turnable figcaption {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--card-width, 100%) * var(--pick-up, 1));
  height: calc(var(--card-height, 100%) * var(--pick-up, 1));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 18px 20px;
  overflow: hidden;
  background: #fbf8ef;
  color: #3d3537;
  font:
    18px/1.3 'Bradley Hand',
    'Segoe Print',
    'Noteworthy',
    cursive;
  text-align: center;
  cursor: pointer;
  transform: translate(-50%, -50%) rotateY(180deg) scale(calc(1 / var(--pick-up, 1)));
  /* Hidden from keyboards and screen readers until the print has turned. */
  visibility: hidden;
  transition: visibility 0s 640ms;
}
.turnable.turned figcaption {
  visibility: visible;
  transition-delay: 0s;
}
/* Written on by hand: where, when, and a line about the day. */
.print-place,
.print-date,
.print-note {
  rotate: -2deg;
}
.print-place {
  font-size: 22px;
}
.print-date {
  color: #6f6265;
  font-size: 15px;
}
.print-note {
  margin-top: 8px;
}
/* The faint mark a photo lab leaves on the back of its paper. */
.turnable figcaption::after {
  content: 'K & B';
  position: absolute;
  right: 14px;
  bottom: 9px;
  color: #d2042d;
  font:
    italic 11px Georgia,
    'Times New Roman',
    serif;
  letter-spacing: 0.08em;
  opacity: 0.4;
}
.print-map-link {
  align-self: center;
  margin-top: 12px;
  color: #a50324;
  font:
    11px/1.5 Arial,
    Helvetica,
    sans-serif;
  text-underline-offset: 3px;
}
.photo-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Details card */

.photo-details {
  position: fixed;
  z-index: 1000;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 16px;
  background: #fffdf7;
  border: 1px solid #dfd5ca;
  border-radius: 20px;
  box-shadow: 0 12px 45px #211d2440;
  color: #32282a;
  font:
    14px/1.55 Arial,
    Helvetica,
    sans-serif;
  cursor: auto;
}
.photo-details[hidden] {
  display: none;
}
.photo-details:not([hidden]) {
  animation: photo-card-reveal 480ms ease-out both;
}
@keyframes photo-card-reveal {
  from {
    opacity: 0;
    translate: 0 7px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
.photo-details p {
  margin: 0 0 9px;
}
.photo-coordinates,
.photo-camera {
  font-size: 12px;
}
.photo-camera {
  color: #736568;
}
.photo-details a {
  color: #a50324;
  text-underline-offset: 3px;
}
.photo-details .photo-dismiss {
  display: block;
  margin-top: 14px;
  padding: 5px 10px;
  border: 1px solid #d2042d;
  background: #f4f2e7;
  color: #a50324;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .interactive-photo,
  .interactive-photo video,
  .turnable figcaption {
    transition: none;
  }
  .interactive-photo.photo-emphasis {
    scale: 1;
    translate: none;
  }
  .photo-details:not([hidden]) {
    animation: none;
  }
}
