/* Drawing Practice — Standalone App Styles */
/* Base: ported from tmp/drawing-prototype.html */

:root {
  --purple: #8E44AD;
  --purple-light: #F4ECF7;
  --purple-dark: #6C3483;
  --green: #27AE60;
  --orange: #E67E22;
  --red: #E74C3C;
  --dk: #1a1a2e;
  --md: #6B7280;
  --lt: #F9FAFB;
  --card-radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #F3F4F6;
  color: var(--dk);
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
.session-header {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: white;
  padding: 20px 20px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.session-header .lesson-label {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  opacity: 0.7;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.session-header h1 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.session-header .target-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  opacity: 0.85;
}

/* Progress bar */
.progress-track {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  margin-top: -12px;
  position: relative;
  z-index: 11;
}
.progress-dot {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.3);
  transition: background 0.3s;
}
.progress-dot.done { background: var(--green); }
.progress-dot.active { background: white; }

/* Step card */
.step-container {
  padding: 16px 20px;
}

.step-card {
  background: white;
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  display: none;
}
.step-card.active { display: block; }

.step-svg-area {
  background: #FAFAFA;
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid #F0F0F0;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-svg-area svg {
  max-width: 100%;
  height: auto;
}

.step-content {
  padding: 20px;
}
.step-number {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--purple);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.step-instruction {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
}
.step-cue {
  font-size: 0.88rem;
  color: var(--md);
  line-height: 1.5;
  padding: 10px 14px;
  background: var(--purple-light);
  border-radius: 10px;
  border-left: 3px solid var(--purple);
  margin-bottom: 12px;
}

/* Expand coaching */
.coaching-toggle {
  font-size: 0.8rem;
  color: var(--purple);
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.coaching-detail {
  display: none;
  font-size: 0.85rem;
  color: var(--md);
  line-height: 1.6;
  padding: 12px 14px;
  background: var(--lt);
  border-radius: 10px;
  margin-top: 8px;
}
.coaching-detail.open { display: block; }

/* Regression / Progression pills */
.options-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.option-pill {
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1.5px solid;
  cursor: pointer;
  font-weight: 600;
  background: white;
}
.option-pill.regression {
  border-color: var(--green);
  color: var(--green);
}
.option-pill.progression {
  border-color: var(--orange);
  color: var(--orange);
}
.option-pill.alternative {
  border-color: var(--purple);
  color: var(--purple);
}

/* Navigation */
.nav-bar {
  padding: 16px 20px 32px;
  display: flex;
  gap: 12px;
}
.nav-btn {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn.secondary {
  background: var(--lt);
  color: var(--md);
}
.nav-btn.primary {
  background: var(--purple);
  color: white;
}
.nav-btn:active {
  transform: scale(0.97);
}

/* Photo capture screen */
.capture-screen {
  display: none;
  padding: 20px;
  text-align: center;
}
.capture-screen.active { display: block; }
.capture-area {
  background: white;
  border-radius: var(--card-radius);
  padding: 40px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}
.capture-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}
.capture-area h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.capture-area p {
  font-size: 0.9rem;
  color: var(--md);
  line-height: 1.5;
}
.capture-btn {
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--purple);
  color: white;
  margin-bottom: 12px;
}
.skip-btn {
  background: none;
  border: none;
  color: var(--md);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 8px;
}

/* AI Feedback screen */
.feedback-screen {
  display: none;
  padding: 20px;
}
.feedback-screen.active { display: block; }
.feedback-card {
  background: white;
  border-radius: var(--card-radius);
  padding: 24px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}
.feedback-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--purple);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.feedback-item {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: flex-start;
}
.feedback-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.feedback-icon.good { background: #E8F8F0; color: var(--green); }
.feedback-icon.fix { background: #FEF3E2; color: var(--orange); }
.feedback-icon.try { background: var(--purple-light); color: var(--purple); }
.feedback-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--dk);
}
.feedback-text strong {
  font-weight: 700;
}

.done-btn {
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--green);
  color: white;
}

/* Toast for option pills */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dk);
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; }

/* Phase label */
.phase-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.2);
  margin-bottom: 2px;
}

/* Technique names in session header */
.technique-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  opacity: 0.9;
}
.technique-tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
}

/* === Lesson Selection View === */
.lesson-list { padding: 16px 20px; }
.lesson-card {
  background: white; border-radius: var(--card-radius);
  padding: 16px 20px; margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer; display: flex; align-items: center; gap: 14px;
  transition: transform 0.15s;
}
.lesson-card:active { transform: scale(0.98); }
.lesson-card__num {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--purple-light); color: var(--purple);
  font-weight: 800; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lesson-card.completed .lesson-card__num { background: var(--green); color: white; }
.lesson-card__info { flex: 1; }
.lesson-card__title { font-size: 0.95rem; font-weight: 700; margin-bottom: 2px; }
.lesson-card__meta { font-size: 0.78rem; color: var(--md); }
.lesson-card__arrow { color: var(--md); font-size: 1.2rem; }

/* === Test Lessons Section === */
.test-lessons-header {
  padding: 20px 0 8px;
  border-top: 2px dashed #D5B8E8;
  margin-top: 8px;
}
.test-lessons-header h2 {
  font-size: 0.95rem; font-weight: 700; color: var(--purple);
  margin-bottom: 4px;
}
.test-lessons-header p {
  font-size: 0.78rem; color: var(--md);
}
.test-lesson-card {
  border-left: 3px solid var(--orange);
}
.test-num {
  background: #FFF3E6 !important;
  color: var(--orange) !important;
  font-weight: 800;
}
.content-source-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #FFF3E6;
  color: var(--orange);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* === Technique mastery dots on lesson cards === */
.lesson-card__techniques {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.technique-dot {
  font-size: 0.65rem; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  background: #E5E7EB; color: var(--md); text-transform: capitalize;
}
.technique-dot.learning { background: #FEF3C7; color: #92400E; }
.technique-dot.comfortable { background: #D1FAE5; color: #065F46; }

/* === Mode Tabs === */
.mode-tabs { display: flex; gap: 0; padding: 12px 20px 0; }
.mode-tab {
  flex: 1; padding: 10px; text-align: center; font-size: 0.85rem;
  font-weight: 700; border: none; background: var(--lt); color: var(--md);
  cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s;
}
.mode-tab:first-child { border-radius: 10px 0 0 0; }
.mode-tab:last-child { border-radius: 0 10px 0 0; }
.mode-tab.active { background: white; color: var(--purple); border-bottom-color: var(--purple); }

/* === Free Draw Upload === */
.free-draw-upload { padding: 20px; text-align: center; }
.upload-area {
  background: white; border-radius: var(--card-radius); padding: 40px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); border: 2px dashed var(--purple-light);
  cursor: pointer; transition: border-color 0.2s;
}
.upload-area:active { border-color: var(--purple); }
.upload-icon { font-size: 3rem; margin-bottom: 12px; color: var(--purple); opacity: 0.6; }
.upload-area h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.upload-area p { font-size: 0.85rem; color: var(--md); }

/* === Loading Spinner === */
.generating-steps { padding: 40px 20px; text-align: center; }
.generating-steps__spinner {
  width: 40px; height: 40px; border: 4px solid var(--purple-light);
  border-top-color: var(--purple); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.generating-steps__text { font-size: 0.95rem; color: var(--md); font-weight: 600; }
.generating-steps__subtext { font-size: 0.8rem; color: var(--md); margin-top: 8px; }
.generating-steps__cancel {
  margin-top: 20px; padding: 8px 24px; border: 1px solid var(--md);
  border-radius: 8px; background: transparent; color: var(--md);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.generating-steps__cancel:active { background: #F0F0F0; }

/* === Technique Rating === */
.technique-rating { padding: 20px; }
.technique-rating__title { font-size: 1rem; font-weight: 800; margin-bottom: 16px; text-align: center; }
.technique-rating__row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid #F0F0F0;
}
.technique-rating__name { font-size: 0.9rem; font-weight: 600; text-transform: capitalize; }
.technique-rating__stars { display: flex; gap: 4px; }
.technique-rating__star {
  font-size: 1.4rem; color: #D0D0D0; cursor: pointer;
  border: none; background: none; padding: 2px;
}
.technique-rating__star--filled { color: var(--purple); }

/* === Three-Layer SVG System === */
.step-svg-layers {
  position: relative;
  width: 100%;
  min-height: 260px;
  /* Aspect ratio box for consistent layout */
  aspect-ratio: 1 / 1;
  max-width: 300px;
  margin: 0 auto;
}
.step-svg-photo,
.step-svg-construction,
.step-svg-lineart {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
/* Layer 1: Photo reference — faded background */
.step-svg-photo {
  z-index: 1;
  opacity: 0.25;
}
.step-photo-img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
/* Layer 2: Construction SVG — guidelines, circles (faded when lineart present) */
.step-svg-construction {
  z-index: 2;
  opacity: 0.5;
}
.step-svg-construction.solo {
  opacity: 1;
}
.step-svg-construction svg {
  width: 100%; height: auto;
}
/* Layer 3: Line art SVG — bold detailed strokes */
.step-svg-lineart {
  z-index: 3;
}
.step-svg-lineart svg {
  width: 100%; height: auto;
}
/* Raster lineart (PNG/WebP) — test lessons with curated/hand-drawn content */
.step-lineart-img {
  width: 100%; height: 100%;
  object-fit: contain;
}

/* Tutorial link — test lesson A (embedded external tutorial) */
.step-tutorial-link {
  padding: 8px 16px;
  background: var(--purple-light);
  border-bottom: 1px solid #E8D5F0;
}
.tutorial-btn {
  display: inline-block;
  color: var(--purple);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.tutorial-btn:active {
  background: rgba(142, 68, 173, 0.12);
}

/* === SVG States === */
.step-svg-placeholder {
  padding: 20px; border: 2px dashed #D5B8E8; border-radius: 12px;
  color: var(--md); font-size: 0.85rem; line-height: 1.5; text-align: center;
  min-height: 200px; display: flex; align-items: center; justify-content: center;
}
.step-svg-loading { color: var(--md); font-size: 0.85rem; }
.step-instruction-detail { font-size: 0.92rem; color: var(--md); line-height: 1.5; margin-bottom: 10px; }

/* === Error/Retry === */
.error-card {
  background: white; border-radius: var(--card-radius); padding: 24px 20px;
  margin: 20px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.error-card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.error-card p { font-size: 0.88rem; color: var(--md); margin-bottom: 16px; }
.retry-btn {
  padding: 12px 24px; border-radius: 10px; border: none; background: var(--purple);
  color: white; font-weight: 700; font-size: 0.9rem; cursor: pointer;
}

/* === App Header === */
.app-header {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: white; padding: 20px;
}
.app-header h1 { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.app-header .progress-summary { font-size: 0.85rem; opacity: 0.8; }

/* === Active pill state === */
.option-pill.active { color: white !important; }
.option-pill.regression.active { background: var(--green); }
.option-pill.progression.active { background: var(--orange); }

/* === Back Home Button === */
.back-home-btn {
  background: none; border: none; color: white; font-size: 0.85rem;
  opacity: 0.85; cursor: pointer; padding: 0; margin-bottom: 6px;
  display: block;
}
.back-home-btn:active { opacity: 1; }

/* === Session Complete Screen === */
.session-complete { padding: 20px; text-align: center; }
.session-complete__header {
  background: linear-gradient(135deg, var(--green), #1E8449);
  color: white; padding: 32px 20px; border-radius: var(--card-radius);
  margin-bottom: 20px;
}
.session-complete__icon {
  width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; margin: 0 auto 12px;
}
.session-complete__header h2 { font-size: 1.3rem; font-weight: 800; }
.session-complete__stats {
  display: flex; gap: 12px; margin-bottom: 20px;
}
.session-complete__stat {
  flex: 1; background: white; border-radius: var(--card-radius);
  padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.session-complete__stat-value {
  font-size: 1.8rem; font-weight: 800; color: var(--purple);
}
.session-complete__stat-label {
  font-size: 0.75rem; color: var(--md); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; margin-top: 2px;
}
.session-complete__section {
  background: white; border-radius: var(--card-radius); padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-bottom: 12px; text-align: left;
}
.session-complete__section-title {
  font-size: 0.75rem; font-weight: 700; color: var(--md);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px;
}
.session-complete__technique {
  display: inline-block; font-size: 0.8rem; font-weight: 600;
  padding: 5px 12px; border-radius: 16px; margin: 0 6px 6px 0;
  background: var(--purple-light); color: var(--purple); text-transform: capitalize;
}
.session-complete__next {
  background: white; border-radius: var(--card-radius); padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-bottom: 20px; text-align: left;
}
.session-complete__next-card {
  display: flex; align-items: center; gap: 12px;
}
.session-complete__next-num {
  width: 36px; height: 36px; border-radius: 50%; background: var(--purple-light);
  color: var(--purple); font-weight: 800; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.session-complete__next-title { font-size: 0.95rem; font-weight: 700; }
.session-complete__actions {
  display: flex; flex-direction: column; gap: 10px; margin-top: 8px;
}

/* === Independent Timer === */
.independent-timer-ring {
  position: relative; width: 160px; height: 160px; margin: 16px auto;
}
.independent-timer-ring svg { position: absolute; top: 0; left: 0; }
.independent-timer {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--purple);
}
.independent-timer--warning { color: var(--red); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
