/* ============================================================
   Literati Voice Recording — Design System Tokens + Styles
   ============================================================ */

:root {
  --primary: #58cdc9;
  --primary-dark: #3aaba7;
  --primary-light: #e8f8f7;
  --accent-warm: #ee6f51;
  --accent-gold: #ffbf70;
  --accent-gold-light: #fff8ed;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --ink: #232323;
  --text-muted: #8a8785;
  --text-light: #b5b2ae;
  --border: #e5e2dd;
  --error: #ee6f51;

  --serif: 'Instrument Serif', 'Hoefler Text', Georgia, serif;
  --sans: 'Plus Jakarta Sans', 'Avenir', system-ui, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
}

/* ---- Reset + Base ---- */

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */

#app {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  min-height: 100vh;
}

/* ---- Step Indicator ---- */

.step-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--border);
  transition: all 250ms ease-out;
}

.step-dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

.step-dot.completed {
  background: var(--primary-dark);
}

/* ---- Step Container ---- */

.step {
  animation: slideIn 250ms ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- Card ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

/* ---- Typography ---- */

h1 {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 400;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: 12px;
}

h2 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 16px;
}

.subhead {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.6;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 28px;
  cursor: pointer;
  transition: all 150ms ease-out;
  width: 100%;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: #2e9490;
}

.btn-secondary {
  background: transparent;
  color: var(--primary-dark);
  border: 1px solid var(--border);
}

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

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn-row .btn {
  flex: 1;
}

.submit-hint {
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-warm);
  margin-top: 12px;
}

/* ---- Record Button ---- */

.record-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 32px 0;
}

.record-btn {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(88, 205, 201, 0.3);
  transition: all 150ms ease-out;
}

.record-btn:hover {
  transform: scale(1.05);
}

.record-btn.recording {
  background: var(--accent-warm);
  animation: pulse 1s ease-in-out infinite;
}

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

.record-btn svg {
  width: 32px;
  height: 32px;
  fill: white;
}

/* ---- Timer ---- */

.timer {
  font-family: var(--serif);
  font-size: 32px;
  color: var(--ink);
  margin-top: 16px;
  min-height: 40px;
}

.timer-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- Reading Passage ---- */

.passage {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}

/* ---- Liveness Code ---- */

.liveness-code {
  display: inline-block;
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

/* ---- Audio Playback ---- */

.audio-playback {
  width: 100%;
  margin: 16px 0;
  opacity: 0;
  animation: fadeIn 400ms ease-out forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* ---- Consent ---- */

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.consent-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--primary-dark);
}

/* ---- Loading / Skeleton ---- */

.loading {
  text-align: center;
  padding: 48px 0;
}

.loading-text {
  font-size: 18px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.skeleton-bar {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 24px auto;
  max-width: 200px;
}

.skeleton-bar::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

@keyframes skeletonPulse {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---- Payment ---- */

.price-tag {
  font-family: var(--serif);
  font-size: 48px;
  color: var(--accent-gold);
  text-align: center;
  margin: 24px 0 8px;
}

.price-desc {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px;
  font-family: var(--sans);
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 150ms;
}

.form-group input:focus {
  border-color: var(--primary);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* ---- Book Picker ---- */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.book-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all 150ms ease-out;
  text-align: center;
}

.book-card:hover {
  border-color: var(--primary);
}

.book-card.selected {
  border-color: var(--primary-dark);
  background: var(--primary-light);
}

.book-cover {
  width: 80px;
  height: 110px;
  margin: 0 auto 12px;
  background: var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 32px;
  color: var(--text-muted);
}

.book-card .title {
  font-family: var(--serif);
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.3;
}

.book-card .author {
  font-size: 12px;
  color: var(--text-muted);
}

.book-card .duration {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

.book-card.unavailable {
  opacity: 0.45;
  cursor: default;
}

.book-card.unavailable:hover {
  border-color: var(--border);
}

/* ---- Progress Bar (Cosmetic) ---- */

.progress-wrap {
  margin: 32px 0;
}

.progress-bar {
  height: 12px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 500ms ease-out;
}

.progress-label {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ---- Done / Success ---- */

.done-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: var(--primary-light);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.done-icon svg {
  width: 40px;
  height: 40px;
  stroke: var(--primary-dark);
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: transform 250ms ease-out;
  z-index: 100;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--error);
}

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

@media (max-width: 480px) {
  h1 { font-size: 32px; }
  .price-tag { font-size: 40px; }
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}
