/* style.css — 버피 메트로놈 스타일시트 (Gym Interval Timer 테마) */

:root {
  --bg-main: #0c0e14;
  --bg-surface: #151924;
  --bg-surface-elevated: #1e2333;
  --bg-input: #11141e;
  --border-subtle: #293044;
  --border-focus: #4b5563;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* 테마별 액센트 컬러 */
  --color-workout: #00e676;
  --color-workout-glow: rgba(0, 230, 118, 0.45);
  --color-workout-bg: #092416;

  --color-rest: #ff5252;
  --color-rest-glow: rgba(255, 82, 82, 0.45);
  --color-rest-bg: #2b1111;

  --color-ready: #ffab00;
  --color-ready-glow: rgba(255, 171, 0, 0.45);
  --color-ready-bg: #261805;

  --color-ended: #00e5ff;
  --color-ended-glow: rgba(0, 229, 255, 0.45);
  --color-ended-bg: #08212e;

  --color-accent-gold: #ffd600;
  --color-error: #ff4d4f;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-full: 9999px;

  --font-mono: 'SF Mono', 'Roboto Mono', 'Cascadia Code', Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 12px 40px;
  overflow-x: hidden;
}

/* 전체 앱 레이아웃 (모바일 세로 우선, PC 중앙 정렬) */
.app-layout {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 상단 헤더 */
.app-header {
  text-align: center;
  padding: 4px 0 2px;
}

.app-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-transform: uppercase;
}

/* =========================================
   진행 화면 (멀리서도 선명하게 보여야 함)
   ========================================= */
.display-panel {
  position: relative;
  background-color: var(--bg-surface);
  border: 3px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 22px 18px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  transition: border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
}

/* 단계별 테마 전환 효과 */
.display-panel.phase-workout {
  border-color: var(--color-workout);
  background-color: var(--color-workout-bg);
  box-shadow: 0 0 35px var(--color-workout-glow), 0 12px 36px rgba(0, 0, 0, 0.7);
}

.display-panel.phase-rest {
  border-color: var(--color-rest);
  background-color: var(--color-rest-bg);
  box-shadow: 0 0 35px var(--color-rest-glow), 0 12px 36px rgba(0, 0, 0, 0.7);
}

.display-panel.phase-ready {
  border-color: var(--color-ready);
  background-color: var(--color-ready-bg);
  box-shadow: 0 0 35px var(--color-ready-glow), 0 12px 36px rgba(0, 0, 0, 0.7);
}

.display-panel.phase-ended {
  border-color: var(--color-ended);
  background-color: var(--color-ended-bg);
  box-shadow: 0 0 35px var(--color-ended-glow), 0 12px 36px rgba(0, 0, 0, 0.7);
}

/* =========================================
   라운드 진행 막대 (화면 맨 위 가로 막대)
   ========================================= */
.progress-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
}

.progress-status {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.progress-status.ready-state {
  color: var(--color-ready);
  font-weight: 900;
}

.progress-time {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.round-progress-bar {
  position: relative;
  width: 100%;
  height: 22px;
  background-color: #0d111a;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  user-select: none;
}

.progress-track {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
}

.progress-segment {
  height: 100%;
  transition: width 0.2s ease;
}

.segment-workout {
  background-color: var(--color-workout);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.segment-rest {
  background-color: var(--color-rest);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.segment-ready {
  background-color: var(--color-ready);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* 마지막 라운드는 휴식이 없으므로 흐리게 처리 */
.segment-rest.dimmed,
.segment-ready.dimmed {
  opacity: 0.22;
  filter: grayscale(0.85);
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.4),
    rgba(0, 0, 0, 0.4) 4px,
    transparent 4px,
    transparent 8px
  );
}

/* 1초 눈금 레이어 (연습실 예약표 칸 느낌) */
.progress-ticks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.progress-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: rgba(0, 0, 0, 0.45);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.22);
}

.progress-tick.major-tick {
  background-color: rgba(0, 0, 0, 0.6);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.45);
  width: 1.5px;
}

/* 미진행 구간 어두운 오버레이 마스크 (진행된 부분은 밝게 노출) */
.progress-unfilled-mask {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  background-color: rgba(12, 14, 20, 0.72);
  pointer-events: none;
}

/* 세로 표시선 (Needle) */
.progress-needle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  background-color: #ffffff;
  transform: translateX(-50%);
  box-shadow: 0 0 8px #ffffff, 0 0 14px rgba(255, 255, 255, 0.8);
  border-radius: 2px;
  z-index: 3;
  pointer-events: none;
}

/* 단계 뱃지 */
.phase-header {
  display: flex;
  justify-content: center;
  width: 100%;
}

.phase-badge {
  display: inline-block;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 6px 28px;
  border-radius: var(--radius-full);
  color: #000;
  background-color: var(--color-workout);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: background-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.display-panel.phase-workout .phase-badge {
  background-color: var(--color-workout);
  color: #052410;
  box-shadow: 0 0 16px var(--color-workout-glow);
}

.display-panel.phase-rest .phase-badge {
  background-color: var(--color-rest);
  color: #fff;
  box-shadow: 0 0 16px var(--color-rest-glow);
}

.display-panel.phase-ready .phase-badge {
  background-color: var(--color-ready);
  color: #1a0e00;
  box-shadow: 0 0 16px var(--color-ready-glow);
}

.display-panel.phase-ended .phase-badge {
  background-color: var(--color-ended);
  color: #03212f;
  box-shadow: 0 0 16px var(--color-ended-glow);
}

/* 카운트인 박 울릴 때 단계 뱃지 번쩍임 피드백 */
.phase-badge.flashing {
  background-color: #ffffff !important;
  color: #000000 !important;
  transform: scale(1.12);
  box-shadow: 0 0 25px #ffffff, 0 0 40px var(--color-ready) !important;
}

/* 대형 글씨 영역 (동작수, 휴식, 카운트말, 종료) */
.timer-area {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: -4px 0;
  min-height: 110px;
}

.timer-number {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, var(--font-mono), sans-serif;
  font-size: clamp(4.4rem, 18vw, 7.2rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
  user-select: none;
  transition: transform 0.08s ease, text-shadow 0.08s ease;
  text-align: center;
  word-break: keep-all;
}

.timer-number.flashing {
  transform: scale(1.08);
  text-shadow: 0 0 25px #ffffff, 0 0 40px var(--color-ready);
}

.display-panel.phase-workout .timer-number {
  color: #ffffff;
  text-shadow: 0 0 20px rgba(0, 230, 118, 0.4);
}

.display-panel.phase-rest .timer-number {
  color: #ffffff;
  text-shadow: 0 0 20px rgba(255, 82, 82, 0.4);
}

.display-panel.phase-ready .timer-number {
  color: #ffffff;
  text-shadow: 0 0 20px rgba(255, 171, 0, 0.4);
}

.display-panel.phase-ended .timer-number {
  color: #ffffff;
  text-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

/* 라운드 & 동작 횟수 통계 */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.stat-card {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-data {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

/* 구분동작 점 표시 */
.subdivision-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
}

.subdivision-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 38px;
}

.dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.3);
  position: relative;
  transition: transform 0.08s ease, background-color 0.08s ease, box-shadow 0.08s ease, border-color 0.08s ease;
}

/* 강박 점 표시 (다르게 표시) */
.dot.accent-dot {
  border-color: var(--color-accent-gold);
  background-color: rgba(255, 214, 0, 0.18);
  box-shadow: 0 0 6px rgba(255, 214, 0, 0.35);
}

.dot.accent-dot::after {
  content: '★';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--color-accent-gold);
  line-height: 1;
}

/* 띡이 울리는 순간 번쩍임(Flash) */
.dot.flashing {
  background-color: #ffffff !important;
  border-color: #ffffff !important;
  transform: scale(1.45);
  box-shadow: 0 0 22px #ffffff, 0 0 35px var(--color-workout) !important;
  z-index: 2;
}

.dot.accent-dot.flashing {
  background-color: #ffffff !important;
  border-color: var(--color-accent-gold) !important;
  box-shadow: 0 0 25px #ffffff, 0 0 40px var(--color-accent-gold) !important;
}

/* =========================================
   띡 간격 및 BPM 실시간 표시 배너
   ========================================= */
.timing-info-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: center;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* =========================================
   시작 / 정지 버튼
   ========================================= */
.control-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.btn {
  height: 58px;
  border-radius: var(--radius-lg);
  border: none;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, filter 0.15s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
}

.btn-start {
  background: linear-gradient(135deg, #00e676 0%, #00b050 100%);
  color: #032410;
  box-shadow: 0 4px 18px rgba(0, 230, 118, 0.35);
}

.btn-start:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-start:disabled {
  background: #252a36;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.6;
}

.btn-stop {
  background: linear-gradient(135deg, #ff5252 0%, #d32f2f 100%);
  color: #ffffff;
  box-shadow: 0 4px 18px rgba(255, 82, 82, 0.35);
}

.btn-stop:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-stop:disabled {
  background: #252a36;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.6;
}

/* =========================================
   설정 패널 및 인풋 카드
   ========================================= */
.settings-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px 16px 20px;
}

#settingsForm {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.setting-card {
  background-color: var(--bg-surface-elevated);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}

.setting-card.full-width {
  grid-column: 1 / -1;
}

.setting-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 4px;
}

.setting-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.setting-unit {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* 스텝퍼 (− / + 버튼) */
.stepper-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background-color: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.stepper-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, transform 0.08s ease, color 0.15s ease;
}

.stepper-btn:hover:not(:disabled) {
  background-color: #2e364d;
  color: #ffffff;
}

.stepper-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.stepper-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.setting-input {
  width: 100%;
  min-width: 0;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.setting-input::-webkit-outer-spin-button,
.setting-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 유효성 검사 에러 상태 */
.setting-card.has-error {
  border-color: var(--color-error);
  background-color: rgba(255, 77, 79, 0.08);
}

.validation-message {
  display: none;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--color-error);
  padding: 0 4px;
  line-height: 1.2;
}

.setting-card.has-error .validation-message {
  display: block;
}

/* 강박 위치 세그먼트 컨트롤 */
.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background-color: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.segment-item {
  position: relative;
  cursor: pointer;
}

.segment-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.segment-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-secondary);
  background: transparent;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.segment-radio:checked + .segment-btn {
  background-color: var(--color-workout);
  color: #032410;
  box-shadow: 0 2px 8px rgba(0, 230, 118, 0.35);
}

.segment-item:hover .segment-btn:not(.segment-radio:checked + .segment-btn) {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

/* =========================================
   실행 중 잠금 (Locked 상태)
   ========================================= */
.settings-panel.is-locked {
  pointer-events: none;
  opacity: 0.5;
}

.settings-panel.is-locked input,
.settings-panel.is-locked button {
  cursor: not-allowed;
}

/* =========================================
   소형 화면 모바일 최적화 (380px 이하)
   ========================================= */
@media (max-width: 380px) {
  #settingsForm {
    grid-template-columns: 1fr;
  }
  
  .timer-number {
    font-size: 4.6rem;
  }

  .stat-data {
    font-size: 1.45rem;
  }
}
