/* memories.css — polaroid deck, sized by width AND height so it fits a short phone screen.
   Transform owners: .mm-card = stack/drag (JS) · .mm-tilt = tilt (JS) · .mm-drop = entrance · .mm-flip = flip. */

.mm-inner { padding-bottom: calc(96px + var(--sab)); }
.mm-center { --mm-w: min(78vw, 320px, calc((100vh - 330px) * .72)); }
@supports (height: 100svh) { .mm-center { --mm-w: min(78vw, 320px, calc((100svh - 330px) * .72)); } }
.mm-head { margin-bottom: 14px; }

.mm-deck {
  position: relative;
  width: var(--mm-w);
  min-width: 190px;
  height: calc(var(--mm-w) * 1.25 + 44px);
  min-height: 280px;
  margin: 6px auto 18px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.mm-card {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;                 /* WebKit sizes abspos buttons to fit-content otherwise */
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  -webkit-touch-callout: none;
  will-change: transform;
}
.mm-card:active { cursor: grabbing; }
.mm-card.is-hidden { opacity: 0; pointer-events: none; }
.mm-card:not(.is-top) { pointer-events: none; }
.mm-tilt { position: absolute; inset: 0; transition: transform .45s var(--ease-out); }
.mm-drop { position: absolute; inset: 0; perspective: 1200px; }
.mm-drop.is-drop-l { animation: mmDropL .6s var(--ease-out) both; }
.mm-drop.is-drop-r { animation: mmDropR .6s var(--ease-out) both; }
@keyframes mmDropL { 0% { transform: translateX(150px) rotate(0deg) scale(.9); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes mmDropR { 0% { transform: translateX(-150px) rotate(0deg) scale(.9); opacity: 0; } 100% { transform: none; opacity: 1; } }
.mm-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform .6s var(--ease-out);
}
.mm-flip.is-flipped { transform: rotateY(180deg); }
.mm-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 0;
  border-radius: 4px;
  background: #fffdf9;
  box-shadow: var(--shadow-card);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.mm-back { transform: rotateY(180deg); align-items: center; justify-content: center; padding: 24px; text-align: center; background: linear-gradient(#fffdf9, #fff3ea); }
.mm-tape {
  position: absolute;
  top: -9px;
  left: 50%;
  width: 70px;
  height: 22px;
  margin-left: -35px;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  transform: rotate(-4deg);
  z-index: 2;
}
.mm-photo { position: relative; width: 100%; aspect-ratio: 4 / 5; overflow: hidden; background: linear-gradient(135deg, var(--paper-2), var(--paper-3)); }
@supports not (aspect-ratio: 4 / 5) { .mm-photo { height: calc((var(--mm-w) - 24px) * 1.25); } }
.mm-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.mm-img.is-developing { animation: develop 1.4s ease-out both; }
.mm-missing { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: rgba(233, 30, 99, .35); }
.mm-missing-heart { width: 30%; height: auto; }
.mm-front.is-missing .mm-img { display: none; }
.mm-front.is-missing .mm-missing { display: flex; }
.mm-caption {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 6px;
  font-size: 17px;
  font-style: italic;
  line-height: 1.25;
  color: var(--ink);
  text-align: center;
}
.mm-note { font-size: 20px; font-style: italic; line-height: 1.45; color: var(--ink); }
.mm-note-alt { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.mm-doodle { width: 46px; height: 42px; color: rgba(233, 30, 99, .55); transform: rotate(-8deg); }

.mm-controls { display: flex; align-items: center; justify-content: center; gap: 10px; }
.mm-ctl {
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-bd);
  background: var(--glass);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.mm-ctl-flip { font-size: 15px; }
.mm-counter { min-width: 56px; padding: 8px 12px; font-size: 15px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-height: 680px) {
  .mm-sub { display: none; }
  .mm-head { gap: 4px; margin-bottom: 8px; }
  .mm-deck { margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .mm-drop.is-drop-l, .mm-drop.is-drop-r { animation: none !important; }
  .mm-flip { transition: none; }
  .mm-flip.is-flipped { transform: none; }
  .mm-back { transform: none; opacity: 0; transition: opacity .2s ease; }
  .mm-front { transition: opacity .2s ease; }
  .mm-flip.is-flipped .mm-back { opacity: 1; }
  .mm-flip.is-flipped .mm-front { opacity: 0; }
  .mm-tilt { transition: none; }
}
