/* ========================================
   忍者卷軸 UI 系統 (Ninja Scroll System)
   三明治切圖法：頂部木條 + 中間紙張 + 底部木條
   ======================================== */

/* Google Font - 書法字體 */
@import url('https://fonts.googleapis.com/css2?family=Yuji+Syuku&display=swap');

/* ========================================
   卷軸容器
   ======================================== */

.ninja-scroll {
    position: relative;
    max-width: 672px; /* max-w-2xl - 一般模式 */
    margin: 0 auto;
    padding: 0 1rem;
    /* 強烈的立體陰影 - 讓卷軸浮起來 */
    filter: drop-shadow(0 25px 50px rgba(0, 0, 0, 0.15));
}

/* 自訂練習 - 更寬的卷軸 */
.ninja-scroll.scroll-wide {
    max-width: 896px; /* max-w-4xl */
}

@media (min-width: 768px) {
    .ninja-scroll {
        padding: 0;
    }
}

/* 頂部木條 */
.ninja-scroll-top {
    height: 16px;
    background: linear-gradient(180deg, #4a3728 0%, #2c241b 50%, #1a1512 100%);
    border-radius: 4px 4px 0 0;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}

/* 木紋效果 */
.ninja-scroll-top::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px,
        rgba(0, 0, 0, 0.1) 2px,
        transparent 4px
    );
    border-radius: 4px 4px 0 0;
}

/* 卷軸軸心裝飾 */
.ninja-scroll-top::after {
    content: '';
    position: absolute;
    left: 50%;
    top: -4px;
    transform: translateX(-50%);
    width: 40px;
    height: 8px;
    background: linear-gradient(180deg, #8B4513 0%, #5D3A1A 100%);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 主體紙張區域 */
.ninja-scroll-body {
    background: #fdfbf7;
    border-left: 3px solid #8B0000;
    border-right: 3px solid #8B0000;
    padding: 2rem 1.5rem;
    position: relative;
    box-shadow: 
        /* 內陰影 - 紙張質感 */
        inset 0 0 30px rgba(139, 0, 0, 0.05),
        inset 0 0 10px rgba(0, 0, 0, 0.03),
        /* 外陰影 - 與背景分離 */
        0 10px 40px rgba(0, 0, 0, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.08);
}

/* 紙張紋理 */
.ninja-scroll-body::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* 底部木條 */
.ninja-scroll-bottom {
    height: 16px;
    background: linear-gradient(180deg, #1a1512 0%, #2c241b 50%, #4a3728 100%);
    border-radius: 0 0 4px 4px;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 -1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}

.ninja-scroll-bottom::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px,
        rgba(0, 0, 0, 0.1) 2px,
        transparent 4px
    );
    border-radius: 0 0 4px 4px;
}

/* 底部軸心裝飾 */
.ninja-scroll-bottom::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    transform: translateX(-50%);
    width: 40px;
    height: 8px;
    background: linear-gradient(180deg, #5D3A1A 0%, #8B4513 100%);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ========================================
   任務標題區
   ======================================== */

.mission-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed rgba(139, 0, 0, 0.3);
}

.mission-title {
    font-family: 'Yuji Syuku', serif;
    font-size: 1.8rem;
    color: #1c1917;
    margin: 0 0 0.5rem 0;
    letter-spacing: 0.1em;
}

/* 桌面版標題更大 */
@media (min-width: 768px) {
    .mission-title {
        font-size: 2.25rem; /* text-4xl */
    }
}

/* 模式特定顏色 */
.mission-title.quick { color: #1c1917; }
.mission-title.custom { color: #1c1917; }
.mission-title.ai { color: #4a5568; }
.mission-title.weakness { color: #8B0000; }

.mission-subtitle {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0;
}

@media (min-width: 768px) {
    .mission-subtitle {
        font-size: 1rem;
    }
}

/* ========================================
   表單樣式 - 忍者工具風格
   ======================================== */

/* 選項網格 */
.ninja-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* 桌面版 - 固定 3 欄 */
@media (min-width: 768px) {
    .ninja-options-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

/* 單選項目 - 手裏劍 */
.ninja-option {
    position: relative;
}

.ninja-option input[type="radio"],
.ninja-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ninja-option-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(139, 0, 0, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Yuji Syuku', serif;
    color: #1c1917;
}

.ninja-option-label:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(139, 0, 0, 0.4);
}

/* 選中狀態 */
.ninja-option input:checked + .ninja-option-label {
    background: rgba(139, 0, 0, 0.1);
    border-color: #8B0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

/* 手裏劍圖標 (Radio) */
.ninja-shuriken {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #64748b;
    border-radius: 50%;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ninja-option input[type="radio"]:checked + .ninja-option-label .ninja-shuriken {
    border-color: transparent;
    background: url('/images/practice/icon-shuriken.png') center/contain no-repeat;
    animation: shuriken-spin 0.5s ease-out;
}

@keyframes shuriken-spin {
    from { transform: rotate(0deg) scale(0.5); }
    to { transform: rotate(360deg) scale(1); }
}

/* 苦無圖標 (Checkbox) */
.ninja-kunai {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #64748b;
    border-radius: 4px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ninja-option input[type="checkbox"]:checked + .ninja-option-label .ninja-kunai {
    border-color: transparent;
    background: url('/images/practice/icon-kunai.png') center/contain no-repeat;
    animation: kunai-stab 0.3s ease-out;
}

@keyframes kunai-stab {
    0% { transform: translateY(-10px) scale(0.8); opacity: 0; }
    50% { transform: translateY(2px) scale(1.1); }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* ========================================
   範圍選擇區（自訂練習用）
   ======================================== */

.ninja-range-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* 寬版卷軸的範圍網格 - 4 欄 */
.scroll-wide .ninja-range-grid {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
    .scroll-wide .ninja-range-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .scroll-wide .ninja-range-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
    
    .ninja-range-grid {
        gap: 1rem;
    }
}

.ninja-range-item {
    position: relative;
}

.ninja-range-item input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ninja-range-label {
    display: block;
    padding: 0.875rem 1rem;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(139, 0, 0, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

/* 桌面版 - 更大的點擊區域 */
@media (min-width: 768px) {
    .ninja-range-label {
        padding: 1.25rem 1rem;
    }
}

.ninja-range-label:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(139, 0, 0, 0.4);
}

.ninja-range-item input:checked + .ninja-range-label {
    background: rgba(139, 0, 0, 0.1);
    border-color: #8B0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

.ninja-range-title {
    font-family: 'Yuji Syuku', serif;
    font-size: 1rem;
    color: #1c1917;
    margin-bottom: 0.25rem;
}

.ninja-range-preview {
    font-size: 0.8rem;
    color: #64748b;
}

/* 苦無標記（角落） */
.ninja-range-item input:checked + .ninja-range-label::before {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: url('/images/practice/icon-kunai.png') center/contain no-repeat;
}

/* ========================================
   題數選擇
   ======================================== */

.ninja-count-select {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-family: 'Yuji Syuku', serif;
}

.ninja-count-select label {
    color: #1c1917;
    font-size: 1rem;
}

.ninja-count-select select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid rgba(139, 0, 0, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.8);
    font-family: 'Yuji Syuku', serif;
    font-size: 1rem;
    color: #1c1917;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B0000' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.ninja-count-select select:focus {
    outline: none;
    border-color: #8B0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

/* ========================================
   開始按鈕 - 任務啟動
   ======================================== */

.ninja-start-btn {
    display: block;
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(180deg, #8B0000 0%, #6B0000 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Yuji Syuku', serif;
    font-size: 1.2rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 12px rgba(139, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.ninja-start-btn:hover {
    transform: scale(1.02);
    box-shadow: 
        0 6px 16px rgba(139, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.ninja-start-btn:active {
    transform: scale(0.98);
}

/* 印章效果 */
.ninja-start-btn::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* ========================================
   替代連結區
   ======================================== */

.ninja-alt-links {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(139, 0, 0, 0.2);
    text-align: center;
}

.ninja-alt-link {
    display: inline-block;
    margin: 0.5rem 0;
    color: #8B0000;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.ninja-alt-link:hover {
    color: #6B0000;
    text-decoration: underline;
}

.ninja-alt-link .new-badge {
    display: inline-block;
    padding: 2px 6px;
    background: #eab308;
    color: #1c1917;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ========================================
   分區標題
   ======================================== */

.ninja-section-title {
    font-family: 'Yuji Syuku', serif;
    font-size: 1.1rem;
    color: #1c1917;
    text-align: center;
    margin: 1.5rem 0 1rem 0;
    position: relative;
}

.ninja-section-title::before,
.ninja-section-title::after {
    content: '〜';
    color: rgba(139, 0, 0, 0.4);
    margin: 0 0.5rem;
}

/* ========================================
   響應式調整
   ======================================== */

@media (max-width: 640px) {
    .ninja-scroll {
        margin: 0 1rem;
    }
    
    .ninja-scroll-body {
        padding: 1.5rem 1rem;
    }
    
    .mission-title {
        font-size: 1.5rem;
    }
    
    .ninja-options-grid {
        grid-template-columns: 1fr;
    }
    
    .ninja-range-grid {
        grid-template-columns: 1fr;
    }
    
    .ninja-start-btn {
        font-size: 1.1rem;
        padding: 0.875rem 1.5rem;
    }
}

/* ========================================
   深色模式
   ======================================== */

[data-theme="dark"] .ninja-scroll-body {
    background: #2a2520;
    box-shadow: 
        inset 0 0 30px rgba(139, 0, 0, 0.1),
        inset 0 0 10px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .mission-title {
    color: #fdfbf7;
}

[data-theme="dark"] .mission-title.weakness {
    color: #ef4444;
}

[data-theme="dark"] .ninja-option-label,
[data-theme="dark"] .ninja-range-label {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(139, 0, 0, 0.3);
    color: #fdfbf7;
}

[data-theme="dark"] .ninja-option-label:hover,
[data-theme="dark"] .ninja-range-label:hover {
    background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ninja-option input:checked + .ninja-option-label,
[data-theme="dark"] .ninja-range-item input:checked + .ninja-range-label {
    background: rgba(139, 0, 0, 0.2);
}

[data-theme="dark"] .ninja-range-title {
    color: #fdfbf7;
}

[data-theme="dark"] .ninja-section-title {
    color: #fdfbf7;
}

[data-theme="dark"] .ninja-alt-link {
    color: #ef4444;
}

[data-theme="dark"] .ninja-count-select select {
    background-color: rgba(0, 0, 0, 0.3);
    color: #fdfbf7;
    border-color: rgba(139, 0, 0, 0.4);
}

/* ========================================
   忍者卷軸內的原有元件覆蓋
   讓 practice-range-item 等元件適應卷軸風格
   ======================================== */

/* 覆蓋 practice-range-grid */
.ninja-scroll-body .practice-range-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* 寬版卷軸 - practice-range-grid 響應式 */
.scroll-wide .ninja-scroll-body .practice-range-grid {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
    .scroll-wide .ninja-scroll-body .practice-range-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .scroll-wide .ninja-scroll-body .practice-range-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
    
    .ninja-scroll-body .practice-range-grid {
        gap: 1rem;
    }
}

/* 覆蓋 practice-range-item */
.ninja-scroll-body .practice-range-item {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(139, 0, 0, 0.2);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.ninja-scroll-body .practice-range-item:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(139, 0, 0, 0.4);
}

.ninja-scroll-body .practice-range-item.checked,
.ninja-scroll-body .practice-range-item:has(input:checked) {
    background: rgba(139, 0, 0, 0.1);
    border-color: #8B0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

.ninja-scroll-body .practice-range-content {
    text-align: center;
}

.ninja-scroll-body .practice-range-title {
    font-family: 'Yuji Syuku', serif;
    color: #1c1917;
}

.ninja-scroll-body .practice-range-preview {
    color: #64748b;
    font-size: 0.85rem;
}

/* 覆蓋 practice-section-title */
.ninja-scroll-body .practice-section-title {
    font-family: 'Yuji Syuku', serif;
    font-size: 1.1rem;
    color: #1c1917;
    text-align: center;
    margin: 1.5rem 0 1rem 0;
    position: relative;
}

.ninja-scroll-body .practice-section-title::before {
    content: '〜';
    color: rgba(139, 0, 0, 0.4);
    margin-right: 0.5rem;
}

.ninja-scroll-body .practice-section-title::after {
    content: '〜';
    color: rgba(139, 0, 0, 0.4);
    margin-left: 0.5rem;
}

/* 覆蓋 practice-question-count */
.ninja-scroll-body .practice-question-count {
    margin: 1.5rem 0;
}

/* 覆蓋 practice-amount-grid */
.ninja-scroll-body .practice-amount-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.ninja-scroll-body .practice-amount-option {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(139, 0, 0, 0.2);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.ninja-scroll-body .practice-amount-option:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(139, 0, 0, 0.4);
}

.ninja-scroll-body .practice-amount-option:has(input:checked) {
    background: rgba(139, 0, 0, 0.1);
    border-color: #8B0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

.ninja-scroll-body .amount-title {
    font-family: 'Yuji Syuku', serif;
    color: #1c1917;
}

.ninja-scroll-body .amount-detail {
    color: #64748b;
    font-size: 0.85rem;
}

/* 覆蓋 practice-start-btn */
.ninja-scroll-body .practice-start-btn {
    display: block;
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(180deg, #8B0000 0%, #6B0000 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Yuji Syuku', serif;
    font-size: 1.2rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 12px rgba(139, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.ninja-scroll-body .practice-start-btn:hover {
    transform: scale(1.02);
    box-shadow: 
        0 6px 16px rgba(139, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* 覆蓋 practice-alt-link */
.ninja-scroll-body .practice-alt-link {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(139, 0, 0, 0.2);
    text-align: center;
}

.ninja-scroll-body .practice-alt-link a {
    color: #8B0000;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.ninja-scroll-body .practice-alt-link a:hover {
    color: #6B0000;
    text-decoration: underline;
}

/* 深色模式覆蓋 */
[data-theme="dark"] .ninja-scroll-body .practice-range-item,
[data-theme="dark"] .ninja-scroll-body .practice-amount-option {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(139, 0, 0, 0.3);
}

[data-theme="dark"] .ninja-scroll-body .practice-range-item:hover,
[data-theme="dark"] .ninja-scroll-body .practice-amount-option:hover {
    background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ninja-scroll-body .practice-range-title,
[data-theme="dark"] .ninja-scroll-body .amount-title,
[data-theme="dark"] .ninja-scroll-body .practice-section-title {
    color: #fdfbf7;
}
