/* Enhanced 4x4x4x4 Breathing App Styles */
/* Modern, calming design with smooth animations for breathing guidance */

/* Reset and base styles */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

/* CSS Custom Properties for theming and consistency */
:root {
  --primary-blue: #6c809a;
  --secondary-green: #8ba88d;
  --bg-gradient-light: linear-gradient(135deg, #dee4ea 0%, #f8f9fa 100%);
  --bg-gradient-dark: linear-gradient(135deg, #1b2430 0%, #0f172a 100%);
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-bg-dark: rgba(30, 37, 50, 0.92);
  --text-dark: #2d3748;
  --text-light: #e5e9f0;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-dark: 0 6px 24px rgba(0, 0, 0, 0.25);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --phaseDur: 4s; /* Dynamic breathing phase duration */
}

/* Body and layout */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-gradient-light);
  color: var(--text-dark);
  overflow-x: hidden;
  position: relative;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

body.dark {
  background: var(--bg-gradient-dark);
  color: var(--text-light);
}

body.no-scroll {
  overflow: hidden;
}

/* Animated background particles for ambient effect */
.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.04);
  animation: float 20s infinite ease-in-out;
}

body.dark .particle {
  background: rgba(255, 255, 255, 0.06);
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(8px, -18px); }
  50% { transform: translate(-8px, 9px); }
  75% { transform: translate(4px, -8px); }
}

/* Main container */
.wrap {
  width: 100%;
  max-width: 520px;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* Header section */
.header {
  text-align: center;
  margin-bottom: 24px;
  animation: fadeDown 0.5s var(--ease);
}

.header h1 {
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  font-size: 2rem;
}

.header p {
  opacity: 0.7;
  font-size: 0.95rem;
}

/* Main card container */
.card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: saturate(120%) blur(8px);
  animation: fadeUp 0.5s var(--ease);
}

body.dark .card {
  background: var(--card-bg-dark);
  box-shadow: var(--shadow-dark);
}

/* Breathing circle container and animation */
.circle-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 240px;
  margin-bottom: 22px;
}

.circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary-blue), var(--secondary-green));
  box-shadow: 0 0 28px rgba(108, 128, 154, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--phaseDur) ease-in-out;
  position: relative;
}

body.dark .circle {
  background: radial-gradient(circle, #445566, #5a7260);
}

/* Breathing circle pulse effect */
.circle::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, transparent 45%, rgba(255, 255, 255, 0.06));
  animation: pulse var(--phaseDur) infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.2;
  }
}

/* Phase indicator text */
.phase {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  font-size: 1.3rem;
  font-weight: 500;
  z-index: 1;
}

/* Control buttons */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 16px 0 10px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-blue), var(--secondary-green));
  box-shadow: 0 2px 12px rgba(108, 128, 154, 0.25);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
  font-weight: 500;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(108, 128, 154, 0.28);
}

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

.btn.secondary {
  background: transparent;
  color: var(--primary-blue);
  border: 1px solid var(--primary-blue);
  box-shadow: none;
}

body.dark .btn.secondary {
  color: var(--text-light);
  border-color: var(--text-light);
}

/* Preset duration chips */
.presets {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 14px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--primary-blue);
  color: var(--primary-blue);
  background: transparent;
  border-radius: 14px;
  padding: 7px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.chip:hover,
.chip.active {
  background: var(--primary-blue);
  color: #fff;
}

/* Timer and cycle display */
.timer,
.cycles {
  text-align: center;
  font-size: 1rem;
}

.cycles {
  opacity: 0.8;
  margin-bottom: 4px;
}

/* Statistics section */
.stats {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin-top: 12px;
}

body.dark .stats {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.stat {
  text-align: center;
}

.stat b {
  display: block;
  color: var(--primary-blue);
  font-size: 1.25rem;
  margin-bottom: 2px;
}

body.dark .stat b {
  color: #c7d2fe;
}

.stat span {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Settings button */
.settings-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.45);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.settings-btn:hover {
  transform: rotate(90deg);
}

body.dark .settings-btn {
  background: rgba(255, 255, 255, 0.16);
}

/* Settings panel */
.panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 360px;
  max-width: 100%;
  height: 100vh;
  z-index: 4;
  background: var(--card-bg);
  box-shadow: -5px 0 20px rgba(0, 0, 0, 0.12);
  transition: right 0.28s var(--ease);
  padding: 26px;
  overflow: auto;
}

.panel.open {
  right: 0;
}

body.dark .panel {
  background: var(--card-bg-dark);
  box-shadow: -5px 0 22px rgba(0, 0, 0, 0.4);
}

.panel h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 14px;
}

/* Settings groups */
.group {
  margin-bottom: 18px;
}

.group label.title {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 8px;
  opacity: 0.9;
}

/* Range sliders */
.range {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  outline: none;
  background: linear-gradient(90deg, var(--primary-blue), var(--secondary-green));
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  border: none;
}

/* Select dropdowns */
select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  font-size: 0.95rem;
}

body.dark select {
  background: rgba(255, 255, 255, 0.92);
  color: #111;
}

/* Toggle switches */
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle {
  position: relative;
  width: 50px;
  height: 24px;
}

.toggle input {
  display: none;
}

.track {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s var(--ease);
  cursor: pointer;
}

.thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease);
  pointer-events: none;
}

.toggle input:checked + .track {
  background: linear-gradient(135deg, var(--primary-blue), var(--secondary-green));
}

.toggle input:checked + .track .thumb {
  transform: translateX(26px);
}

/* Modal dialogs */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.modal.show {
  display: flex;
}

.modal .box {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 28px;
  width: min(520px, 92%);
  box-shadow: var(--shadow);
}

body.dark .modal .box {
  background: var(--card-bg-dark);
  box-shadow: var(--shadow-dark);
}

.modal .box h3 {
  margin-bottom: 10px;
  color: var(--primary-blue);
}

.modal .box ul {
  margin: 10px 0 12px 18px;
}

.modal .box li {
  margin-bottom: 4px;
}

/* Focus mode overlay */
.focus {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 6;
}

.focus.show {
  display: flex;
}

.focus::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bg-gradient-light);
}

body.dark .focus::before {
  background: var(--bg-gradient-dark);
}

.focus .circle {
  width: 200px;
  height: 200px;
}

.focus .exit {
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-dark);
  transition: background 0.2s var(--ease);
}

.focus .exit:hover {
  background: rgba(255, 255, 255, 0.7);
}

body.dark .focus .exit {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

body.dark .focus .exit:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Sound indicator */
.sound-indicator {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 3;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.sound-indicator.show {
  opacity: 1;
}

body.dark .sound-indicator {
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}

/* Animations */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive design */
@media (max-width: 600px) {
  .panel {
    right: -100%;
    width: 100%;
  }
  
  .wrap {
    padding: 16px;
  }
  
  .card {
    padding: 20px;
  }
  
  .circle {
    width: 100px;
    height: 100px;
  }
  
  .focus .circle {
    width: 160px;
    height: 160px;
  }
  
  .controls {
    gap: 8px;
  }
  
  .btn {
    padding: 10px 18px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 1.6rem;
  }
  
  .stats {
    flex-direction: column;
    gap: 12px;
  }
  
  .presets {
    gap: 6px;
  }
  
  .chip {
    padding: 6px 10px;
    font-size: 0.85rem;
  }
}

/* Accessibility and reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid var(--primary-blue);
  }
  
  .btn {
    border: 2px solid transparent;
  }
  
  .btn.secondary {
    border-color: var(--primary-blue);
  }
}

/* Focus indicators for accessibility */
.btn:focus,
.chip:focus,
.range:focus,
select:focus,
.settings-btn:focus {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

body.dark .btn:focus,
body.dark .chip:focus,
body.dark .range:focus,
body.dark select:focus,
body.dark .settings-btn:focus {
  outline-color: var(--text-light);
}