/* ---------- ROOT VARIABLES ---------- */
:root {
    --primary-bg: #ccbe77;
    --secondary-bg: #83A555;
    --accent-color: #728fb5;
    --primary-color: #5569a3;
    --secondary-color: #cdbb76;
    --text-dark: #333;
    --text-light: #fff;
    --box-bg: #fff;
}

/* ---------- RESET & GLOBAL ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Poppins', sans-serif;
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
    background: linear-gradient(120deg, #f7f8fa 0%, #eceff1 100%);
}

/* ---------- MAIN TITLE ---------- */
#main-title {
    text-align: center;
    font-family: 'Lora', serif;
    font-size: 2.2rem;
    color: var(--text-dark);
    margin-top: 2rem;
    margin-bottom: 1rem;
    transition: color 0.3s ease;
}

#main-title:hover {
    color: var(--primary-color);
}

/* ---------- CHAPTER HEADER ---------- */
.chapter-header {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to right, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-light);
    margin-bottom: 2rem;

    /* Flex layout to space items */
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* If you want the title centered horizontally, you can remove text-align: center. */
}

.chapter-header h3 {
    font-family: 'Lora', serif;
    font-size: 1.4rem;
    margin: 0; /* remove default margin */
}

/* Container for the two top buttons */
.header-btn-group {
    display: flex;
    gap: 1rem; /* space between the two buttons */
}

/* ---------- LEVEL SELECTION PANEL ---------- */
.level-selection-panel {
    background: #fff;
    padding: 1.5rem 2rem;
    border-radius: 1rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 300px;

    /* Center the panel absolutely */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.level-selection-panel h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-dark);
}

/* Level Buttons */
.level-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
    width: 100%;
}

.level-btn {
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-light);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.level-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

.level-btn:active {
    transform: translateY(1px);
}

/* ---------- MAIN CONTENT ---------- */
#main-content {
    display: none;
    text-align: center;
    margin-bottom: 2rem;
}

/* ---------- BUTTON PRIMARY & GO STYLE ---------- */
.btn-primary {
    display: none;
    text-decoration: none; /* ensures no underline if it's an <a> */
    background: var(--accent-color);
    color: var(--text-light);
    border: none;
    padding: 0.7rem 1.2rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
}

.btn-go {
    display: inline-block;
    text-decoration: none; /* ensures no underline if it's an <a> */
    background: linear-gradient(97deg, rgb(250, 82, 82) 0%, rgb(221, 36, 118) 100%);
    color: var(--text-light);
    border: none;
    padding: 0.7rem 1.2rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
}

.btn-go:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
}

/* ---------- CARD SCENE (3D) ---------- */
.card-scene {
    width: 800px; /* Original width */
    height: 280px; /* Original height */
    perspective: 1000px;
    margin: 0 auto 2rem auto;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease-in-out;
}

.card--flipped {
    animation: cardFlip 0.6s forwards ease-in-out;
}

.card--unflip {
    animation: cardUnFlip 0.6s forwards ease-in-out;
}

@keyframes cardFlip {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(90deg) rotateZ(-5deg);
    }
    100% {
        transform: rotateY(180deg) rotateZ(0deg);
    }
}

@keyframes cardUnFlip {
    0% {
        transform: rotateY(180deg) rotateZ(0deg);
    }
    50% {
        transform: rotateY(90deg) rotateZ(-5deg);
    }
    100% {
        transform: rotateY(0deg) rotateZ(0deg);
    }
}

/* ---------- CARD FACES ---------- */
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 1rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* FRONT SIDE */
.card-front {
    background: var(--primary-bg);
    color: var(--text-light);
}

.front-top-bar {
    position: absolute;
    top: 8px;
    left: 15px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 6px;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.front-main {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.big-word {
    font-size: 4.5rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

.front-logo {
    position: absolute;
    bottom: 10px;
    right: 10px;
}

.logo {
    width: 90px;
    height: auto;
    opacity: 0.9;
    transition: opacity 0.3s, transform 0.3s;
}

.logo:hover {
    opacity: 1;
    transform: scale(1.05);
}

/* BACK SIDE */
.card-back {
    background: var(--secondary-bg);
    transform: rotateY(180deg);
    color: var(--text-light);
}

.back-content {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 20px;
}

.rotated-label {
    position: absolute;
    left: 10px; /* Moves the label further left on larger screens */
    top: 50%;
    transform: translateY(-50%) rotate(270deg);
    transform-origin: center center;
    background: var(--accent-color);
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 5px;
    letter-spacing: 1px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.rotated-label .part-of-speech {
    color: var(--text-light);
}

.back-definition-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.definition-text {
    position: absolute;
    top: 50%;
    left: 45%;
    transform: translate(-50%, -50%);
    font-family: 'Poppins', sans-serif;
    font-size: 1.3rem;
    text-align: center;
    line-height: 1.4;
    max-width: 45%;
    color: var(--text-light);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    font-weight: 400;
    word-wrap: break-word;
    word-break: break-word;
    opacity: 0.95;
}

.definition-text::before,
.definition-text::after {
    position: absolute;
    color: rgba(255, 255, 255, 0.8);
    font-size: 2.5rem;
    font-family: "Times New Roman", serif;
}

.definition-text::before {
    content: "“";
    top: -30px;
    left: -15px;
}

.definition-text::after {
    content: "”";
    bottom: -30px;
    right: -15px;
}

.back-image-container {
    position: absolute;
    right: 5px; /* Moves the image further right on larger screens */
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

.oct-frame {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.oct-frame::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--accent-color);
    clip-path: polygon(
      30% 0%, 70% 0%, 
      100% 30%, 100% 70%, 
      70% 100%, 30% 100%, 
      0% 70%, 0% 30%
    );
    z-index: 0;
    transition: transform 0.3s, box-shadow 0.3s;
}

.oct-frame .word-image {
    position: relative;
    width: 95%;
    height: 95%;
    object-fit: cover;
    z-index: 1;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s, box-shadow 0.3s;
    clip-path: polygon(
      30% 0%, 70% 0%, 
      100% 30%, 100% 70%, 
      70% 100%, 30% 100%, 
      0% 70%, 0% 30%
    );
}

.oct-frame:hover::before {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
}

.oct-frame:hover .word-image {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
}

.sentence-text {
    position: absolute;
    bottom: 20px;
    left: 45%;
    transform: translateX(-50%);
    background: #fff;
    color: #333;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    line-height: 1.4;
    text-align: center;
    border-radius: 50px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 0.3rem 0.5rem;
    max-width: 90%;
    word-wrap: break-word;
}

/* ---------- WORD LIST STYLES ---------- */
#word-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 800px;
    margin: 20px auto;
    gap: 10px;
}

.word-list-item {
    background: var(--box-bg);
    color: var(--text-dark);
    padding: 10px 16px;
    border-radius: 6px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.word-list-item:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.word-list-item.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-light);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
    transform: translateY(0);
}

/* ---------- RESPONSIVE ADJUSTMENTS ---------- */
@media (max-width: 600px) {
    .card-scene {
        width: 95%; /* Adjusted for mobile */
        height: 220px; /* Reduced from 280px for a slightly smaller card */
    }

    .big-word {
        font-size: 2.5rem;
    }

    .oct-frame {
        width: 100px;  /* Set image container width to 100px */
        height: 100px; /* Set image container height to 100px */
    }

    .definition-text {
        font-size: 1.1rem;
        max-width: 80%;
    }
    
    /* Make the quotation marks smaller */
    .definition-text::before,
    .definition-text::after {
        font-size: 1.5rem; /* Reduced from 2.5rem */
    }

    .sentence-text {
        font-size: 1rem;
    }

    .level-selection-panel {
        width: 90%;
        max-width: 500px;
    }

    /* Adjust rotated label for mobile */
    .rotated-label {
        left: 5px;       /* Move further left */
        padding: 8px 12px;  /* Smaller padding */
        font-size: 0.9rem;  /* Slightly smaller font size */
    }

    /* Ensure back-image-container remains visible */
    .back-image-container {
        right: 0; /* Keep flush with the right edge */
    }
        .front-logo .logo {
        width: 60px; /* Adjust the value as needed */
    }

}
