/* ============================================
   LOVE JAR — Styles
   ============================================ */

/* --- Custom Properties --- */
:root {
  --bg-start: #ffeef8;
  --bg-end: #f0e0ff;
  --primary: #e8507e;
  --primary-light: #ffb6c8;
  --primary-soft: #ffd6e0;
  --accent: #c77dba;
  --accent-light: #e8c8e4;
  --text: #5d3954;
  --text-soft: #8a6580;
  --cream: #fff8f0;
  --white: #ffffff;

  /* Jar */
  --jar-glass: rgba(255, 255, 255, 0.22);
  --jar-glass-border: rgba(255, 255, 255, 0.45);
  --jar-glow-color: rgba(232, 80, 126, 0.25);

  /* Note Colors */
  --note-1: #ffcdd2;
  --note-2: #f8bbd0;
  --note-3: #e1bee7;
  --note-4: #c5cae9;
  --note-5: #b2dfdb;
  --note-6: #fff9c4;
  --note-7: #ffe0b2;
  --note-8: #f0f4c3;

  /* Sizing — scales with the viewport */
  --jar-width: clamp(200px, 56vw, 380px);
  --jar-height: clamp(300px, 52vh, 520px);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  color: var(--text);
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* --- Music Toggle --- */
.music-toggle {
  position: fixed;
  bottom: 1.4rem;
  right: 1.4rem;
  z-index: 50;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(232, 80, 126, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  animation: fadeInUp 0.8s ease-out 0.8s both;
}

.music-toggle:hover,
.music-toggle:focus-visible {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(232, 80, 126, 0.3);
  background: rgba(255, 255, 255, 0.9);
}

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

.music-icon {
  font-size: 1.4rem;
  line-height: 1;
  transition: opacity 0.3s ease;
}

/* Playing state — icon pulses, button gets a glow ring */
.music-toggle.playing {
  box-shadow:
    0 4px 18px rgba(232, 80, 126, 0.18),
    0 0 0 0 rgba(232, 80, 126, 0.4);
  animation: musicRingPulse 2s ease-in-out infinite;
}

.music-toggle.playing .music-icon {
  animation: musicIconBounce 1.2s ease-in-out infinite;
}

@keyframes musicRingPulse {
  0%, 100% {
    box-shadow:
      0 4px 18px rgba(232, 80, 126, 0.18),
      0 0 0 0px rgba(232, 80, 126, 0.35);
  }
  50% {
    box-shadow:
      0 4px 18px rgba(232, 80, 126, 0.18),
      0 0 0 8px rgba(232, 80, 126, 0);
  }
}

@keyframes musicIconBounce {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.15) rotate(-5deg); }
  50% { transform: scale(1) rotate(0deg); }
  75% { transform: scale(1.1) rotate(5deg); }
}

/* Muted state */
.music-toggle.muted .music-icon {
  opacity: 0.35;
}

/* --- App Nav (bottom-left dropdown) --- */
.app-nav {
  position: fixed;
  bottom: 1.4rem;
  left: 1.4rem;
  z-index: 50;
  animation: fadeInUp 0.8s ease-out 0.8s both;
}

.app-nav-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(232, 80, 126, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  z-index: 2;
}

.app-nav-btn .nav-icon {
  font-size: 1.4rem;
  line-height: 1;
  transition: transform 0.3s ease;
}

.app-nav.open .app-nav-btn .nav-icon {
  transform: rotate(-20deg) scale(1.1);
}

.app-nav-btn:hover,
.app-nav-btn:focus-visible {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(232, 80, 126, 0.3);
  background: rgba(255, 255, 255, 0.9);
}

.app-nav-btn:active {
  transform: scale(0.93);
}

/* Dropdown */
.app-nav-dropdown {
  position: absolute;
  bottom: calc(100% + 0.7rem);
  left: 0;
  min-width: 210px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 2px solid var(--primary-light);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(232, 80, 126, 0.18), 0 2px 8px rgba(0,0,0,0.06);
  padding: 0.6rem 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.95);
  transform-origin: bottom left;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  pointer-events: none;
}

.app-nav.open .app-nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.nav-dropdown-header {
  font-family: 'Dancing Script', cursive;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  padding: 0.4rem 1.1rem 0.5rem;
  letter-spacing: 0.02em;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  font-family: 'Quicksand', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 0.6rem;
  margin: 0 0.4rem;
  transition: background 0.18s ease, transform 0.15s ease;
}

.nav-dropdown-item:hover,
.nav-dropdown-item:focus-visible {
  background: rgba(232, 80, 126, 0.1);
  transform: translateX(3px);
}

.nav-dropdown-item:active {
  transform: scale(0.97);
}

.nav-item-emoji {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-item-label {
  white-space: nowrap;
}

/* --- Floating Hearts Background --- */
.floating-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  font-size: 2.4rem;
  opacity: 0;
  animation: floatHeart linear infinite;
  will-change: transform, opacity;
}

@keyframes floatHeart {
  0% {
    transform: translateY(100vh) rotate(0deg) scale(0.7);
    opacity: 0;
  }
  10% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.55;
  }
  90% {
    opacity: 0.45;
  }
  100% {
    transform: translateY(-10vh) rotate(360deg) scale(1.2);
    opacity: 0;
  }
}

/* --- Layout --- */
.container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: 1.2rem 1.5rem 0.8rem;
  gap: 0.6rem;
}

/* --- Header --- */
.header {
  text-align: center;
  padding-bottom: 1.0rem;
  animation: fadeInDown 0.8s ease-out;
}

.title {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  text-shadow: 0 2px 10px rgba(232, 80, 126, 0.15);
  padding-bottom: 1.0rem;
}

.subtitle {
  font-size: clamp(1.1rem, 2.5vw, 1.1rem);
  color: var(--text-soft);
  margin-top: 0.4rem;
  font-weight: 500;
}

/* --- Progress --- */
.progress-section {
  width: 100%;
  max-width: 280px;
  text-align: center;
  padding-bottom: 0rem;
  animation: fadeInDown 0.8s ease-out 0.2s both;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.progress-text span {
  color: var(--primary);
  font-weight: 700;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--primary-soft);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Jar Wrapper --- */
.jar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex: 1;
  animation: fadeInUp 1s ease-out 0.4s both;
}

.jar-hint {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  animation: pulse 2s ease-in-out infinite;
  letter-spacing: 0.05em;
}

/* --- Jar Container (Button) --- */
.jar-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 15px 30px rgba(100, 50, 80, 0.15));
}

.jar-container:hover,
.jar-container:focus-visible {
  transform: scale(1.03);
}

.jar-container:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 10px;
  border-radius: 20px;
}

.jar-container:active {
  transform: scale(0.98);
}

/* --- Jar Lid --- */
.jar-lid {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.jar-lid-top {
  width: calc(var(--jar-width) * 0.42);
  height: clamp(18px, 2.5vh, 28px);
  background: linear-gradient(180deg, #d4a07a 0%, #c4906a 50%, #b8845e 100%);
  border-radius: 8px 8px 2px 2px;
  border: 1px solid rgba(180, 120, 80, 0.3);
  box-shadow: 0 -2px 6px rgba(180, 120, 80, 0.2);
}

.jar-lid-band {
  width: calc(var(--jar-width) * 0.47);
  height: clamp(12px, 2vh, 18px);
  background: linear-gradient(180deg, #c4906a 0%, #a87858 100%);
  border-radius: 0 0 4px 4px;
  border: 1px solid rgba(160, 100, 60, 0.3);
  border-top: none;
  margin-top: -1px;
}

/* --- Jar Neck --- */
.jar-neck {
  width: calc(var(--jar-width) * 0.46);
  height: clamp(16px, 2.5vh, 26px);
  background: var(--jar-glass);
  border-left: 2px solid var(--jar-glass-border);
  border-right: 2px solid var(--jar-glass-border);
  position: relative;
  z-index: 2;
}

.jar-neck::before {
  content: '';
  position: absolute;
  top: 0;
  left: 4px;
  width: 15px;
  height: 100%;
  background: linear-gradient(to right, rgba(255,255,255,0.35), transparent);
  border-radius: 2px;
}

/* --- Jar Body --- */
.jar-body {
  width: var(--jar-width);
  height: var(--jar-height);
  background: var(--jar-glass);
  border: 2px solid var(--jar-glass-border);
  border-top: none;
  border-radius: 8px 8px 50px 50px;
  position: relative;
  z-index: 2;
  overflow: hidden;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* Glass Reflection — left highlight */
.jar-reflection {
  position: absolute;
  top: 8px;
  left: 10px;
  width: 22px;
  height: 85%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.5),
    rgba(255, 255, 255, 0.2) 40%,
    transparent 80%
  );
  border-radius: 20px;
  z-index: 10;
  pointer-events: none;
}

/* Glass Reflection — right subtle */
.jar-reflection-2 {
  position: absolute;
  top: 20px;
  right: 18px;
  width: 10px;
  height: 60%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.25),
    transparent 70%
  );
  border-radius: 10px;
  z-index: 10;
  pointer-events: none;
}

/* --- Notes Inside Jar --- */
.jar-notes {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 2px;
  padding: 10px 10px 15px;
  z-index: 5;
  transition: height 0.5s ease;
}

.jar-note-strip {
  width: clamp(14px, 2.2vw, 22px);
  height: clamp(50px, 8vh, 80px);
  border-radius: 3px 3px 2px 2px;
  position: relative;
  transform-origin: bottom center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  /* animations are applied via JS with baked-in rotation values */
}

.jar-note-strip::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  height: 2px;
  background: rgba(255,255,255,0.4);
  border-radius: 1px;
}

/* Bob up and down — eager bounce (no var() — fully compatible) */
@keyframes noteBob {
  0%   { margin-top: 0; }
  100% { margin-top: -6px; }
}

/* --- Jar Label --- */
.jar-label {
  position: absolute;
  z-index: 12;
  bottom: 40%;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(48px, 7vw, 68px);
  height: clamp(48px, 7vw, 68px);
  background: var(--cream);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--primary-light);
  box-shadow: 0 2px 8px rgba(232, 80, 126, 0.15);
}

.jar-label span {
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--primary);
}

/* --- Jar Glow --- */
.jar-glow {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(var(--jar-width) + 60px);
  height: 100px;
  background: radial-gradient(ellipse, var(--jar-glow-color) 0%, transparent 70%);
  z-index: 1;
  opacity: 1;
  transition: opacity 0.5s ease;
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* --- Jar Shake Animation --- */
.jar-shake {
  animation: jarShake 0.5s ease-in-out;
}

@keyframes jarShake {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-4deg); }
  30% { transform: rotate(4deg); }
  45% { transform: rotate(-3deg); }
  60% { transform: rotate(3deg); }
  75% { transform: rotate(-1deg); }
  90% { transform: rotate(1deg); }
}

/* Jar empty state */
.jar-container.jar-empty {
  opacity: 0.7;
  filter: drop-shadow(0 10px 20px rgba(100, 50, 80, 0.08)) grayscale(0.2);
}

.jar-container.jar-empty .jar-glow {
  opacity: 0;
}

/* --- Note Overlay / Modal --- */
.note-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(93, 57, 84, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.note-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* --- Note Card --- */
.note-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: linear-gradient(145deg, var(--cream) 0%, #fff 50%, var(--primary-soft) 100%);
  border-radius: 24px;
  padding: 2.8rem 2.2rem 2.2rem;
  box-shadow:
    0 25px 60px rgba(93, 57, 84, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  transform: scale(0.7) translateY(40px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.note-overlay.active .note-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.note-card-inner {
  position: relative;
  text-align: center;
}

.note-number {
  font-family: 'Dancing Script', cursive;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

.note-message {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.45;
  padding: 0.8rem 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease 0.3s, transform 0.5s ease 0.3s;
}

.note-overlay.active .note-message {
  opacity: 1;
  transform: translateY(0);
}

/* Note Decorations */
.note-decoration {
  position: absolute;
  font-size: 1.2rem;
  color: var(--primary-light);
  opacity: 0.5;
}

.note-decoration.top-left {
  top: -5px;
  left: -5px;
}

.note-decoration.top-right {
  top: -5px;
  right: -5px;
}

.note-decoration.bottom-left {
  bottom: -5px;
  left: -5px;
}

.note-decoration.bottom-right {
  bottom: -5px;
  right: -5px;
}

/* Note Close Button */
.note-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  background: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-soft);
  box-shadow: 0 3px 12px rgba(0,0,0,0.12);
  transition: transform 0.2s ease, background 0.2s ease;
}

.note-close:hover,
.note-close:focus-visible {
  transform: scale(1.1);
  background: var(--primary-soft);
  color: var(--primary);
}

/* --- Completion Overlay --- */
.completion-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(93, 57, 84, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.completion-overlay.active {
  opacity: 1;
  visibility: visible;
}

.completion-card {
  text-align: center;
  background: linear-gradient(145deg, var(--cream), #fff, var(--primary-soft));
  border-radius: 32px;
  padding: 3rem 2.5rem;
  max-width: 360px;
  box-shadow: 0 30px 80px rgba(93, 57, 84, 0.3);
  transform: scale(0.8);
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s,
              opacity 0.4s ease 0.2s;
}

.completion-overlay.active .completion-card {
  transform: scale(1);
  opacity: 1;
}

.completion-hearts {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  animation: heartBeat 1.5s ease-in-out infinite;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
  60% { transform: scale(1); }
}

.completion-title {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.completion-text {
  color: var(--text-soft);
  font-size: 1rem;
  margin-bottom: 2rem;
  font-weight: 500;
}

.btn-reset {
  display: inline-block;
  padding: 0.8rem 2rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--white);
  font-size: 1rem;
  font-weight: 700;
  border-radius: 50px;
  box-shadow: 0 6px 20px rgba(232, 80, 126, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-reset:hover,
.btn-reset:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(232, 80, 126, 0.45);
}

/* --- Footer --- */
.footer {
  padding-top: 0.3rem;
  padding-bottom: 0.5rem;
  animation: fadeInUp 0.8s ease-out 0.6s both;
}

.reset-link {
  font-size: 0.8rem;
  color: var(--text-soft);
  opacity: 0.5;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.2s ease;
}

.reset-link:hover {
  opacity: 1;
}

/* --- Utility Animations --- */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.97); }
}

/* --- Note Rise Animation --- */
.note-rising {
  position: fixed;
  z-index: 99;
  width: 20px;
  height: 60px;
  border-radius: 4px;
  pointer-events: none;
  animation: noteRise 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes noteRise {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
  60% {
    opacity: 1;
    transform: translateY(-150px) rotate(-10deg) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-200px) rotate(-15deg) scale(0.5);
  }
}

/* --- Responsive --- */

/* On wider screens, cap the jar a bit differently */
@media (min-width: 768px) {
  :root {
    --jar-width: clamp(260px, 32vw, 400px);
    --jar-height: clamp(340px, 55vh, 540px);
  }

  .container {
    padding: 1.5rem 2rem 1rem;
    gap: 0.8rem;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .floating-heart {
    display: none;
  }
}

/* --- Body scroll lock when modal is open --- */
body.modal-open {
  overflow: hidden;
}
