/* styles.css */
:root {
  --brand-color: #21A4B1;
  --brand-yellow: #FFD966;
  --bg-light: #f8fafc;
  --bg-cyan: #e0f7fa;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans TC', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--bg-light) 0%, var(--bg-cyan) 100%);
  color: var(--brand-color);
  position: relative;
  overflow: hidden;
  transition: background 2s ease;
}

/* 音樂播放時的背景變化 */
body.music-playing {
  background: linear-gradient(135deg, var(--bg-light) 0%, #e3f2fd 50%, #bbdefb 100%);
}

body.music-playing .mountain {
  animation: wave 20s ease-in-out infinite alternate;
}

body.music-playing .sun {
  animation: float 8s ease-in-out infinite;
}

body.music-playing .small-sun {
  animation: float 10s ease-in-out infinite reverse;
}

/* 聲音波形動畫 */
.sound-waves {
  width: 100%;
  height: 40px;
  margin: 1rem 0;
  position: relative;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
  overflow: hidden;
}

body.music-playing .sound-waves {
  opacity: 0.5;
}

.wave-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  width: 100%;
}

.wave {
  flex: 1;
  height: 2px;
  background-color: var(--brand-color);
  margin: 0 0.5px;
  border-radius: 1px;
  animation: sound-wave-horizontal 1.5s infinite ease-in-out;
  max-width: 3px;
}

.wave:nth-child(odd) {
  animation-delay: 0.2s;
}

.wave:nth-child(even) {
  animation-delay: 0.6s;
}

.wave:nth-child(3n) {
  animation-delay: 0.9s;
}

.wave:nth-child(3n+1) {
  animation-delay: 0.3s;
}

.wave:nth-child(5n) {
  animation-delay: 0.7s;
}

@keyframes sound-wave-horizontal {
  0%, 100% {
    height: 2px;
  }
  50% {
    height: 20px;
  }
}

/* 響應式調整 */
@media (max-width: 768px) {
  .sound-waves {
    height: 30px;
  }
  
  @keyframes sound-wave-horizontal {
    0%, 100% {
      height: 2px;
    }
    50% {
      height: 15px;
    }
  }
}

@media (max-width: 480px) {
  .sound-waves {
    height: 20px;
  }
  
  @keyframes sound-wave-horizontal {
    0%, 100% {
      height: 1px;
    }
    50% {
      height: 10px;
    }
  }
}

.container {
  text-align: center;
  z-index: 10;
  padding: 2rem;
  position: relative;
  backdrop-filter: blur(5px);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
  animation: fadeIn 1s ease-out;
  transform-style: preserve-3d;
  perspective: 1000px;
  max-width: 90%;
  width: 600px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.mode-title {
  font-size: 2rem;
  font-weight: bold;
  color: var(--brand-color);
  margin-bottom: 1rem;
  position: absolute;
  top: -3.5rem;
  left: 0;
  right: 0;
  text-align: center;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  padding: 0 1rem;
}

.title {
  display: inline-block;
  background-color: rgba(255, 255, 255, 0.8);
  color: var(--brand-color);
  padding: 0.5rem 1.5rem;
  border-radius: 9999px;
  font-weight: bold;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  transform: translateZ(10px);
  font-size: 1.25rem;
}

.title:hover {
  transform: translateZ(20px) scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.brand-slogan {
  font-size: 1rem;
  color: var(--brand-color);
  opacity: 0.8;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 500;
  letter-spacing: 1px;
}

.timer {
  font-size: 10rem;
  font-weight: 700;
  margin: 1rem 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  transform: translateZ(30px);
  animation: pulse 1.5s infinite alternate ease-in-out;
  line-height: 1;
}

@media (max-width: 768px) {
  .timer {
    font-size: 8rem;
  }
  .mode-title {
    font-size: 1.5rem;
    top: -3rem;
  }
}

@media (max-width: 480px) {
  .timer {
    font-size: 6rem;
  }
  .mode-title {
    font-size: 1.2rem;
    top: -2.5rem;
  }
}

@keyframes pulse {
  from { transform: translateZ(30px) scale(1); }
  to { transform: translateZ(30px) scale(1.03); }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 2rem;
  perspective: 1000px;
}

.btn {
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  z-index: 1;
  font-size: 1.1rem;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: -1;
}

.btn:hover::before {
  transform: translateX(0);
}

.btn:active {
  transform: translateY(2px);
}

.btn-preset {
  background-color: var(--brand-color);
  color: white;
  transform: translateZ(5px);
}

.btn-preset:hover {
  background-color: var(--brand-yellow);
  color: var(--brand-color);
  transform: translateZ(10px) scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-adjust {
  background-color: white;
  color: var(--brand-color);
  border: 1px solid var(--brand-color);
  transform: translateZ(5px);
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  border-radius: 0.3rem;
}

.btn-adjust:hover {
  background-color: var(--brand-yellow);
  color: var(--brand-color);
  transform: translateZ(10px) scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.action-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  perspective: 1000px;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.btn-action {
  padding: 0.75rem 2rem;
  font-size: 1.25rem;
  transform: translateZ(15px);
}

.btn-start {
  background-color: var(--brand-color);
  color: white;
}

.btn-start:hover {
  background-color: var(--brand-yellow);
  color: var(--brand-color);
  transform: translateZ(20px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-reset {
  background-color: white;
  color: var(--brand-color);
  border: 1px solid var(--brand-color);
}

.btn-reset:hover {
  background-color: var(--brand-yellow);
  color: var(--brand-color);
  transform: translateZ(20px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-music {
  background-color: white;
  color: #DE6259;
  border: 2px solid #DE6259;
}

.btn-music:hover {
  background-color: var(--brand-yellow);
  color: var(--brand-color);
  transform: translateZ(20px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-music.playing {
  background-color: var(--brand-yellow);
  color: var(--brand-color);
  content: '⏸';
}



.mode-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.btn-mode {
  background-color: rgba(255, 255, 255, 0.7);
  color: var(--brand-color);
  border: 1px solid var(--brand-color);
  transform: translateZ(5px);
  padding: 0.5rem 1rem;
}

.btn-mode.active {
  background-color: var(--brand-color);
  color: white;
}

.btn-mode:hover {
  background-color: var(--brand-yellow);
  color: var(--brand-color);
  transform: translateZ(10px) scale(1.05);
}

.background {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
}

.mountain {
  fill: var(--brand-color);
  fill-opacity: 0.15;
  animation: wave 15s ease-in-out infinite alternate;
  width: 100%;
  position: absolute;
  bottom: 0;
}

@keyframes wave {
  0% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  100% { transform: translateX(-5px); }
}

.sun {
  fill: var(--brand-yellow);
  fill-opacity: 0.7;
  animation: float 6s ease-in-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}

.small-sun {
  fill: var(--brand-yellow);
  fill-opacity: 0.5;
  animation: float 8s ease-in-out infinite reverse;
  transform-origin: center;
  transform-box: fill-box;
}

/* 為太陽添加響應式樣式 */
@media (max-width: 768px) {
  .sun {
    r: 30;
  }
  .small-sun {
    r: 15;
  }
}

@media (max-width: 480px) {
  .sun {
    r: 20;
  }
  .small-sun {
    r: 10;
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.brand {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 10;
  transition: all 0.3s ease;
}

.brand:hover {
  transform: scale(1.05);
}

.brand img {
  height: 40px;
  width: auto;
}

.powered-by {
  position: absolute;
  bottom: -60px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 10;
  transition: all 0.3s ease;
  margin: 0 auto;
}

.powered-by:hover {
  transform: scale(1.05);
}

.powered-by img {
  height: 40px;
  width: auto;
}

/* 粒子背景 */
.particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.particle {
  position: absolute;
  background-color: rgba(33, 164, 177, 0.1);
  border-radius: 50%;
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-100vh) rotate(360deg); }
}

/* 光暈動畫 */
.glow {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(33, 164, 177, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
  animation: glowPulse 8s infinite alternate ease-in-out;
}

.glow:nth-child(2) {
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 217, 102, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
  animation-delay: 2s;
  animation-duration: 10s;
}

@keyframes glowPulse {
  0% { transform: translate(10%, 10%) scale(1); opacity: 0.5; }
  50% { transform: translate(-10%, -5%) scale(1.2); opacity: 0.7; }
  100% { transform: translate(-5%, 15%) scale(0.9); opacity: 0.6; }
}
