@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');

*, *:before, *:after {
    box-sizing: border-box;
}

body {
    font-family: "Libre Baskerville", "Times New Roman", Times, serif;
    background-color: #ffffff;
    color: #000000;
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
    line-height: 1.5;
}

a {
    color: #000000;
    text-decoration: underline;
}

a:hover {
    color: #666666;
}

/* EvAU Header Styles */
.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #000;
    margin-bottom: 20px;
    text-align: center;
    font-size: 0.9em;
}

.exam-header-left {
    flex: 3;
    padding: 10px;
    border-right: 1px solid #000;
}

.exam-header-right {
    flex: 1;
    padding: 10px;
    font-weight: bold;
}

.exam-instructions {
    text-align: justify;
    font-size: 0.9em;
    margin-bottom: 30px;
    padding: 15px 0;
}

.section-title {
    font-weight: bold;
    text-align: center;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.05em;
}

.exam-exercise {
    text-align: justify;
    line-height: 1.6;
}

/* Table / Heatmap Styles */
.heatmap-controls {
    text-align: center;
    margin-bottom: 20px;
}

.heatmap-controls button {
    font-family: inherit;
    font-size: 0.9em;
    padding: 8px 16px;
    margin: 0 5px;
    border: 1px solid #000;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.heatmap-controls button.active {
    background-color: #000;
    color: #fff;
    font-weight: bold;
}

.heatmap-controls button:hover:not(.active) {
    background-color: #eee;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    margin-bottom: 40px;
}

/* Scroll affordance wrapper */
.table-scroll-wrapper {
    position: relative;
}

.table-scroll-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 48px;
    background: linear-gradient(to right, transparent, #fff);
    pointer-events: none;
    z-index: 4;
    opacity: 1;
    transition: opacity 0.4s;
}

.table-scroll-wrapper.scrolled::after {
    opacity: 0;
}

.scroll-hint {
    display: none;
    text-align: center;
    font-size: 0.78em;
    font-style: italic;
    color: #888;
    margin: 0 0 6px 0;
    transition: opacity 0.4s;
}

.scroll-hint.scrolled {
    opacity: 0;
    pointer-events: none;
}

.table-loading {
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #999;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-size: 0.85em;
    text-align: center;
}

th, td {
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 8px 4px;
    min-width: 35px;
}

thead th {
    border-top: 1px solid #000;
}

th:first-child, td:first-child {
    border-left: 1px solid #000;
}

th {
    font-weight: bold;
    background-color: #fff;
}

.community-header {
    text-align: left;
    white-space: nowrap;
    padding-left: 10px;
    position: sticky;
    left: 0;
    background-color: #fff;
    z-index: 5;
    background-clip: padding-box;
    box-shadow: 1px 0 0 0 #000;
}

.val-cell {
    font-weight: bold;
}

/* Green-Red Heatmap Scale - Green (easy) to Red (hard) */
/* Range 0 to 10 */
.heat-0  { background-color: #ffffff; color: #000; }
.heat-1  { background-color: #e8f5e9; color: #000; }
.heat-2  { background-color: #a5d6a7; color: #000; }
.heat-3  { background-color: #66bb6a; color: #000; }
.heat-4  { background-color: #dce775; color: #000; }
.heat-5  { background-color: #fff176; color: #000; }
.heat-6  { background-color: #ffca28; color: #000; }
.heat-7  { background-color: #ffa726; color: #000; }
.heat-8  { background-color: #ef5350; color: #fff; }
.heat-9  { background-color: #d32f2f; color: #fff; }
.heat-10 { background-color: #b71c1c; color: #fff; }

.empty-cell {
    background-color: #fff;
    color: #ccc;
}

/* Clickable cells */
.val-cell {
    cursor: pointer;
    font-weight: bold;
}

.val-cell:hover {
    box-shadow: inset 0 0 0 2px #000;
}

/* Stats Banner */
.stats-banner {
    text-align: center;
    font-size: 0.95em;
    font-style: italic;
    margin: 15px 0 30px 0;
    color: #333;
}

.stat-item {
    display: inline-block;
    padding: 5px 15px;
}

.stat-item:not(:last-child) {
    border-right: 1px solid #999;
}

.stat-number {
    font-weight: bold;
    font-style: normal;
    color: #000;
}

/* Chart Sections */
.chart-section {
    margin: 40px 0 0 0;
    padding-top: 20px;
    border-top: 1px solid #000;
}

.chart-container {
    position: relative;
    width: 100%;
    max-width: 850px;
    margin: 15px auto;
}

/* Loading placeholder shown before Chart.js renders */
.chart-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-style: italic;
    font-size: 0.9em;
    pointer-events: none;
    z-index: 1;
}

.chart-description {
    text-align: center;
    font-size: 0.9em;
    margin-bottom: 10px;
    font-style: italic;
}

.insight-box {
    text-align: center;
    font-size: 0.9em;
    margin: 20px auto 0 auto;
    padding: 0 15px;
    border: none;
    background-color: transparent;
    line-height: 1.6;
    max-width: 850px;
}

/* Heatmap Average Cells */
.avg-cell {
    font-weight: bold;
    font-style: italic;
    background-color: #f5f5f5 !important;
    color: #000 !important;
}

.avg-header {
    font-weight: bold;
    font-style: italic;
    background-color: #f5f5f5;
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow-y: auto;
    overflow-x: hidden;
    background-color: rgba(0,0,0,0.4); 
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto; 
    padding: 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 900px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    font-family: "Libre Baskerville", "Times New Roman", Times, serif;
    position: relative;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* Reset native button styles for the close button */
button.close-btn {
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    font-family: inherit;
}

.exam-block {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #000;
}

.question-block {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    background-color: #fcfcfc;
    overflow-x: auto;
}

.rating-badge {
    display: inline-block;
    padding: 3px 8px;
    margin: 5px 5px 5px 0;
    font-size: 0.85em;
    background: #eee;
    border: 1px solid #ccc;
}

.llm-notes {
    margin-top: 10px;
    font-size: 0.9em;
    font-style: italic;
    color: #444;
    border-left: 3px solid #666;
    padding-left: 10px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        margin: 10px auto;
        padding: 0 10px;
    }
    
    .exam-header {
        flex-direction: column;
    }
    
    .exam-header-left {
        border-right: none;
        border-bottom: 1px solid #000;
        width: 100%;
        box-sizing: border-box;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 15px;
    }
    
    .question-block {
        padding: 10px;
    }
    
    /* Allow table to scroll horizontally with readable font sizes */
    table {
        font-size: 0.8em;
        min-width: 750px;
    }
    
    th, td {
        padding: 6px 3px;
    }
    
    .community-header {
        padding-left: 2px;
        font-size: 0.9em;
    }

    .heatmap-controls {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .heatmap-controls button {
        width: 100%;
        max-width: 250px;
        margin: 0 !important;
        border: 1px solid #000 !important;
    }

    .rubric-markdown {
        padding: 15px;
    }

    .footer {
        padding-bottom: 50px;
        font-size: 0.9em;
    }

    .stats-banner {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px 0;
        border-top: 1px solid #ccc;
        border-bottom: 1px solid #ccc;
        padding: 15px 0;
    }

    .stat-item {
        display: block;
        border-right: none !important;
        padding: 0 10px;
    }
    
    .stat-item:nth-child(odd) {
        border-right: 1px solid #ccc !important;
    }

    .chart-container {
        max-width: 100%;
    }

    /* Chart height overrides for mobile — inline styles use !important */
    #community-chart-container {
        height: 400px !important;
    }

    #timeline-chart-container {
        height: 320px !important;
    }

    /* Larger touch targets for heatmap cells */
    .val-cell {
        padding: 10px 3px;
        min-height: 40px;
    }

    /* Show the scroll hint text on mobile */
    .scroll-hint {
        display: block;
    }

    .insight-box {
        font-size: 0.85em;
    }
}

/* Rubric Styles */
.rubric-toggle-btn {
    font-family: inherit;
    font-size: 0.9em;
    padding: 8px 16px;
    border: 1px solid #000;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.rubric-toggle-btn:hover {
    background-color: #eee;
}

.rubric-markdown {
    font-size: 0.95em;
    text-align: left;
    background-color: #ffffff;
    border: 1px solid #000000;
    padding: 20px;
    margin: 20px auto;
    max-width: 100%;
    box-sizing: border-box;
    line-height: 1.6;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    overflow-x: auto;
}

.rubric-markdown h1, .rubric-markdown h2, .rubric-markdown h3 {
    font-weight: bold;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: #000000;
}

.rubric-markdown h1 {
    font-size: 1.4em;
    border-bottom: 2px solid #000000;
    padding-bottom: 10px;
    margin-bottom: 30px;
}

.rubric-markdown h2 {
    font-size: 1.15em;
    border-bottom: 1px solid #000000;
    padding-bottom: 5px;
    margin-top: 2em;
}

.rubric-markdown p {
    margin-bottom: 1em;
}

.rubric-markdown ul, .rubric-markdown ol {
    margin-bottom: 1.5em;
    padding-left: 25px;
}

.rubric-markdown li {
    margin-bottom: 8px;
}

.rubric-markdown ul ul {
    margin-top: 8px;
    margin-bottom: 8px;
    padding-left: 20px;
}

.rubric-markdown table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 0.9em;
}

.rubric-markdown th, .rubric-markdown td {
    border: 1px solid #000000;
    padding: 10px;
    text-align: left;
}

.rubric-markdown th {
    background-color: #ffffff;
    font-weight: bold;
}

.rubric-markdown tr:nth-child(even) {
    background-color: #ffffff;
}

.rubric-markdown blockquote {
    margin: 20px 0;
    padding: 15px 20px;
    background-color: #ffffff;
    border: 1px solid #000000;
    font-style: italic;
}

.rubric-markdown blockquote p {
    margin: 0 0 10px 0;
}

.rubric-markdown blockquote p:last-child {
    margin-bottom: 0;
}

/* Footer Styles */
.footer {
    text-align: center;
    margin-top: 50px;
    margin-bottom: 30px;
    font-size: 0.85em;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.footer a {
    color: #000;
    text-decoration: underline;
}

.footer a:hover {
    color: #666;
}

/* MathJax/Equation Overflow Fixes */
.mjx-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    vertical-align: middle;
}
