/* Motion Coach 落地頁 — 純瀏覽器，0 server 運算 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: #0a0a0a;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.phone-frame {
  width: 390px;
  height: 844px;
  max-width: 100vw;
  max-height: 100vh;
  background: #000;
  border-radius: 48px;
  box-shadow:
    0 0 0 12px #1a1a1a,
    0 0 0 14px #2a2a2a,
    0 30px 80px rgba(0, 255, 100, 0.1),
    0 60px 120px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 手機全螢幕時拿掉外框 */
@media (max-width: 430px) {
  .phone-frame {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* 狀態列 */
.status-bar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px 0;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
  z-index: 10;
}

.status-bar .title {
  letter-spacing: 1px;
  font-size: 15px;
}

.status-bar .status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #333;
  transition: background 0.3s;
}

.status-bar .status.connected {
  background: #3cdc3c;
  box-shadow: 0 0 8px #3cdc3c;
}

/* 主畫面 */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #000;
  overflow: hidden;
}

.camera-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #1a1a1a;
}

#video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: scaleX(-1);
}

/* 載入畫面 */
.loading-screen {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  gap: 16px;
  transition: opacity 0.3s;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(60, 220, 60, 0.2);
  border-top-color: #3cdc3c;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}

.loading-sub {
  font-size: 13px;
  color: #888;
  text-align: center;
  padding: 0 32px;
}

/* Events banner — 規則觸發事件 */
.events-banner {
  position: absolute;
  top: 56px;
  left: 16px;
  right: 100px;       /* 留給 FPS badge */
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
  z-index: 5;
}

.event-chip {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.event-chip.ok {
  background: rgba(60, 180, 60, 0.85);
  color: #fff;
}

.event-chip.warn {
  background: rgba(240, 60, 60, 0.85);
  color: #fff;
  animation: pulse-warn 1.2s ease-in-out infinite;
}

.event-chip.info {
  background: rgba(60, 200, 240, 0.85);
  color: #000;
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* FPS badge */
.fps-badge {
  position: absolute;
  top: 72px;
  right: 24px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 10px 16px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  border: 1px solid rgba(60, 220, 60, 0.3);
}

.fps-num {
  font-size: 28px;
  font-weight: 800;
  color: #3cdc3c;
  font-feature-settings: "tnum";
  letter-spacing: -1px;
}

.fps-label {
  font-size: 11px;
  color: #888;
  font-weight: 500;
}

/* 偵測提示 */
.detection-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  color: #ccc;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}

.detection-hint.visible {
  opacity: 1;
}

/* 底部資訊面板 */
.feedback-panel {
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.8) 30%);
  padding: 20px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feedback-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.feedback-label {
  color: #888;
  font-weight: 500;
}

.feedback-value {
  color: #fff;
  font-weight: 600;
  font-feature-settings: "tnum";
}

/* 底部按鈕 */
.bottom-bar {
  height: 96px;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 24px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-main {
  flex: 1;
  height: 56px;
  background: #3cdc3c;
  color: #000;
  border: none;
  border-radius: 28px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  font-family: inherit;
}

.btn-main:hover {
  background: #5ee85e;
  transform: translateY(-2px);
}

.btn-main:active {
  transform: translateY(0);
}

.btn-main.recording {
  background: #f03c3c;
  color: #fff;
}

.btn-main:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
  transform: none;
}

.btn-circle {
  width: 56px;
  height: 56px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-circle:hover {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.2);
}
