@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');

:root {
    --primary-color: #4a90e2; 
    --secondary-color: #f4f7f6; 
    --text-color: #333;
    --border-color: #ddd;
    --explanation-bg: #eef5fd;
    --explanation-border: #a0c4e4;
    --hover-bg: #e0eaf6;
    --transition-speed: 0.4s;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #62cff4, #2c67f2); 
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

.container {
    background-color: #fff;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 100%;
    text-align: center; 
    padding-top: 0; /* Remove top padding if nav handles it */
}

h1, h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    font-weight: 600;
}

h1 {
    margin-top: 0; /* Reset top margin if container padding handles spacing */
    margin-bottom: 35px; /* Match nav margin-bottom */
}

/* Styles for Username Input */
.username-container {
    margin-bottom: 25px; /* Space before the start button */
    text-align: center; /* Center label and input */
}

.username-container label {
    display: block; /* Label on its own line */
    margin-bottom: 8px; /* Space between label and input */
    font-weight: 500;
    color: var(--primary-color); /* Use primary color for label */
    font-size: 1.05em;
}

.username-container input[type="text"] {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
    width: 100%; /* Full width within container */
    max-width: 350px; /* Limit max width */
    box-sizing: border-box; /* Include padding and border in width */
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.username-container input[type="text"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2); /* Subtle glow on focus */
    outline: none;
}
/* End Username Input Styles */

#startButton {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease;
    margin-bottom: 30px; 
}

#startButton:hover {
    background-color: #357abd; 
    transform: translateY(-2px);
}

#questionnaire-area {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed) ease-out, opacity var(--transition-speed) ease-out;
    text-align: left; 
}

#questionnaire-area.visible {
    opacity: 1;
    max-height: 7000px; 
}

.question-container {
    background-color: #fff;
    margin-bottom: 25px;
    padding: 20px 25px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: box-shadow var(--transition-speed) ease;
}

.question-container:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.07);
}

.question-container p strong {
    display: block; 
    margin-bottom: 15px;
    font-size: 1.1em;
    color: #555;
    font-weight: 600;
}

/* Style the div wrapping input/label pairs */
.question-container div:has(> input[type="radio"]) {
    margin-bottom: 12px; /* Spacing between options */
    position: relative; /* Needed for positioning the pseudo-element */
}

.question-container label {
    display: inline-block; /* Change to inline-block */
    padding: 10px 15px 10px 30px; /* Adjust padding: top, right, bottom, left */
    border-radius: 6px;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease, border-color var(--transition-speed) ease;
    border: 1px solid var(--border-color);
    width: calc(100% - 40px); /* Adjust width if needed, considering the input */
    vertical-align: middle; /* Align label text with custom radio */
    margin-left: 10px; /* Space between custom radio and label text */
}

.question-container label:hover {
    background-color: var(--hover-bg);
    border-color: #c0d9f0; /* Slightly darker border on hover */
}

.question-container input[type="radio"] {
    opacity: 0;
    position: absolute;
    left: 10px; /* Position hidden radio near the custom one */
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    width: 18px; /* Match custom radio size */
    height: 18px; /* Match custom radio size */
    cursor: pointer; /* Make the area clickable */
}

/* Custom radio button style using ::before on the LABEL's PARENT DIV */
.question-container div:has(> input[type="radio"])::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background-color: #fff;
    transition: border-color var(--transition-speed) ease, background-color var(--transition-speed) ease; /* Added background-color transition */
    pointer-events: none; /* Prevent interfering with clicks */
}

/* Style for the custom radio button when checked */
.question-container input[type="radio"]:checked + label {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border-color: var(--primary-color);
}

/* Corrected rule: Style the PARENT DIV's ::before when its child input is checked */
.question-container div:has(> input[type="radio"]:checked)::before {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

/* Style for the inner dot using ::after on the LABEL's PARENT DIV */
.question-container div:has(> input[type="radio"])::after {
    content: '';
    position: absolute;
    left: 15px; /* Adjust position based on ::before */
    top: 50%;
    transform: translate(-50%, -50%) scale(0); /* Start scaled down */
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #fff;
    transition: transform var(--transition-speed) ease;
    pointer-events: none; /* Prevent interfering with clicks */
}

/* Show the inner dot when checked */
.question-container div:has(> input[type="radio"]:checked)::after {
    transform: translate(-50%, -50%) scale(1); /* Scale up when checked */
}

.question-container input[type="radio"]:focus + label {
     outline: 2px dashed var(--primary-color);
     outline-offset: 2px;
}

/* Corrected focus style for custom radio */
.question-container div:has(> input[type="radio"]:focus-visible)::before {
     border-color: var(--primary-color);
     box-shadow: 0 0 0 2px var(--hover-bg);
}

.explanation {
    margin-top: 15px;
    padding: 15px;
    background-color: var(--explanation-bg);
    border: 1px solid var(--explanation-border);
    border-radius: 6px;
    color: #444;
    font-size: 0.95em;

    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed) ease-in-out, opacity var(--transition-speed) ease-in-out, padding var(--transition-speed) ease-in-out, margin-top var(--transition-speed) ease-in-out;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
}

.explanation.visible {
    opacity: 1;
    max-height: 300px; 
    padding: 15px; 
    margin-top: 15px; 
}

.explanation strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 5px;
}

#submitButton {
    background-color: #4CAF50; /* Green background */
    color: white;
    border: none;
    padding: 15px 30px; /* Consistent padding with start button */
    font-size: 1.1em; /* Consistent font size */
    font-weight: 600; /* Consistent font weight */
    border-radius: 8px; /* Consistent border radius */
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease, opacity var(--transition-speed) ease;
    margin-top: 30px; /* Add some space above the button */
    display: inline-block; /* Ensure it behaves like a block for margin/padding but flows inline */
}

#submitButton:hover {
    background-color: #45a049; /* Darker green on hover */
    transform: translateY(-2px); /* Slight lift effect */
}

#submitButton:disabled {
    background-color: #aaa; /* Grey background when disabled */
    cursor: not-allowed; /* Indicate it's not clickable */
    transform: none; /* Remove hover transform */
    opacity: 0.7; /* Slightly faded */
}

/* --- Quiz Selection Page Styles --- */
.quiz-selection {
    display: flex; /* Use flexbox for layout */
    justify-content: space-around; /* Distribute space between cards */
    flex-wrap: wrap; /* Allow cards to wrap on smaller screens */
    gap: 25px; /* Space between cards */
    margin-top: 40px; /* Space below the heading */
    text-align: left; /* Reset text align from container */
}

.quiz-card {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 25px;
    width: calc(33.333% - 40px); /* Aim for 3 cards per row, adjusting for gap and padding */
    min-width: 220px; /* Minimum width before wrapping */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.07);
    text-decoration: none; /* Remove underline from link */
    color: var(--text-color); /* Inherit text color */
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    display: flex; /* Use flex to help center content if needed */
    flex-direction: column; /* Stack content vertically */
    justify-content: space-between; /* Push content apart */
}

.quiz-card:hover {
    transform: translateY(-5px); /* Lift card on hover */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12); /* Increase shadow on hover */
}

.quiz-card h2 {
    margin-top: 0; /* Remove default top margin */
    margin-bottom: 15px;
    color: var(--primary-color); /* Use primary color for heading */
    font-size: 1.5em;
}

.quiz-card p {
    margin-bottom: 0; /* Remove default bottom margin */
    font-size: 0.95em;
    line-height: 1.5;
    color: #555; /* Slightly lighter text color for description */
}

/* Optional: Add specific background hints or borders */
.quiz-card.easy {
    border-left: 5px solid #6fcf97; /* Green accent for easy */
}
.quiz-card.medium {
    border-left: 5px solid #f2c94c; /* Yellow accent for medium */
}
.quiz-card.hard {
    border-left: 5px solid #eb5757; /* Red accent for hard */
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .quiz-card {
        width: calc(50% - 35px); /* Two cards per row */
    }
}

@media (max-width: 500px) {
    .quiz-card {
        width: 100%; /* One card per row */
        min-width: unset;
    }
    .quiz-selection {
        gap: 15px; /* Reduce gap */
    }
}

