/* =============================================================================
 * styles.css — 「澄 · 纸上星图」暖米纸感
 * 视觉方向:纸上心理报告 / 冥想内省;赤陶点缀、低饱和、留白充足。
 * 仅影响观感;题目、计分、数据逻辑一律不在此改动。
 * ========================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  /* 色 —— 暖米纸感 */
  --bg:        #EDE4D6;  /* 暖米基底 */
  --surface:   #F7F1E6;  /* 纸卡(略亮于底) */
  --surface-2: #F1E9DA;  /* 次级面 */
  --ink:       #2B2420;  /* 深褐墨(主文字) */
  --ink-soft:  #6E6154;  /* 次级文字 */
  --ink-faint: #9A8B7A;  /* 更弱的说明 */
  --accent:    #B5533A;  /* 赤陶(主强调 / 自评) */
  --accent-2:  #C97B4A;  /* 赭(SD3 条形) */
  --sage:      #7C8471;  /* 鼠尾草绿(他评 / 第二线) */
  --hairline:  #D8CBB6;  /* 发丝线 / 星盘环 / 分隔 */
  --hairline-2:#E4D9C6;  /* 更淡的线 */
  --band:      rgba(201, 123, 74, 0.13); /* SD3 参照带 */
  --good:      #6E8B6B;
  --warn:      #B5533A;

  /* 字 */
  --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-body: "Noto Sans SC", system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-latin: "Newsreader", Georgia, "Times New Roman", serif;

  /* 尺度 */
  --maxw: 720px;
  --r: 14px;
  --r-sm: 9px;
  --space: 20px;

  /* 阴影(暖、极轻) */
  --shadow-sm: 0 1px 2px rgba(43, 36, 32, 0.05);
  --shadow: 0 1px 2px rgba(43, 36, 32, 0.04), 0 10px 30px rgba(43, 36, 32, 0.07);
  --shadow-lg: 0 2px 6px rgba(43, 36, 32, 0.06), 0 20px 50px rgba(43, 36, 32, 0.10);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, #F3ECDF 0%, rgba(243, 236, 223, 0) 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.25; margin: 0; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
::selection { background: rgba(181, 83, 58, 0.18); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 40px 22px 80px; }

/* 英文小斜体第二声部(量表名等) */
.latin { font-family: var(--font-latin); font-style: italic; color: var(--ink-faint); font-weight: 400; }

/* 眉标 */
.eyebrow {
  font-family: var(--font-latin); font-style: italic; color: var(--accent);
  letter-spacing: 0.02em; font-size: 0.95rem; margin-bottom: 10px;
}

/* ---------- 屏切换 ---------- */
.screen { display: none; }
.screen.active { display: block; animation: fade 0.5s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card + .card { margin-top: 22px; }

/* ---------- 开屏 / 说明 ---------- */
.hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); letter-spacing: 0.01em; }
.hero .sub { color: var(--ink-soft); font-size: 1.05rem; max-width: 46ch; }
.hero .mark {
  font-family: var(--font-display); font-size: 2.4rem; color: var(--accent);
  line-height: 1; margin-bottom: 18px;
}
.notice {
  margin-top: 18px; padding: 16px 18px; background: var(--surface-2);
  border-left: 3px solid var(--accent); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--ink-soft); font-size: 0.95rem;
}
.disclaimer { color: var(--ink-faint); font-size: 0.86rem; margin-top: 16px; line-height: 1.6; }

/* 极小、非高亮的知情告知,固定页面右下角;pointer-events:none 保证不挡任何按钮 */
.consent-note {
  position: fixed; right: 10px; bottom: 8px; max-width: 220px;
  font-size: 11px; line-height: 1.45; color: var(--ink-faint);
  text-align: right; opacity: 0.72; z-index: 5; pointer-events: none;
}
@media (max-width: 560px) {
  .consent-note { max-width: 150px; font-size: 10px; opacity: 0.6; }
}

/* ---------- 身份表单 ---------- */
.field { margin-bottom: 20px; }
.field > label.lbl {
  display: block; font-weight: 500; margin-bottom: 8px; color: var(--ink);
}
.field .hint { color: var(--ink-faint); font-size: 0.85rem; margin-top: 6px; }

input[type="text"], select {
  width: 100%; padding: 12px 14px; font-family: var(--font-body); font-size: 1rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181, 83, 58, 0.14);
}

/* 模式二选一(自评 / 他评) */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode-opt {
  position: relative; cursor: pointer; border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 18px 16px; background: var(--surface);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.mode-opt:hover { border-color: var(--accent-2); }
.mode-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.mode-opt .t { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.mode-opt .d { color: var(--ink-soft); font-size: 0.9rem; margin-top: 4px; }
.mode-opt:has(input:checked) {
  border-color: var(--accent); background: #F3E7Dc;
  box-shadow: inset 0 0 0 1px var(--accent);
}
.mode-opt:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(181, 83, 58, 0.18); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-size: 1rem; font-weight: 500;
  padding: 13px 26px; border-radius: 100px; border: 1px solid transparent;
  cursor: pointer; transition: transform 0.15s, background 0.2s, box-shadow 0.2s, color 0.2s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #FBF4EA; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #A2492F; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--hairline); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(181, 83, 58, 0.28); }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.nav-row { justify-content: space-between; }

/* ---------- 分节与章节数字 ---------- */
.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 6px; }
.section-num {
  font-family: var(--font-display); font-size: 1.8rem; color: var(--accent);
  font-weight: 600; line-height: 1;
}
.section-head h2 { font-size: 1.5rem; }
.section-intro { color: var(--ink-soft); font-size: 0.98rem; margin: 4px 0 22px; }
.section-rule { height: 1px; background: var(--hairline); border: 0; margin: 0 0 8px; }

/* ---------- 分节标题(页内,居中) ---------- */
.page-section { text-align: center; margin: 6px auto 6px; max-width: 560px; }
.page-section .section-head { justify-content: center; }
.page-section .section-intro { max-width: 480px; margin: 6px auto 0; }
.page-section .section-rule { max-width: 64px; margin: 16px auto 4px; }

/* ---------- 单题 + Likert(放大、居中,无题号) ---------- */
.q { max-width: 560px; margin: 0 auto; padding: 46px 10px; text-align: center; }
.q + .q { border-top: 1px solid var(--hairline-2); }
.q.unanswered.flagged { background: rgba(181, 83, 58, 0.05); border-radius: var(--r-sm); }
.q .q-text { font-size: 1.42rem; font-family: var(--font-display); font-weight: 400; line-height: 1.6; margin-bottom: 30px; }

.likert { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 3vw, 18px); }
.likert .dots { display: flex; align-items: center; gap: clamp(16px, 5vw, 28px); }
.likert .cap { font-size: 0.8rem; color: var(--ink-faint); white-space: nowrap; }
.dot {
  --sz: 26px;
  position: relative; width: var(--sz); height: var(--sz); border-radius: 50%;
  border: 1.5px solid var(--hairline); background: var(--surface); cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
}
.dot:nth-child(1) { --sz: 24px; }
.dot:nth-child(2) { --sz: 28px; }
.dot:nth-child(3) { --sz: 32px; }
.dot:nth-child(4) { --sz: 36px; }
.dot:nth-child(5) { --sz: 40px; }
.dot input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.dot:hover { border-color: var(--accent-2); }
.dot:has(input:checked) { background: var(--accent); border-color: var(--accent); transform: scale(1.06); }
.dot:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(181, 83, 58, 0.22); }

/* ---------- 进度条(大、醒目、百分比) ---------- */
.progress-wrap {
  position: sticky; top: 0; z-index: 20; padding: 16px 0 16px;
  background: linear-gradient(var(--bg) 82%, rgba(237, 228, 214, 0));
  backdrop-filter: saturate(1.1);
}
.progress-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.progress-page { font-family: var(--font-latin); font-style: italic; font-size: 0.9rem; color: var(--ink-soft); white-space: nowrap; }
.progress-track { height: 12px; background: var(--hairline-2); border-radius: 100px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(43, 36, 32, 0.07); }
.progress-bar { height: 100%; width: 0; border-radius: 100px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); }
.progress-percent { text-align: right; margin-top: 8px; }
.progress-percent .pw { font-size: 0.85rem; color: var(--ink-faint); margin-right: 4px; }
#progress-percent-num { font-family: var(--font-latin); font-size: 1.6rem; font-weight: 600; color: var(--accent); }

/* ---------- 结果页 ---------- */
.result-card {
  background:
    radial-gradient(600px 380px at 50% 12%, #FAF5EB 0%, rgba(250, 245, 235, 0) 62%),
    var(--surface);
  border: 1px solid var(--hairline-2); border-radius: var(--r); box-shadow: var(--shadow-lg);
  padding: 34px 30px 30px;
}
.result-head { text-align: center; margin-bottom: 10px; }
.result-head .mark { font-family: var(--font-display); color: var(--accent); font-size: 1.8rem; }
.result-head h2 { font-size: 1.7rem; margin-top: 4px; }
.result-head .who { color: var(--ink-soft); font-size: 0.95rem; margin-top: 6px; }
.result-head .date { color: var(--ink-faint); font-size: 0.82rem; font-family: var(--font-latin); font-style: italic; }

.chart-frame { position: relative; margin: 8px auto 6px; max-width: 480px; }
.chart-frame canvas { width: 100% !important; }

.block-title { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 4px; }
.block-title h3 { font-size: 1.25rem; }
.block-title .latin { font-size: 0.9rem; }
.block-note { color: var(--ink-faint); font-size: 0.85rem; margin-bottom: 14px; }

/* 七轴分数列表 */
.axis-list { display: grid; gap: 2px; }
.axis-row { display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--hairline-2); }
.axis-row:last-child { border-bottom: 0; }
.axis-row .name { font-family: var(--font-display); font-size: 1.05rem; }
.axis-row .name .latin { font-size: 0.82rem; margin-left: 8px; }
.axis-row .score { font-family: var(--font-latin); font-size: 1.5rem; color: var(--accent); font-weight: 600; }
.axis-row .interp { grid-column: 1 / -1; color: var(--ink-soft); font-size: 0.92rem; margin-top: -2px; }

/* SD3 条形区 */
.sd3-frame { margin-top: 8px; }
.sd3-legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--ink-faint); font-size: 0.8rem; margin: 6px 0 10px; }
.sd3-item { padding: 12px 0; border-bottom: 1px solid var(--hairline-2); }
.sd3-item:last-child { border-bottom: 0; }
.sd3-item .sd3-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sd3-item .sd3-name { font-family: var(--font-display); font-size: 1.05rem; }
.sd3-item .sd3-val { font-family: var(--font-latin); font-size: 1.05rem; color: var(--accent-2); font-weight: 600; }
.sd3-item .sd3-band { font-size: 0.82rem; color: var(--ink-faint); margin-left: 8px; }
.sd3-item .sd3-note { color: var(--ink-soft); font-size: 0.9rem; margin-top: 4px; }
.sd3-bar-track { position: relative; height: 12px; background: var(--surface-2); border-radius: 6px; margin: 10px 0 2px; overflow: hidden; }
.sd3-bar-band { position: absolute; top: 0; bottom: 0; background: var(--band); }
.sd3-bar-fill { position: absolute; top: 0; bottom: 0; left: 0; background: var(--accent-2); border-radius: 6px; transition: width 0.6s ease; }
.sd3-bar-ref { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-soft); opacity: 0.5; }
.sd3-scale { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--ink-faint); }

/* 文字提示块 */
.text-block {
  margin-top: 26px; padding: 20px 22px; background: var(--surface-2);
  border-radius: var(--r-sm); color: var(--ink-soft); font-size: 0.94rem; line-height: 1.7;
}
.text-block strong { color: var(--ink); font-weight: 600; }

.result-foot { text-align: center; color: var(--ink-faint); font-size: 0.76rem; margin-top: 24px; line-height: 1.6; }

/* 入库状态提示 */
.save-status { text-align: center; font-size: 0.85rem; margin-top: 10px; min-height: 1.2em; }
.save-status.ok { color: var(--good); }
.save-status.err { color: var(--warn); }

/* ---------- 校验提示条 ---------- */
.validate-msg {
  display: none; margin-top: 14px; padding: 12px 16px; border-radius: var(--r-sm);
  background: rgba(181, 83, 58, 0.10); color: var(--accent); font-size: 0.92rem;
}
.validate-msg.show { display: block; }

/* ---------- 管理页专用 ---------- */
.admin-gate { max-width: 420px; margin: 8vh auto 0; }
.subject-picker { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--hairline-2); }
.table th { color: var(--ink-soft); font-weight: 500; font-size: 0.82rem; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 100px; font-size: 0.76rem; }
.tag.self { background: rgba(181, 83, 58, 0.14); color: var(--accent); }
.tag.informant { background: rgba(124, 132, 113, 0.18); color: #5c6353; }

.gap-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px 16px; padding: 10px 0; border-bottom: 1px solid var(--hairline-2); align-items: baseline; }
.gap-row.head { color: var(--ink-soft); font-size: 0.8rem; border-bottom: 1px solid var(--hairline); }
.gap-row .num { font-family: var(--font-latin); }
.gap-big { color: var(--accent); font-weight: 600; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.85rem; color: var(--ink-soft); margin: 8px 0 14px; }
.legend .swatch { display: inline-block; width: 22px; height: 3px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }

/* ---------- 响应式 ---------- */
@media (max-width: 560px) {
  .wrap { padding: 26px 16px 70px; }
  .card, .result-card { padding: 22px 18px; }
  .mode-grid { grid-template-columns: 1fr; }
  .likert { max-width: 100%; }
  .likert .dots { gap: clamp(14px, 9vw, 30px); }
  .likert .cap { display: none; }
  .likert::before { content: "非常不同意"; font-size: 0.72rem; color: var(--ink-faint); }
  .likert::after { content: "非常同意"; font-size: 0.72rem; color: var(--ink-faint); }
  .q { padding: 34px 4px; }
  .q .q-text { font-size: 1.24rem; margin-bottom: 24px; }
  #progress-percent-num { font-size: 1.35rem; }
  .axis-row .score { font-size: 1.3rem; }
  .gap-row { grid-template-columns: 1fr auto auto; }
  .gap-row .hide-sm { display: none; }
}

/* ---------- 无障碍 ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
