/* CSS for 3D Page Flip Book Portfolio */

/* Import font Outfit, Inter & Montserrat từ Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&family=Montserrat:wght@400;500;600;700;800&display=swap');

:root {
    --bg-color: #0d0f12;
    --book-shadow: 0 9px 21px rgba(0, 0, 0, 0.1);
    --text-color: #ffffff;
    --primary-color: #006937; /* Kềm Nghĩa green */
    --primary-glow: 0 0 15px rgba(0, 105, 55, 0.4);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-focus-border: #006937;

    /* Tỷ lệ gốc của ảnh Catalogue (839px x 1190px) */
    --aspect-ratio: 1.418355;
    --max-page-width: 839px;

    /* Kích thước trang responsive cho Desktop & Tablet */
    --page-width: min(var(--max-page-width), 44vw, calc((90vh - 140px) / var(--aspect-ratio)));
    --page-height: calc(var(--page-width) * var(--aspect-ratio));
}

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

body.body-3d-book {
    background-color: var(--bg-color);
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Kéo tổng thể lên trên */
    padding-top: 5vh; /* Khoảng cách so với header */
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 105, 55, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 229, 255, 0.05) 0%, transparent 40%);
}

.book-container {
    width: 100%;
    max-width: 1800px; /* Đủ rộng để chứa 2 trang kích thước gốc */
    margin: 0 auto; /* Đảm bảo căn giữa container khi body không phải flex */
    height: auto; /* Tự động theo chiều cao của cuốn sách */
    max-height: none;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px 20px 80px 20px; /* Chừa chỗ trống 80px ở đáy để không đè nút */
}

/* The Book itself */
.book {
    position: relative;
    width: var(--page-width); /* Chiều rộng một trang */
    height: var(--page-height); /* Giữ tỷ lệ gốc của ảnh */
    transition: transform 1s ease-in-out;
    transform-style: preserve-3d;
    will-change: transform;
}

/* Paper element */
.paper {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    perspective: 1500px;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform 1.4s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform, z-index;
}

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    overflow: hidden;
    background-color: transparent;
    border: none !important;
    outline: none !important;
}

.front {
    z-index: 2;
    transform: rotateY(0deg);
    border-radius: 0 15px 15px 0;
}

.back {
    z-index: 1;
    transform: rotateY(180deg);
    border-radius: 15px 0 0 15px;
}

/* Content Area */
.front-content, .back-content {
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

/* Đã loại bỏ vệt mờ gáy sách theo yêu cầu */

/* Paper flipped state */
.paper.flipped {
    transform: rotateY(-180deg);
}

/* Controls (Buttons) */
.controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 100;
}

.control-btn {
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    color: #ffffff;
    padding: 12px 24px;
    font-family: 'SVN-Gilroy', 'Montserrat', 'Outfit', sans-serif !important;
    font-size: 14px;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--primary-glow);
}

.control-btn:hover {
    background: #00522a; /* Slightly darker green */
    border-color: #00522a;
    box-shadow: 0 6px 20px rgba(0, 105, 55, 0.5);
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(1px);
}

/* Contact Page Styling */
.contact-page {
    background: #12141c;
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.contact-page h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 30px;
    background: linear-gradient(45deg, #ff3366, #00e5ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

/* Contact Form 7 Custom Styling */
.cf7-wrapper .wpcf7 {
    width: 100%;
}

.cf7-wrapper .wpcf7-form-control-wrap {
    margin-bottom: 20px;
    display: block;
}

.cf7-wrapper input[type="text"],
.cf7-wrapper input[type="email"],
.cf7-wrapper textarea {
    width: 100%;
    padding: 14px 16px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    transition: all 0.3s ease;
}

.cf7-wrapper input[type="text"]:focus,
.cf7-wrapper input[type="email"]:focus,
.cf7-wrapper textarea:focus {
    outline: none;
    border-color: var(--input-focus-border);
    background-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.15);
}

.cf7-wrapper textarea {
    height: 120px;
    resize: none;
}

.cf7-wrapper input[type="submit"] {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #ff3366 0%, #ff5e62 100%);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--primary-glow);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cf7-wrapper input[type="submit"]:hover {
    background: linear-gradient(135deg, #ff5e62 0%, #ff3366 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 51, 102, 0.6);
}

.cf7-wrapper input[type="submit"]:active {
    transform: translateY(0);
}

/* CF7 Success & Error Messages Styling */
.wpcf7-response-output {
    margin: 15px 0 0 0 !important;
    padding: 10px 15px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-family: 'Inter', sans-serif;
}

.wpcf7-mail-sent-ok {
    border: 1px solid #4ade80 !important;
    background-color: rgba(74, 222, 128, 0.1) !important;
    color: #4ade80 !important;
}

.wpcf7-validation-errors {
    border: 1px solid #f87171 !important;
    background-color: rgba(248, 113, 113, 0.1) !important;
    color: #f87171 !important;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Tablet Styles (Hiển thị 2 trang song song, tỷ lệ tự động co giãn) */
@media (min-width: 768px) and (max-width: 1024px) {
    .book-container {
        height: auto !important;
        max-height: none !important;
        padding-bottom: 90px !important; /* Đẩy sách lên để không đè nút */
    }
}

/* Khi màn hình di động:
   Hiệu ứng 3D lật trang đơn. */
@media (max-width: 767px) {
    body.body-3d-book {
        align-items: center;
        padding: 10px 10px 80px 10px; /* Giảm padding trên chừa chỗ cho header, tăng padding dưới chừa chỗ cho nút */
        overflow-y: auto; /* Cho phép cuộn dọc nếu màn hình quá ngắn */
        height: auto;
        min-height: 100vh;
    }

    .book-container {
        width: 100%;
        height: auto;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0 10px; /* Lề thở nhẹ 2 bên (giúp trang đạt ~95vw) */
        overflow: hidden;
    }

    .book {
        width: 100%;
        max-width: min(100%, calc((100vh - 140px) / var(--aspect-ratio))); /* Giới hạn chiều rộng tối đa dựa trên chiều cao thực tế của viewport di động */
        height: 0;
        padding-bottom: 141.8355%; /* Tỉ lệ gốc của ảnh 1.418355 chuẩn xác */
        position: relative;
        transform: none !important;
        display: block !important;
        transform-style: preserve-3d;
    }

    .paper {
        position: absolute !important;
        width: 100% !important;
        height: 100% !important;
        transform-style: preserve-3d;
        transform-origin: left center !important;
        transition: transform 1.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 1.4s ease !important;
        will-change: transform, z-index;
        opacity: 1;
    }

    .front, .back {
        position: absolute !important;
        width: 100% !important;
        height: 100% !important;
        backface-visibility: hidden;
        overflow: hidden;
        border-radius: 12px !important;
        margin-bottom: 0 !important;
        transform: none !important;
    }

    .front {
        transform: rotateY(0deg) !important;
        z-index: 2;
    }

    .back {
        transform: rotateY(180deg) !important;
        z-index: 1;
    }

    /* Lật trang tới (qua bên trái) */
    .paper.mobile-flipped-next {
        transform: rotateY(-180deg) !important;
        transform-origin: left center !important;
        opacity: 0 !important;
        pointer-events: none;
    }

    /* Lật trang lui (qua bên phải) */
    .paper.mobile-flipped-prev {
        transform: rotateY(180deg) !important;
        transform-origin: right center !important;
        opacity: 0 !important;
        pointer-events: none;
    }

    .front-content, .back-content {
        width: 100%;
        height: 100%;
        background-size: 100% 100%;
        background-position: center;
        background-repeat: no-repeat;
    }

    .hide-mobile {
        display: none !important;
    }

    /* Hiển thị các nút lật trang ở dưới di động */
    .controls {
        display: flex !important;
        bottom: 20px;
        position: fixed; /* Ghim cố định ở đáy màn hình di động */
        z-index: 99999 !important;
        left: 50%;
        transform: translateX(-50%);
        width: auto;
        max-width: 95%;
        gap: 8px !important; /* Thu nhỏ khoảng cách giữa các nút */
    }

    .control-btn {
        padding: 8px 14px !important; /* Thu nhỏ padding trên mobile */
        font-size: 12px !important; /* Thu nhỏ chữ */
        white-space: nowrap !important; /* Ngăn chặn việc xuống dòng */
    }
}
