/* css/portfolio.css */

.portfolio-page {
    background: var(--bg-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.portfolio-container {
    flex: 1;
    width: 100%;
}

/* จัดแถวละแถวให้เต็มจอพอดี */
.char-row-section {
    width: 100%;
    height: 100vh; /* บังคับให้แต่ละแถวสูงเต็มจอ */
    min-height: 600px;
    padding-top: 80px; /* เว้นระยะให้ Navbar */
}

.character-grid {
    display: flex;
    width: 100%;
    height: 100%;
}

.char-card {
    flex: 1;
    height: 100%;
    position: relative;
    background-image: var(--bg-img);
    background-size: cover;
    background-position: center;
    overflow: hidden;
    transition: flex 0.6s cubic-bezier(0.25, 1, 0.3, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.char-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(11, 1, 20, 0.95));
    z-index: 1;
    transition: 0.4s;
}

/* Character Selector Hover */
.char-card:hover {
    flex: 2.5;
}

.char-card:hover::before {
    background: linear-gradient(to bottom, transparent 20%, rgba(11, 1, 20, 0.8));
}

.char-info {
    position: absolute;
    bottom: 60px;
    left: 40px;
    right: 40px;
    z-index: 2;
    opacity: 0;
    transform: translateY(30px);
    transition: 0.4s 0.2s;
    pointer-events: none;
}

.char-card:hover .char-info {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.char-role {
    color: var(--electric-blue);
    font-family: var(--font-tech);
    font-size: 0.9rem;
    letter-spacing: 2px;
}

.char-name {
    font-size: 2.8rem;
    margin: 10px 0 20px;
    line-height: 1;
}

.view-profile-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--electric-blue);
    color: white;
    font-family: var(--font-tech);
    font-size: 0.8rem;
    padding-bottom: 5px;
    cursor: pointer;
    transition: 0.3s;
}

.view-profile-btn:hover { color: var(--electric-blue); }

/* --- Footer --- */
.site-footer {
    position: relative;
    width: 100%;
    padding: 30px 20px;
    background: rgba(11, 1, 20, 0.98);
    border-top: 1px solid var(--glass-border);
    z-index: 100;
}

/* --- MODAL STYLES (ส่วนที่ทำให้มันซ่อนตัว) --- */
.modal-overlay {
    position: fixed; /* บังคับให้อยู่บนสุดของจอ */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85); /* พื้นหลังดำโปร่งแสง */
    backdrop-filter: blur(10px); /* ทำฉากหลังเบลอ */
    z-index: 2000; /* ดันให้อยู่เหนือทุกอย่างรวมถึง Navbar */
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* 🔥 สองบรรทัดนี้คือหัวใจสำคัญที่ทำให้มันไม่โผล่มาตอนแรก */
    opacity: 0;
    visibility: hidden;
    
    transition: 0.3s ease; /* เวลาเด้งขึ้นมาจะได้ดูนุ่มนวล */
}

/* เมื่อมีการเติมคลาส .active ผ่าน JavaScript ให้โชว์ตัวออกมา */
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--electric-blue);
    padding: 40px;
    width: 90%;
    max-width: 500px;
    border-radius: 20px;
    position: relative;
    text-align: center;
    box-shadow: 0 0 50px rgba(0, 180, 216, 0.2);
    
    /* เอฟเฟกต์ย่อขยายตอนเปิด */
    transform: scale(0.8);
    transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* แต่งปุ่มปิด (X) */
.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
}

/* แต่งตัวหนังสือใน Modal */
.modal-role {
    color: var(--electric-blue);
    font-family: var(--font-tech);
    display: block;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.modal-actions {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-btn {
    padding: 10px 25px;
    border-radius: 50px;
    text-decoration: none;
    font-size: 0.8rem;
    font-family: var(--font-tech);
    transition: 0.3s;
}

.modal-btn.primary {
    background: var(--electric-blue);
    color: var(--bg-dark);
}

.modal-btn.secondary {
    border: 1px solid white;
    color: white;
}

/* --- Infinite Carousel Styles --- */
.ticker-wrap {
    width: 100%;
    overflow: hidden; /* ตัดส่วนที่ล้นออก */
    background: var(--electric-blue); /* สีพื้นหลังแถบวิ่ง */
    padding: 15px 0;
    border-top: 2px solid var(--glass-border);
    border-bottom: 2px solid var(--glass-border);
    transform: rotate(-1deg); /* เอียงนิดๆ ให้ดูเท่ */
    z-index: 50;
    margin: 40px 0; /* ดึงให้เข้าใกล้แถวบนและล่าง */
}

.ticker {
    display: flex;
    white-space: nowrap; /* ห้ามขึ้นบรรทัดใหม่ */
    animation: tickerLoop 20s linear infinite; /* วิ่งวนไปเรื่อยๆ */
}

.ticker-item {
    font-family: var(--font-tech);
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--bg-dark); /* ตัวหนังสือสีดำตัดกับพื้นสีฟ้า */
    padding: 0 40px;
    letter-spacing: 2px;
}

/* คำสั่งทำให้วิ่ง */
@keyframes tickerLoop {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); } /* วิ่งไปครึ่งทางของเนื้อหาทั้งหมดแล้วเริ่มใหม่ */
}

/* ปรับความสวยงามในหน้าจอมือถือ */
@media (max-width: 768px) {
    .ticker-wrap {
        transform: rotate(0); /* มือถือไม่ต้องเอียงเพื่อให้อ่านง่าย */
        padding: 10px 0;
    }
    .ticker-item {
        font-size: 0.9rem;
        padding: 0 20px;
    }
}

/* --- 🔥 RESPONSIVE MOBILE --- */
@media (max-width: 992px) {
    /* ปิดการ Zoom แตะค้าง หรือเลือกข้อความที่อาจทำให้เลย์เอาต์เคลื่อน */
    .portfolio-page {
        touch-action: pan-y; /* ยอมให้เลื่อนขึ้นลงได้อย่างเดียว ห้าม Zoom */
        user-select: none;
        -webkit-user-select: none;
    }

    .char-row-section {
        height: auto;
        min-height: auto;
        padding-top: 90px;
        padding-bottom: 10px;
    }

    .character-grid {
        flex-direction: column;
        height: auto;
        gap: 20px;
        padding: 0 15px;
    }

    .char-card {
        height: 500px; /* ล็อคความสูงตายตัว */
        flex: none !important; /* ล็อคไม่ให้ยืดหดเด็ดขาด */
        width: 100%;
        border-radius: 20px;
        border-right: none;
        background-attachment: scroll; /* ป้องกันกระตุกในมือถือ */
        
        /* ปิด Animation ทั้งหมดที่เกี่ยวกับการยืด (Hover) ในมือถือ */
        transition: none !important; 
        transform: none !important;
    }

    /* ล็อคให้ Gradient นิ่ง ไม่ต้องรอ Hover */
    .char-card::before {
        background: linear-gradient(to bottom, transparent 30%, rgba(11, 1, 20, 0.95)) !important;
        opacity: 1;
    }

    /* ข้อมูลสมาชิกแสดงแบบ Static */
    .char-info {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        bottom: 30px;
        left: 20px;
        right: 20px;
        pointer-events: auto; /* ยอมให้กดปุ่มข้างในได้ */
    }

    .char-name {
        font-size: 1.8rem;
        text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.9);
    }

    /* ปรับปุ่มให้เป็น Static ไม่ต้องมีเอฟเฟกต์ซับซ้อน */
    .view-profile-btn {
        width: 100%;
        padding: 14px 0;
        background: rgba(0, 180, 216, 0.15);
        border: 1px solid var(--electric-blue);
        border-radius: 10px;
        font-size: 0.85rem;
        pointer-events: all; /* มั่นใจว่าปุ่มกดได้ */
    }

    /* Carousel ให้นิ่งและอยู่ในระดับสายตา */
    .ticker-wrap {
        transform: rotate(0); 
        margin: 25px 0;
        padding: 12px 0;
    }
}
/* สำหรับมือถือจอเล็กเป็นพิเศษ */
@media (max-width: 480px) {
    .char-card {
        height: 480px; /* ลดความสูงลงเล็กน้อย */
    }
    .char-name {
        font-size: 1.6rem;
    }
}