/* Questio Textbook Anti-Print & Security CSS */

@page {
    size: A4 portrait;
    margin: 0 !important;
}

@media print {
    body:not(.questio-allow-print-mode) {
        display: none !important;
        visibility: hidden !important;
    }
    body:not(.questio-allow-print-mode)::before {
        content: "⚠️ 본 교재는 종이 1회 인쇄가 완료되었거나 무단 PDF 저장이 금지되어 있습니다.\A (Questio.co.kr - 지식재산권 및 무단 전재 보호)";
        white-space: pre-wrap;
        display: block !important;
        font-size: 20pt !important;
        font-weight: 800 !important;
        color: #ef4444 !important;
        text-align: center !important;
        padding-top: 150px !important;
        background: #ffffff !important;
        height: 100vh !important;
    }

    html, body {
        width: 210mm !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body.questio-allow-print-mode {
        display: block !important;
        visibility: visible !important;
        background: #ffffff !important;
        color: #000000 !important;
        -webkit-user-select: auto !important;
        user-select: auto !important;
    }

    body.questio-allow-print-mode #questio-lock-overlay,
    body.questio-allow-print-mode #questio-print-toolbar {
        display: none !important;
    }

    .cover {
        width: 210mm !important;
        height: 295mm !important;
        max-height: 295mm !important;
        margin: 0 auto !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        page-break-before: avoid !important;
        page-break-after: always !important;
        break-after: page !important;
        page-break-inside: avoid !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .cover-year {
        position: absolute !important;
        bottom: 25mm !important;
        right: 25mm !important;
    }

    .page-container {
        width: 210mm !important;
        height: 295mm !important;
        max-height: 295mm !important;
        margin: 0 auto !important;
        border: none !important;
        box-shadow: none !important;
        page-break-before: auto !important;
        page-break-after: always !important;
        break-after: page !important;
        page-break-inside: avoid !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    /* Print Legal Tracking Footer */
    body.questio-allow-print-mode::after {
        content: attr(data-print-footer-info);
        display: block !important;
        position: fixed;
        bottom: 8px;
        left: 0;
        width: 100%;
        text-align: center;
        font-size: 9.5pt;
        font-weight: bold;
        color: #dc2626 !important;
        border-top: 2px solid #dc2626;
        padding-top: 5px;
        z-index: 999999;
    }

    /* Page-by-page Print Tracking Watermark */
    body.questio-allow-print-mode .cover::after,
    body.questio-allow-print-mode .page-container::after {
        content: "🖨️ Questio 1회 전용 출력물 (무단 PDF 저장·유포 시 형사고발)";
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(-30deg);
        font-size: 24pt;
        font-weight: 900;
        color: rgba(220, 38, 38, 0.15) !important;
        pointer-events: none;
        white-space: nowrap;
        z-index: 9999;
    }
}

/* Lock State: Hide content children, keep overlay visible */
body.questio-locked > *:not(#questio-lock-overlay) {
    display: none !important;
}

body.questio-locked {
    background: #080c14 !important;
    overflow: hidden !important;
}

/* Global E-Book Cover Page Styles */
.cover { 
    width: 210mm; 
    height: 297mm; 
    background: linear-gradient(135deg, #0a2240 0%, #1d4ed8 100%); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    page-break-after: always; 
    position: relative; 
    overflow: hidden; 
    margin: 0 auto 30px auto; 
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}
.cover::before { 
    content: ''; 
    position: absolute; 
    top: 0; left: 0; right: 0; bottom: 0; 
    background: radial-gradient(circle at center, rgba(255,255,255,0.08) 0%, transparent 70%); 
}
.cover-inner { text-align: center; color: #fff; z-index: 1; padding: 40px; }
.cover-brand { font-size: 14pt; letter-spacing: 0.4em; color: #f59e0b; font-weight: 900; margin-bottom: 25px; font-family: 'Outfit', sans-serif; }
.cover-series { font-size: 18pt; color: #e2e8f0; margin-bottom: 15px; font-weight: 700; }
.cover-vol { font-size: 32pt; font-weight: 900; color: #ffffff; line-height: 1.3; margin-bottom: 25px; text-shadow: 0 4px 10px rgba(0,0,0,0.3); word-break: keep-all; }
.cover-univ { font-size: 24pt; font-weight: 700; color: #f8fafc; margin-bottom: 10px; }
.cover-sub { font-size: 15pt; color: #cbd5e1; margin-bottom: 45px; font-weight: 500; }
.cover-divider { width: 100px; height: 4px; background: linear-gradient(90deg, #f59e0b, #d97706); margin: 0 auto 45px; border-radius: 2px; box-shadow: 0 0 15px rgba(245,158,11,0.6); }
.cover-author { font-size: 12pt; color: #cbd5e1; line-height: 1.6; font-weight: 400; }
.cover-year { position: absolute; bottom: 40px; right: 50px; font-size: 11pt; color: rgba(255,255,255,0.5); z-index:1; font-weight: 700; letter-spacing: 0.1em; }

/* Global Page Container Centering */
.page-container {
    width: 210mm;
    min-height: 297mm;
    background: #ffffff;
    margin: 0 auto 30px auto;
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    page-break-after: always;
    overflow: hidden;
    padding: 20mm;
}

/* Disable selection */
.questio-protected {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* Watermark Layer */
#questio-watermark-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99998;
    opacity: 0.15;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='350' height='220'><text x='30' y='110' fill='%23000000' font-size='16' font-family='sans-serif' font-weight='bold' transform='rotate(-25 175 110)'>Questio.co.kr 무단복사·저장금지</text></svg>");
    background-repeat: repeat;
}

/* Security Print Control Toolbar (Top Fixed) */
#questio-print-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(135deg, #0b0f19, #141c30);
    border-bottom: 2px solid #00ffd5;
    padding: 0.8rem 1.5rem;
    z-index: 99999;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    font-family: 'Pretendard', sans-serif;
}

.questio-print-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.questio-print-btn {
    background: linear-gradient(135deg, #0064ff, #00ffd5);
    color: #080c14;
    font-weight: 800;
    padding: 0.6rem 1.4rem;
    border: none;
    border-radius: 50px;
    font-size: 0.92rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 255, 213, 0.3);
    transition: all 0.2s ease;
}

.questio-print-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 255, 213, 0.5);
}

.questio-print-btn.disabled {
    background: #374151 !important;
    color: #9ca3af !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Lock Overlay Modal */
#questio-lock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 12, 20, 0.95);
    backdrop-filter: blur(12px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Pretendard', sans-serif;
    color: #f3f4f6;
}

.questio-lock-card {
    background: #121a2c;
    border: 1px solid rgba(0, 255, 213, 0.3);
    border-radius: 24px;
    padding: 2.5rem;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.questio-lock-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.questio-lock-sub {
    font-size: 0.92rem;
    color: #9ca3af;
    margin-bottom: 1.8rem;
}

.questio-tab-buttons {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 1.5rem;
}

.questio-tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: #9ca3af;
    padding: 0.6rem;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.questio-tab-btn.active {
    background: rgba(0, 255, 213, 0.2);
    color: #00ffd5;
}

.questio-form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.questio-input-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: #00ffd5;
    margin-bottom: 0.4rem;
}

.questio-input-field {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    color: #ffffff;
    font-size: 0.95rem;
}

.questio-btn-submit {
    width: 100%;
    background: linear-gradient(135deg, #3b82f6, #00ffd5);
    color: #080c14;
    font-weight: 800;
    padding: 0.9rem;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
}

.questio-kakao-btn {
    display: block;
    margin-top: 1.5rem;
    background: #fee500;
    color: #000000;
    font-weight: 800;
    padding: 0.75rem;
    border-radius: 50px;
    text-decoration: none;
    font-size: 0.9rem;
}
