/* Basic body and container styling for centering and background */
body {
    font-family: 'Inter', sans-serif; /* Using Inter font as per guidelines */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align content to the top */
    min-height: 100vh; /* Minimum height to fill the viewport */
    background-color: #f0f2f5; /* Light grey background */
    margin: 0; /* Remove default body margin */
    padding: 20px; /* Padding around the main content */
    box-sizing: border-box; /* Include padding in element's total width and height */
}

.container {
    background-color: #ffffff; /* White background for the main container */
    padding: 30px;
    border-radius: 12px; /* Rounded corners for the container */
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15); /* Soft shadow for depth */
    width: 95%; /* Responsive width */
    max-width: 1000px; /* Maximum width for larger screens */
    text-align: center;
    margin-top: 20px; /* Space from the top of the viewport */
}

/* Heading styles */
h1, h2 {
    color: #2c3e50; /* Darker blue-grey for headings */
    margin-bottom: 20px;
}

/* Input section styling */
.input-section {
    margin-bottom: 30px;
    padding: 25px;
    border: 1px solid #dcdcdc; /* Light grey border */
    border-radius: 10px; /* Rounded corners */
    background-color: #ecf0f1; /* Slightly darker grey background */
    text-align: left;
}

.input-section p {
    color: #34495e; /* Dark blue-grey text */
    margin-bottom: 15px;
}

.input-section ul {
    list-style-type: disc; /* Bullet points */
    margin-left: 20px;
    margin-bottom: 20px;
    color: #555;
}

#wordInput {
    width: calc(100% - 20px); /* Full width minus padding */
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #bdc3c7; /* Medium grey border */
    border-radius: 6px; /* Slightly rounded corners */
    resize: vertical; /* Allow vertical resizing */
    font-size: 16px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08); /* Inner shadow for input field */
}

/* Added style for word count info */
.word-count-info {
    font-size: 0.9em;
    color: #555;
    margin-bottom: 10px;
    text-align: right; /* Align to the right of the textarea */
}

/* Button styling */
#generateDeckBtn, #nextCardsBtn {
    background-color: #3498db; /* Blue button */
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px; /* Rounded corners for buttons */
    cursor: pointer;
    font-size: 17px;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease; /* Smooth transitions */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Button shadow */
    margin-top: 10px;
}

#generateDeckBtn:hover, #nextCardsBtn:hover {
    background-color: #2980b9; /* Darker blue on hover */
    transform: translateY(-2px); /* Slight lift effect on hover */
}

#generateDeckBtn:active, #nextCardsBtn:active {
    transform: translateY(0); /* Press down effect */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Card display section */
.card-display-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee; /* Separator line */
    /* Use flexbox to ensure button is positioned relative to cards */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center button horizontally */
}

.card-container {
    display: flex;
    justify-content: center; /* Center cards horizontally */
    gap: 30px; /* Space between cards */
    flex-wrap: wrap; /* Allow cards to wrap to the next line on smaller screens */
    margin-top: 25px;
    /* Removed min-height here to allow cards to determine height */
    align-items: center; /* Center vertically if only one row */
    width: 100%; /* Ensure container takes full width */
}

/* Individual card styling */
.card {
    background-color: #fdfdfd; /* Off-white card background */
    border: 3px solid #3498db; /* Blue border for cards */
    border-radius: 15px; /* More rounded corners for cards */
    
    /* Responsive sizing for cards */
    flex: 1; /* Allow cards to grow and shrink */
    min-width: 250px; /* Minimum width for cards */
    max-width: calc(50% - 15px); /* Max width to allow two cards per row with gap */
    /* Adjusted aspect ratio to make cards less tall (wider relative to height) */
    aspect-ratio: 1 / 1.1; /* New aspect ratio for desktop */

    display: flex;
    flex-direction: column; /* Stack words vertically by default */
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box; /* Include padding in width/height */
    position: relative; /* Essential for positioning rotated words */
    overflow: hidden; /* Hide words that go outside card boundaries */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1); /* Card shadow */
    transition: transform 0.2s ease; /* Smooth transition for hover effects */
}

.card:hover {
    transform: translateY(-5px); /* Slight lift on hover */
}

/* Remove card title styling as it will be removed from HTML */
/* .card h3 { ... } */

.card p {
    font-weight: bold;
    margin: 0; /* Remove default margin */
    white-space: nowrap; /* Prevent words from wrapping */
    position: absolute; /* Position words for rotation */
    /* Initial state for animation: hidden and slightly above final position */
    opacity: 0;
    transform: translateY(-20px); /* Will be set by JS, but this is a good default */
    /* Transition for the drop and fade-in effect */
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
    /* Dynamic positioning, rotation, and font size will be applied by JavaScript */
    color: #333; /* Default color, will be overridden by JS for random colors */
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        width: 100%; /* Full width on smaller screens */
    }

    .card {
        min-width: 200px; /* Smaller min-width on mobile */
        max-width: 100%; /* Cards stack vertically on smaller screens */
        /* Adjusted aspect ratio for mobile to be more square */
        aspect-ratio: 1 / 1; /* New aspect ratio for mobile */
    }

    .card p {
        font-size: 16px; /* Adjust base font size for smaller cards */
    }

    #generateDeckBtn, #nextCardsBtn {
        padding: 10px 20px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }

    h2 {
        font-size: 1.4em;
    }

    .input-section {
        padding: 15px;
    }

    #wordInput {
        font-size: 14px;
    }

    .card-container {
        gap: 15px; /* Reduce gap between cards */
    }
}

/* Lightbox-specific adjustments */
#lightboxOverlay .card-container {
    max-width: 1000px;
    width: 100%;
    justify-content: center;
    gap: 30px;
}

#lightboxOverlay .card {
    max-width: 45%;
    min-width: 300px;
    aspect-ratio: 1 / 1.1;
}

#lightboxOverlay #toggleSettingsBtn {
    align-self: flex-start;
    margin-bottom: 10px;
}

/* Make sure the Close button stays visible */
#lightboxOverlay button {
    z-index: 10;
}


/* Lightbox overlay enhancements */
#lightboxOverlay {
    padding-top: 80px; /* space for the close button */
}

#lightboxOverlay .card-container {
    width: 100%;
    max-width: 1400px;
    gap: 40px;
    justify-content: center;
}

#lightboxOverlay .card {
    min-width: 400px;
    max-width: 600px;
    flex: 1 1 45%;
    aspect-ratio: 1 / 1.1;
}

/* Improve visibility of the close button */
#lightboxOverlay button#closeBtn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    padding: 12px 24px;
    font-size: 18px;
}

/* Remove toggle button style if left in DOM */
#toggleSettingsBtn {
    display: none !important;
}
