/* General Design & Font Aspects */
:root {
    --primary-color: #005A9C;
    --primary-hover: #00487A;
    --text-color: #333333;
    --background-color: #f4f7f9;
    --card-background: #FFFFFF;
    --border-color: #dee2e6;
    --correct-bg: #e9f7ef;
    --correct-text: #1d7a46;
    --incorrect-bg: #fdecea;
    --incorrect-text: #a91e2c;

    /* Base font size for rem calculations */
    font-size: 100%; /* Default 16px */
}

/* Font size variations for accessibility */
body.font-size-small {
    font-size: 90%; /* ~14.4px base */
}

body.font-size-medium {
    font-size: 100%; /* ~16px base */
}

body.font-size-large {
    font-size: 115%; /* ~18.4px base */
}

/* High Contrast Mode */
body.high-contrast {
    background-color: #000000 !important;
    color: #FFFF00 !important; /* Yellow text for high contrast */
}
body.high-contrast header,
body.high-contrast nav,
body.high-contrast main > section,
body.high-contrast footer {
    background-color: #000000 !important;
    border-color: #FFFF00 !important; /* Optional, but good for contrast */
    box-shadow: none !important; /* Remove shadows in high contrast */
}
body.high-contrast h1,
body.high-contrast h2,
body.high-contrast h3 {
    color: #FFFF00 !important;
}
body.high-contrast a {
    color: #99FFFF !important; /* Cyan for links */
}
body.high-contrast .read-aloud-button,
body.high-contrast #check-button,
body.high-contrast .accessibility-controls button {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #000000 !important;
}
body.high-contrast .read-aloud-button:hover,
body.high-contrast #check-button:hover,
body.high-contrast .accessibility-controls button:hover {
    background-color: #cccccc !important;
}
body.high-contrast .result-span.correct {
    background-color: #006400 !important; /* Dark green for correct */
    color: #FFFFFF !important;
}
body.high-contrast .result-span.incorrect {
    background-color: #8B0000 !important; /* Dark red for incorrect */
    color: #FFFFFF !important;
}
body.high-contrast input[type="text"] {
    background-color: #333333 !important;
    color: #FFFF00 !important;
    border-color: #FFFF00 !important;
}


body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.7;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
}

/* Limit width for readability and center content */
.container {
    max-width: 800px;
    margin: 20px auto;
}

/* Card-like design for sections */
header, nav, main > section, footer, .accessibility-controls {
    background-color: var(--card-background);
    padding: 1.5rem 1.8rem; /* Use rem units */
    border-radius: 0.5rem; /* Use rem units */
    margin-bottom: 1.5rem; /* Use rem units */
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.05); /* Use rem units */
}

/* Typography */
h1, h2, h3 {
    text-transform: none;
    color: var(--primary-color);
}

h1 {
    font-size: 2.5rem; /* Use rem units */
    margin-bottom: 0.625rem; /* Use rem units */
    text-align: center;
}

header p {
    text-align: center;
    font-size: 1.1rem; /* Use rem units */
    color: #6c757d;
}

h2 {
    font-size: 1.875rem; /* Use rem units */
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.625rem; /* Use rem units */
    margin-top: 0;
    display: flex; /* Allow inline elements to be aligned */
    align-items: center; /* Vertically align items */
    justify-content: space-between; /* Push button to the right */
}

h3 {
    font-size: 1.5rem; /* Use rem units */
}

ul {
    list-style-type: disc;
    padding-left: 1.875rem; /* Use rem units */
}

p, li {
    margin-top: 0.625rem; /* Use rem units */
    margin-bottom: 0.625rem; /* Use rem units */
}

/* Link Styling */
a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}

a:hover {
    text-decoration: underline;
}

/* Main Button Styling (e.g., Check Answers button) */
button {
    display: block;
    font-family: inherit;
    font-size: 1.125rem; /* Use rem units */
    font-weight: bold;
    color: #FFFFFF;
    background-color: var(--primary-color);
    padding: 0.875rem 1.75rem; /* Use rem units */
    border: none;
    border-radius: 0.5rem; /* Use rem units */
    margin: 1.875rem 0 0.625rem; /* Use rem units */
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease;
}

button:hover {
    background-color: var(--primary-hover);
}

button:active {
    transform: translateY(1px);
}

/* Read Aloud Button Specific Styling */
.read-aloud-button {
    display: inline-flex; /* Use inline-flex to align icon and text */
    align-items: center;
    gap: 0.3125rem; /* Use rem units */
    font-size: 0.875rem; /* Use rem units */
    padding: 0.5rem 0.9375rem; /* Use rem units */
    margin-top: 0; /* Override main button margin */
    margin-left: 1.25rem; /* Use rem units */
    background-color: #6c757d; /* A more subtle color for read aloud */
    color: #FFFFFF;
    border-radius: 0.3125rem; /* Use rem units */
    box-shadow: none; /* No shadow for this smaller button */
    transition: background-color 0.2s ease-in-out;
}

.read-aloud-button:hover {
    background-color: #5a6268;
}

.read-aloud-button .icon {
    font-size: 1em; /* Ensure icon is legible */
    line-height: 1; /* Align icon vertically */
}

/* Accessibility Controls Styling */
.accessibility-controls {
    display: flex;
    justify-content: flex-end; /* Align to the right */
    gap: 0.625rem; /* Space between buttons */
    padding: 0.75rem 1rem; /* Adjust padding */
    margin-bottom: 1.5rem; /* Consistent margin */
    /* Override card-like defaults for a more compact bar */
    background-color: var(--background-color); 
    box-shadow: none;
    border-radius: 0;
}

.accessibility-controls button {
    display: inline-block; /* Make them inline for the flex container */
    margin: 0; /* Override default button margin */
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--primary-color);
    color: #FFFFFF;
    border-radius: 0.25rem;
    cursor: pointer;
}

.accessibility-controls button:hover {
    background-color: var(--primary-hover);
}

/* Practice Section Styling */
.question-item {
    margin-bottom: 1.5rem; /* Use rem units */
    font-size: 1.05rem; /* Use rem units */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.question-item label {
    flex-grow: 1;
}

input[type="text"] {
    font-family: inherit;
    font-size: 1.0625rem; /* Use rem units (17px) */
    padding: 0.625rem 0.75rem; /* Use rem units */
    border: 2px solid var(--border-color);
    border-radius: 0.375rem; /* Use rem units */
    margin: 0 0.5rem; /* Use rem units */
    min-width: 11.25rem; /* Use rem units (180px) */
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.result-span {
    display: inline-block;
    padding: 0.3125rem 0.75rem; /* Use rem units */
    border-radius: 0.9375rem; /* Use rem units */
    font-size: 0.9rem; /* Use rem units */
    font-weight: bold;
    margin-top: 0.5rem; /* Use rem units */
}

.correct {
    background-color: var(--correct-bg);
    color: var(--correct-text);
}

.incorrect {
    background-color: var(--incorrect-bg);
    color: var(--incorrect-text);
}
