/* The postal devices: the perforated stamp, its carmine plate with banknote line-work, the
   window an invitation plays in, the postmark, the wavy cancellation lines and airmail edging. */

/* A stamp: paper with perforated edges. Each mask layer punches half-holes along one edge;
   `round` fits a whole number of holes, so stamps of one size set flush share their holes. */
.stamp {
  --pitch: 14px;
  --hole: 4.2px;
  --margin: 7%;
  --punch: #0000 96%, #000;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--margin) var(--margin) 0;
  isolation: isolate;
}
/* The paper and its perforations are a still layer behind the stamp's contents, so a film
   playing in the window never makes the browser recompute the mask. */
.stamp::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--stamp-paper);
  -webkit-mask:
    radial-gradient(circle var(--hole) at 50% 0, var(--punch)) 0 0 / var(--pitch) 100% round,
    radial-gradient(circle var(--hole) at 50% 100%, var(--punch)) 0 0 / var(--pitch) 100% round,
    radial-gradient(circle var(--hole) at 0 50%, var(--punch)) 0 0 / 100% var(--pitch) round,
    radial-gradient(circle var(--hole) at 100% 50%, var(--punch)) 0 0 / 100% var(--pitch) round;
  -webkit-mask-composite: source-in;
  mask:
    radial-gradient(circle var(--hole) at 50% 0, var(--punch)) 0 0 / var(--pitch) 100% round,
    radial-gradient(circle var(--hole) at 50% 100%, var(--punch)) 0 0 / var(--pitch) 100% round,
    radial-gradient(circle var(--hole) at 0 50%, var(--punch)) 0 0 / 100% var(--pitch) round,
    radial-gradient(circle var(--hole) at 100% 50%, var(--punch)) 0 0 / 100% var(--pitch) round;
  mask-composite: intersect;
}

/* The shadow is a still box behind the stamps, tinted so the perforation holes read as holes: a filter on the wrapper would be redrawn with
   every frame of the films playing inside it. */
.lift {
  position: relative;
  isolation: isolate;
}
.lift::before {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: -1;
  background: rgb(20 16 24 / 0.13);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.08), 0 14px 22px rgb(20 16 24 / 0.16);
  pointer-events: none;
}

/* The printed area: carmine, guilloche line-work over it, a fine frame line. */
.plate {
  position: relative;
  overflow: hidden;
  background: var(--carmine);
  isolation: isolate;
}
.plate::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("../img/guilloche.svg") center / cover;
  opacity: 0.6;
}
.plate::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgb(251 250 247 / 0.55);
  pointer-events: none;
}

/* The face value in the plate's corner. */
.face {
  position: absolute;
  top: 3.5%;
  left: 5%;
  z-index: 2;
  color: var(--paper);
  font: 800 16px/1 var(--display);
  font-variation-settings: "opsz" 11;
}

/* The line printed in the stamp's bottom margin: the style, then the couple. */
.caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0.75em 4px 1em;
  text-align: center;
}
.caption .label {
  color: var(--carmine);
  letter-spacing: 0.12em;
}
.caption-couple {
  font: italic 700 16px/1.05 var(--display);
  font-variation-settings: "opsz" 14;
  white-space: nowrap;
}

/* A window in the plate showing an invitation's screen, cropped to the stamp's shape. */
.window {
  position: relative;
  aspect-ratio: 3 / 4;
  margin: 15% 7% 7%;
  overflow: hidden;
  background: var(--ink);
}
.window img,
.window video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0;
}
.window video,
.slide video {
  opacity: 0;
  transition: opacity 0.35s ease;
}
.window video.is-playing,
.slide video.is-playing {
  opacity: 1;
}

/* The postmark: the logo laid over a stamp, its ink speckled where the press missed. The grain
   is sized with the mark so its small ring lettering stays readable. */
.postmark {
  position: absolute;
  aspect-ratio: 1;
  background: url("../logo/postmark-ink.svg") center / contain no-repeat;
  -webkit-mask: url("../img/ink-grain.svg") center / 90%;
  mask: url("../img/ink-grain.svg") center / 90%;
  will-change: transform;
  opacity: 0.9;
  pointer-events: none;
  transform: rotate(var(--pm-turn, -12deg));
}

.cancel-lines {
  position: absolute;
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0.9;
  pointer-events: none;
  -webkit-mask: url("../img/ink-grain.svg") center / 260px;
  mask: url("../img/ink-grain.svg") center / 260px;
}

/* Airmail edging, used once at the foot of the page. */
.stripe {
  --band: 14px;
  height: 10px;
  background: repeating-linear-gradient(
    -45deg,
    var(--carmine) 0 var(--band),
    var(--paper) var(--band) calc(var(--band) * 2),
    var(--ink) calc(var(--band) * 2) calc(var(--band) * 3),
    var(--paper) calc(var(--band) * 3) calc(var(--band) * 4)
  );
}
