/* ---------------------------------- */
/* GLOBAL & FONT SETUP (MAXIMUM MOBILE READABILITY) */
/* ---------------------------------- */
:root {
    /* Define primary colors for easier theme changes */
    --color-primary: #1e88e5;
    /* A vibrant, modern blue */
    --color-dark: #263238;
    /* Dark text/headers */
    --color-background: #f4f7f9;
    /* Light, soft background */
    --color-card: #ffffff;
    --color-border: #cccccc;
    /* Slightly darker border for contrast */

    /* Base font size MAXIMIZED for better mobile readability (20px) */
    font-size: 100%;
    /* 20px base / 16px default = 1.25 */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--color-background);
    color: var(--color-dark);
    line-height: 1.6;
    padding: 15px;
    margin: 0 auto;
    max-width: 800px;
    box-sizing: border-box;
}

/* Reduce font size on larger screens (Desktop) to prevent over-sizing */
@media (min-width: 600px) {
    :root {
        font-size: 100%;
        /* Back to 16px base on desktop */
    }

    body {
        padding: 25px;
    }
}

/* ---------------------------------- */
/* TITLES & CONTENEURS (LARGER TEXT) */
/* ---------------------------------- */
h1 {
    color: var(--color-primary);
    font-size: 2.5em;
    /* Bigger title */
    text-align: center;
    margin-bottom: 5px;
    font-weight: 700;
}

p {
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 1.1em;
    /* Larger paragraph text */
}

h2 {
    color: var(--color-dark);
    font-size: 1.3em;
    /* Larger question number/student name title */
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 600;
}

/* Highlighted container for the selected student name */
#student-name-display {
    font-size: 1.2em;
    /* Bigger display name */
    font-weight: 700;
    color: var(--color-primary);
    text-align: center;
    padding: 10px 0;
    margin-bottom: 25px;
    display: none;
}

.question-block {
    background-color: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 30px;
    /* Increased padding inside blocks */
    margin-bottom: 35px;
    /* Increased margin between blocks */
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.question-block img {
    display: block;
    margin: 15px auto;
    max-width: 90%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ---------------------------------- */
/* FORM ELEMENTS & INPUTS (HUGE TOUCH TARGETS) */
/* ---------------------------------- */

/* Selecteur (MASSIVE target area) */
select {
    width: 100%;
    padding: 20px 15px;
    /* Significantly increased padding for a tall element */
    font-size: 1.1em;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background-color: #f9f9f9;
    box-sizing: border-box;
    margin-bottom: 25px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Options de Réponse (Radio Buttons - Biggest hit area) */
/* ---------------------------------- */
/* RADIO & CHECKBOX STYLES (UNIFIED)  */
/* ---------------------------------- */

/* 1. The Container Label (For both Radio & Checkbox) */
.options label {
    display: block;  /* Ensures text flows naturally for inline math */
    position: relative; /* Anchor for absolute positioning of the box/circle */
    
    /* Padding: Top/Bottom 20px, Right 15px, Left 60px (Space for the button) */
    padding: 20px 15px 20px 60px; 
    
    border: 1px solid var(--color-border);
    border-radius: 10px;
    margin-top: 15px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    font-size: 1.1em;
    background-color: transparent;
}

/* Hover effects */
.options label:hover:not([data-is-correct]):not([data-is-incorrect-selected]) {
    background-color: #e9f5ff;
    border-color: var(--color-primary);
}

/* Hide the actual input elements */
.options input[type="radio"],
.options input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    height: 0;
    width: 0;
}

/* 2. The Indicator Base (Shared size & position for Box and Circle) */
.options input[type="radio"] + span,
.options input[type="checkbox"] + span {
    position: absolute;
    left: 15px;       /* Fixed distance from the left edge */
    top: 50%;         /* Center vertically */
    transform: translateY(-50%); /* Adjust for own height */
    
    display: inline-block;
    width: 24px;      /* Fixed Width */
    height: 24px;     /* Fixed Height */
    min-width: 24px;  /* Prevent shrinking */
    
    border: 3px solid #aaa;
    background-color: transparent;
    transition: all 0.2s ease-in-out;
}

/* 3. Shape Specifics */

/* Radio = Circle */
.options input[type="radio"] + span {
    border-radius: 50%;
}

/* Checkbox = Slightly Rounded Square */
.options input[type="checkbox"] + span {
    border-radius: 6px; 
}

/* 4. Checked State (Background Color) */
.options input[type="radio"]:checked + span,
.options input[type="checkbox"]:checked + span {
    border-color: var(--color-primary);
    background-color: var(--color-primary);
}

/* 5. Inner Marks (Dot vs Checkmark) */

/* Create the pseudo-element */
.options input[type="radio"] + span::after,
.options input[type="checkbox"] + span::after {
    content: '';
    position: absolute;
    display: none; /* Hidden by default */
}

/* Show it when checked */
.options input[type="radio"]:checked + span::after,
.options input[type="checkbox"]:checked + span::after {
    display: block;
}

/* RADIO DOT STYLE */
.options input[type="radio"] + span::after {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ffffff; /* White dot */
}

/* CHECKBOX CHECKMARK STYLE */
.options input[type="checkbox"] + span::after {
    left: 7px;
    top: 3px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 3px 3px 0; /* Draw the checkmark */
    transform: rotate(45deg);
    background-color: transparent;
}

/* ---------------------------------- */
/* CONTROL BUTTONS (HUGE AND TALL) */
/* ---------------------------------- */
#controls-navigation {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 35px;
}

@media (min-width: 600px) {
    #controls-navigation {
        flex-direction: row;
    }
}

#controls-submit {
    margin-top: 35px;
}

/* Base button style (Bigger text and maximum padding) */
button {
    width: 100%;
    padding: 20px 20px;
    /* Maximum vertical padding for touch target */
    font-size: 1.2em;
    /* Even larger text */
    border-radius: 10px;
    border: none;
    color: white;
    background-color: var(--color-primary);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
}

button:hover {
    background-color: #1565c0;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

/* Disable button state (used for anti-double click) */
button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#checkAnswerBtn,
#nextQuestionBtn {
    flex-grow: 1;
}

/* ---------------------------------- */
/* FEEDBACK AND MESSAGES (PROMINENT) */
/* ---------------------------------- */
#feedback {
    font-size: 1.2em;
    /* Larger feedback text */
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: none;
}

/* Correct/Incorrect styles - more emphasis */
.feedback-correct {
    color: white !important;
    background-color: #28a745;
}

.feedback-incorrect {
    color: white !important;
    background-color: #dc3545;
}

/* Style for correct option highlight */
.options label[data-is-correct="true"] {
    background-color: #e9fbe9 !important;
    border: 2px solid #28a745 !important;
}

/* Style for incorrect option that was selected */
.options label[data-is-incorrect-selected="true"] {
    background-color: #ffe0e0 !important;
    border: 2px solid #dc3545 !important;
}

/* ---------------------------------- */
/* DRAG AND DROP STYLES (UPDATED FOR INLINE TEXT) */
/* ---------------------------------- */

/* Main container */
.drag-drop-container {
    display: flex;
    flex-direction: column; /* Stack text then options */
    gap: 20px;
    margin-top: 20px;
    padding: 10px;
    background-color: #f7f7f7;
    border-radius: 8px;
}

/* Container for the sentence with holes */
.drag-text-container {
    line-height: 2.5; /* Line height to fit drop zones */
    font-size: 1.1em;
    padding: 15px;
    background-color: var(--color-card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Container for the word bank */
.draggable-options {
    padding: 15px;
    background: #e3f2fd; /* Light blue background for the bank */
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    min-height: 60px;
    border: 1px solid #bbdefb;
}

.draggable-options h3 {
    width: 100%;
    margin-top: 0;
    border-bottom: 2px solid rgba(0,0,0,0.1);
    padding-bottom: 5px;
    margin-bottom: 15px;
    font-size: 1.1em;
    color: var(--color-primary);
    text-align: center;
}

/* The Draggable Word Item (Blue and White) */
.draggable-item {
    padding: 8px 16px; /* Comfortable padding */
    background-color: #3498db; /* Visible Blue */
    color: #ffffff; /* White text */
    border: 1px solid #2980b9;
    border-radius: 4px;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-weight: bold;
    user-select: none;
    display: inline-block;
    font-size: 1em;
    
    /* Mobile Touch Fixes */
    touch-action: none; 
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-touch-callout: none;
}

.draggable-item:hover {
    background-color: #2980b9;
}

.draggable-item:active {
    cursor: grabbing;
}

.draggable-item.dragging {
    opacity: 0.5;
}

/* The Drop Zone (Hole in the text) */
.drop-zone-slot {
    display: inline-flex; /* Sits inside text */
    align-items: center;
    justify-content: center;
    min-width: 100px;
    min-height: 40px;
    margin: 0 5px;
    border-bottom: 3px solid #555; /* Underline look */
    background-color: #eaeaea;
    vertical-align: middle;
    border-radius: 4px;
    padding: 0 5px;
    transition: background-color 0.3s, border-color 0.3s;
    position: relative;
}

.drop-zone-slot:empty::before {
    content: ""; /* Remove text placeholder to look like a blank space */
}

.drop-zone-slot.drag-over {
    background-color: #e0e0ff !important;
    border-bottom-color: #0000ff !important;
}

/* Feedback Colors for Drop Zones */
.drop-zone-slot.feedback-correct {
    border: 2px solid #28a745;
    background-color: #d4edda;
}

.drop-zone-slot.feedback-incorrect {
    border: 2px solid #dc3545;
    background-color: #f8d7da;
}

/* When item is dropped inside the slot */
.drop-zone-slot .draggable-item {
    margin: 0;
    box-shadow: none;
    cursor: pointer;
}


/* Style for checkbox options that were correct but not selected (Missed answer) */
.options label[data-is-not-selected='true'] {
    border-color: #ffc107;
    background-color: #fff3cd;
    box-shadow: 0 0 5px rgba(255, 193, 7, 0.5);
    opacity: 0.8;
}

.options label[data-is-not-selected='true'] span::before {
    content: '⚠️';
    background-color: #ffc107;
    color: var(--color-dark);
}

.options label[data-is-incorrect-selected='true'] {
    border-color: var(--color-danger) !important;
    background-color: var(--color-light-danger) !important;
}

/* ---------------------------------- */
/* UTILITIES & NAVIGATION */
/* ---------------------------------- */

/* Styles for numerical and short answer inputs */
.numerical-input input[type="text"],
.short-answer-input input[type="text"] {
    width: 100%;
    padding: 20px 15px;
    font-size: 1.1em;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    box-sizing: border-box;
    margin-bottom: 25px;
}

.numerical-input p {
    margin-top: -20px;
    text-align: right;
    font-size: 1em;
}

.short-answer-input p {
    margin-top: -20px;
    text-align: right;
    font-size: 0.9em;
    color: #666;
}

.instruction-multi-choice {
    font-size: 0.9em;
    color: var(--color-dark);
    margin-top: 15px;
    font-weight: 500;
}

/* Question Navigation Block */
#question-navigation {
    margin-top: 30px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

#question-navigation h3 {
    margin-top: 0;
    font-size: 1.1em;
    color: #333;
}

#question-markers {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.question-marker {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid #ccc;
    background: white;
    font-weight: bold;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Legend */
#question-navigation p {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 0;
    margin-top: 15px;
}

#question-navigation p span {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    vertical-align: middle;
}

.legend-correct {
    background: #e0ffe0;
    border: 2px solid #00a000;
}

.legend-incorrect {
    margin-left: 15px;
    background: #ffe0e0;
    border: 2px solid #a00000;
}

.legend-unanswered {
    margin-left: 15px;
    background: white;
    border: 2px solid #ccc;
}

.legend-current {
    margin-left: 15px;
    background: #fff3cd;
    border: 2px solid #ffc107;
}

/* ---------------------------------- */
/* STRUCTURE & UTILITIES (MOVED FROM QUIZ TEMPLATE) */
/* ---------------------------------- */

/* Initial state of the quiz content */
#quiz-interface {
    display: none;
}

/* Styling for the introductory page */
#intro-page {
    text-align: center;
    padding: 40px 20px;
    max-width: 600px;
    margin: 0 auto;
}

/* Styling for the start button (overriding base button style) */
#startQuizBtn {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1.2em;
    cursor: pointer;
    background-color: #4CAF50; /* Specific color */
    color: white;
    border: none;
    border-radius: 5px; /* Less rounded than standard button */
}
#startQuizBtn:hover {
    background-color: #45a049;
}

/* Header info for student name and chapter */
.student-header-info {
    background: #f0f0f0;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 5px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Instruction for numerical answers */
.sig-fig-instruction {
    font-size: 0.9em;
    color: #555;
    margin-top: 8px;
    font-style: italic;
}

.math-spacer {
    /* Apply a small margin on the left and right sides */
    margin: 0 0.3em;
    /* This makes the span behave like a block element for the margin to work reliably, 
       but allows it to sit inline with the text. */
    display: inline; 
}

.options label mjx-container {
    white-space: nowrap !important;
    display: inline-block !important;
    vertical-align: middle;
}

/* Prevent text from being split across lines */
.options label > *:not(span) {
    white-space: normal !important;
}
