@property --keepsake-rx { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@property --keepsake-ry { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@property --keepsake-sx { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
@property --keepsake-sy { syntax: "<percentage>"; inherits: false; initial-value: 0%; }

.orbit-keepsake {
  --keepsake-ease-out: cubic-bezier(.23, 1, .32, 1);
  --keepsake-ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --keepsake-flip: 650ms;
  padding-block: clamp(52px, 8vw, 104px);
  color: #edf1f7;
  background: #16213a;
}

.orbit-keepsake .poetry-wrap { max-width: 850px; }
.orbit-keepsake h2 {
  margin: 0 0 clamp(18px, 4vw, 32px);
  font: 500 clamp(2.3rem, 5.6vw, 4.4rem)/1 var(--serif);
  letter-spacing: -.04em;
}

.keepsake-layout {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 430px);
  align-items: center;
  gap: clamp(26px, 5vw, 74px);
}

.keepsake-stage { min-width: 0; }

.keepsake-card {
  display: grid;
  width: min(100%, 380px);
}

/* Tilt layer: owns the pointer tilt and the flip lift; the faces keep their own flip transform. */
.keepsake-tilt {
  display: grid;
  position: relative;
  perspective: 1200px;
}

.keepsake-face {
  grid-area: 1 / 1;
  isolation: isolate;
  display: grid;
  align-content: center;
  position: relative;
  border: 1px solid #8d9db9;
  box-shadow: 0 12px 32px #070b1548;
  overflow: hidden;
  backface-visibility: hidden;
  /* visibility flips at the half-way point (edge-on), which keeps WebKit from showing mirrored text. */
  transition:
    transform var(--keepsake-flip) var(--keepsake-ease-in-out),
    visibility var(--keepsake-flip) steps(2, jump-none);
}

.keepsake-face[aria-hidden="true"] { visibility: hidden; }

.keepsake-back::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid currentColor;
  opacity: .32;
  pointer-events: none;
}

.keepsake-front {
  background: #141e36;
  color: #f0e8df;
}

.keepsake-front img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;
  object-fit: contain;
}

.keepsake-front .keepsake-motion {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
}
.keepsake-front .keepsake-motion.is-ready { opacity: 1; }

.keepsake-back {
  justify-items: center;
  gap: .8em;
  padding: clamp(22px, 5vw, 44px);
  text-align: center;
  background: #e8ebef;
  color: #243650;
  transform: rotateY(-180deg);
}
.keepsake-back strong {
  max-width: 100%;
  font: 500 clamp(1.55rem, 4vw, 3.18rem)/1.04 var(--serif);
  overflow-wrap: anywhere;
}
.keepsake-back p { max-width: 35ch; margin: 0; font-size: clamp(.85rem, 1.8vw, 1.05rem); line-height: 1.44; }
.keepsake-card.is-flipped .keepsake-front { transform: rotateY(180deg); }
.keepsake-card.is-flipped .keepsake-back { transform: rotateY(0); }

/* Sheen: created by orbit-keepsake.js only for fine pointers. */
.keepsake-sheen {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 420ms var(--keepsake-ease-out);
}
.keepsake-sheen span {
  position: absolute;
  inset: -50%;
  background: radial-gradient(circle at center, #ffffff2e 0, #f4f6fa14 22%, transparent 46%);
  transform: translate(var(--keepsake-sx), var(--keepsake-sy));
  transition: transform 420ms var(--keepsake-ease-out);
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .keepsake-tilt {
    transform: perspective(1000px) rotateX(var(--keepsake-rx)) rotateY(var(--keepsake-ry));
    transition: transform 420ms var(--keepsake-ease-out);
  }
  .keepsake-tilt.is-tilting,
  .keepsake-tilt.is-tilting .keepsake-sheen span { transition-duration: 140ms; }
  .keepsake-tilt.is-tilting .keepsake-sheen { opacity: 1; }
}

/* Event details, next steps, downloads: three groups with falling visual weight. */
.keepsake-details {
  color: #fff6e6;
  font-size: .92rem;
  line-height: 1.55;
  text-shadow: 0 1px 6px #0a1324;
}
.keepsake-details time { font-weight: 650; }
.keepsake-details p { margin: 0; }

.keepsake-next {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.orbit-keepsake .keepsake-next .orbit-primary {
  flex: 1 1 11rem;
  min-height: 50px;
  padding-inline: 1.1rem;
  border: 1px solid #fff2d8;
  border-radius: 2px;
  overflow-wrap: anywhere;
}
.orbit-keepsake .keepsake-next .keepsake-calendar {
  background: var(--keepsake-foil, #ecdac0);
  color: #17263c;
}
.orbit-keepsake .keepsake-next .keepsake-share {
  background: #17263cb3;
  color: #fff6e6;
}
.orbit-keepsake .keepsake-next .orbit-primary:focus-visible { outline: 2px solid #fff2d8; outline-offset: 3px; }

.keepsake-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #fff2d830;
}
.orbit-keepsake .keepsake-downloads .poetry-action {
  gap: .5em;
  min-height: 44px;
  justify-content: center;
  padding: .5em .75em;
  border: 1px solid #fff2d860;
  border-radius: 2px;
  background: transparent;
  color: #fff6e6;
  font-size: .86rem;
  line-height: 1.3;
  text-align: center;
}
.orbit-keepsake .keepsake-video svg { width: 17px; height: 17px; }

.keepsake-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px clamp(13px, 3vw, 28px);
  margin-top: 15px;
}
.orbit-keepsake .poetry-action { min-height: 44px; margin-top: 0; }
.orbit-keepsake button.poetry-action {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid currentColor;
  text-align: start;
  cursor: pointer;
}
.orbit-keepsake .poetry-action[aria-disabled="true"] { opacity: .7; cursor: progress; }
.keepsake-actions #keepsake-replay { color: #c1cde0; }

/* Press feedback */
.orbit-keepsake :is(.poetry-action, .orbit-primary) {
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform 160ms var(--keepsake-ease-out);
}
.orbit-keepsake :is(.poetry-action, .orbit-primary):active { transform: scale(.97); }
.orbit-keepsake #keepsake-flip svg { transition: transform 320ms var(--keepsake-ease-out); }
.orbit-keepsake #keepsake-flip[aria-pressed="true"] svg { transform: rotate(180deg); }

@media (hover: hover) and (pointer: fine) {
  .orbit-keepsake .keepsake-next .keepsake-calendar:hover { background: #f6e9d6; }
  .orbit-keepsake .keepsake-next .keepsake-share:hover { background: #24375a; }
  .orbit-keepsake .keepsake-downloads .poetry-action:hover { border-color: #fff2d8; }
}

.orbit-keepsake [hidden] { display: none; }
.keepsake-guest {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding: 14px clamp(16px, 4vw, 32px);
  color: #222f49;
  background: #e8ebef;
  border: 1px solid #a9b7cd;
}
.keepsake-guest p { margin: 0 0 .25em; font-size: .82rem; color: #44536c; }
.keepsake-guest strong { display: block; font: 500 clamp(1.75rem, 4vw, 2.65rem)/1.08 var(--serif); overflow-wrap: anywhere; }
.keepsake-guest .poetry-action { color: #222f49; }
.keepsake-status:not(:empty), .keepsake-share-fallback { display: block; margin-top: .8em; }
.keepsake-share-fallback input { display: block; width: 100%; min-height: 44px; margin-top: .25em; padding-inline: .7em; font: inherit; }

@media (max-width: 720px) {
  .keepsake-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  /* Flip becomes a short cross-fade; no tilt, no sheen. */
  .keepsake-face {
    transform: none !important;
    transition: opacity 220ms ease, visibility 220ms;
  }
  .keepsake-face[aria-hidden="true"] { opacity: 0; }
  .keepsake-sheen { display: none; }
  .orbit-keepsake :is(.poetry-action, .orbit-primary):active,
  .orbit-keepsake #keepsake-flip[aria-pressed="true"] svg { transform: none; }
}
