/* Chapter 5: the jar of wishes */
.jar {
  position: relative;
  flex: none;
  width: min(300px, 72vw, calc(48dvh * 300 / 360));
  aspect-ratio: 300 / 360;
}
.jar-layer, .jar-layer svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.jar-front { pointer-events: none; }

.slip {
  position: absolute;
  width: 18%;
  aspect-ratio: 46 / 30;
  padding: 0;
  border: 3px solid var(--cocoa);
  border-radius: 6px;
  background:
    linear-gradient(135deg, transparent 0 70%, rgba(122, 75, 71, .16) 70% 71%, rgba(255, 255, 255, .55) 71%),
    var(--paper, #FFC2D1);
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  cursor: pointer;
  transition: transform .25s var(--ease-bounce), opacity .3s;
}
.slip::after {  /* the fold line */
  content: "";
  position: absolute;
  top: 18%; bottom: 18%;
  left: 50%;
  border-left: 2px dashed rgba(122, 75, 71, .35);
}
.slip:hover, .slip:focus-visible { transform: translate(-50%, -64%) rotate(var(--r, 0deg)) scale(1.08); z-index: 2; }
.slip:focus-visible { outline: 3px solid var(--candy); outline-offset: 3px; }
.slip.is-read {   /* already unfolded: paler paper with a little heart sticker */
  border-color: rgba(122, 75, 71, .55);
  background:
    linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, .5)),
    linear-gradient(135deg, transparent 0 70%, rgba(122, 75, 71, .16) 70% 71%, rgba(255, 255, 255, .55) 71%),
    var(--paper, #FFC2D1);
}
.slip-heart {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 17px;
  color: var(--rouge);
  filter: drop-shadow(0 1px 0 #fff) drop-shadow(0 0 1px #fff);
  pointer-events: none;
}
.slip-heart svg { display: block; width: 100%; height: auto; }

/* the unfolded note */
.note-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 20px 16px;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.note-card {
  position: relative;
  margin: 0;
  width: min(460px, calc(100vw - 40px));
  max-height: calc(100dvh - 130px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  /* soft paper, tinted with the colour of the folded slip, with the crease still showing */
  background:
    linear-gradient(transparent calc(50% - 1px), rgba(122, 75, 71, .07) 50%, rgba(255, 255, 255, .7) calc(50% + 1px), transparent calc(50% + 2px)),
    linear-gradient(color-mix(in srgb, var(--paper, #FFC2D1) 24%, #FFFDFB), color-mix(in srgb, var(--paper, #FFC2D1) 12%, #FFFDFB));
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(255, 179, 198, .5);
  overflow: hidden;
}
.note-card::before {   /* fine inner border */
  content: "";
  position: absolute;
  inset: 8px;
  border: 1.5px dashed rgba(251, 111, 146, .35);
  border-radius: 14px;
  pointer-events: none;
}
.note-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(28px, 4.5dvh, 40px) clamp(24px, 6vw, 40px) clamp(26px, 4dvh, 36px);
  color: var(--cocoa);
  scrollbar-width: thin;
  scrollbar-color: var(--pastel) transparent;
}
.note-scroll:focus { outline: none; }
.note-card.has-more .note-scroll {   /* more to read below: soft fade at the bottom */
  -webkit-mask-image: linear-gradient(#000 calc(100% - 56px), transparent);
          mask-image: linear-gradient(#000 calc(100% - 56px), transparent);
}
.note-number {
  margin: 0 0 8px;
  text-align: center;
  font: 800 12px/1 var(--font-sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--rouge);
}
.note-title {
  margin: 0;
  text-align: center;
  font: italic 600 clamp(26px, 2vw + 18px, 32px)/1.15 var(--font-serif);
  color: var(--cocoa);
  text-wrap: balance;
}
.note-rule {
  width: 72px;
  height: 10px;
  margin: 14px auto 18px;
  background:
    radial-gradient(circle, var(--candy) 2.5px, transparent 3px) center / 10px 10px no-repeat,
    linear-gradient(var(--pastel), var(--pastel)) left center / 28px 1.5px no-repeat,
    linear-gradient(var(--pastel), var(--pastel)) right center / 28px 1.5px no-repeat;
}
.note-message {
  margin: 0;
  text-align: left;
  font: 500 clamp(19px, .5vw + 16px, 20.5px)/1.62 var(--font-serif);
  overflow-wrap: break-word;
  text-wrap: pretty;
}
.note-fold { position: absolute; inset: 0; border-radius: 20px; pointer-events: none; z-index: 1; }
.note-close {
  min-height: 44px;
  padding: 10px 20px;
  border: 3px solid var(--cocoa);
  border-radius: 999px;
  background: var(--paper);
  color: var(--cocoa);
  font: 800 16px/1 var(--font-sans);
  cursor: pointer;
}
.note-close:focus-visible { outline: 3px solid var(--candy); outline-offset: 3px; }

@media (max-height: 520px) {
  .note-overlay { gap: 10px; padding: 12px 16px; }
  .note-card { max-height: calc(100dvh - 84px); }
  .note-scroll { padding: 22px 32px 20px; }
  .note-title { font-size: 24px; }
  .note-rule { margin: 10px auto 12px; }
  .note-message { font-size: 18px; line-height: 1.55; }
}

@media (prefers-reduced-motion: reduce) {
  .slip { transition: none; }
}
