/* CSS Design System for Love Flashcards Website */

:root {
  /* Day Theme (Sunset Pink) */
  --bg-gradient: linear-gradient(135deg, #ffe5ec 0%, #ffb3c6 50%, #ff85a1 100%);
  --card-bg: rgba(255, 255, 255, 0.45);
  --card-border: rgba(255, 255, 255, 0.6);
  --text-primary: #4a1525;
  --text-secondary: #8c3a52;
  --accent-color: #ff477e;
  --accent-hover: #ff2a63;
  --accent-light: rgba(255, 71, 126, 0.15);
  --shadow-color: rgba(255, 71, 126, 0.15);
  --glow-color: transparent;
  --font-cursive: 'Dancing Script', cursive;
  --font-sans: 'Quicksand', sans-serif;
  --panel-blur: blur(20px);
}

[data-theme="midnight"] {
  /* Night Theme (Midnight Rose) */
  --bg-gradient: linear-gradient(135deg, #0f051d 0%, #2e0828 50%, #4a0d33 100%);
  --card-bg: rgba(15, 5, 29, 0.55);
  --card-border: rgba(255, 71, 126, 0.35);
  --text-primary: #ffe5ec;
  --text-secondary: #ffb3c6;
  --accent-color: #ff477e;
  --accent-hover: #ff759f;
  --accent-light: rgba(255, 71, 126, 0.3);
  --shadow-color: rgba(255, 71, 126, 0.4);
  --glow-color: rgba(255, 71, 126, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  overscroll-behavior-x: none;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-primary);
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: background 0.8s ease;
}

/* Canvas background */
#canvas-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Top control bar */
.top-bar {
  position: absolute;
  top: 15px;
  width: 100%;
  max-width: 450px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
}

.icon-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.icon-btn:hover {
  transform: scale(1.1);
  background: var(--accent-light);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Theme Toggle Icons */
#theme-toggle .theme-sun-icon {
  display: inline-block;
}
#theme-toggle .theme-moon-icon {
  display: none;
}
[data-theme="midnight"] #theme-toggle .theme-sun-icon {
  display: none;
}
[data-theme="midnight"] #theme-toggle .theme-moon-icon {
  display: inline-block;
}

/* Music Equalizer and Toggle */
.music-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.music-off-icon {
  display: inline-block;
}
.music-on-icon {
  display: none;
}
.music-playing .music-off-icon {
  display: none;
}
.music-playing .music-on-icon {
  display: inline-block;
}

/* Main Layout */
.app-container {
  width: 100%;
  max-width: 450px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 70px 24px 20px 24px;
  z-index: 10;
}

.deck-wrapper {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

/* Header Text */
.app-header {
  text-align: center;
  margin-bottom: 10px;
}

.app-header h1 {
  font-family: var(--font-cursive);
  font-size: 2.5rem;
  color: var(--text-primary);
  margin-bottom: 2px;
  text-shadow: 0 2px 4px var(--shadow-color);
}

.app-header .subtitle {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Card Deck area */
.card-deck {
  position: relative;
  width: 100%;
  height: 380px;
  max-width: 320px;
  perspective: 1000px;
  margin: 15px auto;
}

/* Base Card structure */
.card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.5s ease;
  pointer-events: none;
  opacity: 0;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 30px var(--shadow-color), 0 0 0 1px var(--card-border);
  box-shadow: 0 10px 30px var(--shadow-color), 0 0 0 1px var(--card-border), 0 0 15px var(--glow-color);
}

/* Card front/back panels */
.card-front, .card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background: var(--card-bg);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  backface-visibility: hidden;
  overflow: hidden;
}

.card-front > *, .card-back > * {
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.card:not(.active) .card-front > *,
.card:not(.active) .card-back > * {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.card:not(.active) * {
  animation: none !important;
}

.card-back {
  transform: rotateY(180deg);
  justify-content: space-between;
}

/* 3D Flip state */
.card.flipped .card-inner {
  transform: rotateY(180deg);
}

/* Card content details */
.card h2 {
  font-family: var(--font-cursive);
  font-size: 2rem;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.card p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding-bottom: 2rem; /* extra space at bottom */
}

.card-body p {
  width: 100%;
}

.highlight-text {
  font-size: 1.15rem !important;
  font-weight: 700;
  color: var(--accent-color) !important;
  line-height: 1.4 !important;
}

/* Card Visual Art Elements */
.card-art {
  font-size: 4.5rem;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 10px var(--shadow-color));
}

.tap-hint {
  font-size: 0.8rem !important;
  color: var(--text-secondary);
  opacity: 0.8;
  margin-top: 15px;
  animation: pulse-glow 1.8s infinite alternate;
}

@keyframes pulse-glow {
  0% { opacity: 0.4; transform: scale(0.97); }
  100% { opacity: 0.95; transform: scale(1.03); }
}

/* Custom interactive animations on fronts */
.pulse-heart {
  animation: pulse-scale 1.2s infinite ease-in-out;
}
@keyframes pulse-scale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.pulse-heart-fast {
  animation: pulse-scale-fast 0.6s infinite ease-in-out;
}
@keyframes pulse-scale-fast {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.shaking-emoji {
  animation: tilt-shaking 1.5s infinite ease-in-out;
}
@keyframes tilt-shaking {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-8deg) scale(1.05); }
  75% { transform: rotate(8deg) scale(1.05); }
}

.floating-hand {
  animation: float-up-down 2s infinite ease-in-out;
}
@keyframes float-up-down {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.glowing-envelope {
  animation: envelope-glowing 2s infinite ease-in-out;
}
@keyframes envelope-glowing {
  0%, 100% { filter: drop-shadow(0 0 5px var(--accent-color)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 20px var(--accent-color)); transform: scale(1.1); }
}

/* Breathing indicator details */
.breath-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 20px 0; /* increased vertical spacing */
}

.breath-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent-light);
  border: 2px solid var(--accent-color);
  animation: breathe 6s infinite ease-in-out;
}

.breath-text {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  animation: breathe-text-anim 6s infinite ease-in-out;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); background: var(--accent-light); }
  45%, 55% { transform: scale(2.2); background: rgba(255, 71, 126, 0.4); }
}

@keyframes breathe-text-anim {
  0%, 100% { content: "Inhale"; opacity: 0.6; }
  45%, 55% { content: "Hold & Exhale"; opacity: 1; }
}

/* Card deck stack coordinates */
.card.active {
  z-index: 10;
  transform: translate3d(0, 0, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.card.next-1 {
  z-index: 9;
  transform: translate3d(0, 15px, -40px) scale(0.94);
  opacity: 0.85;
}

.card.next-2 {
  z-index: 8;
  transform: translate3d(0, 30px, -80px) scale(0.88);
  opacity: 0.6;
}

.card.hidden-under {
  z-index: 5;
  transform: translate3d(0, 40px, -120px) scale(0.82);
  opacity: 0;
}

/* Swiped styles */
.card.swipe-left {
  transform: translate3d(-140%, 40px, 0) rotate(-15deg) scale(0.9);
  opacity: 0;
  pointer-events: none;
}

.card.swipe-right {
  transform: translate3d(140%, 40px, 0) rotate(15deg) scale(0.9);
  opacity: 0;
  pointer-events: none;
}

/* Interactive Buttons */
.btn {
  background: var(--accent-color);
  color: white;
  border: none;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 10px var(--shadow-color);
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

/* Love slider styles */
.meter-container {
  gap: 15px;
}

.meter-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: var(--accent-light);
  padding: 12px;
  border-radius: 16px;
  width: 100%;
  border: 1px dashed var(--accent-color);
}

.meter-emoji {
  font-size: 2.5rem;
}

.meter-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-color);
}

.love-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--card-border);
  outline: none;
  margin: 15px 0;
}

.love-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 2px 6px var(--shadow-color);
  transition: transform 0.1s ease;
}

.love-slider::-webkit-slider-thumb:active {
  transform: scale(1.3);
}

.slider-hint {
  font-size: 0.75rem !important;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Envelope Container */
.envelope-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 230px;
}

.envelope {
  position: relative;
  width: 220px;
  height: 130px;
  background: #ffcbd6;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px var(--shadow-color);
  cursor: pointer;
  transform-origin: center;
  transition: transform 0.4s ease;
}

[data-theme="midnight"] .envelope {
  background: #b2456e;
}

.envelope:hover {
  transform: scale(1.02);
}

.envelope .flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 110px solid transparent;
  border-right: 110px solid transparent;
  border-top: 75px solid #ff9ebb;
  border-bottom: 0 solid transparent;
  transform-origin: top;
  transition: transform 0.4s ease-in-out, z-index 0.2s ease 0.2s;
  z-index: 3;
}

[data-theme="midnight"] .envelope .flap {
  border-top-color: #8f2e51;
}

.envelope .pocket {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 110px solid #ffb3c6;
  border-right: 110px solid #ffb3c6;
  border-top: 60px solid transparent;
  border-bottom: 70px solid #ffb3c6;
  border-radius: 0 0 8px 8px;
  z-index: 2;
}

[data-theme="midnight"] .envelope .pocket {
  border-left-color: #a33c63;
  border-right-color: #a33c63;
  border-bottom-color: #a33c63;
}

.envelope .letter {
  position: absolute;
  bottom: 10px;
  left: 15px;
  width: 190px;
  height: 110px;
  background: white;
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), z-index 0.1s ease;
  z-index: 1;
  text-align: left;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
}

[data-theme="midnight"] .envelope .letter {
  background: #fdf5f7;
  color: #3d0012;
}

.letter-date {
  font-size: 0.6rem !important;
  color: #aaa;
  margin: 0;
  font-weight: 600;
  text-transform: uppercase;
}

.letter-content {
  font-family: var(--font-sans);
  font-size: 0.65rem !important;
  line-height: 1.4 !important;
  color: #333 !important;
  margin: 0;
}

.letter-signature {
  font-family: var(--font-cursive);
  font-size: 0.9rem !important;
  color: var(--accent-color) !important;
  align-self: flex-end;
  margin-top: auto;
}

/* Open Envelope States */
.envelope.open .flap {
  transform: rotateX(180deg);
  z-index: 0;
}

.envelope.open .letter {
  transform: translateY(-85px);
  z-index: 2;
  height: 145px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.envelope.open {
  transform: translateY(30px);
}

/* Action buttons container */
.hug-buttons-container {
  display: flex;
  gap: 8px;
  margin-top: 30px;
  z-index: 5;
  transition: all 0.5s ease;
  opacity: 1;
  transform: scale(1);
}

.hug-buttons-container.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.action-btn {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  box-shadow: 0 4px 10px var(--shadow-color);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.action-btn:hover {
  transform: translateY(-3px);
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.action-btn:active {
  transform: translateY(0);
}

/* Deck Control Footer */
.deck-controls {
  width: 100%;
  max-width: 320px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.nav-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-btn:hover:not(:disabled) {
  transform: scale(1.08);
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.dots-indicator {
  display: flex;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--card-border);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dot.active {
  background: var(--accent-color);
  transform: scale(1.4);
  box-shadow: 0 0 8px var(--accent-color);
}

/* Alert Notification Banner */
.alert-banner {
  position: absolute;
  top: -60px;
  background: var(--accent-color);
  color: white;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
}

.alert-banner.show {
  top: 70px;
}

.alert-text {
  display: inline-block;
}

/* Custom transitions and scrollbar */
::-webkit-scrollbar {
  display: none;
}

/* Lucide Icons Custom Styling */
.card-art svg {
  width: 4.5rem;
  height: 4.5rem;
  stroke: var(--accent-color);
  stroke-width: 1.5;
}

.meter-emoji svg {
  width: 2.5rem;
  height: 2.5rem;
  stroke: var(--accent-color);
  stroke-width: 2;
}

.btn-flip svg, .action-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  display: inline-block;
  vertical-align: middle;
  stroke-dasharray: none;
}

.btn-flip svg {
  margin-left: 5px;
}

.action-btn svg {
  margin-right: 6px;
}

.app-header svg, h2 svg {
  width: 2.2rem;
  height: 2.2rem;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  stroke: var(--accent-color);
  stroke-width: 2;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-primary);
  stroke-width: 2;
}
