/**
 * Tenths Timer Demo Component
 * Interactive animated timer with pulsing glow effect
 */

/* =========================================
 * TIMER CONTAINER
 * ========================================= */

.timer-demo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-8);
}

/* =========================================
 * TIMER CIRCLE
 * ========================================= */

.timer-circle {
  position: relative;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--duration-normal) var(--ease-out);
}

.timer-circle:hover {
  transform: scale(1.02);
}

.timer-circle:active {
  transform: scale(0.98);
}

/*
 * Timer Glow - matches style guide exactly
 * Single radial gradient from --timer-core to transparent
 */
.timer-glow-outer,
.timer-glow-middle {
  display: none; /* Not used - style guide uses single glow */
}

/* Main Timer Glow - exact SwiftUI implementation */
.timer-glow-inner {
  position: absolute;
  border-radius: 50%;
  inset: -10px;

  /* Radial gradient matching SwiftUI (opacity boosted ~0.15 for web) */
  background: radial-gradient(
    circle at center,
    rgba(78, 209, 129, 0.70) 0%,
    rgba(87, 246, 159, 0.55) 70%,
    rgba(93, 245, 192, 0.50) 90%
  );

  /* Inner white shadow matching SwiftUI: .shadow(.inner(color:.white.opacity(0.65), radius: 15, x: 0, y: 5)) */
  box-shadow: inset 0 5px 15px rgba(255, 255, 255, 0.65);

  animation: breathe 4s cubic-bezier(0.4, 0, 0.2, 1) 4;
}

/* Angular gradient stroke - matching SwiftUI overlay */
.timer-glow-inner::before {
  content: '';
  position: absolute;
  inset: -2.4px;
  border-radius: 50%;
  padding: 5px;

  /* Angular gradient matching SwiftUI:
     lineOne @ 0, lineTwo @ 0.3, lineThree @ 0.7, lineOne @ 1.0
     startAngle: 360°, endAngle: 70°, rotated -140° */
  background: conic-gradient(
    from 220deg,
    rgba(95, 249, 184, 0.51) 0deg,
    rgba(146, 255, 172, 0.50) 108deg,
    rgba(60, 102, 73, 0.22) 252deg,
    rgba(95, 249, 184, 0.51) 360deg
  );

  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* Core Timer Display */
.timer-core {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  /* background: rgba(13, 37, 63, 0.6); */
  /* backdrop-filter: blur(var(--blur-md)); */
  /* -webkit-backdrop-filter: blur(var(--blur-md)); */
  /* border: 2px solid rgba(87, 246, 159, 0.3); */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  z-index: 1;
}

/* Timer is running state - more intense glow */
.timer-demo.running .timer-core {
  border-color: rgba(87, 246, 159, 0.5);
}

.timer-demo.running .timer-glow-inner {
  animation: breathe 4s cubic-bezier(0.4, 0, 0.2, 1) infinite !important;
}

/* =========================================
 * TIMER DISPLAY
 * ========================================= */

.timer-time {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: var(--font-semibold);
  color: var(--color-white);
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.timer-tenths-label {
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: rgba(78, 209, 129, 0.9);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.timer-status {
  font-size: var(--text-xs);
  color: var(--color-gray-400);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
}

.timer-demo.running .timer-status {
  color: var(--color-matter);
}

/* =========================================
 * TIMER INFO
 * ========================================= */

.timer-info {
  text-align: center;
  max-width: 300px;
}

.timer-calculation {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--color-gray-300);
  margin-bottom: var(--space-2);
}

.timer-calculation strong {
  color: var(--color-matter);
}

.timer-hint {
  font-size: var(--text-sm);
  color: var(--color-gray-500);
}

/* =========================================
 * TIMER BUTTON
 * ========================================= */

.timer-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--color-white);
  background: linear-gradient(
    135deg,
    rgba(78, 209, 129, 0.25) 0%,
    rgba(56, 240, 150, 0.15) 100%
  );
  border: 1px solid rgba(78, 209, 129, 0.3);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: 0 4px 20px rgba(78, 209, 129, 0.2);
}

.timer-btn:hover {
  transform: scale(1.05);
  background: linear-gradient(
    135deg,
    rgba(78, 209, 129, 0.35) 0%,
    rgba(56, 240, 150, 0.25) 100%
  );
  box-shadow: 0 8px 30px rgba(78, 209, 129, 0.3);
}

.timer-btn:active {
  transform: scale(0.98);
}

.timer-demo.running .timer-btn {
  background: linear-gradient(
    135deg,
    rgba(210, 66, 66, 0.25) 0%,
    rgba(210, 66, 66, 0.15) 100%
  );
  border-color: rgba(210, 66, 66, 0.3);
  box-shadow: 0 4px 20px rgba(210, 66, 66, 0.2);
}

.timer-demo.running .timer-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(210, 66, 66, 0.35) 0%,
    rgba(210, 66, 66, 0.25) 100%
  );
  box-shadow: 0 8px 30px rgba(210, 66, 66, 0.3);
}

/* Play/Stop Icons */
.timer-btn .icon-play,
.timer-btn .icon-stop {
  width: 16px;
  height: 16px;
}

.timer-btn .icon-stop {
  display: none;
}

.timer-demo.running .timer-btn .icon-play {
  display: none;
}

.timer-demo.running .timer-btn .icon-stop {
  display: block;
}

/* =========================================
 * ANIMATIONS
 * ========================================= */

/* Breathing animation - natural inhale/exhale rhythm */
@keyframes breathe {
  0% {
    box-shadow:
      inset 0 5px 15px rgba(255, 255, 255, 0.65),
      0 0 30px rgba(87, 246, 159, 0.35),
      0 0 60px rgba(87, 246, 159, 0.15);
    transform: scale(0.98);
    opacity: 0.92;
  }
  35% {
    box-shadow:
      inset 0 5px 15px rgba(255, 255, 255, 0.65),
      0 0 60px rgba(87, 246, 159, 0.55),
      0 0 100px rgba(87, 246, 159, 0.35);
    transform: scale(1.02);
    opacity: 1;
  }
  100% {
    box-shadow:
      inset 0 5px 15px rgba(255, 255, 255, 0.65),
      0 0 30px rgba(87, 246, 159, 0.35),
      0 0 60px rgba(87, 246, 159, 0.15);
    transform: scale(0.98);
    opacity: 0.92;
  }
}

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

@media (max-width: 480px) {
  .timer-circle {
    width: 220px;
    height: 220px;
  }

  .timer-core {
    width: 130px;
    height: 130px;
  }

  .timer-glow-inner {
    inset: -8px;
  }

  .timer-time {
    font-size: 1.5rem;
  }
}

/* =========================================
 * REDUCED MOTION
 * ========================================= */

@media (prefers-reduced-motion: reduce) {
  .timer-glow-inner {
    animation: none;
    box-shadow:
      inset 0 5px 15px rgba(255, 255, 255, 0.65),
      0 0 50px rgba(87, 246, 159, 0.45),
      0 0 90px rgba(87, 246, 159, 0.25);
  }

  .timer-circle,
  .timer-btn {
    transition: none;
  }
}
