@font-face {
  font-family: "Bad Script";
  src: url("assets/fonts/badscript-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
  font-display: swap;
}
@font-face {
  font-family: "Bad Script";
  src: url("assets/fonts/badscript-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: "Kurale";
  src: url("assets/fonts/kurale-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
  font-display: swap;
}
@font-face {
  font-family: "Kurale";
  src: url("assets/fonts/kurale-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}

/* The page is a table: ice from the lake photo. Paper things on it stay paper in any theme. */
:root {
  --table: #CAD5F2;
  --on-table: #2337A0;
  --on-table-soft: #4152AA;
  --paper: #FFFAF8;
  --print: #FFFFFF;
  --ink: #2337A0;
  --ink-faint: rgba(35, 55, 160, 0.28);
  --stamp: #D42A41;
  --stamp-deep: #A31D31;
  --blush: #F6C3CF;
  --sun: #FF9A3D;
  --shadow: 0 1px 1px rgba(20, 30, 90, 0.16), 0 16px 30px -12px rgba(20, 30, 90, 0.5);
  --hand: "Bad Script", "Segoe Script", cursive;
  --serif: "Kurale", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --table: #182042;
    --on-table: #E6EAFB;
    --on-table-soft: #AEB8E6;
    --shadow: 0 1px 1px rgba(0, 0, 0, 0.4), 0 18px 34px -12px rgba(0, 0, 0, 0.75);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --table: #182042;
  --on-table: #E6EAFB;
  --on-table-soft: #AEB8E6;
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.4), 0 18px 34px -12px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--table);
  color: var(--on-table);
  font: 18px/1.5 var(--serif);
  overflow-x: clip;
}

img, video { max-width: 100%; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--stamp);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- postcard ---------- */

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: center;
  gap: 26px;
  padding: 28px 16px 40px;
}

.postcard {
  width: min(940px, 100%, calc((100svh - 190px) * 1.5));
  aspect-ratio: 3 / 2;
  perspective: 2200px;
  container: card / inline-size;
  cursor: pointer;
  rotate: -1.2deg;
}

.postcard__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.95s cubic-bezier(0.45, 0.05, 0.2, 1);
}
.postcard[data-showing="photo"] .postcard__inner { transform: rotateY(180deg); }

.side {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* address side */

.side--address {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto auto;
  grid-template-areas:
    "head  stamp"
    "note  stamp"
    "note  ."
    "note  lines"
    "code  lines";
  column-gap: 8cqi;
  padding: 3.6cqi 4.2cqi 3.8cqi;
}
.side--address::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 14%;
  bottom: 8%;
  width: 1px;
  background: var(--ink-faint);
}

.postcard__head {
  grid-area: head;
  margin: 0;
  font-size: 1.75cqi;
  letter-spacing: 0.16em;
}

.note {
  grid-area: note;
  align-self: start;
  margin: 2.4cqi 0 0;
  font: 2.45cqi/1.6 var(--hand);
  rotate: -0.6deg;
}
.note__sign {
  display: inline-block;
  margin-top: 0.8cqi;
  margin-left: 12cqi;
}

.stamp {
  grid-area: stamp;
  justify-self: end;
  position: relative;
  z-index: 1;
  width: 15cqi;
  padding: 0.9cqi;
  border: 0;
  cursor: pointer;
  rotate: 3deg;
  /* perforation: a grid of holes, only the ones on the edge stay visible */
  background: radial-gradient(circle, transparent 0.38cqi, #fff 0.42cqi) -0.6cqi -0.6cqi / 1.2cqi 1.2cqi;
  filter: drop-shadow(0 1px 1.5px rgba(20, 30, 90, 0.4));
}
.stamp__frame {
  display: block;
  padding: 0.7cqi 0.7cqi 0.4cqi;
  background: var(--sun);
}
.stamp__frame img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}
.stamp__value {
  display: block;
  padding-top: 0.2cqi;
  color: var(--ink);
  font-size: 1.6cqi;
  line-height: 1.3;
  text-align: right;
}

.postmark {
  position: absolute;
  top: 7cqi;
  right: 15cqi;
  width: 25cqi;
  color: var(--stamp);
  opacity: 0.78;
  rotate: -12deg;
  pointer-events: none;
  z-index: 2;
}
.postmark__ring {
  font: 12.5px var(--serif);
  letter-spacing: 0.12em;
  fill: currentColor;
}
.postmark__date {
  font: 12px var(--serif);
  letter-spacing: 0.06em;
  fill: currentColor;
}

.lines {
  grid-area: lines;
  margin: 0;
}
.line {
  display: flex;
  align-items: baseline;
  gap: 1.4cqi;
  min-height: 5cqi;
  border-bottom: 1px solid var(--ink-faint);
}
.line + .line { margin-top: 0.6cqi; }
.line dt {
  flex: 0 0 5.5cqi;
  font-size: 1.6cqi;
}
.line dd {
  margin: 0;
  font: 3.1cqi/1.2 var(--hand);
}

.postcode {
  grid-area: code;
  align-self: end;
  display: grid;
  gap: 0.6cqi;
  width: 24cqi;
  margin-top: 2cqi;
}
.postcode svg {
  display: block;
  width: 100%;
  color: var(--ink);
  opacity: 0.6;
}
.postcode span {
  font-size: 1.15cqi;
  opacity: 0.75;
}

/* photo side */

.side--photo {
  transform: rotateY(180deg);
  padding: 2.2cqi;
}
.side--photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 33%;
}
.lettering {
  position: absolute;
  left: 6cqi;
  top: 3.6cqi;
  margin: 0;
  font: 400 15cqi/1 var(--hand);
  color: #fff;
  text-shadow: 0.45cqi 0.45cqi 0 var(--stamp), 0 0 3cqi rgba(25, 20, 70, 0.35);
  rotate: -5deg;
}
.lettering__sub {
  position: absolute;
  left: 7.5cqi;
  top: 21.5cqi;
  margin: 0;
  max-width: 36cqi;
  font-size: 2.3cqi;
  line-height: 1.35;
  color: #fff;
  text-shadow: 0 1px 10px rgba(20, 20, 60, 0.6);
}

@container card (max-width: 560px) {
  .side--address {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "head  stamp"
      "lines lines"
      "note  note"
      "code  code";
    column-gap: 4cqi;
    padding: 5.5cqi;
  }
  .side--address::before { content: none; }
  .postcard__head { font-size: 3.2cqi; }
  .stamp { width: 27cqi; padding: 1.6cqi; background-position: -1cqi -1cqi; background-size: 2cqi 2cqi; background-image: radial-gradient(circle, transparent 0.62cqi, #fff 0.7cqi); }
  .stamp__frame { padding: 1.2cqi 1.2cqi 0.6cqi; }
  .stamp__value { font-size: 3cqi; }
  .postmark { top: 16cqi; right: 25cqi; width: 46cqi; }
  .lines { margin-top: 3cqi; }
  .line { min-height: 9cqi; gap: 2.4cqi; }
  .line dt { flex-basis: 10cqi; font-size: 3.1cqi; }
  .line dd { font-size: 5.6cqi; }
  .note {
    margin-top: 5cqi;
    padding-top: 4cqi;
    border-top: 1px solid var(--ink-faint);
    font-size: 4.9cqi;
    line-height: 1.55;
    rotate: 0deg;
  }
  .note__sign { margin-left: 26cqi; }
  .postcode { width: 44cqi; }
  .postcode span { font-size: 2.3cqi; }

  .side--photo { padding: 3.2cqi; }
  .side--photo img { object-position: 50% 50%; }
  .lettering { font-size: 27cqi; left: 9cqi; top: 6cqi; }
  .lettering__sub { font-size: 4.6cqi; left: 11cqi; top: 37cqi; max-width: 60cqi; }
}

@media (max-width: 640px) {
  .postcard {
    width: min(440px, 100%, calc((100svh - 190px) * 0.625));
    aspect-ratio: 5 / 8;
    rotate: -0.8deg;
  }
}

.flip {
  padding: 14px 24px;
  border: 0;
  border-radius: 5px;
  background: var(--stamp);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--stamp-deep);
}
.flip:active {
  translate: 0 2px;
  box-shadow: 0 1px 0 var(--stamp-deep);
}

.scroll-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -8px 0 0;
  font: 21px/1 var(--hand);
}
.scroll-hint[hidden] { display: none; }
.scroll-hint svg { width: 22px; height: 31px; }

/* ---------- album ---------- */

.album {
  display: grid;
  gap: clamp(88px, 13vw, 180px);
  padding: clamp(40px, 6vw, 72px) 16px clamp(64px, 9vw, 120px);
}

.verse {
  margin: 0;
  font-size: clamp(21px, 0.7vw + 16px, 27px);
  line-height: 1.55;
}
/* one span per line; if a line has to wrap, the rest hangs indented */
.verse span {
  display: block;
  padding-left: 1.2em;
  text-indent: -1.2em;
}
.verse--epigraph {
  justify-self: center;
  font-size: clamp(22px, 1.3vw + 15px, 31px);
}

.spread {
  position: relative;
  width: min(1080px, 100%);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) fit-content(52%);
  gap: clamp(40px, 6vw, 88px);
  align-items: center;
}
.spread--flip { grid-template-columns: fit-content(52%) minmax(0, 1fr); }
.spread--flip > .prints { order: 2; }

.prints { position: relative; }

.prints--pair {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}
.prints--pair > .photo:nth-of-type(1) {
  grid-row: 1;
  grid-column: var(--a);
}
.prints--pair > .photo:nth-of-type(2) {
  grid-row: 1;
  grid-column: var(--b);
  align-self: end;
  margin-bottom: -16%;
  z-index: 1;
}

.photo {
  margin: 0;
  rotate: var(--tilt, 0deg);
}
.photo--narrow {
  width: min(400px, 88%);
  margin-inline: auto;
}

.print {
  position: relative;
  padding: clamp(7px, 1vw, 12px);
  background: var(--print);
  box-shadow: var(--shadow);
}
.print img,
.print video {
  display: block;
  width: 100%;
  height: auto;
}
/* album photo corners */
.print::after {
  content: "";
  position: absolute;
  inset: -3px;
  pointer-events: none;
  --c: var(--ink);
  --s: clamp(22px, 2.6vw, 32px);
  background:
    linear-gradient(135deg, var(--c) 50%, transparent 50%) top left / var(--s) var(--s) no-repeat,
    linear-gradient(225deg, var(--c) 50%, transparent 50%) top right / var(--s) var(--s) no-repeat,
    linear-gradient(45deg, var(--c) 50%, transparent 50%) bottom left / var(--s) var(--s) no-repeat,
    linear-gradient(315deg, var(--c) 50%, transparent 50%) bottom right / var(--s) var(--s) no-repeat;
  filter: drop-shadow(0 1px 1px rgba(10, 15, 50, 0.3));
}

.hand {
  margin: 16px 4px 0;
  font: clamp(19px, 0.6vw + 15px, 23px)/1.35 var(--hand);
  color: var(--on-table);
}

/* photo-booth strip held with tape */
.strip {
  position: relative;
  display: grid;
  gap: 10px;
  width: min(320px, 74%);
  margin-inline: auto;
  padding: 12px 12px 40px;
  background: var(--print);
  box-shadow: var(--shadow);
  rotate: var(--tilt, 0deg);
}
.strip img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 4.4;
  object-fit: cover;
  object-position: 50% 40%;
}
.strip::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 50%;
  width: 118px;
  height: 32px;
  translate: -50% 0;
  rotate: -4deg;
  background: color-mix(in srgb, var(--blush) 82%, transparent);
  box-shadow: 0 1px 2px rgba(20, 30, 90, 0.12);
}

.spread--duo {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  width: min(860px, 100%);
}
.spread--duo > .photo:nth-of-type(2) { margin-top: 72px; }

.spread--live {
  grid-template-columns: minmax(0, 1fr);
  width: min(760px, 100%);
}

/* ---------- stickers ---------- */

.sticker {
  position: absolute;
  z-index: 3;
  width: calc(var(--size, 120px) * var(--k, 1));
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  rotate: var(--tilt, 0deg);
  -webkit-tap-highlight-color: transparent;
}
.sticker img {
  display: block;
  width: 100%;
  height: auto;
}
.sticker--cut img {
  filter:
    drop-shadow(2.5px 0 0 #fff) drop-shadow(-2.5px 0 0 #fff)
    drop-shadow(0 2.5px 0 #fff) drop-shadow(0 -2.5px 0 #fff)
    drop-shadow(0 6px 7px rgba(20, 30, 90, 0.3));
}
.sticker--card img {
  border: 5px solid #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.sticker--pixel img { image-rendering: pixelated; }
.sticker--static { position: relative; }

.sticker.is-squished { animation: squish 0.4s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes squish {
  0% { scale: 1; }
  30% { scale: 0.86 1.1; }
  65% { scale: 1.07 0.95; }
  100% { scale: 1; }
}

/* ---------- pop cat ---------- */

.popzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 16px 64px;
  text-align: center;
}
.popzone__title {
  margin: 0 0 8px;
  font: 400 clamp(32px, 2.6vw + 20px, 48px)/1.1 var(--serif);
}
.popcat {
  position: relative;
  width: min(300px, 72vw);
  aspect-ratio: 320 / 298;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.popcat img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter:
    drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff)
    drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff)
    drop-shadow(0 8px 10px rgba(20, 30, 90, 0.3));
  -webkit-user-drag: none;
  pointer-events: none;
}
.popcat__open,
.popcat.is-open .popcat__closed { visibility: hidden; }
.popcat.is-open .popcat__open { visibility: visible; }

.popcount {
  margin: 6px 0 0;
  font: 23px/1.3 var(--hand);
}
.popcount b {
  font-weight: 400;
  font-family: var(--serif);
}

/* ---------- finale ---------- */

.finale {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: clamp(56px, 8vw, 110px) 16px 24px;
}
.verse--final { font-size: clamp(24px, 1.5vw + 17px, 36px); }
.signature {
  margin: 6px 0 0 clamp(80px, 14vw, 200px);
  font: clamp(34px, 1.8vw + 24px, 48px)/1 var(--hand);
  rotate: -4deg;
}
.finale .sticker { margin-top: 18px; }

.credits {
  max-width: 64ch;
  margin: 48px auto 0;
  padding: 0 16px 120px;
  color: var(--on-table-soft);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}
.credits p { margin: 0; }
.credits a { color: inherit; text-underline-offset: 2px; }

/* ---------- music toggle: the vibing cat only vibes while music plays ---------- */

.music {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 28px);
  padding: 6px 16px 6px 6px;
  border: 0;
  border-radius: 40px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
}
.music img {
  flex: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}
.music__text { display: grid; min-width: 0; }
.music__label { font: 19px/1.1 var(--hand); }
.music__track {
  font-size: 12.5px;
  line-height: 1.3;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .spread,
  .spread--flip {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
  }
  .spread--flip > .prints { order: 0; }
  .spread > .verse { justify-self: center; }
  .prints { width: min(480px, 100%); margin-inline: auto; }
  .sticker { --k: 0.78; }
  .album { gap: 104px; }
  .spread--duo { gap: 40px; }
  .spread--duo > .photo { width: min(400px, 88%); }
  .spread--duo > .photo:nth-of-type(2) { margin-top: 0; justify-self: end; }
}

@media (max-width: 520px) {
  .popzone .sticker { --k: 0.7; position: static; margin-top: 12px; }
  .music { padding-right: 12px; }
  .music img { width: 44px; height: 44px; }
}

@media (min-width: 1100px) {
  .sticker { --k: 1.2; }
}

@media (prefers-reduced-motion: reduce) {
  .postcard__inner { transition: none; }
  .sticker.is-squished { animation: none; }
}
