/* ============================================================
   互动答题系统 · 全局设计系统
   DESIGN_SPEC.md 定义的主视觉语言
   墨蓝 #0F2A4A · 象牙白 #F7F4EC · 匠心金 #C9A24B · 点缀朱 #C0392B
   ============================================================ */

/* ---------- 1. Reset & Tokens ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --ink: #0F2A4A;          /* 墨蓝 - 主色/标题 */
    --ink-soft: #1E3A5F;
    --ink-deep: #0A1E35;
    --paper: #F7F4EC;        /* 象牙白 - 页面底色 */
    --card: #FFFFFF;
    --gold: #C9A24B;         /* 匠心金 */
    --gold-soft: #E6D3A8;
    --vermilion: #C0392B;    /* 朱红 - 点缀 */
    --text: #1A1A1A;
    --text-2: #5C5C5C;
    --line: #D9D2C2;
    --success: #1B7A4F;
    --success-bg: #EAF6EE;
    --danger: #C0392B;
    --danger-bg: #FCEBE9;
    --radius-card: 16px;
    --radius-pill: 28px;
    --shadow-1: 0 6px 20px rgba(15, 42, 74, 0.08);
    --shadow-2: 0 10px 32px rgba(15, 42, 74, 0.14);
    --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
            "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    --num-font: "SF Pro Display", -apple-system, "Helvetica Neue", Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--paper);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* 尊重系统减动效 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 2. 页面容器 ---------- */
.page {
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
}

.page__inner {
    width: 100%;
    max-width: 480px;
    padding: 20px 18px calc(28px + env(safe-area-inset-bottom));
    position: relative;
    z-index: 2;
}

.page__inner--narrow { max-width: 460px; }

/* ---------- 3. 顶部绶带 Ribbon ---------- */
.ribbon {
    width: 100%;
    height: 46px;
    background: linear-gradient(90deg, var(--ink-deep), var(--ink));
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}
.ribbon::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold) 30%, var(--gold) 70%, transparent);
    opacity: .8;
}
.ribbon__logo {
    height: 26px;
    width: auto;
}
.ribbon__title {
    color: var(--gold-soft);
    font-size: 12px;
    letter-spacing: .06em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- 4. 学院印章水印 ---------- */
.seal-watermark {
    position: fixed;
    left: 50%;
    top: 44%;
    transform: translate(-50%, -50%);
    width: 340px;
    height: auto;
    opacity: .055;
    z-index: 1;
    pointer-events: none;
    filter: saturate(0.2);
    border-radius: 50%;
}
/* 答题页弱化学院水印，让线稿背景更突出 */
.page--play .seal-watermark { opacity: .03; width: 260px; top: 78%; }

/* ---------- 5. Hero（首页） ---------- */
.hero {
    position: relative;
    border-radius: var(--radius-card);
    overflow: hidden;
    height: 290px;
    box-shadow: var(--shadow-2);
    margin-bottom: 18px;
}
.hero__bg {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}
.hero__veil {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(10,30,53,.15) 0%, rgba(10,30,53,.25) 45%, rgba(10,30,53,.92) 100%);
}
.hero__content {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 20px 22px 24px;
    text-align: center;
    color: #fff;
}
.hero__logo {
    width: 200px;
    margin: 0 auto 10px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.35));
}
.hero__title {
    font-size: 23px;
    font-weight: 700;
    letter-spacing: .02em;
    text-shadow: 0 1px 6px rgba(0,0,0,.4);
}
.hero__subtitle {
    margin-top: 4px;
    font-size: 14px;
    color: rgba(255,255,255,.88);
    letter-spacing: .08em;
    text-shadow: 0 1px 4px rgba(0,0,0,.35);
}

/* ---------- 6. 卡片 ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-1);
    padding: 26px 24px;
    margin-bottom: 16px;
    position: relative;
    border: 1px solid rgba(217,210,194,.4);
}
.card__head { margin-bottom: 18px; }
.card__head--center { text-align: center; }
.card__step {
    display: inline-block;
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--gold);
    font-weight: 700;
    background: rgba(201,162,75,.12);
    padding: 3px 12px;
    border-radius: 999px;
    margin-bottom: 8px;
}
.card__title { font-size: 19px; color: var(--ink); font-weight: 700; }
.card__desc { font-size: 14px; color: var(--text-2); margin-top: 6px; line-height: 1.6; }

/* 首页进入卡片上移，留出 hero 空间 */
.card--entry { animation: riseIn .5s ease-out both; }
.card--entry .card__head { text-align: center; }
.card--entry .card__step { display: block; }

/* ---------- 7. 按钮 ---------- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .02em;
    transition: background-color .2s ease, color .2s ease, transform .12s ease, box-shadow .2s ease;
}
.btn--block { width: 100%; margin-top: 16px; }
.btn svg { width: 18px; height: 18px; }

.btn--primary {
    background: var(--ink);
    color: var(--paper);
    box-shadow: 0 6px 16px rgba(15,42,74,.28);
}
.btn--primary:active { transform: translateY(1px); box-shadow: 0 3px 10px rgba(15,42,74,.22); }
.btn--primary:hover { background: var(--gold); color: var(--ink); }

.btn--ghost {
    background: transparent;
    color: var(--text-2);
    border: 1.5px solid var(--line);
    min-height: 48px;
    font-size: 15px;
}
.btn--ghost:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- 8. 语言选择 ---------- */
.entry-form { display: flex; flex-direction: column; gap: 12px; }

.entry-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    cursor: pointer;
    transition: border-color .18s, background-color .18s, box-shadow .18s, transform .1s;
    background: #fff;
}
.entry-item:active { transform: scale(.992); }
.entry-item input { position: absolute; opacity: 0; pointer-events: none; }

.entry-item.is-selected {
    border-color: var(--ink);
    background: #FBF7EF;
    box-shadow: 0 0 0 3px rgba(15,42,74,.06);
}

.entry-item__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.entry-item__title { font-size: 16px; font-weight: 600; color: var(--text); }
.entry-item__hint { font-size: 12px; color: var(--text-2); }

.entry-item__chev {
    font-size: 22px;
    color: var(--line);
    font-weight: 300;
    transition: transform .2s, color .2s;
    line-height: 1;
}
.entry-item.is-selected .entry-item__chev {
    color: var(--ink);
    transform: translateX(2px);
}

/* 单选圆点 */
.entry-item::before {
    content: '';
    width: 20px; height: 20px;
    border: 2px solid var(--line);
    border-radius: 50%;
    flex-shrink: 0;
    transition: border-color .18s;
}
.entry-item.is-selected::before {
    border-color: var(--ink);
    background: radial-gradient(circle, var(--ink) 0 5.5px, #fff 6px);
}

/* ---------- 9. Mini Info（首页底部） ---------- */
.mini-info {
    display: flex;
    justify-content: space-around;
    background: var(--card);
    border-radius: 14px;
    padding: 16px 6px;
    box-shadow: var(--shadow-1);
    border: 1px solid rgba(217,210,194,.4);
    margin-bottom: 16px;
}
.mini-info__col { text-align: center; }
.mini-info__num {
    font-family: var(--num-font);
    font-size: 22px;
    font-weight: 800;
    color: var(--ink);
    display: block;
    line-height: 1.2;
}
.mini-info__label {
    font-size: 11px;
    color: var(--text-2);
    letter-spacing: .04em;
}

/* ---------- 10. Footer ---------- */
.footer-credit {
    text-align: center;
    font-size: 11px;
    color: rgba(92,92,92,.75);
    margin-top: 18px;
    padding: 6px 0;
}
.footer-credit--inline { margin-top: 6px; }

/* ============================================================
   答题页交替背景（黑白线稿 + 蓝线稿）
   ============================================================ */
.bg-alt {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.bg-alt__layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 55%;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1.6s ease-in-out;
    will-change: opacity;
}
/* 黑白线稿（image#1） */
.bg-alt__layer--ink {
    background-image: url('assets/images/campus-line.png');
    opacity: 1;
    filter: contrast(0.85) brightness(1.08);
}
/* 蓝线稿（image#2） */
.bg-alt__layer--blue {
    background-image: url('assets/images/campus-line-blue.png');
    opacity: 0;
    filter: hue-rotate(170deg) saturate(0.6) brightness(1.12);
}
/* 切换：当 .bg-alt 处于第二个周期时翻转 */
.bg-alt.is-cycle-2 .bg-alt__layer--ink  { opacity: 0; }
.bg-alt.is-cycle-2 .bg-alt__layer--blue { opacity: 1; }
.bg-alt.is-cycle-3 .bg-alt__layer--ink  { opacity: 1; }
.bg-alt.is-cycle-3 .bg-alt__layer--blue { opacity: 0; }

/* 顶部 + 底部 渐变蒙版：保证内容可读 */
.bg-alt__veil {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(247,244,236,.94) 0%, rgba(247,244,236,.78) 14%, rgba(247,244,236,.74) 80%, rgba(247,244,236,.96) 100%),
        radial-gradient(ellipse at center, transparent 35%, rgba(247,244,236,.7) 100%);
    pointer-events: none;
}

/* ============================================================
   答题页 (play)
   ============================================================ */
.play-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 0 4px;
}

.q-number {
    font-family: var(--num-font);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    background: var(--card);
    padding: 6px 14px;
    border-radius: 999px;
    box-shadow: var(--shadow-1);
    border: 1px solid rgba(217,210,194,.4);
}
.q-number span { color: var(--gold); font-size: 17px; }

/* 进度小圆点 */
.progress-dots { display: flex; align-items: center; gap: 7px; }
.progress-dots .dot {
    width: 22px; height: 6px;
    border-radius: 999px;
    transition: background-color .25s, width .3s;
}
.dot--todo { background: #E2DDD1; }
.dot--done { background: var(--ink); }
.dot--current {
    background: var(--gold);
    width: 30px;
}

/* 题目卡片 */
.q-card {
    padding: 26px 24px 24px;
    background: var(--card);
    box-shadow: 0 10px 32px rgba(15, 42, 74, 0.14);
    animation: riseIn .4s ease-out both;
    transition: transform .24s ease, opacity .24s ease;
}
.q-card--out { transform: translateX(-28px) rotate(-2deg); opacity: 0; }

.q-stem { margin-bottom: 22px; }
.q-stem__cn { font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1.55; }
.q-stem__en {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.6;
    font-style: italic;
    border-left: 3px solid var(--gold-soft);
    padding-left: 10px;
}

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

.option {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 13px 16px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    text-align: left;
    transition: border-color .16s, background-color .16s, box-shadow .16s, transform .08s;
    background: #fff;
    width: 100%;
}
.option:not([disabled]):active { transform: scale(.99); }
.option:not([disabled]):hover { border-color: var(--ink); box-shadow: var(--shadow-1); }

.option__letter {
    flex-shrink: 0;
    width: 30px; height: 30px;
    border-radius: 9px;
    background: #F1EDE2;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    transition: background-color .16s, color .16s;
}
.option__text {
    flex: 1;
    font-size: 15px;
    color: var(--text);
    line-height: 1.45;
    display: flex;
    flex-direction: column;
}
.option__text-en { font-size: 12px; color: var(--text-2); font-style: italic; margin-top: 2px; }

/* 正确 */
.option--correct {
    border-color: var(--success);
    background: var(--success-bg);
}
.option--correct .option__letter { background: var(--success); color: #fff; }
.option--correct .option__text { color: #0E5C39; font-weight: 600; }

/* 错误 */
.option--wrong {
    border-color: var(--danger);
    background: var(--danger-bg);
    animation: shake .45s ease;
}
.option--wrong .option__letter { background: var(--danger); color: #fff; }
.option--wrong .option__text { color: var(--danger); font-weight: 600; }

/* 其它置灰 */
.option--dim { opacity: .5; }

/* 反馈条 */
.feedback {
    margin: 18px 2px 0;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .25s, transform .25s;
}
.feedback.is-visible { opacity: 1; transform: translateY(0); }
.feedback svg { width: 20px; height: 20px; flex-shrink: 0; }
.feedback--ok { background: var(--success-bg); color: var(--success); border: 1px solid rgba(27,122,79,.3); }
.feedback--bad { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(192,57,43,.3); }

/* ============================================================
   结算页 (result)
   ============================================================ */
.card--result { text-align: center; }

.score-circle {
    width: 180px; height: 180px;
    margin: 6px auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: conic-gradient(var(--ink) calc(var(--pct, 0) * 1%), #ECE6D9 0);
    position: relative;
}
.score-circle::before {
    content: '';
    position: absolute;
    inset: 12px;
    background: var(--card);
    border-radius: 50%;
}
.score-circle__inner {
    position: relative;
    z-index: 1;
    text-align: center;
}
.score-hero {
    font-family: var(--num-font);
    font-size: 62px;
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
}
.score-hero__unit { font-size: 15px; color: var(--text-2); margin-top: 4px; }

.score-badge {
    display: inline-block;
    font-size: 15px;
    font-weight: 700;
    padding: 6px 20px;
    border-radius: 999px;
    margin-top: 2px;
}
.score-badge--master { background: linear-gradient(120deg, var(--gold), #E6CF8F); color: var(--ink); }
.score-badge--great { background: var(--ink); color: var(--gold-soft); }
.score-badge--fair { background: #E9E4D8; color: var(--text); }
.score-badge--try-again { background: var(--danger-bg); color: var(--danger); }

.score-quote {
    margin-top: 14px;
    font-size: 15px;
    color: var(--text-2);
    line-height: 1.7;
    padding: 0 6px;
}

/* 每题回顾 */
.answer-review {
    margin: 20px 0 4px;
    border-top: 1px dashed var(--line);
    padding-top: 14px;
}
.answer-review__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 4px;
    font-size: 14px;
    color: var(--text-2);
}
.answer-review__icon {
    font-size: 16px;
    font-weight: 700;
}
.answer-review__icon.is-ok { color: var(--success); }
.answer-review__icon.is-bad { color: var(--danger); }

/* ============================================================
   尾页 (thanks)
   ============================================================ */
.page--thanks { background: #FBF9F2; }
.bg-texture {
    position: fixed; inset: 0;
    background-image: url('assets/images/campus-line.png');
    background-size: cover;
    background-position: center 70%;
    opacity: .05;
    pointer-events: none;
    z-index: 0;
}

.card--thanks {
    text-align: center;
    padding: 30px 24px 34px;
}
.thanks-logo {
    width: 190px;
    margin: 4px auto 20px;
}
.thanks-title { font-size: 20px; font-weight: 700; color: var(--ink); }
.thanks-desc {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.8;
}

.mini-score {
    display: inline-block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-2);
    background: var(--success-bg);
    color: var(--success);
    padding: 4px 16px;
    border-radius: 999px;
}
.mini-score strong { font-size: 16px; }

/* 二维码 */
.qr-wrap { margin: 22px auto 6px; }
.qr-frame {
    width: 216px; height: 216px;
    margin: 0 auto;
    background: #fff;
    border-radius: 24px;
    padding: 10px;
    border: 4px solid var(--gold);
    box-shadow: var(--shadow-2);
    position: relative;
}
/* 二维码四角花框 */
.qr-frame::before, .qr-frame::after {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    border: 3px solid var(--gold);
}
.qr-frame::before { top: -6px; left: -6px; border-right: none; border-bottom: none; border-top-left-radius: 10px; }
.qr-frame::after { bottom: -6px; right: -6px; border-left: none; border-top: none; border-bottom-right-radius: 10px; }
.qr-frame__img {
    width: 100%; height: 100%;
    object-fit: contain;
    border-radius: 14px;
}
.qr-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-2);
    letter-spacing: .08em;
}
.qr-hint::before { content: '⌄'; display: block; color: var(--gold); font-size: 18px; margin-bottom: 2px; }

.thanks-actions .btn--block { margin-top: 18px; }

/* 吉祥物 */
.mascot--thanks {
    position: absolute;
    right: -6px;
    bottom: -8px;
    width: 92px;
    opacity: .92;
    pointer-events: none;
}

/* ============================================================
   动效
   ============================================================ */
@keyframes riseIn {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 深色模式下文案可读性保持（遵循浅色设计，仅深色系统兜底） */
@media (prefers-color-scheme: dark) {
    :root {
        --paper: #F7F4EC;
    }
}

/* 横屏 / 平板：双列选项 */
@media (min-width: 640px) and (orientation: landscape) {
    .q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

/* ============================================================
   二维码弹层（结算页 2s 自动弹出）
   ============================================================ */
body.has-popover { overflow: hidden; }

.qr-popover {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .35s ease;
}
.qr-popover.is-open {
    opacity: 1;
    pointer-events: auto;
}

.qr-popover__mask {
    position: absolute;
    inset: 0;
    background: rgba(10, 30, 53, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.qr-popover__panel {
    position: relative;
    background: var(--card);
    border-radius: 22px;
    padding: 30px 26px 26px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 18px 48px rgba(10, 30, 53, .35);
    text-align: center;
    transform: translateY(16px) scale(.96);
    transition: transform .45s cubic-bezier(.22,1,.36,1);
}
.qr-popover.is-open .qr-popover__panel {
    transform: translateY(0) scale(1);
}

.qr-popover__close {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #F1EDE2;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .2s;
}
.qr-popover__close:hover { background: var(--gold-soft); }
.qr-popover__close svg { width: 16px; height: 16px; }

.qr-popover__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 16px;
    letter-spacing: .02em;
}

.qr-popover__frame {
    width: 220px;
    height: 220px;
    margin: 0 auto 10px;
    background: #fff;
    border-radius: 22px;
    padding: 10px;
    border: 4px solid var(--gold);
    box-shadow: 0 8px 24px rgba(15, 42, 74, .15);
    position: relative;
}
.qr-popover__frame::before,
.qr-popover__frame::after {
    content: '';
    position: absolute;
    width: 22px; height: 22px;
    border: 3px solid var(--gold);
}
.qr-popover__frame::before {
    top: -8px; left: -8px;
    border-right: none; border-bottom: none;
    border-top-left-radius: 12px;
}
.qr-popover__frame::after {
    bottom: -8px; right: -8px;
    border-left: none; border-top: none;
    border-bottom-right-radius: 12px;
}
.qr-popover__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

.qr-popover__hint {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 18px;
    letter-spacing: .06em;
}
.qr-popover__hint::before {
    content: '⌄';
    display: block;
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 4px;
}

.qr-popover .btn--block { margin-top: 4px; }
