/* ตั้งค่าตัวแปรสีและ Reset */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --hover-glow: 0 0 20px rgba(56, 189, 248, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', 'Prompt', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- ส่วน Top Controls (รวม Donate + ภาษา) --- */
.top-controls {
    position: absolute;
    top: 20px;
    right: 30px;
    z-index: 100;
    
    /* จัดเรียงแนวนอน */
    display: flex;
    align-items: center;
    gap: 12px;
    
    /* พื้นหลัง Glass */
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 30px; /* ทำให้มนกว่าเดิม */
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* ปุ่ม Donate ด้านบน */
.top-donate-btn {
    background: none;
    border: none;
    color: #ff8fa3; /* สีชมพู */
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.top-donate-btn:hover {
    color: #ff6384;
    text-shadow: 0 0 10px rgba(255, 99, 132, 0.6);
    transform: scale(1.05);
}

.top-donate-btn i {
    font-size: 1rem;
    animation: heartbeat 1.5s infinite; /* ใส่ Effect หัวใจเต้น */
}

/* เส้นคั่นแนวตั้ง */
.vertical-sep {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.2);
}

/* กลุ่มปุ่มภาษา */
.lang-group button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.3s ease;
    padding: 0 2px;
}

.lang-group button:hover { color: #fff; }

.lang-group button.active {
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.lang-group .divider {
    color: rgba(255,255,255,0.3);
    margin: 0 2px;
    font-size: 0.8rem;
}

/* Animation หัวใจเต้น */
@keyframes heartbeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.3); }
    28% { transform: scale(1); }
    42% { transform: scale(1.3); }
    70% { transform: scale(1); }
}

/* ปรับสำหรับมือถือ */
@media (max-width: 600px) {
    .top-controls {
        top: 15px;
        right: 15px;
        padding: 6px 12px;
        gap: 8px;
    }
    
    /* ซ่อนคำว่า "เลี้ยงกาแฟ" ในมือถือ ให้เหลือแต่ไอคอนหัวใจ */
    .top-donate-btn .btn-text {
        display: none; 
    }
    
    .top-donate-btn i {
        font-size: 1.1rem; /* ขยายไอคอนขึ้นหน่อยเพราะไม่มี text */
    }
}

/* ส่วนหัว */
/* --- ส่วน Header แบบ Typing Coder --- */
header {
    text-align: center;
    padding: 4rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    font-family: 'Courier New', monospace; /* เปลี่ยนฟอนต์ให้เหมือนโค้ด */
    color: #38bdf8;
    margin-bottom: 0.5rem;
    
    /* สร้างกรอบเพื่อทำ Effect พิมพ์ */
    border-right: 4px solid #38bdf8; /* เคอร์เซอร์ */
    white-space: nowrap;
    overflow: hidden;
    width: 0; /* เริ่มต้นที่ 0 */
    
    /* Animation การพิมพ์ */
    animation: typing 2s steps(20, end) forwards, blink 0.75s step-end infinite;
}

p.subtitle {
    color: #94a3b8;
    font-size: 1.1rem;
    margin-top: 1rem;
    opacity: 0;
    animation: fadeIn 1s ease-out 2s forwards; /* ให้ค่อยๆ ขึ้นมาหลังจากพิมพ์เสร็จ */
}

/* Keyframes สำหรับ Animation */
@keyframes typing {
    from { width: 0 }
    to { width: 9ch; } /* 'OLE Lab' มีประมาณ 7-9 ตัวอักษร */
}

@keyframes blink {
    from, to { border-color: transparent }
    50% { border-color: #38bdf8; }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* ปรับตำแหน่งปุ่มบนมือถือ */
@media (max-width: 600px) {
    .lang-switch {
        top: 15px;
        right: 15px;
        padding: 5px 12px;
    }
    h1 { font-size: 2.2rem; }
}

/* Grid Container */
.container {
    width: 90%;
    max-width: 1200px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    padding-bottom: 3rem;
}

/* การ์ดแต่ละใบ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* เอฟเฟกต์ Hover */
.card:hover {
    transform: translateY(-8px);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: var(--hover-glow);
    border-color: var(--accent-color);
}

/* ไอคอนในการ์ด */
.card-icon {
    width: fit-content;      /* 1. ให้กว้างเท่าเนื้อหาข้างใน ไม่ยืดเต็ม */
    display: flex;           /* 2. จัดไอคอนให้อยู่กึ่งกลาง */
    align-items: center;     /* 3. จัดกึ่งกลางแนวตั้ง */
    justify-content: center; /* 4. จัดกึ่งกลางแนวนอน */
    
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    padding: 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    transition: transform 0.3s ease;
}

/* สีเฉพาะของแต่ละการ์ด (อ้างอิงจากลำดับ) */
.card:nth-child(1) .card-icon { color: #fbbf24; } /* QuoteFlex - เหลือง */
.card:nth-child(2) .card-icon { color: #a78bfa; } /* QR Code - ม่วง */
.card:nth-child(3) .card-icon { color: #4ade80; } /* EasyCert - เขียว */
.card:nth-child(4) .card-icon { color: #f472b6; } /* Length - ชมพู */

.card:hover .card-icon {
    transform: scale(1.1) rotate(5deg);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ลูกศร Link */
.link-arrow {
    margin-top: auto;
    padding-top: 1.5rem;
    color: var(--accent-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}

.card:hover .link-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Custom Logo */
.custom-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
}

/* Footer */
footer {
    margin-top: auto;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;

    display: flex;
    flex-direction: column; /* เรียงลงมาเป็นแนวตั้ง */
    align-items: center;    /* จัดให้อยู่ตรงกลางแนวนอน */
    gap: 0.5rem;            /* ระยะห่างระหว่างข้อความกับตัวนับ */
}

/* Animation Keyframes */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    h1 { font-size: 2rem; }
    .container { grid-template-columns: 1fr; }
}

/* --- Card Styles (เพิ่มใหม่) --- */

/* 1. Style: Glass (ค่าเริ่มต้น) */
.card.style-glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 2. Style: Solid (ทึบ) */
.card.style-solid {
    background: #1e293b; /* สีกรมท่าทึบ */
    border: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.card.style-solid:hover {
    background: #334155;
    transform: translateY(-5px);
}

/* 3. Style: Outline (ขอบ) */
.card.style-outline {
    background: transparent;
    border: 2px solid #38bdf8; /* ขอบสีฟ้า */
    box-shadow: none;
}
.card.style-outline:hover {
    background: rgba(56, 189, 248, 0.1);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

/* 4. Style: Gradient (ไล่สี) */
.card.style-gradient {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(56, 189, 248, 0.3);
}
.card.style-gradient:hover {
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
    border-color: #38bdf8;
}

/* --- 5. Style: Liquid (iOS Glass) --- */
.card.style-liquid {
    /* พื้นหลังโปร่งแสงแบบไล่ระดับ */
    background: linear-gradient(
        135deg, 
        rgba(255, 255, 255, 0.1), 
        rgba(255, 255, 255, 0.01)
    );
    
    /* เทคนิค iOS: เบลอหนักๆ + เร่งสีให้สดขึ้น (Saturate) */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    
    /* ขอบแบบแสงสะท้อน (บนซ้ายสว่าง ล่างขวามืด) */
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    border-left: 1px solid rgba(255, 255, 255, 0.4);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    
    /* เงาฟุ้งๆ นุ่มลึก */
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    border-radius: 24px; /* มุมโค้งมนกว่าปกติ */
}

/* เอฟเฟกต์ตอนเอาเมาส์ชี้ (Hover) */
.card.style-liquid:hover {
    transform: translateY(-5px) scale(1.02);
    background: linear-gradient(
        135deg, 
        rgba(255, 255, 255, 0.15), 
        rgba(255, 255, 255, 0.05)
    );
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(56, 189, 248, 0.2); /* เรืองแสงสีฟ้าอ่อนๆ */
    border-color: rgba(255, 255, 255, 0.6);
}

/* ปรับสีไอคอนให้เข้ากับ Liquid */
.card.style-liquid .card-icon {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* เพิ่มต่อท้ายไฟล์ style.css */
.visitor-count {
    /* margin-top: 10px; */
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--accent-color); /* สีฟ้า */
    display: inline-flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(5px);
}

.visitor-count i {
    font-size: 0.8rem;
}

/* --- Styles สำหรับปุ่มและ Popup Donate --- */

/* 1. ปุ่มด้านขวาบน */
.top-controls {
    position: absolute;
    top: 20px; right: 30px; z-index: 1000; /* เพิ่ม z-index ให้แน่ใจว่าอยู่บนสุด */
    display: flex; align-items: center; gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.top-donate-btn {
    background: none; border: none;
    color: #ff8fa3; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    font-size: 0.9rem;
    font-family: 'Poppins', sans-serif;
}

.top-donate-btn i { animation: heartbeat 1.5s infinite; }
@keyframes heartbeat {
    0% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
    45% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* เส้นคั่นและปุ่มภาษา */
.vertical-sep { width: 1px; height: 18px; background: rgba(255,255,255,0.2); }
.lang-group button { 
    background: none; border: none; color: #94a3b8; 
    cursor: pointer; font-weight: 600; padding: 0 4px; 
}
.lang-group button.active { color: #38bdf8; }
.lang-group .divider { color: rgba(255,255,255,0.3); }

/* 2. พื้นหลัง Popup (Modal Overlay) */
.modal-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); /* พื้นหลังสีดำจางๆ */
    backdrop-filter: blur(5px);      /* เบลอฉากหลัง */
    z-index: 9999;                   /* สำคัญ! ต้องสูงกว่าทุกอย่าง */
    
    /* ซ่อนไว้ก่อน */
    opacity: 0; visibility: hidden;
    transition: all 0.3s ease;
    
    /* จัดกึ่งกลาง */
    display: flex; justify-content: center; align-items: center;
}

/* แสดงผลเมื่อมี class .active */
.modal-overlay.active { opacity: 1; visibility: visible; }

/* 3. กล่องเนื้อหา Popup */
.modal-content {
    background: #1e293b;
    padding: 2.5rem;
    border-radius: 24px;
    text-align: center;
    position: relative;
    width: 90%; max-width: 350px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0); /* เด้งขึ้นมา */
}

/* ตกแต่งรูป QR Code */
.qr-wrapper {
    background: #fff;
    padding: 10px;
    border-radius: 12px;
    margin: 20px 0;
}
.qr-image { width: 100%; display: block; border-radius: 8px; }

/* ปุ่มปิด (กากบาท) */
.close-btn {
    position: absolute; top: 15px; right: 20px;
    font-size: 2rem; color: #94a3b8; cursor: pointer; line-height: 1;
}
.close-btn:hover { color: #fff; }

/* Responsive มือถือ */
@media (max-width: 600px) {
    .btn-text { display: none; } /* ซ่อนคำว่าเลี้ยงกาแฟในมือถือ */
    .top-controls { padding: 6px 12px; gap: 8px; }
}

/* --- ส่วนเสริมปุ่ม Ko-fi ใน Modal --- */

/* เส้นคั่น "หรือ" (OR) */
.divider-text {
    margin: 15px 0 10px;
    color: #94a3b8;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    opacity: 0.8;
}

/* ขีดเส้นซ้ายขวาของคำว่า "หรือ" */
.divider-text::before, 
.divider-text::after {
    content: "";
    height: 1px;
    width: 40px; /* ความยาวเส้น */
    background: rgba(255, 255, 255, 0.2);
}

/* ปุ่ม Ko-fi */
.kofi-btn {
    background: #29abe0; /* สีฟ้า Ko-fi */
    color: #fff;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 50px;
    display: inline-flex; /* ใช้ inline-flex เพื่อให้ขนาดพอดีคำ */
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(41, 171, 224, 0.3);
    border: 2px solid transparent; /* เตรียมเส้นขอบไว้ */
}

.kofi-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(41, 171, 224, 0.5);
    background: #1da1f2; /* เข้มขึ้นนิดนึงตอน Hover */
}

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

.kofi-btn i {
    font-size: 1.1rem;
    animation: steam 2s infinite ease-out; /* อนิเมชั่นควันกาแฟ (ถ้าต้องการ) */
}