/* ============================================
   GRUNDLÄGGANDE & RESET
   ============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  transition: background 1.2s ease;
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================
   TEMA-GRUNDER (bakgrundsfärger)
   ============================================ */
body[data-theme="midnight"] {
  --bg-start: #0a0e27;
  --bg-end: #1a1040;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-shadow: rgba(100, 80, 255, 0.2);
  --text-primary: #e0d8ff;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --accent: #7c6fff;
  --glow-color: rgba(124, 111, 255, 0.4);
  --inhale-bg-start: #0f1a3e;
  --inhale-bg-end: #1e1260;
  --exhale-bg-start: #0a0e27;
  --exhale-bg-end: #150d35;
}

body[data-theme="aurora"] {
  --bg-start: #0b1a0f;
  --bg-end: #0a2020;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-shadow: rgba(80, 255, 180, 0.2);
  --text-primary: #d4ffe8;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --accent: #4fff9e;
  --glow-color: rgba(80, 255, 160, 0.4);
  --inhale-bg-start: #0d2a15;
  --inhale-bg-end: #0f3520;
  --exhale-bg-start: #0b1a0f;
  --exhale-bg-end: #081510;
}

body[data-theme="sunset"] {
  --bg-start: #1a0a0a;
  --bg-end: #2d1020;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-shadow: rgba(255, 140, 80, 0.2);
  --text-primary: #ffe0d0;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --accent: #ff8c50;
  --glow-color: rgba(255, 140, 80, 0.4);
  --inhale-bg-start: #3a1520;
  --inhale-bg-end: #4a1a28;
  --exhale-bg-start: #1a0a0a;
  --exhale-bg-end: #2d1020;
}

body[data-theme="ocean"] {
  --bg-start: #050e1a;
  --bg-end: #0a1628;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-shadow: rgba(40, 140, 255, 0.2);
  --text-primary: #d0e8ff;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --accent: #3090ff;
  --glow-color: rgba(48, 144, 255, 0.4);
  --inhale-bg-start: #0a1e3a;
  --inhale-bg-end: #0f2848;
  --exhale-bg-start: #050e1a;
  --exhale-bg-end: #0a1628;
}

body[data-theme="sakura"] {
  --bg-start: #1a0c14;
  --bg-end: #201020;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-shadow: rgba(255, 140, 200, 0.2);
  --text-primary: #ffe0f0;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --accent: #ff8cc8;
  --glow-color: rgba(255, 140, 200, 0.4);
  --inhale-bg-start: #2a1020;
  --inhale-bg-end: #351530;
  --exhale-bg-start: #1a0c14;
  --exhale-bg-end: #201020;
}

/* ============================================
   BAKGRUND
   ============================================ */
body {
  background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
  transition: background 1.5s ease;
}

body.phase-inhale {
  background: linear-gradient(160deg, var(--inhale-bg-start), var(--inhale-bg-end));
}

body.phase-exhale {
  background: linear-gradient(160deg, var(--exhale-bg-start), var(--exhale-bg-end));
}

/* ============================================
   TEMA-VÄLJARE
   ============================================ */
.theme-bar {
  display: flex;
  gap: 12px;
  padding: 16px 0 8px;
  z-index: 10;
}

.theme-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

.theme-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.theme-btn.active {
  transform: scale(1.2);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 12px var(--glow-color);
}

.theme-btn[data-theme="midnight"] { background: linear-gradient(135deg, #7c6fff, #4a3abf); }
.theme-btn[data-theme="aurora"]   { background: linear-gradient(135deg, #4fff9e, #20b060); }
.theme-btn[data-theme="sunset"]   { background: linear-gradient(135deg, #ff8c50, #d05020); }
.theme-btn[data-theme="ocean"]    { background: linear-gradient(135deg, #3090ff, #1a60b0); }
.theme-btn[data-theme="sakura"]   { background: linear-gradient(135deg, #ff8cc8, #c04080); }

/* ============================================
   MÖNSTER-VÄLJARE
   ============================================ */
.pattern-bar {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  z-index: 10;
}

.pattern-btn {
  padding: 8px 18px;
  border-radius: 24px;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.02em;
}

.pattern-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--glass-shadow);
}

/* ============================================
   ANDNINGSOMRÅDE (CENTRUM)
   ============================================ */
.breathing-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex: 1;
}

.circle-container {
  position: relative;
  width: 260px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Yttre glödring */
.glow-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
  opacity: 0.4;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Glas-cirkel */
.glass-circle {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1.5px solid var(--glass-border);
  box-shadow:
    inset 0 0 30px rgba(255, 255, 255, 0.05),
    0 8px 32px var(--glass-shadow),
    0 0 60px var(--glow-color);
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 1s ease;
  z-index: 2;
}

/* Inre glöd */
.inner-glow {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
  opacity: 0.3;
  z-index: 1;
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 1s ease;
}

/* ---- Animationer för cirkeln ---- */
.glass-circle.animating-in {
  animation: breatheIn var(--inhale-duration, 4s) ease-in-out forwards;
}

.glass-circle.animating-hold-in {
  animation: holdIn var(--hold-in-duration, 7s) ease forwards;
}

.glass-circle.animating-exhale {
  animation: breatheOut var(--exhale-duration, 8s) ease-in-out forwards;
}

.glass-circle.animating-hold-out {
  animation: holdOut var(--hold-out-duration, 0s) ease forwards;
}

@keyframes breatheIn {
  0%   { transform: scale(1);    box-shadow: inset 0 0 30px rgba(255,255,255,0.05), 0 8px 32px var(--glass-shadow), 0 0 60px var(--glow-color); }
  100% { transform: scale(1.45); box-shadow: inset 0 0 50px rgba(255,255,255,0.1),  0 8px 48px var(--glass-shadow), 0 0 100px var(--glow-color); }
}

@keyframes holdIn {
  0%   { transform: scale(1.45); }
  100% { transform: scale(1.45); }
}

@keyframes breatheOut {
  0%   { transform: scale(1.45); box-shadow: inset 0 0 50px rgba(255,255,255,0.1),  0 8px 48px var(--glass-shadow), 0 0 100px var(--glow-color); }
  100% { transform: scale(1);    box-shadow: inset 0 0 30px rgba(255,255,255,0.05),  0 8px 32px var(--glass-shadow), 0 0 60px var(--glow-color); }
}

@keyframes holdOut {
  0%   { transform: scale(1); }
  100% { transform: scale(1); }
}

/* Glow-ring animationer */
.glow-ring.animating-in {
  animation: glowIn var(--inhale-duration, 4s) ease-in-out forwards;
}

.glow-ring.animating-exhale {
  animation: glowOut var(--exhale-duration, 8s) ease-in-out forwards;
}

@keyframes glowIn {
  0%   { transform: scale(1);    opacity: 0.4; }
  100% { transform: scale(1.35); opacity: 0.7; }
}

@keyframes glowOut {
  0%   { transform: scale(1.35); opacity: 0.7; }
  100% { transform: scale(1);    opacity: 0.4; }
}

/* Inner-glow animationer */
.inner-glow.animating-in {
  animation: innerGlowIn var(--inhale-duration, 4s) ease-in-out forwards;
}

.inner-glow.animating-exhale {
  animation: innerGlowOut var(--exhale-duration, 8s) ease-in-out forwards;
}

@keyframes innerGlowIn {
  0%   { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(2.5); opacity: 0.6; }
}

@keyframes innerGlowOut {
  0%   { transform: scale(2.5); opacity: 0.6; }
  100% { transform: scale(1); opacity: 0.3; }
}

/* ============================================
   FAS-TEXT & TIMER
   ============================================ */
.phase-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  min-height: 2em;
  display: flex;
  align-items: center;
  transition: opacity 0.4s ease;
}

.timer-display {
  font-size: 1rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

/* ============================================
   KNAPPAR (START / ÅTERSTÄLL)
   ============================================ */
.controls {
  display: flex;
  gap: 14px;
  padding-bottom: 20px;
  z-index: 10;
}

.action-btn, .reset-btn {
  border: none;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.action-btn {
  padding: 16px 48px;
  border-radius: 50px;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  box-shadow: 0 4px 24px var(--glass-shadow);
}

.action-btn:active {
  transform: scale(0.96);
}

.reset-btn {
  padding: 16px 28px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-size: 0.9rem;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
}

.reset-btn:active {
  transform: scale(0.96);
}

/* ============================================
   SESSION-RAPPORT
   ============================================ */
.session-info {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: bottom 0.4s ease;
  white-space: nowrap;
}

.session-info.visible {
  bottom: 20px;
}

/* ============================================
   PARTIKEL-EFFEKT (valfritt, subtilt)
   ============================================ */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  animation: float linear infinite;
}

@keyframes float {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ============================================
   RESPONSIVT (större skärmar)
   ============================================ */
@media (min-width: 600px) {
  .glass-circle { width: 200px; height: 200px; }
  .circle-container { width: 320px; height: 320px; }
  .phase-text { font-size: 1.5rem; }
}

@media (min-width: 900px) {
  body { justify-content: center; gap: 40px; }
  .theme-bar, .pattern-bar { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); }
  .pattern-bar { top: 70px; }
}

/* ============================================
   REDUCERA RÖRELSE
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
