/* ═══════════════════════════════════════════════════════════════
   YogaBud — App Styles
   Aesthetic: Dark organic · Sage + Amber · Cormorant + DM Sans
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg:            #08090a;
  --bg2:           #0f1210;
  --sage:          #4a7c59;
  --sage-light:    #6aab7e;
  --sage-dim:      rgba(74, 124, 89, 0.4);
  --amber:         #c9974a;
  --amber-light:   #e0b668;
  --text:          #ede8da;
  --text-muted:    rgba(237, 232, 218, 0.55);
  --text-dim:      rgba(237, 232, 218, 0.28);
  --good:          #6aab7e;
  --warn:          #c9974a;
  --error:         #b86060;
  --glass-bg:      rgba(8, 9, 10, 0.76);
  --glass-border:  rgba(74, 124, 89, 0.22);
  --font-display:  'Cormorant Garamond', 'Palatino Linotype', Georgia, serif;
  --font-body:     'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --r:             10px;
  --r-lg:          18px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Noise grain overlay ───────────────────────────────────── */
.grain {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9000;
  opacity: 0.35;
  mix-blend-mode: overlay;
}

/* ── Screens ───────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  overflow-y: auto;
}
.screen.active { display: flex; }

/* ══════════════════════════════════════════════════════════════
   WELCOME SCREEN
   ══════════════════════════════════════════════════════════════ */
#screen-welcome {
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  position: relative;
}

#screen-welcome::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 45% at 15% 85%, rgba(74, 124, 89, 0.14) 0%, transparent 65%),
    radial-gradient(ellipse 35% 55% at 85% 15%, rgba(201, 151, 74, 0.07) 0%, transparent 65%),
    radial-gradient(ellipse 60% 30% at 50% 50%, rgba(74, 124, 89, 0.04) 0%, transparent 80%);
  pointer-events: none;
}

.welcome-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 360px;
  width: 100%;
  animation: fade-up 0.7s ease both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo-mark {
  width: 68px;
  height: 68px;
  margin: 0 auto 1.4rem;
  color: var(--sage-light);
  animation: breathe 4s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(74, 124, 89, 0.35));
}

@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: 0.88; }
  50%       { transform: scale(1.06); opacity: 1;    }
}

.app-name {
  font-family: var(--font-display);
  font-size: 3.8rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  color: var(--text);
  margin-bottom: 0.4rem;
  line-height: 1;
}

.app-tagline {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 2.6rem;
  line-height: 1.8;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.8rem;
}

.hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.5;
}
.hint em { color: var(--amber); font-style: normal; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 0.85rem 2rem;
  background: var(--sage);
  color: var(--text);
  border: none;
  border-radius: var(--r);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-primary:hover  { background: var(--sage-light); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(74,124,89,0.3); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  width: 100%;
  padding: 0.85rem 2rem;
  background: transparent;
  color: var(--text-muted);
  border: 0.5px solid rgba(237, 232, 218, 0.18);
  border-radius: var(--r);
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--sage-dim); color: var(--text); }

.icon-btn {
  width: 34px;
  height: 34px;
  background: transparent;
  border: 0.5px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.icon-btn:hover  { border-color: var(--amber); color: var(--amber); }
.icon-btn.active { border-color: var(--amber); color: var(--amber); background: rgba(201,151,74,0.12); }

/* ══════════════════════════════════════════════════════════════
   SESSION SCREEN
   ══════════════════════════════════════════════════════════════ */
#screen-session {
  flex-direction: column;
  background: #000;
}

/* Camera full-viewport background */
.camera-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#camera-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror so it feels natural */
}

#pose-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.camera-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.85rem;
  z-index: 5;
  transition: opacity 0.5s;
}
.camera-loading.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--sage-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Glass utility — used for all overlay panels */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r);
}

/* Top bar */
.session-topbar {
  position: fixed;
  top: max(env(safe-area-inset-top), 10px);
  left: 12px;
  right: 12px;
  z-index: 10;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pose-info { flex: 1; min-width: 0; }

.pose-sanskrit {
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-style: italic;
  color: var(--amber);
  letter-spacing: 0.07em;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pose-english {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-controls { display: flex; gap: 8px; flex-shrink: 0; margin-left: 12px; }

/* Hold timer ring — bottom right */
.timer-widget {
  position: fixed;
  bottom: 168px;
  right: 14px;
  width: 86px;
  height: 86px;
  z-index: 10;
}

#timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 6;
}

.ring-fill {
  fill: none;
  stroke: var(--sage-light);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.6s ease, stroke 0.4s;
}
.ring-fill.complete { stroke: var(--amber-light); }

.timer-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.timer-seconds {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 300;
  color: var(--text);
  line-height: 1;
}

.timer-label {
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* Rep counter — bottom left */
.rep-counter {
  position: fixed;
  bottom: 168px;
  left: 14px;
  z-index: 10;
  padding: 10px 14px;
  text-align: center;
  min-width: 58px;
}

.rep-number {
  display: block;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 300;
  color: var(--amber);
  line-height: 1;
}

.rep-label {
  display: block;
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* Feedback bubble — above score bar */
.feedback-bubble {
  position: fixed;
  bottom: 104px;
  left: 12px;
  right: 12px;
  z-index: 10;
  padding: 11px 15px;
  min-height: 50px;
  display: flex;
  align-items: center;
}

.feedback-bubble p {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.55;
  font-family: var(--font-display);
  font-style: italic;
}

/* Alignment score bar */
.score-bar {
  position: fixed;
  bottom: 50px;
  left: 12px;
  right: 12px;
  z-index: 10;
  padding: 8px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.score-track {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.09);
  border-radius: 2px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  width: 0%;
  background: var(--sage-light);
  border-radius: 2px;
  transition: width 0.6s ease, background 0.4s;
}

.score-value {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text);
  min-width: 34px;
  text-align: right;
}

/* Voice listening indicator */
.voice-indicator {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--glass-bg);
  border: 0.5px solid var(--glass-border);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  white-space: nowrap;
}
.voice-indicator.active { opacity: 1; }

.voice-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1);   }
  50%       { opacity: 0.4; transform: scale(0.65); }
}

/* Bottom hint */
.mic-status {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 0.68rem;
  color: var(--text-dim);
  pointer-events: none;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   SETTINGS SCREEN
   ══════════════════════════════════════════════════════════════ */
#screen-settings {
  flex-direction: column;
  background: var(--bg);
  overflow-y: auto;
  position: relative;
}

#screen-settings::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 70% 40% at 50% 100%, rgba(74, 124, 89, 0.07) 0%, transparent 70%);
  pointer-events: none;
}

.settings-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 2rem) 1.5rem 3rem;
  animation: fade-up 0.4s ease both;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 1.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}
.back-btn:hover { color: var(--text); }

.settings-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 300;
  color: var(--text);
  margin-bottom: 2rem;
  letter-spacing: 0.03em;
}

.settings-section {
  margin-bottom: 1.6rem;
}

.settings-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.5rem;
}

.settings-input {
  width: 100%;
  padding: 0.72rem 1rem;
  background: rgba(255,255,255,0.04);
  border: 0.5px solid rgba(237,232,218,0.14);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
}
.settings-input:focus { border-color: var(--sage); }
.settings-input option { background: #0f1210; color: var(--text); }

.settings-hint {
  font-size: 0.73rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  line-height: 1.55;
}
.settings-hint a { color: var(--amber); text-decoration: none; }
.settings-hint a:hover { text-decoration: underline; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.toggle-row .settings-label { margin-bottom: 0; flex: 1; }

.toggle {
  position: relative;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.25s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.25s, background 0.25s;
}
.toggle input:checked + .toggle-slider { background: var(--sage); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: #fff; }

.disclaimer {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.65;
  padding: 12px 14px;
  border: 0.5px solid rgba(237,232,218,0.08);
  border-radius: var(--r);
  background: rgba(255,255,255,0.02);
}
.disclaimer em { color: var(--text-muted); font-style: normal; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (min-width: 600px) {
  .feedback-bubble {
    max-width: 560px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 24px);
  }
  .score-bar {
    max-width: 560px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 24px);
  }
}

@media (min-width: 900px) {
  /* Landscape desktop / laptop webcam users */
  .timer-widget  { bottom: 180px; right: 24px; }
  .rep-counter   { bottom: 180px; left: 24px; }
  .session-topbar { top: 16px; left: 16px; right: 16px; }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .logo-mark, .voice-dot, .spinner { animation: none; }
  .welcome-content { animation: none; }
}
