/* styles.css - MBTI 人格测试 · 极简心理风 · 移动端优先 */

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

:root {
  --bg: #FAFAFA;
  --card-bg: #FFFFFF;
  --text: #2C3E50;
  --text-secondary: #7F8C8D;
  --text-light: #BDC3C7;
  --border: #ECEFF1;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --primary: #4A90D9;
  --primary-light: #E8F0FE;
  --primary-dark: #3A7BC8;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow-x: hidden;
}

/* ===== App Container ===== */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  position: relative;
  overflow: hidden;
}

/* ===== Views ===== */
.view {
  display: none;
  padding: 24px 20px;
  min-height: calc(100vh - var(--nav-height) - var(--safe-bottom));
}

.view.active {
  display: block;
  animation: fadeSlideIn 0.35s ease;
}

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

/* ===== Home View ===== */
.home-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 78vh;
  text-align: center;
  gap: 16px;
  padding: 20px;
}

.home-icon {
  font-size: 72px;
  margin-bottom: 4px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

.home-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
  line-height: 1.3;
}

.home-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 8px;
}

.home-hint {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 8px;
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-block;
  padding: 15px 48px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: var(--font);
  min-width: 200px;
  min-height: 52px;
  box-shadow: 0 4px 15px rgba(74, 144, 217, 0.3);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  letter-spacing: 0.3px;
}

.btn-primary:active {
  transform: scale(0.96);
  opacity: 0.9;
  box-shadow: 0 2px 8px rgba(74, 144, 217, 0.2);
}

.btn-secondary {
  display: inline-block;
  padding: 12px 36px;
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 50px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  min-height: 48px;
  transition: all 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-secondary:active {
  background: var(--primary-light);
  transform: scale(0.96);
}

/* ===== Test View ===== */
.test-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 48px;
}

.btn-back {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--primary);
  cursor: pointer;
  padding: 10px 8px;
  font-family: var(--font);
  min-height: 44px;
  min-width: 44px;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-back:active {
  opacity: 0.6;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 3px;
  transition: width 0.35s ease;
  width: 0%;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 44px;
  text-align: right;
  font-weight: 500;
}

.test-body {
  padding: 0 4px;
}

.question-text {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 40px;
  color: var(--text);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-option {
  display: block;
  width: 100%;
  padding: 20px 24px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 17px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  min-height: 60px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  line-height: 1.5;
}

.btn-option:active {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(0.98);
}

/* ===== Result View ===== */
.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 24px;
  gap: 20px;
  text-align: center;
}

.result-type {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--primary);
  margin-bottom: 4px;
}

.result-tagline {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 8px;
}

.result-dimensions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 20px 0 20px;
}

.dim-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dim-labels {
  display: flex;
  gap: 4px;
  min-width: 20px;
  font-size: 16px;
  font-weight: 700;
  justify-content: center;
}

.dim-label-left { color: var(--text); }
.dim-label-right { color: var(--text-light); }

.dim-bar-wrap {
  flex: 1;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.dim-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.dim-pct {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: right;
  font-weight: 500;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

.result-actions .btn-primary,
.result-actions .btn-secondary {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

/* ===== Detail View ===== */
.detail-header {
  margin-bottom: 20px;
  padding-top: 4px;
}

.detail-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 20px;
}

.detail-hero {
  text-align: center;
  padding: 28px 0 16px;
}

.detail-code {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.detail-name {
  font-size: 22px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--text);
}

.detail-tagline {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 8px;
  font-style: italic;
}

.detail-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.detail-section h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.detail-section ul {
  list-style: none;
  padding: 0;
}

.detail-section li {
  padding: 7px 0;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
}

.detail-section li::before {
  content: '';
  display: inline-block;
  min-width: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 12px;
  margin-top: 8px;
  flex-shrink: 0;
}

.detail-section.traits-section .traits-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.trait-tag {
  padding: 8px 18px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.detail-section p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ===== All Types View ===== */
.alltypes-header {
  text-align: center;
  padding: 20px 0 24px;
}

.alltypes-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.alltypes-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.types-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 2px;
}

.type-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.type-card:active {
  transform: scale(0.96);
  box-shadow: var(--shadow-lg);
}

.type-card .card-code {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.type-card .card-name {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-light);
  min-height: var(--nav-height);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

.nav-icon {
  font-size: 24px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ===== Responsive ===== */
@media (min-width: 481px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .bottom-nav {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .types-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

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

  .home-title {
    font-size: 32px;
  }
}
