/* ================================
   SELF-REFLECTION APP - DESIGN SYSTEM
   Premium, Serious, Intellectual Aesthetic
   ================================ */

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

/* === Design Tokens === */
:root {
  /* Colors - Deep, Serious Palette */
  --bg-primary: hsl(220, 15%, 8%);
  --bg-secondary: hsl(220, 12%, 12%);
  --bg-tertiary: hsl(220, 10%, 16%);
  --bg-elevated: hsl(220, 10%, 20%);

  --text-primary: hsl(45, 30%, 94%);
  --text-secondary: hsl(45, 15%, 70%);
  --text-muted: hsl(45, 10%, 50%);

  --accent: hsl(38, 60%, 55%);
  --accent-hover: hsl(38, 65%, 62%);
  --accent-muted: hsl(38, 40%, 35%);

  --success: hsl(160, 50%, 45%);
  --warning: hsl(35, 90%, 55%);
  --error: hsl(0, 60%, 55%);

  --border-subtle: hsl(220, 10%, 22%);
  --border-medium: hsl(220, 10%, 28%);

  /* Typography */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Literata', 'Georgia', 'Times New Roman', serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* Spacing (8px grid) */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 2.5rem;
  --space-6: 3rem;
  --space-8: 4rem;
  --space-10: 5rem;
  --space-12: 6rem;

  /* Borders & Shadows */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px hsla(0, 0%, 0%, 0.3);
  --shadow-md: 0 4px 12px hsla(0, 0%, 0%, 0.4);
  --shadow-lg: 0 8px 24px hsla(0, 0%, 0%, 0.5);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --max-width: 1100px;
  --max-width-wide: 1400px;
}

/* === Base Styles === */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Typography === */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 500;
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

h1 {
  font-size: var(--text-4xl);
}

h2 {
  font-size: var(--text-3xl);
}

h3 {
  font-size: var(--text-2xl);
}

h4 {
  font-size: var(--text-xl);
}

p {
  margin-bottom: var(--space-2);
}

.text-serif {
  font-family: var(--font-serif);
}

.text-muted {
  color: var(--text-muted);
}

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

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

/* === Links === */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--accent-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-lg);
}

/* === Form Elements === */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px hsla(38, 60%, 55%, 0.15);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}

.form-hint {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* === Cards === */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.card-elevated {
  background: var(--bg-tertiary);
  box-shadow: var(--shadow-md);
}

/* === Progress Bar === */
.progress-container {
  margin-bottom: var(--space-4);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-muted), var(--accent));
  border-radius: 3px;
  transition: width var(--transition-slow);
}

/* === Layout Utils === */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-wide {
  max-width: var(--max-width-wide);
}

.section {
  padding: var(--space-8) 0;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: var(--space-1);
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

.mt-2 {
  margin-top: var(--space-2);
}

.mt-4 {
  margin-top: var(--space-4);
}

.mt-6 {
  margin-top: var(--space-6);
}

.mb-2 {
  margin-bottom: var(--space-2);
}

.mb-4 {
  margin-bottom: var(--space-4);
}

.mb-6 {
  margin-bottom: var(--space-6);
}

/* === Animations === */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade-in {
  animation: fadeIn var(--transition-slow) ease forwards;
}

.animate-slide-in {
  animation: slideIn var(--transition-slow) ease forwards;
}

/* Staggered animation delays */
.delay-1 {
  animation-delay: 100ms;
}

.delay-2 {
  animation-delay: 200ms;
}

.delay-3 {
  animation-delay: 300ms;
}

.delay-4 {
  animation-delay: 400ms;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: hsla(0, 0%, 0%, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  max-width: 500px;
  width: 90%;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}

/* === Disclaimer Box === */
.disclaimer {
  background: var(--bg-tertiary);
  border-left: 3px solid var(--warning);
  padding: var(--space-3);
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* === Case Display === */
.case-text {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  line-height: 1.9;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.case-decision-point {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  font-weight: 500;
  color: var(--accent);
}

.case-meta {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.case-tag {
  padding: 2px 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === Synthesis Section === */
.synthesis-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.synthesis-section:last-child {
  border-bottom: none;
}

.synthesis-title {
  font-size: var(--text-lg);
  color: var(--accent);
  margin-bottom: var(--space-2);
}

.evidence-citation {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
}

.uncertainty-marker {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* === Responsive === */
@media (max-width: 640px) {
  :root {
    --text-4xl: 2rem;
    --text-3xl: 1.75rem;
  }

  .container {
    padding: 0 var(--space-3);
  }

  .section {
    padding: var(--space-6) 0;
  }

  .btn-lg {
    width: 100%;
  }
}