/* Shared friendly-card quiz page styles for bigfive and assessment engine.
   移动端优先，断点 768px/1024px；命名空间 tl-q-*。 */

/* --------------------------------------------------------------------------
 * Page band + centered answer column
 * -------------------------------------------------------------------------- */

.tl-q-page {
  --tl-q-page-bg: #eef1f8;
  --tl-q-card-bg: #fff;
  --tl-q-card-radius: 20px;
  --tl-q-card-shadow: 0 6px 22px rgba(31, 41, 55, 0.07);
  --tl-q-col: 100%;

  background: var(--tl-q-page-bg);
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  padding: 0 0 32px;
  min-height: calc(100vh - 180px);
  overflow-x: hidden;
}

.tl-q-page > * {
  margin-left: auto;
  margin-right: auto;
  max-width: var(--tl-q-col);
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 768px) {
  .tl-q-page {
    --tl-q-col: 780px;
    padding: 0 0 48px;
  }
  .tl-q-page > * {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (min-width: 1024px) {
  .tl-q-page {
    --tl-q-col: 880px;
    padding: 0 0 64px;
  }
}

/* --------------------------------------------------------------------------
 * 答题页整页统一色带：主区域与答题区同色，消除页眉下/页脚上
 * 的异色空白带（body #f6f8fc 与答题区 #eef1f8 拼接的色差）
 * -------------------------------------------------------------------------- */

.tl-main:has(.tl-q-page) {
  background: var(--tl-q-page-bg);
  padding-top: 0;
  padding-bottom: 0;
}

.tl-main:has(.tl-q-page) + .tl-footer {
  margin-top: 0;
}

/* --------------------------------------------------------------------------
 * Compact test-info banner (category + title)
 * -------------------------------------------------------------------------- */

.tl-q-banner {
  background: linear-gradient(135deg, #312e81 0%, #4338ca 50%, #6366f1 100%);
  color: #fff;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.tl-q-page > .tl-q-banner {
  padding-top: 0.75rem;
  border-radius: 0;
}
@media (min-width: 768px) {
  .tl-q-page > .tl-q-banner {
    padding-top: 0.75rem;
    border-radius: 0 0 0.75rem 0.75rem;
  }
}
@media (min-width: 1024px) {
  .tl-q-page > .tl-q-banner {
    padding-top: 0.75rem;
  }
}
.tl-q-banner-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.tl-q-banner-cat {
  display: inline-block;
  background: rgba(255, 255, 255, 0.95);
  color: #312e81;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.tl-q-banner-title {
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 800;
  line-height: 1.25;
  margin: 0;
  color: #fff;
}
.tl-q-banner-desc {
  font-size: 0.8rem;
  opacity: 0.85;
  line-height: 1.5;
  margin: 0.4rem 0 0;
}

/* --------------------------------------------------------------------------
 * Flag/notice (above the card)
 * -------------------------------------------------------------------------- */

.tl-q-notice {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  color: #92400e;
  font-size: 14px;
  line-height: 1.5;
}

.tl-q-notice-title {
  font-weight: 700;
  margin: 0 0 4px;
}

.tl-q-notice p {
  margin: 0 0 4px;
}

.tl-q-notice p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
 * Card
 * -------------------------------------------------------------------------- */

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

@media (min-width: 768px) {
  .tl-q-card {
    padding: 24px 26px 28px;
  }
}

@media (min-width: 1024px) {
  .tl-q-card {
    padding: 28px 30px 32px;
  }
}

/* --------------------------------------------------------------------------
 * Meta row
 * -------------------------------------------------------------------------- */

.tl-q-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #6b7280;
  font-size: 12.5px;
  line-height: 1.4;
  margin-bottom: 12px;
}

.tl-q-meta-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tl-q-countdown {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tl-q-countdown.is-low {
  color: #ea580c;
  font-weight: 700;
}

.tl-q-percent {
  font-weight: 700;
  color: #374151;
}

/* --------------------------------------------------------------------------
 * Progress capsule
 * -------------------------------------------------------------------------- */

.tl-q-bar {
  height: 8px;
  background: #eceffa;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 16px;
}

.tl-q-bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6366f1, #4f46e5);
  border-radius: 99px;
  transition: width 220ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .tl-q-bar > i {
    transition-duration: 1ms;
  }
}

/* --------------------------------------------------------------------------
 * Question navigator grid
 * -------------------------------------------------------------------------- */

.tl-q-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tl-q-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

a.tl-q-nav-btn {
  cursor: pointer;
  border: 2px solid #d1d5e8;
  background: #fff;
  color: #6b7280;
}

a.tl-q-nav-btn:hover {
  border-color: #4f46e5;
  color: #4f46e5;
}

a.tl-q-nav-btn.is-answered {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}

a.tl-q-nav-btn.is-answered:hover {
  background: #4338ca;
  border-color: #4338ca;
}

span.tl-q-nav-btn.is-current {
  border: 2px solid #4f46e5;
  background: #fff;
  color: #4f46e5;
  cursor: default;
}

/* --------------------------------------------------------------------------
 * Type chip
 * -------------------------------------------------------------------------- */

.tl-q-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef0ff;
  color: #4f46e5;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 99px;
  margin-bottom: 14px;
}

.tl-q-chip.is-timed {
  background: #fff1e8;
  color: #ea580c;
}

/* --------------------------------------------------------------------------
 * Fieldset + question text
 * -------------------------------------------------------------------------- */

.tl-q-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.tl-q-text {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  color: #111827;
  margin: 0 0 18px;
}

@media (min-width: 768px) {
  .tl-q-text {
    font-size: 21px;
    margin-bottom: 20px;
  }
}

.tl-q-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  margin: 0 0 16px;
}

/* --------------------------------------------------------------------------
 * Options list
 * -------------------------------------------------------------------------- */

.tl-q-options {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.tl-q-opt {
  --tl-q-opt-border: #e8eaf2;
  --tl-q-opt-bg: #fff;
  --tl-q-opt-fg: #1f2937;
  --tl-q-pip-ring: #9aa6c2;
  --tl-q-pip-dot: #9aa6c2;
  --tl-q-badge-bg: #f0f1f8;
  --tl-q-badge-fg: #6b7280;

  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 48px;
  padding: 14px 15px;
  border: 2px solid var(--tl-q-opt-border);
  border-radius: 15px;
  background: var(--tl-q-opt-bg);
  color: var(--tl-q-opt-fg);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

@media (min-width: 1024px) {
  .tl-q-opt {
    min-height: 52px;
    padding-top: 13px;
    padding-bottom: 13px;
  }
}

.tl-q-opt:hover:not(:disabled):not(.is-selected) {
  --tl-q-opt-border: #c7cbdd;
  --tl-q-opt-bg: #fafbff;
}

.tl-q-opt:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

.tl-q-opt:active:not(:disabled) {
  --tl-q-opt-border: #4f46e5;
  --tl-q-opt-bg: #4f46e5;
  --tl-q-opt-fg: #fff;
  --tl-q-pip-ring: transparent;
  --tl-q-pip-dot: #fff;
  --tl-q-badge-bg: rgba(255, 255, 255, 0.22);
  --tl-q-badge-fg: #fff;
}

.tl-q-opt.is-selected,
.tl-q-opt.is-selected:hover {
  --tl-q-opt-border: #4f46e5;
  --tl-q-opt-bg: #4f46e5;
  --tl-q-opt-fg: #fff;
  --tl-q-pip-ring: transparent;
  --tl-q-pip-dot: #fff;
  --tl-q-badge-bg: rgba(255, 255, 255, 0.22);
  --tl-q-badge-fg: #fff;
}

.tl-q-opt.is-locked {
  cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
  .tl-q-opt {
    transition-duration: 1ms;
  }
}

/* --------------------------------------------------------------------------
 * Pip (Likert progressive-fill circle)
 * -------------------------------------------------------------------------- */

.tl-q-pip {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.tl-q-pip > i {
  display: block;
  width: calc(4px + 13px * var(--fill, 0) / 100);
  height: calc(4px + 13px * var(--fill, 0) / 100);
  border-radius: 50%;
  background: var(--tl-q-pip-dot);
}

/* --------------------------------------------------------------------------
 * Badge (MC letter)
 * -------------------------------------------------------------------------- */

.tl-q-badge {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--tl-q-badge-bg);
  color: var(--tl-q-badge-fg);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
 * Label + check
 * -------------------------------------------------------------------------- */

.tl-q-label {
  flex: 1 1 auto;
}

.tl-q-check {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #4f46e5;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.tl-q-check::after {
  content: "✓";
}

.tl-q-opt.is-selected .tl-q-check {
  display: flex;
}

/* --------------------------------------------------------------------------
 * Tap note + card footer hint
 * -------------------------------------------------------------------------- */

.tl-q-tapnote {
  color: #9aa1af;
  font-size: 13.5px;
  text-align: center;
  margin: 16px 0 0;
  line-height: 1.4;
}

.tl-q-hint {
  color: #9aa1af;
  font-size: 13.5px;
  text-align: center;
  margin: 6px 0 0;
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
 * Outside-card controls
 * -------------------------------------------------------------------------- */

.tl-q-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  min-height: 44px;
}

.tl-q-back,
.tl-q-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.tl-q-back:hover,
.tl-q-link:hover {
  color: #4f46e5;
}

.tl-q-back:focus-visible,
.tl-q-link:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
  border-radius: 4px;
}

.tl-q-back.is-disabled {
  color: #9ca3af;
  cursor: not-allowed;
  pointer-events: none;
}

.tl-q-exits {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 359px) {
  .tl-q-exits {
    gap: 6px;
  }
  .tl-q-back,
  .tl-q-link {
    font-size: 13px;
  }
}

/* --------------------------------------------------------------------------
 * Loading overlay — 脉冲光环方案
 * -------------------------------------------------------------------------- */

.tl-q-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(ellipse at 50% 40%, #1e1b4b 0%, #0f0d2e 50%, #07061a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  animation: tl-q-load-in 400ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

@keyframes tl-q-load-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 脉冲光环容器 */
.tl-q-loading-rings {
  position: relative;
  width: 160px;
  height: 160px;
  margin-bottom: 32px;
}

/* 三层脉冲圆环 */
.tl-q-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(129, 140, 248, 0.4);
  animation: tl-q-pulse 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.tl-q-ring--2 {
  animation-delay: 0.8s;
}

.tl-q-ring--3 {
  animation-delay: 1.6s;
}

@keyframes tl-q-pulse {
  0% {
    transform: scale(0.5);
    opacity: 0.8;
    border-color: rgba(129, 140, 248, 0.6);
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
    border-color: rgba(129, 140, 248, 0);
  }
}

/* 中心图标 */
.tl-q-loading-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  background: rgba(99, 102, 241, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.3), inset 0 0 20px rgba(99, 102, 241, 0.1);
  animation: tl-q-core-glow 2s ease-in-out infinite alternate;
}

.tl-q-loading-core svg {
  width: 44px;
  height: 44px;
}

@keyframes tl-q-core-glow {
  from { box-shadow: 0 0 40px rgba(99, 102, 241, 0.3), inset 0 0 20px rgba(99, 102, 241, 0.1); }
  to   { box-shadow: 0 0 60px rgba(99, 102, 241, 0.5), inset 0 0 30px rgba(99, 102, 241, 0.2); }
}

/* 大脑路径描边动画 */
.tl-q-brain {
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
  animation: tl-q-brain-draw 1.5s ease-out 0.3s forwards;
}

@keyframes tl-q-brain-draw {
  to { stroke-dashoffset: 0; }
}

/* 神经元节点脉冲 */
.tl-q-dot {
  animation: tl-q-dot-pulse 1.5s ease-in-out infinite;
}

.tl-q-dot--1 { animation-delay: 0.5s; }
.tl-q-dot--2 { animation-delay: 0.8s; }
.tl-q-dot--3 { animation-delay: 1.1s; }

@keyframes tl-q-dot-pulse {
  0%, 100% { r: 2; opacity: 0.5; }
  50%      { r: 3; opacity: 1; }
}

/* 神经元连线闪烁 */
.tl-q-line {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: tl-q-line-flow 1.2s ease-in-out infinite;
}

.tl-q-line--1 { animation-delay: 0s; }
.tl-q-line--2 { animation-delay: 0.4s; }
.tl-q-line--3 { animation-delay: 0.8s; }

@keyframes tl-q-line-flow {
  0%   { stroke-dashoffset: 20; opacity: 0.3; }
  50%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: -20; opacity: 0.3; }
}

/* 文字 */
.tl-q-loading-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 6px;
  text-align: center;
  letter-spacing: -0.01em;
}

.tl-q-loading-sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  margin: 0 0 28px;
  text-align: center;
}

/* 进度条 */
.tl-q-loading-bar {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.tl-q-loading-bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6366f1, #a5b4fc, #6366f1);
  background-size: 200% 100%;
  border-radius: 99px;
  transition: width 3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tl-q-loading-bar > i.is-animating {
  width: 100%;
  animation: tl-q-bar-shimmer 1.2s ease-in-out infinite;
}

@keyframes tl-q-bar-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 无障碍：减弱动画 */
@media (prefers-reduced-motion: reduce) {
  .tl-q-loading { animation-duration: 1ms; }
  .tl-q-ring { animation: none; transform: scale(1.2); opacity: 0.3; }
  .tl-q-loading-core { animation: none; }
  .tl-q-brain { animation: none; stroke-dashoffset: 0; }
  .tl-q-dot, .tl-q-line { animation: none; opacity: 0.6; }
  .tl-q-loading-bar > i.is-animating { animation: none; width: 100%; transition-duration: 1ms; }
}
