.memory-card {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 3 / 4;
  container-type: inline-size;
  overflow: hidden;
  border-radius: 4.8% / 3.6%;
  color: #382d26;
  background: #fffefa;
  box-shadow: 0 12px 32px #382a1c18;
  text-align: left;
}

.memory-card__front {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 6.4cqw;
}

.memory-card__meta,
.memory-card__signature {
  font-size: 3.5cqw;
  line-height: 1.35;
  color: #77685a;
}

.memory-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3cqw;
}

.memory-card__date {
  margin-left: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.memory-card__signature {
  margin-top: auto;
  font-family: var(--serif, 'Songti SC', 'Noto Serif CJK SC', Georgia, serif);
  letter-spacing: .15em;
}

.memory-card__body {
  display: grid;
  flex: 1;
  min-height: 0;
  align-items: safe center;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.memory-card__copy {
  margin: 0;
  font-family: var(--serif, 'Songti SC', 'Noto Serif CJK SC', Georgia, serif);
  font-size: 6.1cqw;
  font-weight: 500;
  line-height: 1.58;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.memory-card__copy--empty {
  opacity: .72;
}

.managed-card-copy {
  position: absolute;
  z-index: 2;
  overflow: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  white-space: pre-wrap;
  font-family: var(--caption-font, var(--serif));
  color: var(--caption-color, inherit);
}

.managed-card-copy p + p { margin-top: .5em; }

.memory-card__media {
  position: absolute;
  display: block;
  inset: 0 0 auto;
  width: 100%;
  height: 59%;
  object-fit: cover;
}

.memory-card__media--empty {
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(135deg, #ebddc6, #ebddc6 10px, #e7d7be 10px, #e7d7be 20px);
  color: #6e5947;
  font-size: 4.8cqw;
}

.memory-card__accent {
  display: block;
  flex: none;
  align-self: center;
  max-width: 58%;
  max-height: 27cqw;
  margin-bottom: 3cqw;
  border: .8cqw solid #fffefa;
  border-radius: 2.5cqw;
  object-fit: contain;
  box-shadow: 0 1cqw 3cqw #382a1c30;
}

.memory-card--classic {
  border: 1px solid #eaddcc;
}

.memory-card--classic .memory-card__tag {
  padding: 1.15cqw 2.9cqw;
  border-radius: 999px;
  background: #fbedcf;
  color: #805023;
  white-space: nowrap;
}

.memory-card--classic .memory-card__signature {
  padding-top: 3cqw;
  border-top: 1px dashed #e3d3be;
}

.memory-card--classic .memory-card__body {
  padding: 3cqw 1.5cqw;
  text-align: center;
}

.memory-card--classic:not(.memory-card--has-media) .memory-card__copy:not(.memory-card__copy--empty)::before {
  content: '“';
  display: block;
  height: .72em;
  font-family: Georgia, serif;
  font-size: 2.7em;
  color: #bd8f5c;
  line-height: 1;
}

.memory-card--classic.memory-card--has-media .memory-card__media {
  inset: 14% 6.4% auto;
  width: 87.2%;
  height: 49%;
  border-radius: 4cqw;
  pointer-events: auto;
  z-index: 2;
}

.memory-card--classic video.memory-card__media {
  background: #292524;
  object-fit: contain;
}

.memory-card--classic.memory-card--has-media .memory-card__body {
  margin-top: 68cqw;
  padding-inline: 0;
  text-align: left;
}

.memory-card--classic.memory-card--has-media .memory-card__copy {
  font-size: 4.8cqw;
}

.memory-card--classic.memory-card--media-only .memory-card__media {
  height: 72%;
}

.memory-card--watercolor {
  --wash-background: url('assets/watercolor.webp');
  --wash-shadow: 25 60 56;
  --wash-ink: #244a44;
  color: #fffefa;
  background: #a9b8ab var(--wash-background) center / cover no-repeat;
}

.memory-card--watercolor[data-template-id='watercolor-rose'] {
  --wash-background: url('assets/watercolor-rose.webp');
  --wash-shadow: 114 49 59;
  --wash-ink: #723c48;
}

.memory-card--watercolor[data-template-id='watercolor-moss'] {
  --wash-background: url('assets/watercolor-moss.webp');
  --wash-shadow: 49 68 36;
  --wash-ink: #46553a;
}

.memory-card--watercolor[data-template-id='watercolor-dusk'] {
  --wash-background: url('assets/watercolor-dusk.webp');
  --wash-shadow: 58 47 91;
  --wash-ink: #4f4565;
}

.memory-card--watercolor .memory-card__front {
  padding: 8.5cqw;
}

.memory-card--watercolor .memory-card__body {
  margin-block: 18cqw 7cqw;
  padding: 3cqw 1.5cqw;
}

.memory-card--watercolor.memory-card--has-accent .memory-card__body {
  margin-block: 16cqw 3cqw;
}

.memory-card--watercolor .memory-card__accent {
  align-self: flex-start;
  margin-bottom: 0;
}

.memory-card--watercolor .memory-card__copy {
  font-family: 'Kaiti SC', STKaiti, KaiTi, var(--serif, Georgia, serif);
  font-weight: 650;
  text-shadow: 0 1px 3px rgb(var(--wash-shadow) / .67), 0 2px 10px rgb(var(--wash-shadow) / .66);
  font-size: 7.05cqw;
  line-height: 1.66;
}

.memory-card--watercolor .memory-card__meta,
.memory-card--watercolor .memory-card__signature {
  color: var(--wash-ink);
}

.memory-card--watercolor .memory-card__meta {
  flex-direction: row-reverse;
}

.memory-card--watercolor .memory-card__date {
  margin-inline: 0 auto;
}

.memory-card--watercolor .memory-card__signature {
  text-align: right;
}

.memory-card:is(.memory-card--postcard, .memory-card--polaroid)::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--memory-frame) center / 100% 100% no-repeat;
  pointer-events: none;
}

.memory-card--postcard {
  --memory-frame: url('assets/postcard-frame.webp');
  background: #f4ebda;
  color: #374043;
}

.memory-card--polaroid {
  --memory-frame: url('assets/polaroid-frame.webp');
  background: #dbc19b;
  color: #4d3325;
}

.memory-card--polaroid .memory-card__media {
  inset: 10.4% auto auto 13.7%;
  width: 70%;
  height: 38%;
  transform: rotate(5deg);
}

.memory-card:is(.memory-card--postcard, .memory-card--polaroid) .memory-card__front {
  inset: 64% 10% 7%;
  padding: 0;
}

.memory-card--photo-template .memory-card__meta {
  order: 1;
  padding-top: 1.6cqw;
  border-top: 1px solid #795a4430;
}

.memory-card:is(.memory-card--postcard, .memory-card--polaroid) .memory-card__body {
  margin-bottom: 2.7cqw;
}

.memory-card:is(.memory-card--postcard, .memory-card--polaroid) .memory-card__copy {
  font-size: 5.7cqw;
}

.memory-card--photo-template .memory-card__signature {
  display: none;
}
