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

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-rank-1: #2563eb;
  --color-rank-2: #7c3aed;
  --color-rank-3: #c026d3;
  --color-rank-4: #64748b;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --transition: 200ms ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Page Transitions ────────────────────────────── */
.page {
  animation: fadeIn 300ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Typography ──────────────────────────────────── */
h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 16px;
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 1rem;
  margin-bottom: 24px;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

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

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg);
}

.btn-link {
  background: none;
  color: var(--color-primary);
  padding: 8px 0;
  font-weight: 500;
}

.btn-link:hover {
  text-decoration: underline;
}

/* ── Progress Bar ────────────────────────────────── */
.progress-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
}

.progress-bar .step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  transition: background var(--transition);
}

.progress-bar .step.active {
  background: var(--color-primary);
}

.progress-bar .step.done {
  background: var(--color-success);
}

.progress-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

/* ── Card ────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ── Ranking Widget ──────────────────────────────── */
.question-block {
  margin-bottom: 32px;
}

.question-block .question-prompt {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 12px;
}

.ranking-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform 100ms ease;
  user-select: none;
}

.rank-card:hover {
  border-color: var(--color-primary);
  background: #f0f5ff;
}

.rank-card:active {
  transform: scale(0.98);
}

.rank-card.ranked {
  border-color: var(--color-primary);
  background: #eff6ff;
}

.rank-card.ranked[data-assigned-rank="1"] { border-color: var(--color-rank-1); }
.rank-card.ranked[data-assigned-rank="2"] { border-color: var(--color-rank-2); }
.rank-card.ranked[data-assigned-rank="3"] { border-color: var(--color-rank-3); }
.rank-card.ranked[data-assigned-rank="4"] { border-color: var(--color-rank-4); }

.rank-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--color-border);
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}

.rank-card.ranked .rank-badge {
  color: #fff;
}

.rank-card.ranked[data-assigned-rank="1"] .rank-badge { background: var(--color-rank-1); }
.rank-card.ranked[data-assigned-rank="2"] .rank-badge { background: var(--color-rank-2); }
.rank-card.ranked[data-assigned-rank="3"] .rank-badge { background: var(--color-rank-3); }
.rank-card.ranked[data-assigned-rank="4"] .rank-badge { background: var(--color-rank-4); }

.rank-card .item-text {
  font-size: 0.95rem;
  line-height: 1.4;
}

/* ── Report ──────────────────────────────────────── */
.report-header {
  text-align: center;
  margin-bottom: 32px;
}

.report-section {
  animation: fadeIn 300ms ease;
}

/* Rankings page */
.dimension-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 32px;
}

.dimension-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.dimension-badge-wrap {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.dimension-badge-wrap svg {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.dimension-info {
  flex: 1;
}

.dimension-name {
  font-weight: 600;
  font-size: 1rem;
}

.dimension-rank-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.dimension-bar {
  width: 80px;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.dimension-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 600ms ease;
}

/* Report navigation */
.report-nav {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.report-dots {
  display: flex;
  gap: 8px;
}

.report-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background var(--transition), border-color var(--transition);
}

.report-dot.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.report-dot:hover:not(.active) {
  border-color: var(--color-primary);
}

.report-nav-btns {
  display: flex;
  gap: 12px;
}

/* All Dimensions page */
.all-dimensions-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.all-dim-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.all-dim-badge {
  width: 56px;
  flex-shrink: 0;
}

.all-dim-badge svg {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.all-dim-content {
  flex: 1;
}

.all-dim-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.all-dim-summary {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Deep dive pages */
.deep-dive-badge {
  width: 80px;
  margin: 0 auto 16px;
}

.deep-dive-badge svg {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.deep-dive-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.deep-dive-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.deep-dive-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.deep-dive-section p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
}

.deep-dive-section.blind-spots {
  background: #fef9ee;
  border-color: #fde68a;
}

.deep-dive-section.blind-spots h2 {
  color: #92400e;
}

/* ── Email Capture ───────────────────────────────── */
.email-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.email-form input[type="email"] {
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
}

.email-form input[type="email"]:focus {
  border-color: var(--color-primary);
}

/* ── Spinner ─────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 0;
  color: var(--color-text-muted);
}

/* ── Error ───────────────────────────────────────── */
.error-message {
  padding: 12px 16px;
  background: #fef2f2;
  color: var(--color-error);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ── Welcome ─────────────────────────────────────── */
.welcome-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 48px;
}

.welcome-page h1 {
  margin-bottom: 12px;
}

.welcome-page .subtitle {
  max-width: 400px;
  margin-bottom: 32px;
}

.welcome-instructions {
  text-align: left;
  width: 100%;
  margin-bottom: 32px;
}

.welcome-instructions h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.welcome-instructions ol {
  padding-left: 20px;
}

.welcome-instructions li {
  margin-bottom: 8px;
  color: var(--color-text-muted);
}

/* ── Story intro ─────────────────────────────────── */
.story-intro {
  text-align: center;
  padding: 32px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.story-intro .story-number {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.story-intro p {
  color: var(--color-text-muted);
  max-width: 480px;
  margin: 0 auto;
}

/* ── Utility ─────────────────────────────────────── */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.text-center { text-align: center; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 480px) {
  #app {
    padding: 16px 12px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .rank-card {
    padding: 12px 14px;
  }

  .dimension-bar {
    width: 60px;
  }
}
