/*
 * H5报名页样式（移动优先 + PC 自适应）
 * 自适应策略：
 *   1. 固定 16px 根字号 + px 尺寸体系，几何确定，任何视口下组件不被缩放变形；
 *   2. 移动端单列全宽，PC（>=768px）卡片居中 + 表单双列；
 *   3. 防移位：错误提示区预留固定高度、按钮跟随文档流、无 position:fixed、图标纯 CSS 绘制；
 *   4. 视觉：渐变头部 + 白色表单面板，标题与元信息居中。
 */

:root {
    --primary: #2b6cff;
    --primary-light: #4f8dff;
    --primary-dark: #1f56d6;
    --text: #1b1f27;
    --text-sub: #4b5563;
    --text-muted: #98a2b3;
    --border: #e6eaf2;
    --bg: #f4f6fa;
    --card: #ffffff;
    --danger: #e5484d;
    --success: #12b76a;
    --radius-sm: 12px;
    --radius-md: 14px;
    --radius-lg: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性优先级兜底：避免 .btn-submit 等 display 声明覆盖它 */
[hidden] { display: none !important; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    /* 顶部淡蓝渐变，衬托头部卡片 */
    background: linear-gradient(180deg, #e9f0ff 0%, var(--bg) 260px, var(--bg) 100%);
    min-height: 100vh;
    min-height: 100dvh;
}

.page {
    width: 100%;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ========== 状态区（加载中 / 异常 / 成功） ========== */
.state {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
}
.state[hidden] { display: none; }
.state-text { margin-top: 18px; font-size: 15px; color: var(--text-sub); }
.state-title { font-size: 20px; font-weight: 600; margin-top: 18px; }
.state-sub { margin-top: 6px; font-size: 13px; color: var(--text-muted); }

/* 加载指示器：纯 CSS 旋转环 */
.spinner {
    width: 34px; height: 34px;
    border: 3px solid rgba(43, 108, 255, 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 圆形图标（对勾/感叹号均用 CSS 绘制，无图片请求） */
.icon-circle {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.icon-success { background: #e7f7ee; }
.icon-error { background: #fdecec; }
/* 对勾：旋转的短边框 */
.icon-success-mark {
    width: 26px; height: 13px;
    border-left: 3px solid var(--success);
    border-bottom: 3px solid var(--success);
    transform: rotate(-45deg) translate(1px, -2px);
}
/* 感叹号：竖条 + 圆点 */
.icon-error-mark {
    width: 3px; height: 24px;
    background: var(--danger);
    border-radius: 2px;
    position: relative;
}
.icon-error-mark::after {
    content: "";
    position: absolute;
    left: 0; bottom: -11px;
    width: 3px; height: 3px;
    border-radius: 50%;
    background: var(--danger);
}

/* 成功页信息摘要 */
.summary {
    margin-top: 22px;
    width: 100%;
    max-width: 340px;
    text-align: left;
    background: #f7f9fc;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px 16px;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    font-size: 14px;
}
.summary-row + .summary-row { border-top: 1px dashed #e8edf5; }
.summary-row .summary-key { color: var(--text-muted); flex-shrink: 0; }
.summary-row .summary-val { text-align: right; word-break: break-all; font-weight: 500; }

/* ========== 报名卡片 ========== */
.card {
    width: 100%;
    animation: fadeUp 0.28s ease-out both;
}
.card[hidden] { display: none; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .card { animation: none; }
}

/* 头部：渐变色块，内容整体居中 */
.card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 26px 20px 34px;
    border-radius: 0 0 28px 28px;
    text-align: center;
    color: #fff;
}
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 12px;
    letter-spacing: 0.5px;
}
.card-title {
    margin-top: 12px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    word-break: break-word;
}
/* 元信息：整行居中，时间文本可换行，名额用胶囊 */
.card-meta {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.meta-time {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    word-break: break-word;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
}
.chip .chip-key { opacity: 0.8; }
.chip .chip-val { font-weight: 500; }

/* 表单面板：上移与头部叠压，形成层次 */
.card-body {
    margin-top: -20px;
    background: var(--card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 22px 20px 28px;
    box-shadow: 0 -6px 24px rgba(20, 40, 90, 0.06);
}

.card-desc {
    margin-bottom: 20px;
    padding: 12px 14px;
    background: #f5f8ff;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-sub);
    white-space: pre-line;
    word-break: break-word;
}
.card-desc:empty { display: none; }

/* ========== 表单 ========== */
.field { margin-bottom: 6px; }
.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
}
.req { color: var(--danger); margin-left: 2px; }

.field-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    font-size: 15px;
    color: var(--text);
    background: #f7f9fc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
}
.field-input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(43, 108, 255, 0.12);
}
.field-input::placeholder { color: #b3bccb; }

/* 错误提示：始终占位（固定高度），出现时不推动下方元素 */
.field-error {
    min-height: 20px;
    margin-top: 2px;
    font-size: 12px;
    line-height: 20px;
    color: var(--danger);
}

/* 性别分段选择器：等宽固定高度，切换只改样式不改尺寸 */
.segmented {
    display: flex;
    gap: 4px;
    height: 48px;
    padding: 4px;
    background: #f1f4f9;
    border-radius: var(--radius-sm);
}
.seg {
    flex: 1;
    height: 100%;
    font-size: 15px;
    color: var(--text-sub);
    background: transparent;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}
.seg-active {
    background: #fff;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.08);
}

/* 提交按钮：文档流内全宽，非固定定位 */
.btn-submit {
    display: block;
    width: 100%;
    height: 50px;
    margin-top: 14px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 20px rgba(43, 108, 255, 0.28);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: transform 0.1s, box-shadow 0.16s, background 0.16s;
}
.btn-submit:active {
    transform: scale(0.99);
    box-shadow: 0 4px 12px rgba(43, 108, 255, 0.24);
}
.btn-submit:disabled {
    background: #b9cdf5;
    box-shadow: none;
    cursor: not-allowed;
}
.form-tip {
    margin-top: 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-muted);
    text-align: center;
}
.btn-retry { max-width: 240px; margin: 24px auto 0; }

/* ========== 提示弹窗（重复报名 / 操作频繁） ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    animation: maskIn 0.18s ease-out;
}
.modal-card {
    position: relative;
    width: 100%;
    max-width: 320px;
    padding: 24px 20px 20px;
    background: #fff;
    border-radius: 18px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(16, 24, 40, 0.2);
    animation: modalIn 0.2s ease-out;
}
.modal-title { font-size: 17px; font-weight: 600; line-height: 1.4; }
.modal-text {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-sub);
    word-break: break-word;
}
.modal-btn { margin-top: 20px; height: 46px; font-size: 15px; }
.modal-btn:focus { outline: none; }
.modal-btn:focus-visible {
    outline: 2px solid rgba(43, 108, 255, 0.45);
    outline-offset: 2px;
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .modal-mask, .modal-card { animation: none; }
}

/* ========== PC 端（>=768px）：卡片式居中 + 双列表单 ========== */
@media (min-width: 768px) {
    body { padding: 48px 24px; }
    .card {
        max-width: 680px;
        margin: 0 auto;
        border-radius: var(--radius-lg);
        overflow: hidden;
        box-shadow: 0 24px 60px rgba(16, 24, 40, 0.1);
    }
    .card-header { padding: 36px 40px 32px; border-radius: 0; }
    .card-title { font-size: 26px; }
    .card-body {
        margin-top: 0;
        padding: 28px 40px 32px;
        border-radius: 0;
        box-shadow: none;
    }
    .card-desc { font-size: 14px; margin-bottom: 24px; }
    #signupForm {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 20px;
        row-gap: 6px;
    }
    #signupForm .field { margin-bottom: 0; }
    /* 提交按钮与提示跨两列 */
    #signupForm .btn-submit {
        grid-column: 1 / 3;
        max-width: 320px;
        margin: 14px auto 0;
    }
    #signupForm .form-tip { grid-column: 1 / 3; }
    .state { min-height: 70vh; }
    .state-title { font-size: 22px; }
    .btn-retry { max-width: 280px; }
}

@media (min-width: 1200px) {
    body { padding-top: 64px; }
}
