/*
 * gb-freeze.css — CSS-only freeze for the gradebook tables (#gvMain).
 *
 * Freezes the top header row and the first (student-name) column.
 * Replaces the GridViewScroll plugin on these tables: the plugin clones the
 * first column into an overlay sized at page load, which drifted out of line
 * with the real rows and duplicated names below the table.
 *
 * Applied by gb-freeze.js, which adds .gb-freeze to the table and
 * .gb-freeze-wrap to its scroll container.
 *
 * Selectors start with "#gvMain.gb-freeze" so they outrank the older
 * per-page "#gvMain …" rules still present on some gradebook pages.
 */

/* The scroll box — sticky cells stick to this. */
.gb-freeze-wrap {
    overflow: auto !important;
    max-height: 70vh;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #dee2e6;
}

/* Sticky cells need separated borders, or the borders scroll away from them. */
#gvMain.gb-freeze {
    border-collapse: separate !important;
    border-spacing: 0;
    width: auto;
    min-width: 100%;
}
#gvMain.gb-freeze td,
#gvMain.gb-freeze th {
    white-space: nowrap;
    background-clip: padding-box;
    /* one line between cells (separate borders would otherwise double up) */
    border: 0;
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
}

/* Frozen top header row. Cells with their own inline background (e.g. the
   yellow penalty headers) keep it, because inline styles win over this. */
#gvMain.gb-freeze > thead > tr:first-child > td,
#gvMain.gb-freeze > thead > tr:first-child > th {
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: #f4f6f9;
    box-shadow: 0 2px 4px -2px rgba(0, 0, 0, 0.25);
}

/* Frozen first column. */
#gvMain.gb-freeze tr > td:first-child,
#gvMain.gb-freeze tr > th:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: #fff;
    box-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.25);
}
#gvMain.gb-freeze > thead > tr > td:first-child,
#gvMain.gb-freeze > thead > tr > th:first-child {
    z-index: 2;
    background-color: #f4f6f9;
}

/* Top-left corner sits above both frozen edges. */
#gvMain.gb-freeze > thead > tr:first-child > td:first-child,
#gvMain.gb-freeze > thead > tr:first-child > th:first-child {
    z-index: 4;
    box-shadow: 2px 2px 4px -2px rgba(0, 0, 0, 0.25);
}

/* Printing / PDF: show the whole table, not just the scroll window. */
@media print {
    .gb-freeze-wrap { overflow: visible !important; max-height: none !important; height: auto !important; border: 0; }
    #gvMain.gb-freeze td, #gvMain.gb-freeze th { position: static !important; box-shadow: none !important; }
}
