/* =============================================
   PianoCare – Piano Tuning Scanner
   Mobile-first styles
   ============================================= */

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --success-muted: #166534;
  --warning: #f59e0b;
  --danger: #ef4444;
  --white-key: #f8fafc;
  --white-key-done: #86efac;
  --white-key-active: #3b82f6;
  --black-key: #1e293b;
  --black-key-done: #166534;
  --black-key-active: #2563eb;
  --radius: 12px;
  --transition: 300ms ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ---- Steps / Wizard ---- */

.step {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.step.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.step-content {
  width: 100%;
  max-width: 480px;
  padding: 2rem 1.5rem;
  text-align: center;
}

/* ---- Welcome ---- */

.logo-area {
  margin-bottom: 1.5rem;
}

.piano-icon {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  animation: gentle-bounce 2s ease-in-out infinite;
}

@keyframes gentle-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.instructions {
  text-align: left;
  margin: 0 auto 2rem;
  max-width: 320px;
}

.instruction-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.instruction-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.privacy-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* ---- Microphone ---- */

.mic-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

#step-mic h2 {
  margin-bottom: 0.75rem;
}

#step-mic p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 0.15s ease, opacity var(--transition);
  -webkit-tap-highlight-color: transparent;
}

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

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid #334155;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

/* ---- Error ---- */

.error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}

.error-msg p {
  color: var(--danger);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

/* ---- Recording ---- */

.recording-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 1rem 1rem 1.5rem !important;
  justify-content: flex-start;
}

.recording-header {
  margin-bottom: 0.75rem;
}

.recording-header h2 {
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

.note-name {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Progress */

.progress-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 55px;
  text-align: right;
}

/* Piano container */

.piano-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-card);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  position: relative;
}

.piano-container svg {
  width: 100%;
  height: 100%;
}

/* Detected note popup */

.detected-note {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--primary);
  color: white;
  font-size: 2rem;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.detected-note.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Milestone toast */

.milestone-toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--success);
  color: #052e16;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
  white-space: nowrap;
}

.milestone-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Recording controls */

.recording-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  padding-top: 0.5rem;
}

/* ---- Report ---- */

.report-header {
  margin-bottom: 1.5rem;
}

.report-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.report-summary {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 0.5rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.25rem;
}

/* Report table */

.report-table-wrapper {
  max-height: 50vh;
  overflow-y: auto;
  border-radius: var(--radius);
  background: var(--bg-card);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.report-table th {
  position: sticky;
  top: 0;
  background: #334155;
  padding: 0.6rem 0.4rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.report-table td {
  padding: 0.5rem 0.4rem;
  text-align: center;
  border-bottom: 1px solid #1e293b;
}

.report-table tr:last-child td {
  border-bottom: none;
}

.status-intune {
  color: var(--success);
  font-weight: 600;
}

.status-slight {
  color: var(--warning);
  font-weight: 600;
}

.status-offtune {
  color: var(--danger);
  font-weight: 600;
}

/* ---- Responsive ---- */

@media (min-width: 768px) {
  .step-content {
    max-width: 560px;
  }
}

/* ---- Animations ---- */

@keyframes pulse-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}

.key-active-glow {
  animation: pulse-glow 1s ease-in-out infinite;
}
