/* The finals calendar (UI-42). Layout and colour of the page's frame are
   Tailwind utilities in templates/pages/finals.html; here is what the script
   draws (the search rows and the calendar) and what a utility cannot say.
   Dark mode is in dark-mode.css under "Finals calendar". */

/* A display class beats the hidden attribute (the Tentative tag is
   inline-block). The id out-ranks any utility, so hidden wins on this page. */
#finals-app [hidden] {
    display: none;
}

/* The file: one big target, a button so the keyboard reaches it, and a drop
   zone for a file dragged from the desktop. */
.finals-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 2.5rem 1rem;
    border: 2px dashed #d1d5db;
    border-radius: 0.75rem;
    background: transparent;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.finals-drop:hover,
.finals-drop:focus-visible,
.finals-drop.is-dragging {
    border-color: #20719c;
    background: #f5fbff;
}

.finals-status {
    min-height: 1.25rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    text-align: center;
    color: #4b5563;
}

.finals-status[data-status='error'] {
    color: #b91c1c;
}

/* The strip that says which schedule is loaded. */
.finals-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.finals-strip__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-left: auto;
}

.finals-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    background: #ffffff;
    color: #20719c;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.finals-button:hover:not(:disabled) {
    border-color: #9ca3af;
    background: #f9fafb;
}

.finals-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Clear's first press: "Confirm?" for three seconds. */
.finals-button.is-armed {
    border-color: #fca5a5;
    color: #b91c1c;
}

.finals-search:focus {
    outline: 2px solid #20719c;
    outline-offset: 1px;
}

/* Search results: one row per course and section. */
.finals-results {
    max-height: 26rem;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
}

.fr-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #f3f4f6;
}

.fr-row:first-child {
    border-top: 0;
}

.fr-main {
    flex: 1;
    min-width: 0;
}

.fr-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.125rem 0.5rem;
}

.fr-code {
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
}

.fr-name {
    font-size: 0.875rem;
    color: #374151;
}

.fr-meta {
    margin-top: 0.125rem;
    font-size: 0.8125rem;
    color: #6b7280;
}

.fr-add {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid #20719c;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #20719c;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.fr-add:hover {
    background: #f5fbff;
}

.fr-add.is-added {
    background: #20719c;
    color: #ffffff;
}

.fr-add.is-added:hover {
    background: #1d5d7f;
}

/* The calendar: one row of weekday names, then a row per week. The script
   sets --fc-columns to 6 (Monday to Saturday) or 7 (with Sunday). */
.finals-calendar {
    --fc-columns: 6;
}

.fc-head,
.fc-week {
    display: grid;
    grid-template-columns: repeat(var(--fc-columns), minmax(0, 1fr));
    gap: 0.375rem;
    margin-bottom: 0.375rem;
}

.fc-weekday {
    padding: 0 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6b7280;
}

.fc-day {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    min-height: 7rem;
    padding: 0.375rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #ffffff;
}

/* A day NDU set exams on: a thin bar on top, the exam period at a glance. */
.fc-day.is-exam-day {
    box-shadow: inset 0 3px 0 #9edcff;
}

.fc-day.is-quiet {
    background: #f9fafb;
}

.fc-date {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
}

.fc-day.is-quiet .fc-date {
    color: #9ca3af;
}

.fc-date__long {
    display: none;
}

/* An exam. Its fill is the student's course colour and its text colour is
   derived from it (domain/contrast.js), both set by the script. */
.fc-block {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.375rem 1.5rem 0.375rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.fc-block__code {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 700;
}

.fc-block.is-clash {
    outline: 2px solid #dc2626;
    outline-offset: 1px;
}

.fc-block__clash {
    margin-top: 0.125rem;
    font-weight: 600;
}

.fc-block__remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: inherit;
    font-size: 0.75rem;
    opacity: 0.75;
    cursor: pointer;
}

.fc-block__remove:hover,
.fc-block__remove:focus-visible {
    background: rgba(0, 0, 0, 0.12);
    opacity: 1;
}

/* A phone: seven columns cannot hold a course code, so the calendar becomes
   a list of the days that hold an exam, each with its long date. */
@media (max-width: 639px) {
    .fc-head {
        display: none;
    }

    .fc-week {
        display: block;
        margin: 0;
    }

    .fc-day {
        display: none;
        min-height: 0;
        margin-bottom: 0.5rem;
    }

    .fc-day.has-picks {
        display: flex;
    }

    .fc-day.is-exam-day {
        box-shadow: none;
    }

    .fc-date__short {
        display: none;
    }

    .fc-date__long {
        display: inline;
    }

    .fc-block {
        font-size: 0.875rem;
    }

    .fc-block__code {
        font-size: 0.9375rem;
    }

    .finals-strip__actions {
        margin-left: 0;
    }
}
