/* =============== RESET & BASE =============== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Poppins", sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
  /* iOS FIX: Ensure scrolling works */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* FIX FOR iOS: Change from fixed to absolute */
body::before {
  content: "";
  position: absolute; /* CHANGED FROM fixed */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.65);
  pointer-events: none; /* ALLOWS TOUCH THROUGH */
  z-index: 0;
}

.invitation-container {
  max-width: 100%;
  margin: 0 auto;
  background: transparent;
  position: relative;
  z-index: 1;
  padding: 0;
}

/* iOS SPECIFIC FIXES */
@supports (-webkit-touch-callout: none) {
  html,
  body {
    height: -webkit-fill-available;
  }

  body {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .invitation-container {
    overflow-y: visible !important;
  }

  /* Ensure all sections can scroll */
  section,
  div {
    position: relative;
    overflow: visible !important;
  }
}

/* =============== SAVE THE DATE SECTION =============== */
.save-date-section {
  padding: 50px 20px 30px;
  text-align: center;
  background: transparent;
}

.save-date-title {
  font-family: "Dancing Script", cursive;
  font-size: 3.5rem;
  font-weight: 700;
  color: #000;
  margin-bottom: 25px;
  text-shadow: 0 2px 10px rgba(255, 182, 193, 0.4);
  letter-spacing: 2px;
  animation: fadeInDown 1s ease;
}

.couple-names {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.name {
  font-family: "Dancing Script", cursive;
  font-size: 1.8rem;
  font-weight: 600;
  color: #000;
  text-shadow: 0 1px 5px rgba(255, 182, 193, 0.3);
}

.ampersand {
  font-family: "Playfair Display", serif;
  font-size: 2rem;
  color: #333;
  font-weight: 300;
  margin: 0 5px;
}

/* =============== PHOTO SECTION =============== */
.photo-section {
  padding: 20px 15px 30px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.photo-frame {
  width: 90%;
  max-width: 400px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  position: relative;
  animation: fadeInUp 1s ease 0.3s both;
  overflow: visible !important; /* iOS FIX */
}

.photo-frame::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.8),
    rgba(240, 240, 240, 0.8)
  );
  border-radius: 17px;
  z-index: -1;
}

.main-photo {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  object-fit: cover;
}

/* =============== DATE TIME SECTION =============== */
.datetime-section {
  padding: 30px 20px 40px;
  text-align: center;
}

.datetime-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  margin-bottom: 15px;
  padding: 0 10px;
}

.time-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.time {
  font-size: 2.8rem;
  font-weight: 600;
  color: #000;
  font-family: "Poppins", sans-serif;
  line-height: 1;
  margin-bottom: 8px;
}

.day-name {
  font-size: 1.1rem;
  color: #555;
  font-weight: 500;
  font-family: "Poppins", sans-serif;
}

.divider-line {
  width: 2px;
  height: 70px;
  background: linear-gradient(180deg, transparent, #ddd, transparent);
}

.date-block {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-main {
  font-size: 3.5rem;
  font-weight: 700;
  color: #000;
  font-family: "Poppins", sans-serif;
  line-height: 1;
}

.year {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.year-digit {
  font-size: 2.5rem;
  font-weight: 600;
  color: #000;
  font-family: "Poppins", sans-serif;
  line-height: 1;
}

.lunar-date {
  font-size: 1rem;
  color: #666;
  font-style: italic;
  margin-top: 15px;
  font-family: "Poppins", sans-serif;
}

/* =============== QUOTE SECTION =============== */
.quote-section {
  padding: 40px 25px 40px;
  text-align: center;
}

.quote-text {
  font-family: "Dancing Script", cursive;
  font-size: 1.5rem;
  color: #000;
  line-height: 1.8;
  margin: 10px 0;
  text-shadow: 0 1px 3px rgba(255, 182, 193, 0.2);
}

/* =============== FAMILY SECTION =============== */
.family-section {
  padding: 40px 15px 60px;
  background: transparent;
  margin: 0;
}

.family-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow: visible !important; /* iOS FIX */
}

.family-info-block {
  background: #ffffff;
  padding: 25px 18px;
  border-radius: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  margin: 0;
}

.groom-family {
  background-color: #ffffff !important;
}

.family-label {
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 12px;
  font-family: "Poppins", sans-serif;
}

.family-parents {
  margin-bottom: 15px;
}

.family-parents p {
  font-size: 0.9rem;
  color: #666;
  margin: 5px 0;
  font-family: "Poppins", sans-serif;
}

.character-illustration {
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.character-icon {
  width: 180px;
  height: 180px;
  object-fit: contain;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.person-label {
  font-size: 0.95rem;
  color: #888;
  margin-top: 10px;
  margin-bottom: 5px;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
}

.family-info-block .person-name {
  font-family: "Dancing Script", cursive;
  font-size: 1.8rem;
  font-weight: 600;
  color: #000;
  text-shadow: none;
}

.photo-block {
  width: 100%;
  height: 100%;
  min-height: 250px;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  margin: 0;
  padding: 0;
}

.family-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  transition: transform 0.4s ease;
}

.family-photo:hover {
  transform: scale(1.08);
}

/* =============== INVITATION LETTER SECTION =============== */
.invitation-letter-section {
  padding: 50px 15px 0px;
  background: rgba(255, 255, 255, 0.95);
  text-align: center;
}

.invitation-letter-title {
  font-family: "Dancing Script", cursive;
  font-size: 3.5rem;
  font-weight: 700;
  color: #000;
  margin-bottom: 15px;
}

.invitation-letter-subtitle {
  font-family: "Poppins", sans-serif;
  font-size: 1.1rem;
  font-weight: 500;
  color: #000;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  line-height: 1.5;
}

/* =============== THREE PHOTOS SECTION =============== */
.three-photos-section {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 30px 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* iOS FIX */
}

.photo-item-left,
.photo-item-right {
  flex: 0 0 auto;
  width: 30%;
  max-width: 200px;
}

.photo-item-center {
  flex: 0 0 auto;
  width: 35%;
  max-width: 240px;
}

.wedding-photo {
  width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* =============== RECEPTION SECTION =============== */
.reception-section {
  padding: 10px 0 20px;
  margin-top: 20px;
}

.reception-title {
  font-size: 1.3rem;
  font-weight: 500;
  color: #000;
  margin-bottom: 25px;
  font-family: "Poppins", sans-serif;
  text-align: center;
}

.reception-datetime {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.reception-time-block,
.reception-date-block,
.reception-year-block {
  text-align: center;
  min-width: 80px;
}

.reception-time {
  font-size: 1.2rem;
  font-weight: 500;
  color: #000;
  font-family: "Poppins", sans-serif;
}

.reception-divider {
  width: 1px;
  height: 50px;
  background: #000;
  opacity: 0.3;
}

.reception-day-number {
  font-size: 4rem;
  font-weight: 700;
  color: #333;
  line-height: 1;
  margin-bottom: 5px;
  font-family: "Poppins", sans-serif;
}

.reception-month {
  font-size: 1rem;
  color: #000;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
}

.reception-year {
  font-size: 1.2rem;
  font-weight: 500;
  color: #000;
  font-family: "Poppins", sans-serif;
}

.reception-day-name {
  font-size: 1.1rem;
  color: #000;
  margin-bottom: 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
}

.reception-lunar-date {
  font-size: 0.85rem;
  color: #666;
  font-style: italic;
  font-family: "Poppins", sans-serif;
}

/* =============== ADDRESS SECTION =============== */
.address {
  padding: 30px 20px 40px;
  text-align: center;
  background: white;
}

.address h1 {
  font-size: 1.6rem;
  margin-bottom: 15px;
  color: #333;
}

.address h2 {
  font-size: 1.3rem;
  margin-bottom: 10px;
  color: #555;
}

.address p {
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 20px;
}

.map-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
}

iframe {
  width: 100%;
  height: 350px;
  border: 0;
  pointer-events: auto; /* iOS FIX: Allow interaction */
}

/* =============== BANKING SECTION =============== */
.banking-section {
  padding: 40px 20px 50px;
  background: #f8f9fa;
  text-align: center;
}

.banking-container {
  max-width: 800px;
  margin: 0 auto;
}

.banking-title {
  font-family: "Poppins", sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 30px;
  text-align: center;
}

.banking-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 25px;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .banking-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
  }
}

.banking-card {
  background: white;
  border-radius: 12px;
  padding: 25px 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.banking-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.groom-banking {
  border-top: 4px solid #667eea;
}

.bride-banking {
  border-top: 4px solid #ec4899;
}

.banking-family-label {
  font-family: "Poppins", sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 20px;
  text-align: center;
}

.groom-banking .banking-family-label {
  color: #667eea;
}

.bride-banking .banking-family-label {
  color: #ec4899;
}

.qr-code-container {
  margin: 15px 0 25px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.qr-code-image {
  width: 160px;
  height: 240px;
  border-radius: 6px;
  object-fit: cover;
  background: white;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Banking details */
.banking-details {
  width: 100%;
  text-align: left;
  margin-top: 10px;
}

.banking-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
}

.banking-info-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.banking-info-label {
  font-family: "Poppins", sans-serif;
  font-size: 0.95rem;
  color: #666;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.banking-info-value {
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  text-align: right;
  margin-left: 10px;
  flex: 1;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.groom-banking .banking-info-value {
  color: #667eea;
}

.bride-banking .banking-info-value {
  color: #ec4899;
}

/* Copy functionality styles */
.banking-info-value.copyable {
  cursor: pointer;
  position: relative;
  padding: 2px 5px;
  border-radius: 4px;
  transition: background-color 0.2s;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  min-height: 44px; /* iOS minimum touch target */
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.banking-info-value.copyable:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.banking-info-value.copyable:active {
  background-color: rgba(102, 126, 234, 0.1);
}

.banking-note {
  font-family: "Poppins", sans-serif;
  font-size: 0.9rem;
  color: #666;
  font-style: italic;
  margin-top: 30px;
  text-align: center;
  padding: 15px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  border-left: 3px solid #ec4899;
}

/* =============== MUSIC TOGGLE BUTTON =============== */
.music-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  z-index: 9999; /* Higher z-index for iOS */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 22px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px; /* iOS minimum touch target */
  min-width: 44px;
}

.music-toggle-btn:active {
  transform: scale(0.9);
}

/* =============== THANK YOU SECTION =============== */
.thank-you-section {
  padding: 2rem;
  text-align: center;
  background: #f9f9f9;
  border-radius: 1rem 1rem 0 0;
  margin-top: 2rem;
}

.thank-you-message {
  color: #666;
  margin-bottom: 1rem;
  font-style: italic;
}

.thank-you-title {
  font-family: "Dancing Script", cursive;
  font-size: 2.5rem;
  font-weight: bold;
  color: #333;
  margin: 1rem 0;
}

.couple-signature {
  font-family: "Dancing Script", cursive;
  font-size: 2rem;
  font-weight: 600;
  color: #000;
  margin-top: 1rem;
}

/* =============== ANIMATIONS =============== */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* =============== RESPONSIVE DESKTOP =============== */
@media (min-width: 768px) {
  .invitation-container {
    max-width: 500px;
    margin: 0 auto;
  }

  .save-date-title {
    font-size: 4.5rem;
  }

  .name {
    font-size: 2.2rem;
  }

  .photo-frame {
    max-width: 450px;
  }

  .time {
    font-size: 3.2rem;
  }

  .date-main {
    font-size: 4rem;
  }

  .year-digit {
    font-size: 2.8rem;
  }

  .quote-text {
    font-size: 1.8rem;
  }

  .family-section {
    padding: 50px 20px;
  }

  .family-info-block {
    padding: 25px 20px;
  }

  .character-icon {
    width: 220px;
    height: 220px;
  }

  .family-info-block .person-name {
    font-size: 2.2rem;
  }

  .photo-block {
    min-height: 300px;
  }

  .invitation-letter-title {
    font-size: 4rem;
  }

  .invitation-letter-subtitle {
    font-size: 1.2rem;
  }

  .reception-day-number {
    font-size: 5rem;
  }

  .reception-title {
    font-size: 1.5rem;
  }

  .banking-section {
    padding: 50px 30px 60px;
  }

  .banking-title {
    font-size: 2rem;
    margin-bottom: 35px;
  }

  .banking-card {
    padding: 30px 25px;
  }

  .qr-code-image {
    width: 180px;
    height: 220px;
  }
}

/* =============== RESPONSIVE MOBILE =============== */
@media (max-width: 480px) {
  .save-date-title {
    font-size: 2.8rem;
  }

  .name {
    font-size: 1.5rem;
  }

  .ampersand {
    font-size: 1.6rem;
  }

  .photo-frame {
    width: 85%;
  }

  .time {
    font-size: 2.3rem;
  }

  .day-name {
    font-size: 1rem;
  }

  .date-main {
    font-size: 2.8rem;
  }

  .year-digit {
    font-size: 1.8rem;
  }

  .datetime-content {
    gap: 15px;
  }

  .divider-line {
    height: 50px;
  }

  .quote-text {
    font-size: 1.3rem;
  }

  .family-section {
    padding: 30px 15px;
  }

  .family-info-block {
    padding: 15px 10px;
  }

  .family-label {
    font-size: 0.9rem;
  }

  .family-parents p {
    font-size: 0.85rem;
  }

  .character-icon {
    width: 150px;
    height: 150px;
  }

  .family-info-block .person-name {
    font-size: 1.5rem;
  }

  .photo-block {
    min-height: 200px;
  }

  .invitation-letter-title {
    font-size: 2.5rem;
  }

  .invitation-letter-subtitle {
    font-size: 0.9rem;
  }

  .reception-day-number {
    font-size: 3rem;
  }

  .reception-title {
    font-size: 1.1rem;
  }

  .reception-datetime {
    gap: 10px;
  }

  .reception-divider {
    height: 40px;
  }

  .photo-item-left,
  .photo-item-right {
    width: 28%;
  }

  .photo-item-center {
    width: 38%;
  }

  .address h1 {
    font-size: 1.4rem;
  }

  .address h2 {
    font-size: 1.1rem;
  }

  .address p {
    font-size: 1rem;
  }

  .banking-section {
    padding: 30px 15px 40px;
  }

  .banking-title {
    font-size: 1.5rem;
    margin-bottom: 25px;
  }

  .banking-card {
    padding: 20px 15px;
  }

  .qr-code-image {
    width: 140px;
    height: 180px;
  }

  .banking-info-label {
    font-size: 0.9rem;
  }

  .banking-info-value {
    font-size: 0.95rem;
  }

  .music-toggle-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
    bottom: 15px;
    right: 15px;
  }
}

/* =============== TABLET ADJUSTMENTS =============== */
@media (min-width: 481px) and (max-width: 767px) {
  .invitation-container {
    margin: 15px auto;
    max-width: 450px;
  }

  .banking-info-row {
    flex-wrap: nowrap;
  }
}

/* =============== PREVENT TEXT SELECTION FOR MOBILE =============== */
@media (max-width: 767px) {
  * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  input,
  textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
  }
}

/* =============== LOADING SCREEN =============== */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, #e276f8 0%, #6dec62 100%);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
