/* Reset and Variable definitions */
:root {
  --bg-color: #080a0f;
  --card-bg: rgba(13, 18, 29, 0.7);
  --card-border: rgba(255, 255, 255, 0.07);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --color-primary: #10b981; /* Emerald green for start */
  --color-primary-glow: rgba(16, 185, 129, 0.4);
  --color-pause: #f59e0b; /* Amber for pause */
  --color-pause-glow: rgba(245, 158, 11, 0.4);
  --color-accent: #3b82f6; /* Blue for hover/accent */
  --color-accent-glow: rgba(59, 130, 246, 0.3);
  
  /* Wheel parameters */
  --digit-height: 80px;
  --wheel-radius: 123px; /* 40px / tan(18deg) = 40 / 0.3249 = 123px */
  --wheel-width: 65px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

/* Ambient glow blobs in background */
.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.4;
  pointer-events: none;
}

.bg-glow-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(0, 0, 0, 0) 70%);
  top: -10%;
  left: 15%;
  animation: float-slow 15s ease-in-out infinite alternate;
}

.bg-glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, rgba(0, 0, 0, 0) 70%);
  bottom: -15%;
  right: 10%;
  animation: float-slow 20s ease-in-out infinite alternate-reverse;
}

@keyframes float-slow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.1); }
}

/* Main Container Layout */
.app-container {
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 20px;
}

/* Glassmorphic Card */
.timer-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-radius: 32px;
  padding: 40px 48px;
  width: 100%;
  max-width: 520px;
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

.timer-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Header */
.timer-header {
  text-align: center;
  margin-bottom: 40px;
}

.timer-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #ffffff 30%, #a1a1aa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.timer-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Wheels Area */
.wheels-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  background: rgba(5, 7, 12, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 24px 32px;
  border-radius: 24px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8);
  margin-bottom: 40px;
  position: relative;
}

/* 3D Wheel Container */
.wheel-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Arrow Buttons */
.arrow {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.6;
  outline: none;
  z-index: 15;
}

.arrow:hover {
  color: var(--text-primary);
  opacity: 1;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.arrow-up:hover {
  transform: translateY(-2px);
}

.arrow-down:hover {
  transform: translateY(2px);
}

.arrow:active {
  transform: scale(0.9);
}

/* Hiding arrows when running */
.running .arrow {
  opacity: 0 !important;
  pointer-events: none;
  transform: translateY(0) scale(0.8);
}

/* Wheel Viewport viewport and 3D context */
.wheel-viewport {
  width: var(--wheel-width);
  height: var(--digit-height);
  overflow: visible;
  position: relative;
  perspective: 1000px;
  margin: 4px 0;
}

/* Decagon Drum */
.wheel-3d {
  width: 100%;
  height: 100%;
  position: absolute;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

/* Each Digit Face */
.digit {
  position: absolute;
  width: 100%;
  height: var(--digit-height);
  left: 0;
  top: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Share Tech Mono', monospace;
  font-size: 3.8rem;
  font-weight: bold;
  color: #4b5563; /* Dimmed gray for inactive digits */
  opacity: 0.55;   /* Semi-transparent to make center pop */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: rotateX(calc(var(--i) * 36deg)) translateZ(var(--wheel-radius));
  text-shadow: none;
  transition: color 0.3s ease, opacity 0.3s ease, text-shadow 0.3s ease;
}

.digit.active {
  color: var(--text-primary); /* Bright white for center active digit */
  opacity: 1;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

/* Position digits for 6-sided wheel */
[data-faces="6"] .digit {
  transform: rotateX(calc(var(--i) * 60deg)) translateZ(var(--wheel-radius));
}



/* Cylindrical shading overlay */
.wheel-shadow {
  position: absolute;
  top: -5px;
  left: 0;
  width: 100%;
  height: calc(100% + 10px);
  pointer-events: none;
  z-index: 10;
  border-radius: 4px;
  background: linear-gradient(
    to bottom,
    rgba(5, 7, 12, 0.95) 0%,
    rgba(5, 7, 12, 0.4) 15%,
    rgba(5, 7, 12, 0) 45%,
    rgba(5, 7, 12, 0) 55%,
    rgba(5, 7, 12, 0.4) 85%,
    rgba(5, 7, 12, 0.95) 100%
  );
}

/* Highlight center indicator line */
.wheels-wrapper::before {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  height: calc(var(--digit-height) - 4px);
  top: 50%;
  transform: translateY(-50%);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.015) 0%,
    rgba(255, 255, 255, 0.0) 100%
  );
  pointer-events: none;
  border-radius: 8px;
}

/* Colon Separator style */
.colon-separator {
  font-family: 'Share Tech Mono', monospace;
  font-size: 3.5rem;
  font-weight: bold;
  color: var(--text-primary);
  margin: 0 4px;
  padding-bottom: 8px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  align-self: center;
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.running .colon-separator {
  animation: blink 1s infinite;
}

/* Control Buttons Section */
.controls-wrapper {
  display: flex;
  gap: 20px;
  width: 100%;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 16px;
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  outline: none;
}

.btn-icon {
  font-size: 1.1rem;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-secondary:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: #04100c;
  box-shadow: 0 0 20px var(--color-primary-glow);
}

.btn-primary:hover {
  background: #10c88b;
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

/* Style for pause state */
.btn-primary.paused-state {
  background: var(--color-pause);
  color: #1a1000;
  box-shadow: 0 0 20px var(--color-pause-glow);
}

.btn-primary.paused-state:hover {
  background: #fbbf24;
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.6);
}

/* Wheel active selection glow when timer is set */
.wheel-container:hover .digit.active {
  color: #60a5fa;
  text-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
}

.wheel-container:hover .digit:not(.active) {
  color: #3b82f6;
  opacity: 0.35;
}

/* Flashing Alarm Screen Overlay */
.alarm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.alarm-overlay.flashing {
  animation: pulse-alarm 1s infinite;
}

@keyframes pulse-alarm {
  0%, 100% {
    background-color: rgba(239, 68, 68, 0);
    box-shadow: inset 0 0 0px rgba(239, 68, 68, 0);
  }
  50% {
    background-color: rgba(239, 68, 68, 0.18);
    box-shadow: inset 0 0 80px rgba(239, 68, 68, 0.5);
  }
}

/* Card vibration during alarm */
.timer-card.vibrating {
  animation: vibrate 0.5s infinite;
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(239, 68, 68, 0.25);
}

@keyframes vibrate {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(2px, -2px); }
  60% { transform: translate(-1px, -1px); }
  80% { transform: translate(2px, 1px); }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  :root {
    --digit-height: 60px;
    --wheel-radius: 93px; /* 30px / tan(18deg) = 93px */
    --wheel-width: 50px;
  }
  .timer-card {
    padding: 30px 24px;
  }
  .wheels-wrapper {
    padding: 16px 20px;
    gap: 6px;
  }
  .digit {
    font-size: 2.8rem;
  }
  .colon-separator {
    font-size: 2.5rem;
  }
  .timer-header h1 {
    font-size: 1.8rem;
  }
}
