/* ================================================
   BREATHELY - Custom Styles & Animations
   ================================================ */

/* Safe area for notched phones */
.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 3px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.15);
}

/* ---- Page Transitions ---- */
.page-enter {
  animation: pageEnter 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ---- Fade In ---- */
.fade-in {
  animation: fadeIn 0.6s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in-up {
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Staggered Children ---- */
.stagger > * {
  opacity: 0;
  animation: fadeInUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }
.stagger > *:nth-child(7) { animation-delay: 0.35s; }
.stagger > *:nth-child(8) { animation-delay: 0.4s; }
.stagger > *:nth-child(9) { animation-delay: 0.45s; }
.stagger > *:nth-child(10) { animation-delay: 0.5s; }

/* ---- Countdown Animation ---- */
.countdown-pop {
  animation: countdownPop 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes countdownPop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  60% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---- Pulse Glow ---- */
.pulse-glow {
  animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.1);
  }
  50% {
    box-shadow: 0 0 40px rgba(14, 165, 233, 0.25);
  }
}

/* ---- Card Styles ---- */
.glass {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.glass-hover {
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
              background-color 0.2s,
              border-color 0.2s;
}
.glass-hover:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}
.glass-hover:active {
  transform: scale(0.98);
}

/* ---- Range Input Styling ---- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 12px rgba(14, 165, 233, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

/* ---- Select Styling ---- */
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.5)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

/* ---- Toggle Switch ---- */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.3s;
  flex-shrink: 0;
}
.toggle.active {
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle.active::after {
  transform: translateX(20px);
}

/* ---- Pattern SVG Animation ---- */
.pattern-path {
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  animation: drawPath 1.5s ease forwards;
}
@keyframes drawPath {
  to {
    stroke-dashoffset: 0;
  }
}

/* ---- Player Overlay ---- */
#player-overlay {
  user-select: none;
  -webkit-user-select: none;
}

/* ---- Horizontal Scroll ---- */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scroll-x::-webkit-scrollbar {
  display: none;
}

/* ---- Phase Badge Colors ---- */
.phase-inhale {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.2);
}
.phase-hold {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.2);
}
.phase-exhale {
  background: rgba(244, 114, 182, 0.15);
  color: #f472b6;
  border: 1px solid rgba(244, 114, 182, 0.2);
}

/* ---- Category Gradient Backgrounds ---- */
.cat-calm { background: linear-gradient(135deg, rgba(14,165,233,0.2), rgba(6,182,212,0.1)); }
.cat-balance { background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(20,184,166,0.1)); }
.cat-sleep { background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(168,85,247,0.1)); }
.cat-relax { background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(168,85,247,0.1)); }
.cat-energy { background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(249,115,22,0.1)); }
.cat-focus { background: linear-gradient(135deg, rgba(6,182,212,0.2), rgba(59,130,246,0.1)); }
.cat-custom { background: linear-gradient(135deg, rgba(236,72,153,0.2), rgba(244,63,94,0.1)); }

/* ---- Gradient Text ---- */
.gradient-text {
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- Breathing guide text shimmer ---- */
.shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.6) 0%, rgba(255,255,255,1) 50%, rgba(255,255,255,0.6) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Number Input Buttons ---- */
.num-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: white;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.num-btn:hover {
  background: rgba(255,255,255,0.1);
}
.num-btn:active {
  transform: scale(0.92);
}

/* ---- Misc ---- */
.text-shadow-glow {
  text-shadow: 0 0 30px rgba(14, 165, 233, 0.5);
}

/* Player transition */
#player-overlay {
  transition: opacity 0.4s ease;
}

/* Empty state illustration */
.empty-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(14,165,233,0.1), rgba(139,92,246,0.1));
  border: 1px dashed rgba(255,255,255,0.1);
}
