@import url("https://fonts.googleapis.com/css2?family=Damion&family=Zain:ital,wght@0,200;0,300;0,400;0,700;0,800;0,900;1,300;1,400&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  user-select: none;
}
body {
  font-family: "Damion", "Zain", cursive;
  min-height: 100vh;
  min-height: 100dvh;

  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: radial-gradient(circle at center, #2b1020 0%, #0f050b 100%);
}

/* ---------- Container: portrait, fits any screen ---------- */
.card-container {
  --k: 1; /* text scale */
  --page: #2b1020;
  --edge: rgba(255, 77, 109, 0.12);
  width: min(560px, 94vw, calc(92dvh * 3 / 4));
  aspect-ratio: 3 / 4;
  container-type: inline-size;
  perspective: 1500px;
  -webkit-tap-highlight-color: transparent;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  cursor: pointer;
  transform: translateY(-25%); /* centers closed cover (bottom half) */
  transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.card.open {
  transform: translateY(0);
}

/* ---------- Pages ---------- */
.inside-bottom,
.inside-top {
  position: absolute;
  overflow: hidden;
  display: block;
  background: var(--page);
}

.inside-bottom {
  left: 0;
  bottom: 0;
  width: 100%;
  height: 50%;
  border-radius: 0 0 3cqw 3cqw;
  transform-origin: center top; /* seam */
  transform: translateZ(-6px) scale(1.004); /* 1 + 6/1500 */
  box-shadow:
    inset 0 -1px 0 var(--edge),
    inset 1px 0 0 var(--edge),
    inset -1px 0 0 var(--edge),
    0 20px 30px -5px rgba(0, 0, 0, 0.35);
}

.inside-top {
  inset: 0;
  border-radius: 3cqw 3cqw 0 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: rotateX(180deg);
  box-shadow:
    inset 0 1px 0 var(--edge),
    inset 1px 0 0 var(--edge),
    inset -1px 0 0 var(--edge);
}

/* cover hairline gap at seam */
.inside-top::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--page);
}

/* light crease shadow */
.inside-bottom::before,
.inside-top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 7cqw;
  z-index: 5;
  pointer-events: none;
}

.inside-bottom::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0));
}

.inside-top::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0));
}

/* ---------- Text across spread ---------- */
.spread-text {
  position: absolute;
  left: 0;
  width: 100%;
  height: 200%; /* = full open card */
}

.spread-text.top {
  top: 0;
}
.spread-text.bottom {
  top: -100%;
}

.spread-text .col {
  position: absolute;
  top: 50%; /* seam */
  left: 6cqw;
  right: 6cqw;
  transform: translateY(-50%);
  text-align: center;
}

.spread-text h3 {
  color: #ff4d6d;
  font-size: calc(7.5cqw * var(--k));
  margin-bottom: 3cqw;
}

.spread-text p {
  color: #ffb3c1;
  font-size: calc(4.4cqw * var(--k));
  line-height: 1.55;
  margin-bottom: 4cqw;
}

.spread-text .signature {
  color: #ff4d6d;
  font-size: calc(4.8cqw * var(--k));
  text-align: right;
}

/* ---------- Folding flap ---------- */
.card-flap {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 50%;
  transform-origin: center top; /* hinge at seam */
  transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 2;
  will-change: transform;
}

.card.open .card-flap {
  transform: rotateX(180deg);
}

/* ---------- Cover ---------- */
.cover-front {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, #2b1020 0%, #0f050b 100%);
  border: 1px solid rgba(255, 77, 109, 0.15);
  border-top: none;
  border-radius: 0 0 3cqw 3cqw;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  box-shadow: 10px 20px 25px -6px rgba(0, 0, 0, 0.4);
  padding: 4cqw;
  text-align: center;
}

.cover-front h2 {
  font-size: calc(6cqw * var(--k));
  margin-top: 3cqw;
  font-weight: normal;
}

.cover-front .heart-mask {
  position: absolute;
  top: 5cqw;
  right: 5cqw;
  overflow: hidden;
  width: 26cqw;
  height: 26cqw;
  clip-path: shape(
    from 50% 91%,
    line to 90% 50%,
    arc to 50% 9% of 1%,
    arc to 10% 50% of 1%
  );
  display: flex;
  justify-content: center;
  align-items: center;
  transform: rotate(25deg);
}

.cover-front .cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1);
  transform: scale(1.2) rotate(-50deg);
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card-flap {
    transition-duration: 0.01s;
  }
}
