* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Google Sans', sans-serif;
    background: #f9f9f9;
    color: #111;
    overflow: auto;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.intro-done {
    opacity: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

@font-face {
    font-family: 'Google Sans';
    src: url('fonts/GoogleSans-Bold.woff2') format('woff2'),
         url('fonts/GoogleSans-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Google Sans';
    src: url('fonts/GoogleSans-Medium.woff2') format('woff2'),
         url('fonts/GoogleSans-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Google Sans';
    src: url('fonts/GoogleSans-Regular.woff2') format('woff2'),
         url('fonts/GoogleSans-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

canvas#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: radial-gradient(circle at center, #eaf4ff, #f9f9f9);
}

#logoIntro {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #fff;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#introLogo {
    width: 160px;
    height: 160px;
    transition: transform 1s ease-in-out, opacity 0.5s ease-out;
}

#loadingSpinner {
    margin-top: 20px;
    width: 20px;
    height: 20px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#typingTextContainer {
    margin-top: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid #444; /* Con trỏ */
    width: 0; /* Bắt đầu với width 0 */
    opacity: 1;
    /* Hiệu ứng gõ chữ mượt và con trỏ nhấp nháy */
    animation:
        typing 1.5s linear forwards, /* Thời gian gõ chữ (ví dụ 2.5s) */
        blink-caret 1s step-end infinite; /* Con trỏ nhấp nháy */
}

/* Keyframes cho hiệu ứng gõ chữ mượt */
@keyframes typing {
    from {
        width: 0
    }

    to {
        width: var(--typing-final-width);
    } /* Sử dụng biến CSS để linh hoạt */
}

/* Keyframes cho con trỏ nhấp nháy */
@keyframes blink-caret {
    from,
    to {
        border-color: transparent
    }

    50% {
        border-color: #444
    }
}

header {
    opacity: 0;
    text-align: center;
    padding: 32px 20px 16px;
    transition: opacity 1s ease;
}

body.loaded header {
    opacity: 1;
}

header img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 16px;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
}

.main-content {
    flex: 1;
}

.grid {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
}

.tool-card {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.06);
    text-decoration: none;
    color: inherit;
    backdrop-filter: blur(5px);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.35s ease;
}

.tool-card.loaded {
    opacity: 1;
    transform: translateY(0) scale(1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tool-card:nth-child(1) {
    --i: 0;
}

.tool-card:nth-child(2) {
    --i: 1;
}

.tool-card:nth-child(3) {
    --i: 2;
}

.tool-card:nth-child(4) {
    --i: 3;
}

.tool-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.tool-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
}

.tool-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.tool-desc {
    font-size: 0.9rem;
    color: #555;
}

footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid #ccc;
    font-size: 14px;
    margin-top: auto;
    /* Đẩy footer xuống dưới cùng */
}

footer p {
    margin-top: 0;
    margin-bottom: 10px;
    /* Khoảng cách với hàng link */
}

footer a {
    color: #005bd4;
    text-decoration: none;
}

footer a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.footer-nav ul {
    list-style: none;
    /* Bỏ dấu chấm của list */
    padding: 0;
    margin: 0;
    display: flex;
    /* Hiển thị các mục theo hàng ngang */
    justify-content: center;
    /* Căn giữa các mục */
    flex-wrap: wrap;
    /* Cho phép xuống dòng trên màn hình nhỏ */
}

.footer-nav li {
    margin: 0 10px;
    /* Khoảng cách giữa các mục */
}

.footer-nav a {
    color: #555;
    /* Màu chữ cho các liên kết footer nav */
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-nav a:hover {
    color: #005bd4;
    /* Màu khi hover */
}

/* Responsive Adjustments for Tablets and smaller (max-width: 768px) */
@media (max-width: 768px) {
    #introLogo {
        width: 120px;
        height: 120px;
    }

    #typingTextContainer {
        font-size: 1rem;
        padding: 0 10px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 16px;
        margin: 20px auto;
        padding: 0 15px;
    }

    .tool-card {
        padding: 20px;
    }

    .tool-icon {
        font-size: 1.8rem;
    }

    .tool-title {
        font-size: 1rem;
    }

    .tool-desc {
        font-size: 0.85rem;
    }

    .footer-nav ul {
        flex-wrap: wrap;
        margin-bottom: 10px;
    }

    .footer-nav li {
        margin: 5px 8px;
        display: inline-block;
        position: relative;
        padding: 0 5px;
    }

    .footer-nav li:not(:last-child)::after {
        content: "|";
        color: #888;
        position: absolute;
        right: -5px;
        top: 50%;
        transform: translateY(-50%);
    }
}

@media (max-width: 480px) {
    #introLogo {
        width: 100px;
        height: 100px;
    }

    #typingTextContainer {
        font-size: 0.9rem;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .grid {
        grid-template-columns: 1fr;
        padding: 0 10px;
    }

    .footer-nav li {
        font-size: 0.85rem;
        margin: 3px 6px;
    }

    .footer-nav li:not(:last-child)::after {
        right: -4px;
    }
}

/* Responsive Adjustments for Mobile Phones (max-width: 480px) */
@media (max-width: 480px) {
    #introLogo {
        width: 100px;
        height: 100px;
    }

    #typingTextContainer {
        font-size: 0.9rem;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .grid {
        grid-template-columns: 1fr;
        padding: 0 10px;
    }
}