/* Structural/accessibility utilities added after the original SOJ UI. This file must not redefine the visual system. */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    z-index: 2000;
    top: 10px;
    left: 10px;
    padding: 8px 12px;
    border: 1px solid #444;
    border-radius: 5px;
    background: #fff;
    color: #222;
    font-weight: 800;
    transform: translateY(-180%);
}

.skip-link:focus {
    transform: translateY(0);
}

:focus-visible {
    outline: 2px solid #555;
    outline-offset: 2px;
}

body input:focus-visible,
body select:focus-visible,
body textarea:focus-visible,
body button:focus-visible,
body a:focus-visible,
body summary:focus-visible,
body [tabindex]:focus-visible {
    outline: 2px solid #555;
    outline-offset: 2px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.sample-box {
    min-height: 88px;
}

.card.submit-card {
    padding: 28px 30px;
}

body .code-input {
    min-height: 430px;
}

/* Current problem metadata markup is a dl; reset browser defaults while keeping the original OJ density. */
.problem-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin: 0;
    color: #555;
    font-size: 14px;
}

.problem-meta > div {
    display: flex;
    gap: 6px;
}

.problem-meta dt,
.problem-meta dd {
    margin: 0;
}

.problem-meta dt {
    color: #777;
}

.problem-meta dd {
    color: #333;
    font-weight: 800;
}

/* Accessibility contrast exceptions. Keep semantic status colors readable without retheming the application. */
body .solved-mark,
body .status-accepted {
    color: #087f5b;
}

body .status-wrong_answer,
body .status-runtime_error,
body .status-compile_error,
body .status-time_limit_exceeded,
body .status-memory_limit_exceeded {
    color: #c92a2a;
}

body .status-waiting,
body .status-running {
    color: #a55b00;
}

body .status-system_error {
    color: #55554f;
}

.problem-filter-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
}

.problem-filter-summary::-webkit-details-marker {
    display: none;
}

.problem-filter-summary::after {
    content: "+";
    color: #666;
    font-size: 18px;
    line-height: 1;
}

.problem-filter-panel[open] .problem-filter-summary::after {
    content: "−";
}

.difficulty-range-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.difficulty-range-selected {
    display: inline-grid;
    grid-template-columns: minmax(84px, 1fr) auto minmax(84px, 1fr);
    align-items: center;
    width: 260px;
    max-width: 100%;
    min-height: 32px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.difficulty-range-bound {
    min-width: 0;
    text-align: center;
}

.difficulty-range-slider {
    --range-left: 0%;
    --range-right: 100%;
    position: relative;
    height: 38px;
    margin: 3px 2px 0;
}

.difficulty-range-slider::before,
.difficulty-range-slider::after {
    content: "";
    position: absolute;
    top: 16px;
    height: 6px;
    border-radius: 2px;
}

.difficulty-range-slider::before {
    right: 0;
    left: 0;
    background: #d2d2cc;
}

.difficulty-range-slider::after {
    right: calc(100% - var(--range-right));
    left: var(--range-left);
    background: #222;
}

.difficulty-range-slider input[type="range"] {
    position: absolute;
    z-index: 2;
    top: 2px;
    left: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    appearance: none;
    background: transparent;
    pointer-events: none;
}

.difficulty-range-slider input[type="range"]::-webkit-slider-runnable-track {
    height: 32px;
    background: transparent;
}

.difficulty-range-slider input[type="range"]::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    margin-top: 6px;
    appearance: none;
    border: 2px solid #222;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    pointer-events: auto;
}

.difficulty-range-slider input[type="range"]::-moz-range-track {
    height: 32px;
    background: transparent;
}

.difficulty-range-slider input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 2px solid #222;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    pointer-events: auto;
}

.difficulty-range-scale {
    display: flex;
    justify-content: space-between;
    color: #777;
    font-size: 12px;
}

.problem-table {
    min-width: 700px;
}

.problem-table .problem-tags {
    flex-wrap: nowrap;
    overflow: hidden;
    max-width: 500px;
}

.problem-table .problem-tag {
    overflow: hidden;
    max-width: 420px;
    text-overflow: ellipsis;
}

.pagination .pagination-page.active {
    border-color: #444;
    background: #444;
    color: #fff;
    font-weight: 800;
}

@media (max-width: 800px) {
    .difficulty-range-header {
        align-items: stretch;
        flex-direction: column;
    }

    .difficulty-range-selected {
        width: 100%;
    }
}

@media (max-width: 700px) {
    .card.submit-card {
        padding: 16px;
    }

    .problem-meta {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .problem-meta > div {
        display: grid;
        gap: 1px;
    }
}

@media (max-width: 420px) {
    .problem-meta {
        grid-template-columns: 1fr;
    }
}
