/* ==========================================================================
   Design System: Minimalist Polaroid & Warm Paper
   Aesthetic: Clean, Timeless, Warm Vintage Cream & Real Polaroid Frame
   ========================================================================== */

:root {
  /* Color Palette - Warm Natural Cream & Linen */
  --bg-gradient-start: #FAF8F5;
  --bg-gradient-mid: #F4EFEB;
  --bg-gradient-end: #EDE6DF;
  
  --card-bg: rgba(255, 255, 255, 0.94);
  --card-border: #E8E1D7;
  --card-shadow: 0 18px 45px -10px rgba(50, 40, 35, 0.09),
                 0 6px 16px -4px rgba(50, 40, 35, 0.04);

  /* Deep High-Contrast Text (Clean & Mature) */
  --text-primary: #211D20;
  --text-secondary: #564D52;
  --text-muted: #84797E;

  /* Warm Muted Rosewood / Terracotta Accent */
  --accent-primary: #9C4557;
  --accent-primary-hover: #863647;
  --accent-primary-active: #6E2A39;
  --accent-light: #F7ECEF;
  --accent-glow: rgba(156, 69, 87, 0.22);

  --secondary-bg: #FFFFFF;
  --secondary-border: #DCD3C7;
  --secondary-text: #2D262A;
  --secondary-hover: #F6F1EA;

  --success-color: #276B46;
  --success-bg: #EAF3ED;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;

  /* Radii */
  --radius-card: 24px;
  --radius-btn: 9999px;
  --radius-badge: 9999px;

  /* Transition Easing */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: linear-gradient(160deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Canvas layers */
#ambient-canvas,
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#ambient-canvas {
  z-index: 1;
  opacity: 0.5;
}

#confetti-canvas {
  z-index: 99;
}

/* Top sound toggle bar */
.top-nav {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
}

.glass-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-badge);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.glass-pill-btn:hover {
  background: #FFFFFF;
  color: var(--text-primary);
  border-color: #C8BFB3;
}

/* App Wrapper */
.app-wrapper {
  position: relative;
  z-index: 10;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

/* ==========================================================================
   Cards & Layout
   ========================================================================== */

.card {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 26px 22px 28px;
  text-align: center;
  position: relative;
  transition: opacity 0.35s var(--ease-spring), transform 0.35s var(--ease-spring);
}

.card.hidden {
  display: none !important;
  opacity: 0;
  transform: scale(0.97) translateY(10px);
}

.card.active {
  display: block !important;
  animation: cardEnter 0.45s var(--ease-spring) forwards;
}

@keyframes cardEnter {
  0% {
    opacity: 0;
    transform: scale(0.96) translateY(14px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

/* ==========================================================================
   Polaroid Photo Frame Component
   ========================================================================== */

.polaroid-frame {
  position: relative;
  background: #FFFFFF;
  padding: 10px 10px 22px 10px;
  border-radius: 4px;
  box-shadow: 0 12px 28px rgba(45, 35, 30, 0.1), 0 2px 6px rgba(0, 0, 0, 0.04);
  border: 1px solid #EBE4D8;
  width: 100%;
  max-width: 270px;
  margin: 8px auto 2px;
  transform: rotate(-1deg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.polaroid-frame:hover {
  transform: rotate(0deg) scale(1.015);
  box-shadow: 0 16px 36px rgba(45, 35, 30, 0.14);
}

.washi-tape {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(0.8deg);
  width: 66px;
  height: 18px;
  background: rgba(226, 218, 206, 0.82);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  z-index: 2;
  border-radius: 2px;
}

.polaroid-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 2px;
  background: #EDE6DC;
}

.hero-image,
.dialog-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
  display: block;
}

.modal-polaroid {
  max-width: 210px;
  padding: 8px 8px 18px 8px;
  transform: rotate(0.5deg);
  margin-top: 4px;
}

/* ==========================================================================
   Typography & Badges
   ========================================================================== */

.content-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 4px;
}

.sub-badge {
  display: inline-block;
  padding: 5px 13px;
  background: #EFE9DF;
  color: #554A43;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-radius: var(--radius-badge);
  border: 1px solid #E2D9CC;
}

.success-badge {
  background: var(--success-bg);
  color: var(--success-color);
  border-color: #D3E5D9;
}

.warmth-badge {
  background: #F8ECE4;
  color: #8C4724;
  border-color: #EDD8CC;
}

.apology-badge {
  background: #F7EAEF;
  color: #863647;
  border-color: #EBD3DB;
}

.main-heading {
  font-family: var(--font-sans);
  font-size: 1.32rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  word-break: break-word;
}

.quote-heading {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-style: italic;
  font-weight: 600;
  color: var(--accent-primary);
  line-height: 1.45;
}

.body-text {
  font-size: 0.93rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-weight: 500;
  max-width: 90%;
}

/* ==========================================================================
   Stationery Note / Long Letter
   ========================================================================== */

.letter-paper {
  width: 100%;
  background: #F9F6F0;
  border: 1.5px solid #E5DCCE;
  border-radius: 16px;
  padding: 18px 18px;
  text-align: left;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.02);
  position: relative;
  margin-top: 4px;
}

.letter-text {
  font-family: var(--font-sans);
  font-size: 0.91rem;
  font-weight: 500;
  color: #2D2528;
  line-height: 1.72;
  position: relative;
  z-index: 1;
  word-break: break-word;
}

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */

.action-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.options-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.22s var(--ease-spring);
  position: relative;
  user-select: none;
}

.btn:active {
  transform: scale(0.97) !important;
}

.btn-primary {
  background: var(--accent-primary);
  color: #FFFFFF;
  box-shadow: 0 6px 18px var(--accent-glow);
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 8px 22px rgba(156, 69, 87, 0.32);
  transform: translateY(-1.5px);
}

.btn-outline {
  background: var(--secondary-bg);
  color: var(--secondary-text);
  border: 1.5px solid var(--secondary-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.btn-outline:hover {
  background: var(--secondary-hover);
  border-color: #B8ADA0;
  color: var(--text-primary);
  transform: translateY(-1.5px);
}

.btn-secondary {
  background: #F4EFEB;
  color: #614650;
  border: 1.5px solid #E2D7CC;
}

.btn-secondary:hover {
  background: #ECE4DB;
  color: var(--text-primary);
  transform: translateY(-1.5px);
}

.btn-wa {
  background: #25D366;
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.3);
  font-size: 0.98rem;
}

.btn-wa:hover {
  background: #1EBE5D;
  box-shadow: 0 8px 22px rgba(37, 211, 102, 0.4);
  transform: translateY(-1.5px);
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 6px 14px;
}

.btn-text:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.full-width {
  width: 100%;
}

/* Redirect loader */
.redirect-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(39, 107, 70, 0.08);
  border-radius: var(--radius-badge);
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--success-color);
  margin-top: 4px;
}

.loading-ring {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(39, 107, 70, 0.2);
  border-top-color: var(--success-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Custom Apology Dialog Modal (<dialog>)
   ========================================================================== */

.custom-dialog {
  border: none;
  background: transparent;
  padding: 16px;
  margin: auto;
  max-width: 440px;
  width: 92%;
  z-index: 100;
}

.custom-dialog::backdrop {
  background: rgba(30, 25, 23, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: backdropFade 0.25s ease forwards;
}

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

.dialog-card {
  background: #FFFFFF;
  color: var(--text-primary);
  border-radius: var(--radius-card);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.2);
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  border: 1px solid #EAE3D9;
  animation: modalPop 0.35s var(--ease-spring) forwards;
}

@keyframes modalPop {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(16px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dialog-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #F4EFEB;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dialog-close-btn:hover {
  background: #E8E0D5;
  color: var(--text-primary);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dialog-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.dialog-text {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.62;
  font-weight: 500;
}

.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

/* ==========================================================================
   Mobile Optimization
   ========================================================================== */

@media (max-width: 480px) {
  .app-wrapper {
    padding: 16px 12px;
  }

  .card {
    padding: 22px 18px 24px;
    border-radius: 20px;
  }

  .polaroid-frame {
    max-width: 250px;
  }

  .main-heading {
    font-size: 1.2rem;
  }

  .body-text {
    font-size: 0.88rem;
  }

  .btn {
    padding: 13px 18px;
    font-size: 0.9rem;
  }
}
