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

:root {
  --bg: #0F172A;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --border: rgba(51, 65, 85, 0.5);
  --radius: 1rem;
  --max-w: 32rem;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

ul { list-style: none; }

/* ─── Animations ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-300px); }
  to { opacity: 1; transform: translateX(0); }
}

.fade-up {
  animation: fadeUp 0.6s ease forwards;
}

.fade-up-delay {
  animation: fadeUp 0.6s ease forwards;
  animation-delay: 0.3s;
  opacity: 0;
}

.slide-in-right {
  animation: slideInRight 0.3s ease forwards;
}

.slide-in-left {
  animation: slideInLeft 0.3s ease forwards;
}

/* Staggered fade-up for result sections */
.result-section {
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.result-section:nth-child(1) { animation-delay: 0s; }
.result-section:nth-child(2) { animation-delay: 0.15s; }
.result-section:nth-child(3) { animation-delay: 0.3s; }
.result-section:nth-child(4) { animation-delay: 0.45s; }
.result-section:nth-child(5) { animation-delay: 0.6s; }
.result-section:nth-child(6) { animation-delay: 0.75s; }
.result-section:nth-child(7) { animation-delay: 0.9s; }
.result-section:nth-child(8) { animation-delay: 1.05s; }
.result-section:nth-child(9) { animation-delay: 1.2s; }
.result-section:nth-child(10) { animation-delay: 1.35s; }
.result-section:nth-child(11) { animation-delay: 1.5s; }
.result-section:nth-child(12) { animation-delay: 1.65s; }

/* ─── Start Page ─── */
.start-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
  text-align: center;
}

.start-emoji {
  font-size: 3.75rem;
  margin-bottom: 1.5rem;
}

.start-title {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.4;
}

.start-desc {
  color: var(--text-muted);
  font-size: 1.125rem;
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

.start-btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 1.125rem;
  padding: 1rem 2.5rem;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.start-btn:hover {
  background: var(--accent-hover);
}

.start-sub {
  color: var(--text-dim);
  font-size: 0.875rem;
  margin-top: 1rem;
}

/* ─── Test Page ─── */
.test-container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.progress-area {
  padding: 2rem 1.5rem 1.5rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.progress-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.progress-track {
  width: 100%;
  height: 0.5rem;
  background: #334155;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 9999px;
  transition: width 0.5s ease;
}

.question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.question-card {
  width: 100%;
  padding: 0 1.5rem;
}

.question-number {
  font-size: 0.875rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 2rem;
  line-height: 1.6;
  white-space: pre-line;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-line;
}

.option-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: scale(1.02);
}

.option-btn:active {
  transform: scale(0.98);
}

.nav-area {
  padding: 1.5rem;
}

.back-btn {
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: color 0.2s;
}

.back-btn:hover {
  color: var(--text);
}

/* ─── Result Page ─── */
.result-container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* Header */
.result-header {
  text-align: center;
  margin-bottom: 2rem;
}

.result-header .label {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.result-header .emoji {
  font-size: 3.75rem;
  margin-bottom: 1rem;
}

.result-header .type-code {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  margin-bottom: 0.5rem;
}

.result-header .nickname {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.result-header .description {
  color: #cbd5e1;
  line-height: 1.6;
}

/* Cards */
.card {
  background: rgba(30, 41, 59, 0.8);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.card-title {
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card p, .card li {
  color: #cbd5e1;
  line-height: 1.6;
  font-size: 0.9375rem;
}

.card.highlight {
  border-color: rgba(99, 102, 241, 0.3);
}

.card .italic {
  font-style: italic;
}

/* Dimension analysis */
.dimension-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.dimension-item:last-child {
  margin-bottom: 0;
}

.dimension-badge {
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.dimension-info {
  min-width: 0;
}

.dimension-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

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

.dimension-meta .sep {
  color: var(--text-dim);
}

.dimension-meta .name {
  color: #e2e8f0;
  font-weight: 500;
}

.dimension-desc {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

/* Traits list */
.trait-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.trait-dot {
  color: var(--accent);
  margin-top: 0.125rem;
}

/* Strengths & Weaknesses grid */
.sw-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.sw-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.sw-card li {
  font-size: 0.875rem;
  margin-bottom: 0.375rem;
}

/* Match */
.match-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.match-item:last-child {
  margin-bottom: 0;
}

.match-icon {
  font-size: 1.125rem;
}

.match-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.match-name {
  font-weight: 600;
}

.match-type {
  color: var(--accent);
}

.match-type.worst {
  color: var(--text-dim);
}

/* ─── Viral Section (inside card) ─── */
.viral-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.viral-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: #cbd5e1;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.viral-emoji {
  font-size: 1.125rem;
  flex-shrink: 0;
}

.viral-copy-btn {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.875rem;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.9375rem;
  border-radius: 0.75rem;
  transition: background 0.2s;
}

.viral-copy-btn:hover {
  background: var(--accent-hover);
}

.retest-link {
  display: block;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.875rem;
  margin-top: 0.5rem;
  border-radius: var(--radius);
  transition: color 0.2s;
}

.retest-link:hover {
  color: var(--text);
}

/* ─── 404 ─── */
.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
  text-align: center;
}

.not-found .emoji { font-size: 3.75rem; margin-bottom: 1.5rem; }
.not-found h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.75rem; }
.not-found p { color: var(--text-muted); margin-bottom: 2rem; }
.not-found a {
  background: var(--accent);
  color: white;
  font-weight: 600;
  padding: 0.75rem 2rem;
  border-radius: 0.75rem;
  transition: background 0.2s;
}
.not-found a:hover { background: var(--accent-hover); }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #334155;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ─── Site Header ─── */
.site-header {
  width: 100%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .header-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
}

.site-header .logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-header .logo span {
  font-size: 1.25rem;
}

.site-header nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.site-header nav a {
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.site-header nav a:hover {
  color: var(--text);
}

.site-header .nav-cta {
  background: var(--accent);
  color: white !important;
  padding: 0.375rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: background 0.2s;
}

.site-header .nav-cta:hover {
  background: var(--accent-hover);
}

/* Mobile nav */
.mobile-menu-btn {
  display: none;
  font-size: 1.5rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .site-header nav {
    display: none;
  }
  .site-header nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    padding: 1rem 1.5rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .mobile-menu-btn {
    display: block;
  }
}

/* ─── Site Footer ─── */
.site-footer {
  width: 100%;
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  margin-top: 3rem;
}

.site-footer .footer-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.site-footer .footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.site-footer .footer-links a {
  font-size: 0.8125rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.site-footer .footer-links a:hover {
  color: var(--text);
}

.site-footer .footer-copy {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.site-footer .footer-disclaimer {
  font-size: 0.6875rem;
  color: var(--text-dim);
  max-width: 40rem;
  line-height: 1.6;
}

/* ─── Page Layout ─── */
.page-container {
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.page-container h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.page-container h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.page-container h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.page-container p {
  color: #cbd5e1;
  line-height: 1.8;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.page-container ul, .page-container ol {
  color: #cbd5e1;
  line-height: 1.8;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  list-style: disc;
}

.page-container ol {
  list-style: decimal;
}

.page-container li {
  margin-bottom: 0.375rem;
}

.page-breadcrumb {
  font-size: 0.8125rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.page-breadcrumb a {
  color: var(--text-muted);
  transition: color 0.2s;
}

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

/* ─── Blog Cards ─── */
.blog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .blog-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.blog-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.blog-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.blog-card .blog-tag {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.blog-card h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  margin-top: 0;
  line-height: 1.5;
}

.blog-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}

.blog-card .read-more {
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 0.75rem;
}

/* ─── MBTI Type Grid ─── */
.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1.5rem 0;
}

@media (min-width: 640px) {
  .type-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.type-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
  transition: all 0.2s;
}

.type-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.type-card .type-emoji {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.type-card .type-code {
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 0.125rem;
}

.type-card .type-name {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ─── Static Result Page ─── */
.static-result .cta-section {
  text-align: center;
  margin: 2rem 0;
  padding: 2rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.static-result .cta-section p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.static-result .cta-btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-weight: 600;
  padding: 0.875rem 2rem;
  border-radius: 0.75rem;
  transition: background 0.2s;
}

.static-result .cta-btn:hover {
  background: var(--accent-hover);
}

/* ─── All Types Link ─── */
.all-types-section {
  margin-top: 2rem;
}

.all-types-section h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ─── Article Meta & Summary ─── */
.article-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.article-summary {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  border-radius: 0 0.5rem 0.5rem 0;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.article-summary p {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem !important;
}

.article-summary ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0 !important;
}

.article-summary ul li {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

/* ─── Responsive ─── */
@media (min-width: 640px) {
  .start-title {
    font-size: 2.25rem;
  }
  .question-text {
    font-size: 1.5rem;
  }
}
