/* psych-answers-v1 — 心理測驗答案：四組題目選擇 + 分數計算. Self-contained per prototype principle. */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 720px);
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ SIDEBAR ============ */
.sidebar { position: sticky; top: 24px; height: calc(100vh - 48px); display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 32px; font-weight: 800; margin-bottom: 36px; color: var(--text); }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a {
  padding: 14px 18px;
  color: var(--text-soft);
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar nav a.active,
.sidebar nav a:hover {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}
.new-post {
  border-radius: 999px;
  background: var(--cta-bg);
  color: var(--cta-text);
  font-weight: 700;
  padding: 14px 22px;
  font-size: 16px;
}

/* ============ MAIN ============ */
.main { min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  min-height: 44px;
  gap: 12px;
}
.topbar .back {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  font-size: 22px;
  color: var(--text);
}
.topbar h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.topbar-brand img { width: 24px; height: 24px; object-fit: contain; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

/* ============ OWNER CARD ============ */
.owner-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.owner-row { display: flex; align-items: center; gap: 12px; }
.owner-row .avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.owner-who { flex: 1; min-width: 0; }
.owner-who b { display: block; font-size: 15px; font-weight: 700; }
.owner-who small { display: block; font-size: 12px; color: var(--text-soft); margin-top: 1px; }
.owner-analyse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: var(--cta-bg);
  color: var(--cta-text);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
}
.owner-analyse:hover { opacity: 0.9; }

/* ============ PANE NAV ============ */
.pane-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  padding: 4px;
  margin-bottom: 14px;
}
.pane-nav::-webkit-scrollbar { display: none; }
.pane-nav button {
  flex: 1 0 auto;
  padding: 9px 16px;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.pane-nav button.on {
  background: var(--cta-bg);
  color: var(--cta-text);
}

/* ============ RESULT CARD ============ */
.res-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.res-card small {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.78);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.res-card b { display: block; font-size: 23px; font-weight: 800; letter-spacing: -0.01em; }
.res-card b [data-mbti] { cursor: pointer; border-bottom: 2px dashed rgba(255,255,255,0.45); }
.res-card[hidden] { display: none !important; }

/* ============ LIST SECTIONS ============ */
.list-section { padding: 0; overflow: hidden; margin-bottom: 14px; }
.list-section[hidden] { display: none !important; }
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.list-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.sort-note { font-size: 11px; color: var(--text-soft); font-weight: 600; }

/* ============ 分數計算 ============ */
.score-wrap { padding: 14px 18px; display: grid; gap: 10px; }

/* MBTI 維度 */
.axis-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.axis-side {
  display: flex;
  align-items: baseline;
  gap: 6px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text-soft);
}
.axis-side b { font-size: 16px; font-weight: 800; }
.axis-side small { font-size: 12px; font-weight: 600; }
.axis-side span { margin-left: auto; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.axis-side.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

/* 九型 / Big 5 計分列 */
.sc-row {
  display: grid;
  grid-template-columns: 118px 1fr 44px;
  align-items: center;
  gap: 10px;
}
.sc-name { font-size: 12px; font-weight: 600; color: var(--text-soft); white-space: nowrap; }
.sc-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}
.sc-bar i { display: block; height: 100%; border-radius: 999px; background: #cbd5e1; }
.sc-val { font-size: 12px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.sc-row.top .sc-bar i { background: var(--primary); }
.sc-row.top .sc-name,
.sc-row.top .sc-val { color: var(--primary-dark); }

/* ECR 依附風格四宮格 */
.quad-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.quad-cell {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text-soft);
}
.quad-cell b { display: block; font-size: 14px; font-weight: 800; }
.quad-cell small { font-size: 11px; font-weight: 600; }
.quad-cell.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

/* ============ 題目列表 ============ */
.q-list { list-style: none; padding: 0; margin: 0; }
.q-list li { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.q-list li:last-child { border-bottom: 0; }
.q-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.q-head b { font-size: 14px; font-weight: 700; flex: 1; }
.q-or { margin: 0 6px; font-size: 11px; font-weight: 600; color: var(--text-muted); } /* 16 型雙極題：上句 定係 下句 */
.q-trait {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}
.q-opts { display: grid; gap: 6px; }
.q-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-soft);
}
.q-opt svg { flex-shrink: 0; }
.q-opt .q-label { flex: 1; min-width: 0; }
.q-opt .q-tag { font-style: normal; font-size: 10px; font-weight: 700; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }
.q-opt.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
}
.q-opt.on .q-tag { color: var(--primary-dark); }

.info-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.6;
  text-align: center;
}
.info-note a { color: var(--primary-dark); font-weight: 600; }

/* ============ Avatar gradients ============ */
.avatar.g1 { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.avatar.g2 { background: linear-gradient(135deg, #ec4899, #f97316); }
.avatar.g3 { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.avatar.g4 { background: linear-gradient(135deg, #10b981, #059669); }
.avatar.g5 { background: linear-gradient(135deg, #f59e0b, #ef4444); }

/* ============ BACK TO TOP ============ */
.to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 50;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.32);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
}
.to-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (hover: hover) {
  .to-top:hover { background: var(--primary-dark); }
}
.to-top:active { transform: translateY(0) scale(0.94); }

/* ============ MOBILE NAV ============ */
.mobile-nav { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); padding: 16px; gap: 18px; }
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .sidebar { display: none; }
  .main { padding: 14px 16px 90px; }
  .topbar { padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
  .topbar .back { display: inline-flex; }
  .topbar h1 { font-size: 18px; text-align: center; }
  .topbar-brand { display: none; }
  .sc-row { grid-template-columns: 100px 1fr 40px; }

  .to-top {
    bottom: 88px; right: 16px; width: 42px; height: 42px;
    transition: opacity 0.2s, transform 0.2s, background 0.15s,
                bottom 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  body.nav-hidden .to-top { bottom: 28px; }

  .mobile-nav {
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: 10px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 20;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  }
  .mobile-nav.nav-hidden {
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
  }
  .mobile-nav a { text-align: center; font-size: 12px; color: var(--text-soft); padding: 8px 4px; }
  .mobile-nav a.active { color: var(--text); font-weight: 600; }
  .mobile-nav .compose-btn {
    width: 46px; height: 46px;
    margin: auto; padding: 0;
    border-radius: 50%;
    background: var(--cta-bg); color: var(--cta-text);
    display: grid; place-items: center; line-height: 1;
  }
}

/* IPIP-NEO-120 — 維度之下 6 個面向分數 */
.fc-wrap { display: grid; gap: 5px; margin: 2px 0 10px; padding-left: 16px; }
.fc-row { display: grid; grid-template-columns: 102px 1fr 34px; align-items: center; gap: 10px; }
.fc-row .sc-bar { height: 5px; }
.fc-name { font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.fc-val { font-size: 11px; font-weight: 700; color: var(--text-soft); text-align: right; font-variant-numeric: tabular-nums; }
