/* The folding card. --pw = page width (set by fitCard). */
.xcard {
  --pw: 300px;
  --ph: calc(var(--pw) / 0.68);
  width: calc(var(--pw) * 2);
  height: var(--ph);
  perspective: calc(var(--pw) * 6);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.xcard-spread {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: translateX(calc(var(--pw) * -0.5)) scale(var(--closed-scale, 1));
  transition: transform 1.1s cubic-bezier(.6, .05, .2, 1);
}
.xcard.open .xcard-spread {
  transform: translateX(0) scale(1);
}

.xpage {
  position: absolute;
  top: 0;
  width: var(--pw);
  height: var(--ph);
  container-type: inline-size;
  overflow: hidden;
}
.xpage-right {
  left: var(--pw);
  border-radius: 2px 6px 6px 2px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7), 0 6px 18px rgba(0, 0, 0, .35);
}
.xpage-paper {
  position: absolute;
  inset: 0;
  background-color: #fbf5e8;
  background-image:
    radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, .7), rgba(0, 0, 0, 0) 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .35  0 0 0 0 .2  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  border: 1px solid rgba(160, 120, 60, .25);
}
.xpage-right .xpage-paper {
  box-shadow: inset 14px 0 18px -14px rgba(90, 60, 20, .35);
}
.xpage-left .xpage-paper {
  box-shadow: inset -14px 0 18px -14px rgba(90, 60, 20, .35);
}
.xpage-paper::after {
  content: '';
  position: absolute;
  inset: 3.5cqw;
  border: 0.5cqw solid rgba(200, 160, 70, .35);
  border-radius: 1.5cqw;
  outline: 0.25cqw solid rgba(200, 160, 70, .25);
  outline-offset: 1.2cqw;
}

/* Cover: hinged on its left edge, flips over to become the left page. */
.xcover {
  position: absolute;
  top: 0;
  left: var(--pw);
  width: var(--pw);
  height: var(--ph);
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(.6, .05, .2, 1);
  z-index: 2;
}
.xcard.open .xcover {
  transform: rotateY(-180deg);
}
.xcover-front,
.xcover-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.xcover-back {
  left: 0;
  transform: rotateY(180deg);
  border-radius: 6px 2px 2px 6px;
}
.xcover-front {
  container-type: inline-size;
  border-radius: 2px 6px 6px 2px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 120, 120, .35), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(0, 0, 0, .45), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 6px),
    linear-gradient(160deg, #b5162a, #7d0c1a 60%, #5c0712);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .75), 0 6px 18px rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(255, 220, 150, .25);
}
.cover-frame {
  position: absolute;
  inset: 5cqw;
  border: 0.8cqw solid #e7c26a;
  border-radius: 3cqw;
  box-shadow: inset 0 0 0 1.6cqw rgba(0, 0, 0, 0), inset 0 0 0 2.1cqw rgba(231, 194, 106, .45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #f7dc94;
  text-shadow: 0 0.4cqw 0 rgba(80, 30, 0, .6), 0 0 3cqw rgba(255, 210, 120, .35);
}
.cover-holly {
  width: 38cqw;
  margin-bottom: 2cqw;
  filter: drop-shadow(0 1cqw 1cqw rgba(0, 0, 0, .4));
}
.cover-month {
  font-family: 'Great Vibes', cursive;
  font-size: 14cqw;
  line-height: 1;
}
.cover-num {
  font-variant-numeric: lining-nums;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 46cqw;
  line-height: .95;
  background: linear-gradient(180deg, #fff3c2, #e8bb55 45%, #a97818 75%, #f3d78a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0.6cqw 0 rgba(60, 20, 0, .55));
}
.cover-sub {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 6.5cqw;
  margin-top: 2cqw;
  opacity: .9;
}
.cover-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 240, 200, .28) 45%, transparent 60%);
  background-size: 250% 100%;
  animation: coverShine 4.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes coverShine {
  0%, 55% { background-position: 120% 0; }
  100% { background-position: -60% 0; }
}

/* Left page: the clue text. */
.xpage-text {
  position: absolute;
  inset: 9cqw 9cqw 9cqw 10cqw;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  color: #3b2a1c;
  scrollbar-width: none;
}
.xpage-text::-webkit-scrollbar { display: none; }
.xpage-date {
  font-family: 'Great Vibes', cursive;
  color: #a5162a;
  font-size: 10cqw;
  line-height: 1.1;
  margin-bottom: 3cqw;
}
.xpage-body {
  font-family: 'Caveat', cursive;
  font-size: 8.2cqw;
  line-height: 1.22;
  overflow-wrap: anywhere;
}
.xpage-empty { opacity: .55; }

/* Right page: photos. */
.xpage-photos {
  position: absolute;
  inset: 8cqw;
  display: flex;
  align-items: center;
  justify-content: center;
}
.xphoto-track {
  position: relative;
  width: 100%;
  height: 86%;
}
.xphoto {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  height: fit-content;
  max-height: 100%;
  background: #fff;
  padding: 4cqw 4cqw 12cqw;
  box-shadow: 0 1.5cqw 4cqw rgba(60, 40, 10, .35);
  transform: translateX(calc(var(--off, 0) * 110%)) rotate(var(--tilt));
  opacity: 0;
  transition: transform .45s cubic-bezier(.3, .7, .2, 1), opacity .3s;
  box-sizing: border-box;
  cursor: zoom-in;
}
.xphoto.on { opacity: 1; }
.xphoto img {
  display: block;
  width: 100%;
  max-height: calc(var(--ph) * 0.55);
  object-fit: contain;
  background: #eee;
  pointer-events: none;
}
.xphoto-dots {
  position: absolute;
  bottom: -0.5cqw;
  left: 0;
  right: 0;
  display: flex;
  gap: 2cqw;
  justify-content: center;
}
.xphoto-dots i {
  width: 2.2cqw;
  height: 2.2cqw;
  border-radius: 50%;
  background: rgba(120, 80, 30, .3);
}
.xphoto-dots i.on { background: #a5162a; }
.xphoto-nav {
  position: absolute;
  bottom: -3.5cqw;
  width: 11cqw;
  height: 9cqw;
  padding: 0;
  border: 0.3cqw solid rgba(165, 22, 42, .35);
  border-radius: 5cqw;
  background: rgba(255, 255, 255, .7);
  color: #7d0c1a;
  font-size: 7cqw;
  line-height: 1;
  z-index: 2;
  display: grid;
  place-items: center;
}
.xphoto-nav.prev { left: 14cqw; }
.xphoto-nav.next { right: 14cqw; }
.xphoto-hint {
  position: absolute;
  bottom: -4cqw;
  font-family: 'Caveat', cursive;
  color: rgba(80, 50, 20, .55);
  font-size: 5.5cqw;
}
.xphoto-dots ~ .xphoto-hint { bottom: 4cqw; }
.xphoto-none {
  width: 40cqw;
  opacity: .25;
  filter: grayscale(.2);
}

/* Stickers. --size is in % of page width. */
.xstickers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.xsticker {
  position: absolute;
  width: calc(var(--size) * 1cqw);
  height: calc(var(--size) * 1cqw);
  transform: translate(-50%, -50%) rotate(var(--rot));
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0.6cqw 0.8cqw rgba(0, 0, 0, .3));
}
.xsticker svg { width: 100%; height: 100%; overflow: visible; }
.xsticker .emoji {
  font-size: calc(var(--size) * 0.82cqw);
  line-height: 1;
}
