:root {
    --background-color: #fff;
    --text-color: #000;
    --button-fill: #e0e0e0;
    --button-hover-fill: #c0c0c0;
    --correct-color: #4CAF50;
    --wrong-color: #F44336;
    --font-family: 'Tahoma', sans-serif;
    --button-border: 1px solid rgba(0, 0, 0, 0.229);
}

body.dark {
    --background-color: #333;
    --text-color: #fff;
    --button-fill: #555;
    --button-hover-fill: #777;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
    width: 100%;
}

/* Footer Layout */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: transparent;
    z-index: 1000;
}

.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px;
    box-sizing: border-box;
    width: 100%;
}

/* Menu Button */
.menu-button {
    cursor: pointer;
    padding: 7px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
    color: var(--text-color);
    background-color: var(--button-fill);
    border: var(--button-border);
    max-width: 1em;
}

.menu {
    position: absolute;
    bottom: 40px;
    left: 2px;
    background-color: transparent;
    overflow: hidden;
    transition: max-height 0.2s ease-in-out, border-color 0.2s ease-in-out;
    max-height: 0;
    border-color: transparent;
    display: flex;
    flex-direction: column;
}

.menu.open {
    max-height: 500px;
    border-color: #ccc;
}

.menu-item {
    padding: 5px;
    color: var(--text-color);
    background-color: var(--button-fill);
    transition: background-color 0.2s;
    cursor: pointer;
    border: var(--button-border);
    border-radius: 4px;
    margin-bottom: 2px;
}

/* New styles for font controls */
.menu-item.font-adjust {
  padding: 5px;
  color: var(--text-color);
  background-color: var(--button-fill);
  transition: background-color 0.2s;
  cursor: pointer;
  border: var(--button-border);
  border-radius: 4px;
  margin-bottom: 2px;
  display: inline-block; /* Make buttons sit side-by-side */
  width: calc(33.33% - 5px); /* Account for margins */
  text-align: center;
  box-sizing: border-box;
}

/* Horizontal spacing between buttons */
.menu-item.font-adjust:not(:last-child) {
  margin-right: 2px;
}

/* Read Button */
/* .read-button {
    background-color: var(--button-fill);
    color: var(--text-color);
    border: var(--button-border);
    padding: 7px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}
 */
/* Question Navigator */
.question-navigator {
    display: flex;
    align-items: center;
}

#question-number {
    width: 40px;
    padding: 2px;
    margin: 0 5px;
    border: 2px solid var(--button-fill);
    border-radius: 4px;
    text-align: center;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* Navigation Buttons */
.navigation-buttons {
    display: flex;
    gap: 10px;
}

.navigation-buttons button {
    background-color: var(--button-fill);
    color: var(--text-color);
    border: var(--button-border);
    padding: 7px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.navigation-buttons button:hover,
.menu-button:hover,
.menu-item:hover {
    background-color: var(--button-hover-fill);
}

.selectable {
    -webkit-user-select: text; /* Safari */
    -ms-user-select: text; /* Internet Explorer/Edge */
    user-select: text;
}
.non-selectable {
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none;
}
.all-selectable {
    -webkit-user-select: all; /* Safari */
    -ms-user-select: all; /* Internet Explorer/Edge */
    user-select: all;
}


/* Question Section */
.menu-item.font-size-control {
    display: flex;
    gap: 4px;
}

.menu-item.font-size-control button {
    min-width: 30px;
    padding: 2px 0;
    cursor: pointer;
    background: var(--menu-bg);
    border: 1px solid var(--border-color);
    border-radius: 3px;
}

.question-box {
    /* Remove font-size from here */
    margin: 2px 0px 40px;
    text-align: left;
    padding: 2px;
    /* These are technically the same, but use both */
    overflow-wrap: break-word;
    word-wrap: break-word;
    -ms-word-break: break-all;
    /* This is the dangerous one in WebKit, as it breaks things wherever */
    word-break: break-all;
    /* Instead use this non-standard one: */
    word-break: break-word;

    /* Adds a hyphen where the word breaks, if supported (No Blink) */
    -ms-hyphens: auto;
    -moz-hyphens: auto;
    -webkit-hyphens: auto;
    hyphens: auto;
}

#question-text {
    margin-top:0px;
    margin-right: 5px;
    margin-left: 5px;
}
#question-text img {
    width: 100%;
    max-width: 100%;
}
#explanations-container img {
    width: 100%;
    max-width: 100%;
    height: auto;
    box-sizing: border-box;
}

.option-button {
    display: block;
    width: 100%;
    text-align: left;
    margin-top: 10px;
    padding: 8px 10px;
    background-color: transparent;
    color: var(--text-color); /* Ensure this is explicitly set */
    border: 2px solid var(--button-fill);
    border-radius: 5px;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s; /* Add transition for color */
    font-size: 0.75em;
    position: relative;
    z-index: 2;
    transition: border-radius 0.3s ease;
}

.option-button:hover {
    background-color: var(--button-hover-fill);
    cursor: pointer; /* Changes cursor to hand pointer on hover */
}

.option-button.correct {
    background-color: var(--correct-color);
    border-color: var(--correct-color);
}

.option-button.wrong {
    background-color: var(--wrong-color);
    border-color: var(--wrong-color);
}
.option-container {
    margin-bottom: 5px;
}

.option-button.feedback-visible {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
}

.option-feedback {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: var(--background-color-light);
    border: 2px solid var(--button-fill);
    border-top: none;
    border-radius: 0 0 5px 5px;
    padding: 0 10px;
    font-size: 0.9em;
    color: var(--text-color-secondary);
    margin-top: -2px; /* Align with button border */
}

.option-button.correct + .option-feedback {
    border-color: var(--correct-color);
    background-color: rgba(40, 167, 69, 0.1);
}

.option-button.wrong + .option-feedback {
    border-color: var(--wrong-color);
    background-color: rgba(220, 53, 69, 0.1);
}

.option-button.correct + .option-feedback,
.option-button.wrong + .option-feedback {
    border-top: 1px solid var(--border-color);
}

p {
    margin: 0.3em;
}
#options-container p {
    margin: 0;
    padding: 0;
    display: inline;
    font-style: normal;
    font-weight: normal;
    text-decoration: none;
    text-transform: none;
    line-height: normal;
  }
pre {
    margin: 0px;
}

/* Styling for pre elements with prettyprint class */
pre.prettyprint {
    background-color: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.7em;
    overflow-x: auto;
    max-width: 100%;
    white-space: pre;
    margin: 0;
}

/* Line numbers styling */
pre.prettyprint.linenums {
    padding-left: 5px;
    position: relative;
    counter-reset: line;
}

pre.prettyprint.linenums:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #ebebeb;
    border-right: 1px solid #ddd;
}

/* Optional: Add a nice header to your code blocks */
.code-header {
    background-color: #e0e0e0;
    padding: 5px 15px;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    border: 1px solid #ccc;
    border-bottom: none;
    font-weight: bold;
    font-family: sans-serif;
    font-size: 12px;
    color: #333;
}

/* Pair with pre to make a nice code block */
.code-header + pre.prettyprint {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
}

/* For your inline code elements */
code {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.7em;
    padding: 2px 5px;
    color: rgb(0, 0, 0);
    margin-bottom: 0.5em;
}

.code-controls {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 4px;
    padding: 3px;
    z-index: 10;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.code-controls button {
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    opacity: 0.6;
}
.code-controls button:hover {
    opacity: 1;
    transform: scale(1.03);
}

.run-button {
    cursor: pointer;
    padding: 5px 10px;
    border: none;
    border-radius: 3px;
    background-color: #f0f0f0;
    color: #333;
    font-size: 16px;
    font-weight: bold;
}
.run-button:hover {
    background: #45a049;
}
.run-button:disabled {
    background: #cccccc;
    cursor: wait;
}

/* NEW: Styles for Edit and Reset buttons */
.edit-button {
    background: #008CBA;
    color: white;
}
.edit-button:hover {
    background: #007ba7;
}

.reset-button {
    background: #E75A5A;
    color: white;
}
.reset-button:hover {
    background: #D43E3E;
}


/* NEW: Style for the textarea to match the <pre> block */
.code-editor {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    border-radius: 4px;
    resize: vertical;
    /* Mimic pre styles */
    background-color: #ffffff;
    border: 1px solid #ccc;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.7em;
    line-height: 1.5;
}

.code-output {
    display: none;
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-top: none;
    padding: 10px;
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    margin-top: -5px;
    max-height: 200px;
    overflow-y: auto;
}

/* Dark theme adjustments for code blocks including line numbering */
body.dark pre.prettyprint {
    background-color: #3e3e3e;
    border-color: #2d2d2d;
    color: #fff;
}

body.dark pre.prettyprint.linenums {
    padding-left: 5px;
    counter-reset: line;
    position: relative;
}

body.dark pre.prettyprint.linenums:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #353535;
    border-right: 1px solid #2d2d2d;
}

body.dark pre.prettyprint.linenums .line {
    counter-increment: line;
    position: relative;
    display: block;
    padding-left: 5px; /* Space for line numbers */
    margin: 0;
    line-height: 1.5;
}

body.dark pre.prettyprint.linenums .line:before {
    content: counter(line);
    position: absolute;
    left: 0;
    width: 40px;
    text-align: right;
    padding-right: 10px;
    color: #bbb;
    background-color: inherit;
}

body.dark .code-header {
    background-color: #444;
    border-color: #2d2d2d;
    border-bottom: none;
    color: #fff;
}

body.dark .run-button:disabled {
    background: #555;
    color: #999;
}

body.dark .code-output {
    background-color: #303030;
    border-color: #2d2d2d;
    border-top: none;
    color: #fff;
}

body.dark code {
    background-color: #3e3e3e;
    border-color: #2d2d2d;
    color: #fff;
}

body.dark .edit-button {
    background: #1d7291;
}
body.dark .edit-button:hover {
    background: #2590b9;
}
/* REPLACES .code-container */
.code-wrapper {
    position: relative;
}


/* REPLACES old .run-button style */
.run-button {
    background: #4CAF50;
    color: white;
}
.run-button:hover {
    background: #45a049;
}
.run-button:disabled {
    background: #cccccc;
    cursor: wait;
}

/* NEW: Styles for Edit and Reset buttons */
.edit-button {
    background: #008CBA;
    color: white;
}
.edit-button:hover {
    background: #007ba7;
}

.reset-button {
    background: #E75A5A;
    color: white;
}
.reset-button:hover {
    background: #D43E3E;
}


/*
  The old .code-output styles are still valid and do not need to be changed.
*/

/* --- Dark Theme Adjustments --- */

body.dark .run-button:disabled {
    background: #555;
    color: #999;
}

body.dark .edit-button {
    background: #1d7291;
}
body.dark .edit-button:hover {
    background: #2590b9;
}

body.dark .reset-button {
    background: #b64545;
}
body.dark .reset-button:hover {
    background: #d45c5c;
}

body.dark .code-editor {
    background-color: #3e3e3e;
    border-color: #2d2d2d;
    color: #f1f1f1;
}

br {
content: "";
margin: 1em;
display: block;
font-size: 24%;
}
strong {
    font-weight: 500;
    text-decoration: underline;
}
code strong{
    text-decoration: none;
}
img {
width: 100%;
max-width: 100%;
height: auto;
box-sizing: border-box;
}

/* PopUp Error window */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--background-color);
    color: var(--text-color);
    border: 1px solid var(--button-border);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 2s;
    size: 2vw;
}

.popup.show {
    visibility: visible;
    animation: fadeInOut 4s forwards;
}

#total-questions {
    /* your regular text & background colours */
    --bg: var(--background-color);
    color: var(--text-color);
  
    /* small padding so the halo isn't clipped */
    padding: 0.1em 0.2em;
    display: inline-block;
  
    /* use four shadows in the four diagonal directions */
    text-shadow:
      1px  1px 0 var(--bg),
     -1px  1px 0 var(--bg),
      1px -1px 0 var(--bg),
     -1px -1px 0 var(--bg);
  
    /* optional extra “soft” glow beyond the hard outline */
    /* drop-shadow applies outside the element’s shape */
    filter: drop-shadow(0 0 2px var(--bg));
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    25% { opacity: 1; }
    75% { opacity: 1; }
    100% { opacity: 0; }
}

/* Grid Layout for Test Container */
/* ======= TEST CONTAINER GRID ======= */
#test-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 25px;
    max-width: 1200px;
    margin: 0 auto;
    transition: grid-template-columns 0.1s ease, padding 0.1s ease, gap 0.1s ease;
}

#test-container button {
    aspect-ratio: 1/1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    border-radius: 16px;
    border: none;
    font-family: var(--font-family);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--card-shadow);
    background-color: var(--button-fill);
    color: var(--text-color);
    position: relative;
    overflow: hidden;
    max-width: 200px;
}

#test-container button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(255,255,255,0.1) 0%, 
        rgba(255,255,255,0) 50%, 
        rgba(255,255,255,0.1) 100%);
    opacity: 0;
    transition: opacity 0.4s;
}

#test-container button:hover {
    box-shadow: var(--card-hover-shadow);
    transform: translateY(-5px);
}

#test-container button:hover::before {
    opacity: 1;
}

/* Button type styling */
#test-container .category-button {
    background: linear-gradient(135deg,#9ab2ff 0%, #c4fac5 100%);
    font-size: 1.1rem;
}

#test-container .test-button {
    background-color: var(--button-fill);
    font-size: 0.95rem;
}

#test-container .back-button {
    background: linear-gradient(135deg, #ffec9a 0%, #fad0c4 100%);
    font-size: 1rem;
}
/* Category buttons */
#test-container .category-button {
    background-color: #ffffff;
    font-size: 1.05rem;
    font-weight: 600;
    border: 1px solid #ccc;
}

/* Test buttons */
#test-container .test-button {
    background-color: #f9f9f9;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid #ddd;
}

/* Back button */
#test-container .back-button {
    background-color: #ececec;
    font-weight: bold;
    font-size: 1rem;
}

/* Hover effect */
#test-container button:hover {
    background-color: var(--button-hover-fill, #e0e0e0);
    transform: translateY(-2px);
}

/* ======= ANIMATIONS ======= */
@keyframes floatIn {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

#test-container button {
    animation: floatIn 0.2s ease-out;
    animation-fill-mode: both;
}

@view-transition {
  navigation: auto;
}

@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
