/* 当代中国年轻人的未来期许调查 —— 样式表
   移动优先；系统字体（不加载任何外部字体，保证大陆访问速度）*/

:root {
  --bg:        #faf9f7;
  --surface:   #ffffff;
  --surface-2: #f2f0ec;
  --border:    #e2ded7;
  --border-2:  #cfc9c0;
  --text:      #1c1a17;
  --text-2:    #5f5950;
  --text-3:    #8b8479;
  --accent:    #2f4f6f;
  --accent-2:  #3f6b95;
  --accent-bg: #eaf0f6;
  --danger:    #9a3b32;
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(28,26,23,.05), 0 4px 14px rgba(28,26,23,.06);
  --shadow-lg: 0 2px 6px rgba(28,26,23,.07), 0 12px 32px rgba(28,26,23,.12);
  --maxw:      36rem;
  --ease:      cubic-bezier(.22,.61,.36,1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #14161a;
    --surface:   #1c1f25;
    --surface-2: #23272e;
    --border:    #2f343c;
    --border-2:  #434a55;
    --text:      #eceef1;
    --text-2:    #a7aeb8;
    --text-3:    #7c848f;
    --accent:    #8fb6dc;
    --accent-2:  #a9c9e8;
    --accent-bg: #1e2934;
    --danger:    #e0857c;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.4);
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 布局 ---------- */

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.75rem 1.25rem calc(3rem + env(safe-area-inset-bottom));
}

.stack > * + * { margin-top: 1.15rem; }
.stack { animation: rise .38s var(--ease) both; }
.center { text-align: center; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- 排版 ---------- */

h1 {
  font-size: clamp(1.45rem, 5.2vw, 1.85rem);
  line-height: 1.4;
  letter-spacing: -.01em;
  margin: 0;
  font-weight: 700;
}

h2 {
  font-size: clamp(1.15rem, 4.2vw, 1.4rem);
  line-height: 1.5;
  margin: 0;
  font-weight: 650;
  letter-spacing: -.005em;
}

.eyebrow {
  margin: 0;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--text-3);
}

.prose { color: var(--text-2); font-size: .96rem; }
.prose p { margin: 0 0 .85rem; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--text); font-weight: 650; }

.meta-note {
  margin: 0;
  font-size: .84rem;
  color: var(--text-3);
}

/* ---------- 进度条 ---------- */

.progress-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: .7rem 1.25rem .55rem;
}

.progress-bar {
  max-width: var(--maxw);
  margin: 0 auto;
  height: 3px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

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

.progress-label {
  max-width: var(--maxw);
  margin: .35rem auto 0;
  font-size: .76rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- 问题块 ---------- */

.q { margin-top: 1.9rem; }
.q:first-child { margin-top: 0; }

.q-label {
  display: block;
  font-size: 1rem;
  font-weight: 620;
  line-height: 1.6;
  margin-bottom: .8rem;
}

.q-sub {
  display: block;
  font-size: .85rem;
  font-weight: 400;
  color: var(--text-3);
  margin-top: .2rem;
}

.q-label .hl {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- 选项 ---------- */

.options { display: grid; gap: .5rem; }
.options.cols-2 { grid-template-columns: 1fr 1fr; }

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .78rem .95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .95rem;
  line-height: 1.5;
  transition: border-color .16s var(--ease), background .16s var(--ease),
              transform .12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.opt:active { transform: scale(.985); }

.opt input { position: absolute; opacity: 0; pointer-events: none; }

.opt .dot {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-2);
  border-radius: 50%;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}

.opt.checkbox .dot { border-radius: 5px; }

.opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.opt:has(input:checked) .dot {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 4px var(--accent);
}

.opt.checkbox:has(input:checked) .dot {
  box-shadow: inset 0 0 0 9px var(--accent);
  position: relative;
}

.opt.checkbox:has(input:checked) .dot::after {
  content: "";
  position: absolute;
  left: 5px; top: 2px;
  width: 5px; height: 9px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.opt:has(input:disabled) { opacity: .42; cursor: not-allowed; }

.opt .idx {
  margin-left: auto;
  flex: 0 0 auto;
  min-width: 1.55rem; height: 1.55rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
  font-size: .8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- 下拉与输入 ---------- */

.select-wrap { position: relative; }

.select-wrap::after {
  content: "";
  position: absolute;
  right: 1rem; top: 50%;
  width: 7px; height: 7px;
  border: solid var(--text-3);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

select, input[type="number"] {
  width: 100%;
  padding: .8rem 2.4rem .8rem .95rem;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .16s var(--ease);
}

input[type="number"] { padding-right: .95rem; }

select:focus-visible, input:focus-visible, .opt:focus-visible, .btn:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 按钮 ---------- */

.btn {
  display: block;
  width: 100%;
  padding: .92rem 1.2rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 620;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity .16s var(--ease), transform .12s var(--ease),
              background .16s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(.99); }

.btn-primary { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { color: #10141a; }
}

.btn-primary:disabled {
  opacity: .38;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}

.btn-row { margin-top: 2.2rem; }
.btn-row .btn + .btn { margin-top: .6rem; }

/* ---------- 排序任务 ---------- */

.screen-task { animation: rise .34s var(--ease) both; }

.task-head { margin-bottom: .95rem; }

.task-prompt {
  margin: .3rem 0 0;
  font-size: clamp(1rem, 3.8vw, 1.2rem);
  line-height: 1.5;
}

.task-prompt .hl { color: var(--accent); font-weight: 700; }

.task-hint {
  margin: .35rem 0 0;
  font-size: .83rem;
  color: var(--text-3);
  min-width: 0;
}

.cards { display: grid; gap: .6rem; }

.card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: .8rem .9rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease),
              transform .16s var(--ease), opacity .3s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.card:active { transform: scale(.99); }

@media (hover: hover) {
  .card:hover { border-color: var(--border-2); box-shadow: var(--shadow-lg); }
}

.card-tag {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-3);
  margin-bottom: .45rem;
}

/* 移动端 2×2 网格：三张卡片可一屏看完，避免每轮滚动 */
.attrs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .42rem .8rem;
}

.attr { min-width: 0; }

.attr dt {
  margin: 0 0 .05rem;
  font-size: .76rem;
  line-height: 1.35;
  color: var(--text-3);
}

.attr dd {
  margin: 0;
  font-size: .98rem;
  line-height: 1.35;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 提示文字与撤销操作同处一行，置于卡片上方——点错时无需滚动即可看到 */
.task-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
  min-height: 1.9em;
}

.task-actions {
  display: flex;
  align-items: baseline;
  gap: .15rem;
  flex: 0 0 auto;
}

.btn-link {
  padding: .3rem .5rem;
  font: inherit;
  font-size: .84rem;
  color: var(--text-3);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: color .16s var(--ease), background .16s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn-link:hover,
.btn-link:active { color: var(--accent); background: var(--accent-bg); }
.btn-link[hidden] { display: none; }
.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 已选中（第一名） */
.card.chosen {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.card.chosen .card-tag { color: var(--accent); }

.card .rank-badge {
  position: absolute;
  top: .85rem; right: .95rem;
  min-width: 1.7rem; height: 1.7rem;
  padding: 0 .4rem;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .02em;
  animation: pop .3s var(--ease) both;
}

@keyframes pop {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: none; }
}

/* 第二阶段：已淘汰的卡片保留但弱化 */
.card.settled {
  opacity: .5;
  pointer-events: none;
  box-shadow: none;
}

.card.dimmed { opacity: .55; }

/* 老家标记（仅用于内部核对，默认不展示） */
.card .home-flag { display: none; }

/* ---------- 要素排序 ---------- */

.factor-hint {
  font-size: .86rem;
  color: var(--text-3);
  margin: 0 0 .8rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- 完成页 ---------- */

.done-mark {
  width: 3.4rem; height: 3.4rem;
  margin: 1rem auto .4rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 700;
  animation: pop .45s var(--ease) both;
}

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100vw - 2.5rem);
  padding: .7rem 1.1rem;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: .87rem;
  box-shadow: var(--shadow-lg);
  animation: rise .3s var(--ease) both;
}

/* ---------- 桌面端 ---------- */

/* 矮屏（iPhone SE 等）：进一步压缩，保证三张卡片一屏可见 */
@media (max-height: 720px) {
  .app { padding-top: .9rem; padding-bottom: 1.5rem; }
  .card { padding: .62rem .8rem .66rem; }
  .card-tag { margin-bottom: .3rem; }
  .attrs { gap: .28rem .7rem; }
  .attr dt { font-size: .72rem; }
  .attr dd { font-size: .92rem; }
  .cards { gap: .45rem; }
  .task-head { margin-bottom: .6rem; }
  .task-prompt { font-size: .98rem; }
  /* 轮次序号已在顶部进度条显示，此处不再重复 */
  .screen-task .eyebrow { display: none; }
  .task-hint { margin-top: .25rem; font-size: .8rem; }
  .task-bar { min-height: 1.75em; }
  .btn-link { font-size: .8rem; padding: .25rem .4rem; }
  .progress-wrap { padding: .5rem 1.25rem .4rem; }
}

@media (min-width: 700px) {
  :root { --maxw: 44rem; }
  .app { padding-top: 3rem; }
  .cards { grid-template-columns: repeat(3, 1fr); gap: .75rem; }
  .card { padding: 1.1rem .95rem; }
  /* 桌面端卡片较窄，属性改回单列纵向 */
  .attrs { grid-template-columns: 1fr; gap: .5rem; }
  .attr dd { font-size: 1rem; }
}
