/* ================================================
   Checklist Procedurale CAD — Styles
   Design system: shared-design-system.md
   ================================================ */

/* --- Design Tokens --- */
:root, [data-theme='light'] {
  --font-display: 'Chillax', 'Arial', sans-serif;
  --font-body: 'Nunito', 'Helvetica Neue', sans-serif;

  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Surfaces */
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-surface-2: #f0f4f8;
  --color-border: #d0d7e0;
  --color-divider: #e2e8f0;

  /* Text */
  --color-text: #1a2a3a;
  --color-text-muted: #5a6a7a;
  --color-text-faint: #94a3b8;

  /* Primary — Steel Blue */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-primary-dark: #1e40af;

  /* Success */
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-success-dark: #15803d;

  /* Error */
  --color-error: #dc2626;
  --color-error-light: #fee2e2;

  /* Warning */
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;

  /* Accent */
  --color-accent: #0d9488;
  --color-accent-light: #ccfbf1;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme='dark'] {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-2: #283548;
  --color-border: #334155;
  --color-divider: #1e293b;
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-text-faint: #64748b;
  --color-primary: #60a5fa;
  --color-primary-hover: #3b82f6;
  --color-primary-light: #1e3a5f;
  --color-primary-dark: #93c5fd;
  --color-success: #4ade80;
  --color-success-light: #14532d;
  --color-success-dark: #22c55e;
  --color-error: #f87171;
  --color-error-light: #450a0a;
  --color-warning: #fbbf24;
  --color-warning-light: #451a03;
  --color-accent: #2dd4bf;
  --color-accent-light: #134e4a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

/* --- Base Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}
body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color 0.3s ease, color 0.3s ease;
}
img, svg { display: block; max-width: 100%; height: auto; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a, button, [role='button'] {
  transition: color var(--transition-interactive), background var(--transition-interactive);
}
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
h1, h2, h3 { text-wrap: balance; line-height: 1.15; }
p, li { text-wrap: pretty; max-width: 72ch; }

/* --- Confetti Canvas --- */
#confetti-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1001;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: var(--space-4);
}
.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.header-icon {
  flex-shrink: 0;
  color: var(--color-primary);
  width: 36px;
  height: 36px;
}
.header-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}
.header-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}
.theme-toggle:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* --- Progress Area --- */
.progress-bar-area {
  padding: var(--space-3) var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.progress-dots {
  display: flex;
  gap: var(--space-2);
}
.progress-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  transition: background 0.3s ease, transform 0.3s ease;
}
.progress-dot.completed {
  background: var(--color-success);
  transform: scale(1.1);
}
.progress-dot.current {
  background: var(--color-primary);
  animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}
.timer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.timer svg {
  flex-shrink: 0;
  display: inline;
}
.progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Main Container --- */
.checklist-container {
  max-width: 700px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-20);
}
.checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* --- Step Card --- */
.step-card {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5);
  position: relative;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Timeline connector line */
.step-card:not(:last-child)::before {
  content: '';
  position: absolute;
  left: calc(var(--space-5) + 20px);
  top: calc(var(--space-5) + 44px);
  bottom: 0;
  width: 2px;
  background: var(--color-border);
  transition: background 0.4s ease;
}
.step-card.completed:not(:last-child)::before {
  background: var(--color-success);
}

/* Number circle */
.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  background: var(--color-surface-2);
  border: 2px solid var(--color-border);
  color: var(--color-text-faint);
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}
.step-card.current .step-number {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.15);
}
[data-theme='dark'] .step-card.current .step-number {
  box-shadow: 0 0 0 4px rgba(96,165,250,0.2);
}
.step-card.completed .step-number {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

/* Checkmark replaces number on complete */
.step-number .num { display: block; }
.step-number .check-icon { display: none; }
.step-card.completed .step-number .num { display: none; }
.step-card.completed .step-number .check-icon { display: block; }

/* Step Content */
.step-content {
  flex: 1;
  min-width: 0;
}
.step-card-inner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: all 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.step-card.current .step-card-inner {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1), var(--shadow-md);
}
[data-theme='dark'] .step-card.current .step-card-inner {
  box-shadow: 0 0 0 3px rgba(96,165,250,0.15), var(--shadow-md);
}
.step-card.locked .step-card-inner {
  opacity: 0.5;
}
.step-card.completed .step-card-inner {
  opacity: 0.75;
  border-color: var(--color-success);
}

/* Step header row */
.step-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.step-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  transition: all 0.3s ease;
}
.step-card.completed .step-icon {
  background: var(--color-success-light);
  color: var(--color-success);
}
.step-card.locked .step-icon {
  background: var(--color-surface-2);
  color: var(--color-text-faint);
}
.step-icon svg {
  width: 20px;
  height: 20px;
}
.step-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  flex: 1;
}
.lock-badge {
  display: none;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
}
.lock-badge svg {
  width: 14px;
  height: 14px;
}
.step-card.locked .lock-badge {
  display: inline-flex;
}

/* Step body */
.step-description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  line-height: 1.6;
}

/* Step actions row */
.step-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Complete button */
.btn-complete {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition-interactive);
}
.btn-complete:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-complete:active:not(:disabled) {
  transform: translateY(0);
}
.btn-complete:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.btn-complete svg {
  width: 18px;
  height: 18px;
}
.step-card.completed .btn-complete {
  background: var(--color-success);
  pointer-events: none;
}

/* Tip button */
.btn-tip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--color-warning-light);
  color: var(--color-warning);
  border: 1px solid transparent;
  min-height: 44px;
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.btn-tip:hover {
  border-color: var(--color-warning);
  background: var(--color-warning-light);
}
.btn-tip svg {
  width: 16px;
  height: 16px;
}

/* Tooltip */
.tip-tooltip {
  display: none;
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  color: var(--color-text);
  line-height: 1.5;
  animation: slide-down 0.25s ease;
}
.tip-tooltip.visible {
  display: block;
}

/* --- Animations --- */
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes unlock-step {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.step-card.just-unlocked {
  animation: unlock-step 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes celebrate-pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.step-card.just-completed .step-number {
  animation: celebrate-pop 0.4s ease;
}

/* --- Completion Overlay --- */
.completion-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(4px);
}
.completion-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.completion-card {
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-10) var(--space-8);
  text-align: center;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: translateY(24px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.completion-overlay.visible .completion-card {
  transform: translateY(0) scale(1);
}
.completion-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-full);
  background: var(--color-success-light);
  color: var(--color-success);
  margin: 0 auto var(--space-5);
}
.completion-icon svg {
  width: 48px;
  height: 48px;
}
.completion-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}
.completion-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  max-width: 100%;
}
.completion-time {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-8);
}
.completion-time svg {
  flex-shrink: 0;
  display: inline;
}
.completion-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-full);
  min-height: 48px;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: 2px solid var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 2px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-text-faint);
  transform: translateY(-1px);
}

/* --- Floating Restart --- */
.floating-restart {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  z-index: 50;
  min-height: 48px;
  transition: all var(--transition-interactive);
}
.floating-restart:hover {
  background: var(--color-error-light);
  color: var(--color-error);
  border-color: var(--color-error);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.floating-restart svg {
  flex-shrink: 0;
  display: inline;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .app-header {
    padding: var(--space-3) var(--space-4);
  }
  .header-title {
    font-size: var(--text-base);
  }
  .header-subtitle {
    display: none;
  }
  .progress-bar-area {
    padding: var(--space-2) var(--space-4);
  }
  .checklist-container {
    padding: var(--space-4) var(--space-3) var(--space-20);
  }
  .step-card {
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
  }
  .step-card:not(:last-child)::before {
    left: calc(var(--space-3) + 16px);
    top: calc(var(--space-3) + 36px);
  }
  .step-number {
    width: 32px;
    height: 32px;
    font-size: var(--text-xs);
  }
  .step-card-inner {
    padding: var(--space-4);
  }
  .step-icon {
    width: 32px;
    height: 32px;
  }
  .step-icon svg {
    width: 16px;
    height: 16px;
  }
  .completion-card {
    padding: var(--space-6) var(--space-4);
  }
  .floating-restart span {
    display: none;
  }
  .floating-restart {
    padding: var(--space-3);
    border-radius: var(--radius-full);
  }
}
