/* Mirror — Meridian structure, warm palette */
/* Concept: "Warm Mirror" — intimate, nurturing, science-backed */

:root {
  /* Warm palette — shifted from Meridian cool neutrals */
  --bg: #faf8f4;
  --bg-warm: #f2ede5;
  --bg-raised: #e8e0d4;
  --bg-dark: #1c1915;
  --bg-dark-elevated: #262219;

  --text: #1c1915;
  --text-secondary: #7a6e5f;
  --text-tertiary: #a69b8a;
  --text-on-dark: #f0ebe3;
  --text-on-dark-secondary: rgba(240, 235, 227, 0.6);

  /* Warm amber accent — honey, nurturing */
  --accent: #b8874a;
  --accent-hover: #a07539;
  --accent-subtle: #f5eed9;
  --accent-text: #8a6530;

  /* Shadows — Meridian precision, warmer tint */
  --shadow-border: 0 0 0 1px rgba(28, 25, 21, 0.06);
  --shadow-card: 0 1px 2px rgba(28, 25, 21, 0.04), 0 4px 16px rgba(28, 25, 21, 0.04), 0 8px 24px rgba(28, 25, 21, 0.02);
  --shadow-elevated: 0 2px 4px rgba(28, 25, 21, 0.04), 0 8px 24px rgba(28, 25, 21, 0.06), 0 16px 48px rgba(28, 25, 21, 0.04), 0 0 0 1px rgba(28, 25, 21, 0.06);
  --shadow-glow: 0 0 0 1px rgba(184, 135, 74, 0.2), 0 4px 16px rgba(184, 135, 74, 0.1);

  /* Typography */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  letter-spacing: 0.01em;
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
}

/* ── App container ── */
#app {
  width: 100%;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ── Screen system ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
  transform: translateY(20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

.screen.exiting {
  opacity: 0;
  transform: translateY(-20px);
}

.screen-content {
  width: 100%;
  max-width: 480px;
  padding: var(--space-xl) var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-lg);
}

/* ── Typography ── */
h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text);
}

h2 em {
  font-style: italic;
  color: var(--accent);
}

p { color: var(--text-secondary); }

.screen-sub {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  max-width: 360px;
}

cite {
  display: block;
  font-size: 0.75rem;
  font-style: normal;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
  margin-top: var(--space-xs);
}

/* ── Buttons — Meridian pills ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 9999px;
  padding: 14px 32px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, opacity 0.2s;
  min-height: 48px;
  letter-spacing: 0.01em;
}

.btn-primary:hover { background: var(--bg-dark-elevated); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary:disabled:hover { background: var(--text); }

.btn-small { padding: 10px 24px; min-height: 40px; font-size: 0.875rem; }

.btn-text {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  transition: color 0.2s;
}
.btn-text:hover { color: var(--text-secondary); }

/* ── Landing ── */
.landing-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-subtle);
  padding: 6px 16px;
  border-radius: 9999px;
}

.landing-title { margin: var(--space-md) 0; }

.landing-sub {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 340px;
  line-height: 1.6;
}

/* ── Science cards ── */
.science-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
  text-align: left;
}

.science-card {
  background: var(--bg-warm);
  border-radius: 14px;
  padding: var(--space-lg);
  box-shadow: var(--shadow-border);
  opacity: 0;
  transform: translateY(12px);
  animation: cardReveal 0.5s ease forwards;
}

.science-card[data-delay="200"] { animation-delay: 0.2s; }
.science-card[data-delay="400"] { animation-delay: 0.4s; }

@keyframes cardReveal {
  to { opacity: 1; transform: translateY(0); }
}

.card-number {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.science-card p {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
}

.science-card strong { font-weight: 600; color: var(--text); }

/* ── Focus pills ── */
.focus-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
  max-width: 400px;
}

.focus-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: none;
  border-radius: 9999px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-border);
}

.focus-pill:hover {
  background: var(--bg-warm);
  color: var(--text);
}

.focus-pill.selected {
  background: var(--accent-subtle);
  color: var(--accent-text);
  box-shadow: var(--shadow-glow);
}

.pill-icon { font-size: 0.75rem; }

/* ── Recording intro ── */
.record-intro-visual {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.wave-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-subtle);
  border: 2px solid var(--accent);
  opacity: 0.7;
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

.tip-box {
  background: var(--bg-warm);
  border-radius: 14px;
  padding: var(--space-lg);
  text-align: left;
  box-shadow: var(--shadow-border);
  max-width: 400px;
}

.tip-label {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.tip-box p {
  font-size: 0.875rem;
  line-height: 1.6;
}

.tip-box em { color: var(--text); font-style: italic; }

/* ── Recording screen ── */
.recording-prompt {
  width: 100%;
  text-align: left;
}

.prompt-instruction {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
}

.prompt-text {
  font-family: var(--font-display);
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text);
  border: none;
  padding: var(--space-lg);
  background: var(--bg-warm);
  border-radius: 14px;
  box-shadow: var(--shadow-border);
  font-style: italic;
}

.recording-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
}

.waveform {
  width: 100%;
  height: 60px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-warm);
}

#waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.recording-timer {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.btn-record {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg);
  border: none;
  border-radius: 9999px;
  padding: 14px 28px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-elevated);
  transition: all 0.2s;
  min-height: 48px;
}

.btn-record:hover { box-shadow: var(--shadow-glow); }

.record-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d94a4a;
  transition: all 0.2s;
}

.btn-record.recording .record-dot {
  animation: recordPulse 1s ease-in-out infinite;
  background: #e03c3c;
}

.btn-record.recording .record-label::after { content: 'Tap to stop'; }
.btn-record.recording .record-label { font-size: 0; }
.btn-record.recording .record-label::after { font-size: 0.9375rem; }

@keyframes recordPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ── Mic selector ── */
.mic-select-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
}

.mic-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.mic-select {
  flex: 1;
  appearance: none;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239a9690'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: none;
  border-radius: 10px;
  padding: 8px 32px 8px 12px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--text);
  box-shadow: var(--shadow-border);
  cursor: pointer;
  outline: none;
  transition: box-shadow 0.2s;
  min-width: 0;
  text-overflow: ellipsis;
}

.mic-select:focus { box-shadow: var(--shadow-glow); }

/* ── Recording playback preview ── */
.recording-playback {
  width: 100%;
  background: var(--bg-warm);
  border-radius: 10px;
  padding: var(--space-md);
  box-shadow: var(--shadow-border);
}

.playback-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.btn-preview {
  background: var(--accent-subtle);
  border: none;
  border-radius: 9999px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-preview:hover { background: var(--accent); color: white; }

.playback-info {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.hidden { display: none !important; }

/* ── Processing ── */
.processing-content {
  gap: var(--space-xl);
}

.processing-visual {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.morph-shape {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--accent-subtle), var(--accent));
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  animation: morph 4s ease-in-out infinite;
  opacity: 0.8;
}

@keyframes morph {
  0%   { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
  25%  { border-radius: 58% 42% 55% 45% / 56% 60% 40% 44%; }
  50%  { border-radius: 50% 50% 33% 67% / 55% 27% 73% 45%; }
  75%  { border-radius: 33% 67% 58% 42% / 63% 68% 32% 37%; }
  100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
}

.processing-title {
  font-size: 1.5rem;
}

.processing-sub {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.processing-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  text-align: left;
}

.step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-tertiary);
  transition: color 0.3s;
}

.step.active { color: var(--text); }
.step.done { color: var(--accent); }

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-raised);
  transition: background 0.3s, transform 0.3s;
  flex-shrink: 0;
}

.step-dot.active {
  background: var(--accent);
  transform: scale(1.2);
  animation: stepPulse 1.2s ease-in-out infinite;
}

.step.done .step-dot {
  background: var(--accent);
  transform: scale(1);
  animation: none;
}

@keyframes stepPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Reveal ── */
.reveal-prelude {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.reveal-ready {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.reveal-title {
  font-size: 2rem;
  margin-bottom: var(--space-md);
}

.affirmation-player {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.affirmation-card {
  background: var(--bg-warm);
  border-radius: 14px;
  padding: var(--space-lg);
  box-shadow: var(--shadow-border);
  text-align: left;
  opacity: 0.5;
  transition: all 0.4s;
  transform: scale(0.97);
}

.affirmation-card.active {
  opacity: 1;
  transform: scale(1);
  box-shadow: var(--shadow-glow);
}

.affirmation-card.playing {
  background: var(--accent-subtle);
}

.affirmation-text {
  font-family: var(--font-display);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--text);
  font-style: italic;
}

.audio-wave {
  height: 3px;
  margin-top: var(--space-md);
  background: var(--bg-raised);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.audio-wave::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.affirmation-card.playing .audio-wave::after {
  animation: waveProgress var(--audio-duration, 3s) linear forwards;
}

@keyframes waveProgress {
  to { width: 100%; }
}

.playback-controls {
  display: flex;
  justify-content: center;
  margin-top: var(--space-sm);
}

.btn-play {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 9999px;
  padding: 14px 32px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}

.btn-play:hover { background: var(--accent-hover); }
.btn-play:active { transform: scale(0.97); }
.btn-play:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-play svg { width: 16px; height: 16px; }

/* ── Reveal footer ── */
.reveal-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--bg-raised);
  width: 100%;
}

.reveal-cta {
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--text);
}

.email-capture {
  display: flex;
  gap: var(--space-sm);
  width: 100%;
  max-width: 360px;
}

.email-input {
  flex: 1;
  background: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: var(--shadow-border);
  outline: none;
  transition: box-shadow 0.2s;
}

.email-input:focus {
  box-shadow: var(--shadow-glow);
}

.email-input::placeholder {
  color: var(--text-tertiary);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  .screen-content { padding: var(--space-lg) var(--space-md); }
  .science-card { padding: var(--space-md); }
  .prompt-text { font-size: 1rem; padding: var(--space-md); }
}

/* ── Dark scheme for reveal screen ── */
[data-screen="reveal"] {
  background: var(--bg-dark);
}

[data-screen="reveal"] h2,
[data-screen="reveal"] .reveal-cta {
  color: var(--text-on-dark);
}

[data-screen="reveal"] .reveal-ready {
  color: var(--accent);
}

[data-screen="reveal"] .affirmation-card {
  background: var(--bg-dark-elevated);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
}

[data-screen="reveal"] .affirmation-card.active {
  box-shadow: 0 0 0 1px rgba(184, 135, 74, 0.3), 0 4px 16px rgba(184, 135, 74, 0.1);
}

[data-screen="reveal"] .affirmation-card.playing {
  background: rgba(184, 135, 74, 0.1);
}

[data-screen="reveal"] .affirmation-text {
  color: var(--text-on-dark);
}

[data-screen="reveal"] .audio-wave {
  background: rgba(255,255,255,0.08);
}

[data-screen="reveal"] .reveal-footer {
  border-top-color: rgba(255,255,255,0.08);
}

[data-screen="reveal"] .email-input {
  background: var(--bg-dark-elevated);
  color: var(--text-on-dark);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}

[data-screen="reveal"] .email-input::placeholder {
  color: var(--text-on-dark-secondary);
}

[data-screen="reveal"] .btn-text {
  color: var(--text-on-dark-secondary);
}

/* ── Processing screen bg ── */
[data-screen="processing"] {
  background: var(--bg-warm);
}
