/* intro_char_select_styles.css */

/* ====================================================
   0. Body 模式背景控制
   ===================================================== */
body {
    transition: background-color 0.4s ease;
}

/* 介紹模式：深沉的鄉村風格 */
body.intro-mode {
    background-color: #1a120b;
}

/* 角色選擇模式：溫暖木質調漸層，清楚與介紹頁區分 */
body.char-select-mode {
    background: linear-gradient(135deg, #3a2a1a 0%, #6b4226 40%, #4a3520 100%);
    background-attachment: fixed;
}


/* ====================================================
   1. 分頁切換動畫
   ===================================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.section-fade-out {
    animation: fadeOutUp 0.35s ease forwards;
    pointer-events: none;
}

.section-fade-in {
    animation: fadeInUp 0.4s ease forwards;
}


/* ====================================================
   2. 介紹區塊 (Intro Section)
   ===================================================== */
#intro-section {
    background-image: url('../images/intro.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    border-radius: 12px;
    color: white;
    position: relative;
    min-height: 380px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: none;
    padding: 30px 24px;
    overflow: hidden;
}

/* 半透明遮罩讓文字更清晰 */
#intro-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    border-radius: 12px;
    z-index: 0;
}

#intro-section>* {
    position: relative;
    z-index: 1;
}

#intro-section h1 {
    color: #FFFFFF;
    font-size: clamp(1.8em, 5vw, 3em);
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow:
        2px 2px 6px rgba(0, 0, 0, 0.8),
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

#story-text {
    position: relative;
    min-height: 90px;
    overflow: hidden;
    width: min(90%, 600px);
    margin-top: 16px;
    z-index: 5;
}

#story-text p {
    font-size: clamp(1em, 2.5vw, 1.2em);
    background-color: rgba(0, 0, 0, 0.65);
    padding: 14px 18px;
    border-radius: 8px;
    position: absolute;
    width: calc(100% - 30px);
    left: 15px;
    top: 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    color: #f0f0f0;
    line-height: 1.5;
}

#story-text p.active-story-line {
    opacity: 1;
    transform: translateY(0);
}

#story-text p.fading-out {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.4s ease-in, transform 0.4s ease-in;
}


/* ====================================================
   3. 角色選擇區塊 (Character Selection Section)
   ===================================================== */
#character-selection-section {
    background-color: rgba(255, 255, 255, 0.82);
    border-radius: 12px;
    padding: 24px 20px 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.character-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.character-select-header h2 {
    margin: 0;
    flex-grow: 1;
    text-align: center;
    font-size: clamp(1.1em, 3vw, 1.5em);
}

/* 重置按鈕 */
.reset-button {
    padding: 7px 13px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: clamp(0.78em, 2vw, 0.9em);
    transition: background-color 0.25s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.reset-button:hover {
    background-color: #c82333;
}


/* ====================================================
   4. 角色卡片格式
   ===================================================== */

/* 四欄（寬螢幕預設） */
.character-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 8px;
    padding-bottom: 4px;
}

/* 定義掉落動畫 */
@keyframes jumpDown {
    0% {
        transform: translateY(-80px);
        opacity: 0;
    }

    60% {
        transform: translateY(12px);
        opacity: 1;
    }

    80% {
        transform: translateY(-4px);
        opacity: 1;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.character-card {
    position: relative;
    border: 3px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
    aspect-ratio: 3 / 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #2a2a2a;

    opacity: 0;
    animation: jumpDown 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.character-card:nth-child(1) {
    animation-delay: 0.05s;
}

.character-card:nth-child(2) {
    animation-delay: 0.15s;
}

.character-card:nth-child(3) {
    animation-delay: 0.25s;
}

.character-card:nth-child(4) {
    animation-delay: 0.35s;
}

.character-card:hover,
.character-card:focus {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    border-color: #bcaaa4;
    outline: none;
}

.character-card.selected {
    border-color: #ffc107;
    box-shadow: 0 5px 20px rgba(255, 193, 7, 0.55);
    transform: scale(1.05);
}

.character-image-full {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.character-card:hover .character-image-full,
.character-card:focus .character-image-full {
    transform: scale(1.08);
}

.character-overlay-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 14px 10px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.65) 55%, rgba(0, 0, 0, 0) 100%);
    color: white;
    text-align: center;
    box-sizing: border-box;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.character-overlay-info h3 {
    margin: 0 0 4px;
    font-size: clamp(0.9em, 2vw, 1.2em);
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    color: #fff;
}

.character-overlay-info .ability {
    font-size: clamp(0.72em, 1.5vw, 0.88em);
    line-height: 1.3;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}

.character-card.selected .character-overlay-info {
    background: linear-gradient(to top, rgba(255, 193, 7, 0.88) 0%, rgba(255, 193, 7, 0.6) 55%, rgba(0, 0, 0, 0) 100%);
    color: #212529;
}

.character-card.selected .character-overlay-info h3,
.character-card.selected .character-overlay-info .ability {
    text-shadow: none;
    color: #1a1a1a;
}

/* 確認角色按鈕 */
#confirm-character-btn,
.confirm-button {
    display: block;
    margin: 22px auto 6px auto;
    padding: 11px 28px;
    background-color: #795548;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: clamp(0.9em, 2.5vw, 1.05em);
    font-weight: 600;
    transition: background-color 0.25s ease, transform 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

#confirm-character-btn:hover,
.confirm-button:hover {
    background-color: #5d4037;
    transform: translateY(-1px);
}

#confirm-character-btn:active,
.confirm-button:active {
    transform: translateY(0);
}


/* ====================================================
   5. 響應式設計
   ===================================================== */

/* 平板（768px 以下）：兩欄 */
@media (max-width: 768px) {
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .character-select-header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    #intro-section {
        min-height: 300px;
        padding: 24px 16px;
    }

    #character-selection-section {
        padding: 18px 14px 16px;
    }
}

/* 手機（480px 以下）：兩欄，更緊湊 */
@media (max-width: 480px) {
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .character-select-header {
        margin-bottom: 14px;
    }

    .character-overlay-info {
        padding: 10px 8px 8px;
    }

    #confirm-character-btn,
    .confirm-button {
        width: 90%;
        padding: 12px 20px;
    }
}

/* 超小手機（360px 以下）：單欄 */
@media (max-width: 360px) {
    .character-grid {
        grid-template-columns: repeat(1, 1fr);
        max-width: 220px;
        margin: 0 auto;
    }
}