/* ===== CSS RESET AND BASE STYLES ===== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== TYPOGRAPHY SYSTEM ===== */
h1 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1.2;
  margin: 0;
}

h2, h3, h4 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 400;
}

button {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 500;
}

/* ===== COLOR PALETTE AND THEMES ===== */
:root {
  /* Primary Colors */
  --primary-blue: #4A90E2;
  --secondary-blue: #87CEEB;
  --accent-purple: #B19CD9;
  
  /* Background Colors */
  --bg-primary: #F8F9FA;
  --bg-secondary: #FFFFFF;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  
  /* Text Colors */
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --text-white: #FFFFFF;
  
  /* Border Colors */
  --border-light: #E5E7EB;
  --border-medium: #D1D5DB;
  
  /* Animation Variables */
  --phase-duration: 4s;
  --transition-ease: cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #1A1A1A;
  --bg-secondary: #2D2D2D;
  --text-primary: #FFFFFF;
  --text-secondary: #CCCCCC;
  --text-muted: #999999;
  --border-light: #404040;
  --border-medium: #555555;
}

/* High Contrast Mode */
[data-high-contrast="true"] {
  --primary-blue: #0066CC;
  --secondary-blue: #0080FF;
  --accent-purple: #8A2BE2;
  --text-primary: #000000;
  --text-secondary: #000000;
  --bg-primary: #FFFFFF;
  --bg-secondary: #FFFFFF;
}

/* ===== LAYOUT AND GRID SYSTEM ===== */
.app-container {
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* ===== COMPONENT STYLES ===== */

/* Technique Selection */
.technique-selection {
  padding: 0 1rem;
}

.technique-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  min-width: 120px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.technique-btn:hover {
  border-color: var(--primary-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
}

.technique-btn.active {
  border-color: var(--primary-blue);
  background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
  color: var(--text-white);
}

.technique-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.technique-desc {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Breathing Container */
.breathing-container {
  width: 90vw;
  max-width: 300px;
  height: 300px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Breathing Ball */
.breathing-ball {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--secondary-blue), var(--primary-blue));
  position: relative;
  transition: transform var(--phase-duration) var(--transition-ease);
  will-change: transform;
  box-shadow: 0 8px 32px rgba(74, 144, 226, 0.3);
}

/* Breathing Ball States */
.breathing-ball.inhale {
  transform: scale(1.2);
}

.breathing-ball.exhale {
  transform: scale(0.8);
}

.breathing-ball.hold {
  transform: scale(1.2);
}

.breathing-ball.rest {
  transform: scale(0.8);
}

/* Breathing Text */
.breathing-text {
  font-size: 1.125rem;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
  pointer-events: none;
}

/* Instructions */
.instructions {
  max-width: 400px;
  margin: 0 auto;
}

/* Progress Container */
.progress-container {
  text-align: center;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  min-width: 48px;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
  color: var(--text-white);
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border-medium);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary-blue);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid var(--border-light);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

/* Form Controls */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-track {
  background: var(--border-light);
  height: 8px;
  border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: var(--primary-blue);
  height: 20px;
  width: 20px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(74, 144, 226, 0.3);
}

input[type="range"]::-moz-range-track {
  background: var(--border-light);
  height: 8px;
  border-radius: 4px;
  border: none;
}

input[type="range"]::-moz-range-thumb {
  background: var(--primary-blue);
  height: 20px;
  width: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(74, 144, 226, 0.3);
}

input[type="checkbox"] {
  accent-color: var(--primary-blue);
}

select {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border-light);
}

select:focus {
  border-color: var(--primary-blue);
  outline: none;
}

/* Modal Styles */
.settings-panel,
.session-config {
  backdrop-filter: blur(4px);
}

.settings-panel .bg-white,
.session-config .bg-white {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

/* Setting Groups */
.setting-group {
  margin-bottom: 1rem;
}

.setting-section {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
}

.setting-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* ===== ANIMATION DEFINITIONS ===== */
@keyframes breathe-inhale {
  from { transform: scale(0.8); }
  to { transform: scale(1.2); }
}

@keyframes breathe-exhale {
  from { transform: scale(1.2); }
  to { transform: scale(0.8); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Breathing Ball Animation Classes */
.breathing-ball.animate-inhale {
  animation: breathe-inhale var(--phase-duration) var(--transition-ease) forwards;
}

.breathing-ball.animate-exhale {
  animation: breathe-exhale var(--phase-duration) var(--transition-ease) forwards;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Mobile First (320px+) - Base styles already applied */

/* Small Mobile (375px+) */
@media (min-width: 375px) {
  .breathing-container {
    max-width: 320px;
    height: 320px;
  }
  
  .breathing-ball {
    width: 220px;
    height: 220px;
  }
}

/* Large Mobile (425px+) */
@media (min-width: 425px) {
  .breathing-container {
    max-width: 350px;
    height: 350px;
  }
  
  .breathing-ball {
    width: 240px;
    height: 240px;
  }
}

/* Tablet (768px+) */
@media (min-width: 768px) {
  h1 {
    font-size: 2.5rem;
  }
  
  .breathing-container {
    max-width: 400px;
    height: 400px;
  }
  
  .breathing-ball {
    width: 280px;
    height: 280px;
  }
  
  .breathing-text {
    font-size: 1.25rem;
  }
  
  .technique-btn {
    min-width: 140px;
    padding: 1.25rem;
  }
  
  .btn {
    padding: 0.875rem 2rem;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  h1 {
    font-size: 3rem;
  }
  
  .breathing-container {
    max-width: 500px;
    height: 500px;
  }
  
  .breathing-ball {
    width: 350px;
    height: 350px;
  }
  
  .breathing-text {
    font-size: 1.5rem;
  }
  
  .technique-btn {
    min-width: 160px;
    padding: 1.5rem;
  }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
  .breathing-container {
    max-width: 600px;
    height: 600px;
  }
  
  .breathing-ball {
    width: 400px;
    height: 400px;
  }
}

/* ===== ACCESSIBILITY STYLES ===== */

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus Indicators */
*:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* High Contrast Focus */
[data-high-contrast="true"] *:focus-visible {
  outline: 3px solid #000000;
  outline-offset: 2px;
}

/* Skip Links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-blue);
  color: var(--text-white);
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
}

.skip-link:focus {
  top: 6px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .breathing-ball {
    transition: none;
  }
  
  .breathing-ball.inhale::after {
    content: "Inhale";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-white);
    font-weight: 600;
    font-size: 1.2rem;
  }
  
  .breathing-ball.exhale::after {
    content: "Exhale";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-white);
    font-weight: 600;
    font-size: 1.2rem;
  }
  
  .breathing-ball.hold::after {
    content: "Hold";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-white);
    font-weight: 600;
    font-size: 1.2rem;
  }
  
  .breathing-ball.rest::after {
    content: "Rest";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-white);
    font-weight: 600;
    font-size: 1.2rem;
  }
}

/* Touch-Friendly Sizing */
@media (pointer: coarse) {
  .btn {
    min-height: 48px;
    min-width: 48px;
    padding: 1rem 1.5rem;
  }
  
  .technique-btn {
    min-height: 48px;
    padding: 1rem;
  }
  
  input[type="range"]::-webkit-slider-thumb {
    height: 24px;
    width: 24px;
  }
  
  input[type="range"]::-moz-range-thumb {
    height: 24px;
    width: 24px;
  }
}

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

.fade-out {
  animation: fadeOut 0.3s ease-in-out;
}

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

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

/* ===== PRINT STYLES ===== */
@media print {
  .controls-section,
  .settings-panel,
  .session-config {
    display: none;
  }
  
  .breathing-container {
    break-inside: avoid;
  }
  
  body {
    background: white;
    color: black;
  }
}