@import url('https://fonts.googleapis.com/css2?family=Mochiy+Pop+P+One&display=swap');

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f2acac;
  font-family: 'Mochiy Pop P One', sans-serif;
}

/* Hide radio inputs */
.valentines-day-card input {
  display: none;
}

/* Container for the 3D flip card */
.valentines-day-card {
  position: relative;
  width: 300px;
  height: 300px;
  perspective: 1000px;
}

/* Common styles for each face */
.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #fff0f3;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
  border: 2px solid #fff0f3;
  border-radius: 10px;
  box-shadow: inset 100px 20px 100px rgba(0,0,0,0.15), 30px 0 50px rgba(0,0,0,0.3);
}

/* Default transforms (only front face visible initially) */
.card-front {
  background-color: #fff0f3;
  width: 300px;
  height: 300px;
  transform-origin: left;
  transition: 0.6s ease;
  box-shadow: inset 100px 20px 100px rgba(0, 0, 0, 0.15),
              30px 0 50px rgba(0, 0, 0, 0.3);
  backface-visibility: visible;
  z-index: 3;
}

.card-front:before {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  background-color: #d04e4e;
  top: 10px;
  left: 10px;
}

/* Create a pseudo-element for the backside (left page) */
.card-front::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Set this to the color you want for the left page */
  background-color: #f7cac9;
  /* Rotate the pseudo-element so it acts as the backside */
  transform: rotateY(180deg);
  backface-visibility: visible;
  /* Place it behind the front design */
  z-index: -1;
}

/* Wrap any front content (such as text) inside a container */
.card-front .front-content {
  transition: transform 0.6s ease;
}

/* Instead of counter-rotating the text, we hide it in open states so the left page appears blank */
#state2:checked ~ .card-front .front-content,
#state3:checked ~ .card-front .front-content {
  display: none;
}

/* Hide inside pages by rotating them 180deg */
.card-inside-1,
.card-inside-2 {
  transform: rotateY(180deg);
  z-index: 1;
  
}
.card-inside-2 {
  transform-origin: left;
}


/* ----- State-Based Transforms ----- */

/* STATE 1: Closed (Front Cover Visible) */
#state1:checked ~ .card-front {
  transform: rotateY(0deg);
  z-index: 3;
}
#state1:checked ~ .card-inside-1 {
  transform: rotateY(180deg);
  z-index: 1;
}
#state1:checked ~ .card-inside-2 {
  transform: rotateY(180deg);
  z-index: 1;
}

/* STATE 2: First Inside Page (Open Book with One Page) */
#state2:checked ~ .card-front {
  transform: rotateY(-150deg);
  z-index: 2; /* behind the active right page */
}
#state2:checked ~ .card-inside-1 {
  transform: rotateY(0deg);
  z-index: 3; /* becomes the right page */
}
#state2:checked ~ .card-inside-2 {
  transform: rotateY(180deg);
  z-index: 1;
}

/* STATE 3: Second Inside Page (Book Fully Open, Page Turned) */
#state3:checked ~ .card-front {
  transform: rotateY(-180deg);
  z-index: 2;
}
#state3:checked ~ .card-inside-1 {
  transform: rotateY(0deg);
  z-index: 1; /* stays as the left page */
}
#state3:checked ~ .card-inside-2 {
  transform: rotateY(0deg);
  z-index: 3; /* flips in as the new right page */
}

/* ----- Clickable Overlay Button ----- */
.flip-btn {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 4;
  /* Uncomment below to visualize the clickable area */
  /* background-color: rgba(0,0,0,0.1); */
}

/* ----- Original Decorative Elements (from your card) ----- */

/* Note on the front */
.note {
  position: relative;
  width: 200px;
  height: 150px;
  background-color: #fff0f3;
  top: 75px;
  left: 50px;
  color: #333;
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  filter: drop-shadow(0 0 20px rgba(0,0,0,0.3));
}

.note:before,
.note:after {
  position: absolute;
  content: "";
  background-color: #ba1c1c;
  width: 40px;
  height: 40px;
}

.note:before {
  transform: rotate(-45deg);
  top: -20px;
  left: 80px;
}

.note:after {
  border-radius: 50%;
  top: -35px;
  left: 65px;
  box-shadow: 30px 0 #ba1c1c;
}

/* Text on the first inside page */
.text-one {
  position: absolute;
  color: #333;
  font-size: 30px;
  top: 30px;
  width: 300px;
  text-align: center;
}

.text-one:before,
.text-one:after {
  position: absolute;
  left: 5px;
  text-align: center;
  width: 300px;
}

.text-one:before {
  content: "Valentines";
  top: 30px;
  color: #d04e4e;
}

.text-one:after {
  content: "Bieee";
  top: 60px;
}

/* Heart element */
.heart {
  position: absolute;
  background-color: #d04e4e;
  height: 60px;
  width: 60px;
  top: 180px;
  left: 120px;
  transform: rotate(-45deg);
  animation: beat 0.8s infinite;
}

.heart:before,
.heart:after {
  content: "";
  background-color: #d04e4e;
  border-radius: 50%;
  height: 60px;
  width: 60px;
  position: absolute;
}

.heart:before {
  top: -30px;
  left: 0;
}

.heart:after {
  left: 30px;
  top: 0;
}

/* Smile element */
.smile {
  position: absolute;
  width: 30px;
  height: 15px;
  background-color: #333;
  z-index: 1;
  border-radius: 0 0 100px 100px;
  top: 200px;
  left: 135px;
  overflow: hidden;
}

.smile:before {
  content: "";
  position: absolute;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  background-color: #030202;
  top: 5px;
  left: 5px;
}

/* Eyes element */
.eyes {
  position: absolute;
  border-radius: 50%;
  background-color: #333;
  width: 10px;
  height: 10px;
  z-index: 1;
  top: 190px;
  left: 165px;
  box-shadow: -40px 0 #333;
  transform-origin: 50%;
  animation: close 2s infinite;
}

@keyframes close {
  0%, 100% {
    transform: scale(1, 0.05);
  }
  5%, 95% {
    transform: scale(1, 1);
  }
}

@keyframes beat {
  0%, 40%, 100% {
    transform: scale(1) rotate(-45deg);
  }
  25%, 60% {
    transform: scale(1.1) rotate(-45deg);
  }
}

/* Message on the second inside page */
.inner-message {
  width: 100%;
  top: 40%;
  text-align: center;
  font-size: 24px;
  color: #333;
}
