/**
 * 门票系统 - 重新设计
 * 北欧极简风格 | 登机牌样式
 * 固定颜色主题：深海蓝、阳光黄、云灰蓝、晨雾白
 */

:root {
    /* 固定颜色主题 */
    --deep-sea-blue: #003D75;
    --sunshine-yellow: #FFCC00;
    --cloud-gray-blue: #5A7184;
    --morning-mist-white: #F0F4F8;

    /* 辅助颜色 */
    --text-primary: #1A1A1A;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.16);
}

/* ===== 1. 全局样式重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== 2. 遮罩层 ===== */
.ticket-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: overlayFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===== 3. 门票容器 ===== */
.ticket-container {
    position: relative;
    perspective: 1000px;
}

/* ===== 4. 门票主体 - 登机牌样式 ===== */
.boarding-pass {
    display: flex;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    width: 1000px;
    height: 400px;
    max-width: 95vw;
    position: relative;

    /* 2D渲染，避免抖动 */
    transform-style: flat;
    will-change: auto;
}

/* 撕开后调整容器 */
.boarding-pass.torn {
    width: 700px;
    height: auto;
    min-height: 400px;
}

/* ===== 5. 主体区域（70%）===== */
.ticket-main-section {
    flex: 0 0 70%;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 上半部分 - 蓝色背景（整体渐变的前70%） */
.ticket-main-top {
    background: linear-gradient(to right, #003D75 0%, #004E95 100%);
    padding: 6px 40px;
    position: relative;
    height: 91.2px;
    min-height: 91.2px;
    max-height: 91.2px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
}

/* 下半部分 - 白色背景 */
.ticket-main-bottom {
    background: white;
    padding: 36px 40px 40px 40px;
    flex: 1;
    position: relative;
}

/* 背景图片支持 */
.ticket-main-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
    pointer-events: none;
}

.ticket-main-section.has-background::before {
    opacity: 0.15;
}

.ticket-main-section.has-background .ticket-main-top::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 61, 117, 0.9) 0%, rgba(0, 86, 163, 0.9) 100%);
    z-index: 0;
}

/* 内容层 */
.ticket-main-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

/* Logo区域 */
.ticket-logo-area {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ticket-logo {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.ticket-logo-text {
    font-size: 9px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 标题区域 */
.ticket-title-area {
    margin-top: 0;
}

.ticket-title {
    font-size: 16px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    margin-bottom: 2px;
    letter-spacing: -0.3px;
}

.ticket-subtitle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 500;
    letter-spacing: 0.3px;
    line-height: 1.3;
}

/* 信息展示区 - 左侧网格+右侧二维码 */
.ticket-info-section {
    margin-top: 0;
    display: flex;
    gap: 20px;
    align-items: center;
}

/* 信息网格 */
.ticket-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 24px;
    flex: 1;
}

.ticket-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ticket-info-label {
    font-size: 10px;
    color: var(--deep-sea-blue);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.ticket-info-value {
    font-size: 14px;
    color: var(--deep-sea-blue);
    font-weight: 600;
    line-height: 1.3;
}

/* 页脚 - 简化布局 */
.ticket-main-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 61, 117, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ticket-organizer {
    font-size: 11px;
    color: rgba(0, 61, 117, 0.7);
    font-weight: 500;
}

.ticket-number {
    font-size: 10px;
    color: rgba(0, 61, 117, 0.6);
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* 主体二维码 - 信息网格右侧 */
.ticket-main-qr {
    width: 115px;
    height: 115px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.ticket-main-qr canvas,
.ticket-main-qr img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* ===== 6. 虚线分割线 ===== */
.ticket-divider {
    position: relative;
    width: 3px;
    background: repeating-linear-gradient(
        to bottom,
        var(--cloud-gray-blue) 0px,
        var(--cloud-gray-blue) 10px,
        transparent 10px,
        transparent 20px
    );
    flex-shrink: 0;
}

/* 半圆缺口 */
.ticket-divider::before,
.ticket-divider::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.88);
    border-radius: 50%;
}

.ticket-divider::before {
    top: -12px;
}

.ticket-divider::after {
    bottom: -12px;
}

/* ===== 7. 小票区域（30%）===== */
.ticket-stub-section {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* 小票上半部分 - 蓝色背景（整体渐变的后30%） */
.stub-top {
    background: linear-gradient(to right, #004E95 0%, #0056a3 100%);
    padding: 0 20px;
    text-align: center;
    height: 91.2px;
    min-height: 91.2px;
    max-height: 91.2px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stub-title {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 小票下半部分 - 白色背景 */
.stub-bottom {
    background: white;
    flex: 1;
    padding: 24px 20px 28px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
}

/* 参赛者信息 */
.stub-participant {
    text-align: center;
    margin-bottom: 12px;
}

.stub-participant-label {
    font-size: 9px;
    color: var(--deep-sea-blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    opacity: 0.7;
}

.stub-participant-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--deep-sea-blue);
}

/* 座位号 */
.stub-seat {
    margin-bottom: 12px;
}

.stub-seat-label {
    font-size: 9px;
    color: var(--deep-sea-blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    text-align: center;
    opacity: 0.7;
}

.stub-seat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--deep-sea-blue);
    text-align: center;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

/* 二维码 */
.stub-qr-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 12px;
}

.stub-qr-code {
    width: 85px;
    height: 85px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    padding: 4px;
}

.stub-qr-code canvas,
.stub-qr-code img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.stub-qr-placeholder {
    font-size: 48px;
    color: var(--border-color);
}

.stub-qr-hint {
    font-size: 9px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 条形码 */
.stub-barcode {
    margin-top: 12px;
    width: 100%;
    height: 40px;
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    padding: 4px;
}

.stub-barcode svg,
.stub-barcode canvas {
    max-width: 100%;
    max-height: 100%;
}

/* ===== 8. 切割圆球滑块 ===== */
.tear-slider-container {
    position: absolute;
    top: 0;
    left: 70%;
    transform: translateX(-50%);
    width: 3px;
    height: 400px;
    z-index: 100;
    pointer-events: none;
}

.tear-track {
    position: absolute;
    width: 100%;
    height: 100%;
    background: transparent;
}

.tear-slider {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 45px;
    height: 45px;
    background: rgba(255, 204, 0, 0.4);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    cursor: grab;
    pointer-events: all;
    box-shadow: 0 2px 12px rgba(255, 204, 0, 0.3),
                0 0 0 2px rgba(255, 255, 255, 0.3);
    transition: background 0.2s ease, transform 0.2s ease;
    user-select: none;
    border: 2px solid rgba(255, 204, 0, 0.6);
}

.tear-slider:hover {
    background: rgba(255, 204, 0, 0.5);
    transform: translateX(-50%) scale(1.1);
}

.tear-slider:active {
    cursor: grabbing;
    background: rgba(255, 204, 0, 0.6);
    transform: translateX(-50%) scale(0.95);
}

.tear-slider-icon {
    display: none;
}

.tear-hint {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: hintPulse 2s ease-in-out infinite;
    writing-mode: horizontal-tb;
    display: none; /* 隐藏"向下滑动"提示 */
}

@keyframes hintPulse {
    0%, 100% {
        opacity: 0.6;
        transform: translateX(-50%) translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) translateY(4px);
    }
}

/* ===== 9. 打印动画（3-5秒）===== */
.ticket-printing {
    animation: printTicket 4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes printTicket {
    0% {
        transform: translateX(-120%);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 打印进度条 */
.print-progress-container {
    position: absolute;
    bottom: -48px;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.print-progress-bar {
    height: 100%;
    background: var(--sunshine-yellow);
    border-radius: 2px;
    animation: printProgress 4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    box-shadow: 0 0 12px var(--sunshine-yellow);
}

@keyframes printProgress {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

/* ===== 10. 撕裂动效 ===== */
.boarding-pass.tearing {
    pointer-events: none;
    background: transparent !important;
    box-shadow: none !important;
}

/* 撕裂动画 - 小票向右飞出并旋转 */
.tearing .ticket-stub-section {
    animation: tearAwayStub 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transform-origin: left center;
}

/* 撕裂动画 - 主体轻微震动 */
.tearing .ticket-main-section {
    animation: mainShake 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes tearAwayStub {
    0% {
        transform: translateX(0) rotate(0deg);
        opacity: 1;
    }
    30% {
        transform: translateX(20px) rotate(3deg);
    }
    100% {
        transform: translateX(400px) rotate(25deg);
        opacity: 0;
    }
}

@keyframes mainShake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50% {
        transform: translateX(-3px);
    }
    20%, 40%, 60% {
        transform: translateX(3px);
    }
}

/* 撕开后 - 主体放大展示，移除背景 */
.boarding-pass.torn {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    animation: zoomToView 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    overflow: visible !important;
    width: auto !important;
    height: auto !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.boarding-pass.torn .ticket-main-section {
    border-radius: 16px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
    width: 700px;
    max-width: 90vw;
    flex: none !important;
}

@keyframes zoomToView {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.15);
    }
}

/* 撕开后 - 淡化遮罩层 */
.ticket-overlay.viewing {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(12px);
}

/* 撕开后 - 完全隐藏小票和分割线 */
.torn .ticket-stub-section {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.torn .ticket-divider {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    width: 0 !important;
}

/* 撕开后 - 隐藏滑块和进度条 */
.torn .tear-slider-container {
    display: none !important;
}

.torn .print-progress-container {
    display: none !important;
}

/* ===== 11. 收藏动画 ===== */
.stub-collecting {
    animation: collectToPocket 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes collectToPocket {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-100px) scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: translateY(0) scale(0.3);
        opacity: 0;
    }
}

/* ===== 12. 收藏展示 ===== */
.ticket-collection-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px;
    padding: 24px;
}

.ticket-thumbnail {
    position: relative;
    aspect-ratio: 3 / 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.ticket-thumbnail:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.ticket-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ticket-thumbnail-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 50%);
    display: flex;
    align-items: flex-end;
    padding: 12px;
}

.ticket-thumbnail-title {
    font-size: 12px;
    font-weight: 600;
    color: white;
    line-height: 1.3;
}

/* ===== 13. 响应式设计 ===== */
@media (max-width: 768px) {
    .boarding-pass {
        width: 95vw;
        flex-direction: column;
        min-height: auto;
    }

    .ticket-main-section {
        flex: 0 0 auto;
        padding: 32px 24px;
    }

    .ticket-stub-section {
        flex: 0 0 auto;
        padding: 24px;
    }

    .ticket-divider {
        width: 100%;
        height: 3px;
        background: repeating-linear-gradient(
            to right,
            var(--cloud-gray-blue) 0px,
            var(--cloud-gray-blue) 10px,
            transparent 10px,
            transparent 20px
        );
    }

    .ticket-divider::before,
    .ticket-divider::after {
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .ticket-divider::before {
        left: -12px;
    }

    .ticket-divider::after {
        right: -12px;
        left: auto;
    }

    .tear-slider-container {
        top: auto;
        bottom: 30%;
        left: 50%;
        transform: translate(-50%, 50%);
        width: 200px;
        height: 80px;
        flex-direction: row;
    }

    .tear-track {
        width: 100%;
        height: 4px;
    }
}

/* ===== 14. 辅助动画 ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== 15. 工具类 ===== */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.fade-out {
    animation: fadeOut 0.3s ease-out;
}

.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
