/* ---------------------------------------------------------------------------
   Proctor: an invigilation console.

   The thing this replaces is a printed class roll on a clipboard, and it is read
   the same way: by someone standing in a lab with eighty students, finding out
   who needs them. So the screen is a dense roll with a status edge you can scan
   down, not a grid of cards and not a page of statistics.

   One rule governs the palette: SATURATED COLOUR MEANS THE STATE OF A STUDENT,
   and nothing else may use it. No coloured headings, no accent buttons, no
   decorative tints. When something on this screen is green or red it is because
   a person is fine or is not, which is the only question the room is asking.
   (The single exception is a destructive confirmation, which borrows the broken
   colour because it means the same thing: something is about to go badly.)

   State is never colour alone. Every status carries a word as well as an edge,
   because these screens get read on washed-out projectors and by people who do
   not separate red from green.

   No webfonts, deliberately. The student page is opened from inside the locked
   down sandbox, where the firewall passes only the hosts on the allowlist, so a
   request to fonts.googleapis.com would hang and then fail. The type comes off
   the machine, and the personality comes from how it is set: tabular figures,
   real weight contrast, and ruling that does the work a border-radius usually
   pretends to.
   --------------------------------------------------------------------------- */

:root {
    --paper:     #f6f7f9;
    --surface:   #ffffff;
    --ink:       #16202c;  /* a true dark navy, not black with a tint on it */
    --ink-soft:  #5a6673;
    --rule:      #d7dce2;
    --rule-firm: #b6bfc9;

    /* Dark enough to be used as text on white, which is what lets every status
       be a word and not just a wash. */
    --settled:   #0f7b4f;
    --watch:     #a35a00;
    --broken:    #b3261e;

    --settled-wash: #eef7f2;
    --watch-wash:   #fdf4e7;
    --broken-wash:  #fcefee;

    --measure: 68ch;

    /* Segoe UI Variable is on the Windows 11 lab image and is a genuinely good
       UI face; the rest is the ladder down to whatever a staff laptop has. */
    --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
            "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Mono", Consolas, "SFMono-Regular", ui-monospace, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    /* Figures line up down a column of times and counts. */
    font-variant-numeric: tabular-nums;
}

/* --- type scale ----------------------------------------------------------- */

h1, h2, h3 { font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.55rem; letter-spacing: -.011em; }
h2 { font-size: 1.1rem; margin-top: 1.9rem; }
h3 { font-size: .97rem; margin-top: 1.4rem; color: var(--ink-soft); font-weight: 600; }

p { margin: 0 0 .7rem; max-width: var(--measure); }

code, pre, .hash, .mono { font-family: var(--mono); font-size: .89em; }

pre {
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: .6rem .75rem;
    overflow-x: auto;
    margin: 0 0 .6rem;
}

/* A hash has to wrap. It ran off the right edge of its box and the last
   characters were simply not on screen, which makes it useless for the one thing
   it is there for: comparing it against what PowerShell printed. */
pre.hash {
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: visible;
    line-height: 1.55;
}

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

/* Underlines come back on hover. In a roll of eighty names they are eighty pieces
   of texture competing with the one signal the page exists to show. */
tbody td a { text-decoration: none; }
tbody td a:hover { text-decoration: underline; }

small { font-size: .85rem; color: var(--ink-soft); display: block; margin-top: .15rem; }

/* --- the frame ------------------------------------------------------------ */

/* A top bar, not a sidebar. There are four destinations, and the roll needs the
   horizontal space more than the navigation does. */
.masthead {
    display: flex;
    align-items: baseline;
    gap: 1.6rem;
    flex-wrap: wrap;
    padding: .55rem 1.5rem;
    background: var(--ink);
    color: #fff;
}

.masthead .wordmark {
    font-weight: 600;
    font-size: 1.02rem;
    letter-spacing: .005em;
    color: #fff;
    text-decoration: none;
}

.masthead nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }

.masthead nav a {
    color: #c6cfdb;
    text-decoration: none;
    padding-bottom: 2px;
    border-bottom: 2px solid transparent;
}

.masthead nav a:hover { color: #fff; }
.masthead nav a.active { color: #fff; border-bottom-color: #fff; }

.masthead .aside { margin-left: auto; }
.masthead .aside a { color: #c6cfdb; text-decoration: none; }
.masthead .aside a:hover { color: #fff; text-decoration: underline; }

.content { padding: 1.4rem 1.5rem 4rem; }

/* --- the roll ------------------------------------------------------------- */

table {
    border-collapse: collapse;
    width: 100%;
    background: var(--surface);
    margin: 0 0 1rem;
}

thead th {
    text-align: left;
    font-size: .84rem;
    font-weight: 600;
    color: var(--ink-soft);
    padding: .45rem .7rem;
    border-bottom: 1px solid var(--rule-firm);
    white-space: nowrap;
}

tbody td {
    padding: .35rem .7rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 1px solid var(--rule-firm); }

/* The status edge. An inset shadow rather than a border because a border on a
   table cell in a collapsed table fights its neighbours. */
tbody tr td:first-child { box-shadow: inset 4px 0 0 0 transparent; }

tr.green  td:first-child { box-shadow: inset 4px 0 0 0 var(--settled); }
tr.amber  td:first-child { box-shadow: inset 4px 0 0 0 var(--watch); }
tr.broken td:first-child { box-shadow: inset 4px 0 0 0 var(--broken); }
tr.warn   td:first-child { box-shadow: inset 4px 0 0 0 var(--watch); }

/* No wash on the rows, and this was the correction that mattered. Tinting every
   row that needs attention looked right with three rows and became a wall of pink
   at thirteen: when most of the room is in trouble, which is exactly when this
   screen is being read hardest, a full-row fill makes every row equally loud and
   the eye has nothing to land on. The gutter and the word carry it, and they keep
   working whether one row is bad or all of them are. */

/* Ended is not a problem, it is finished. Receding is the correct signal. */
tr.ended  td { color: var(--ink-soft); }
tr.off    td { color: var(--ink-soft); background: var(--paper); }

td.url, td .hash { word-break: break-all; }

/* --- status words --------------------------------------------------------- */

.state { font-weight: 600; white-space: nowrap; }
.state.green  { color: var(--settled); }
.state.amber  { color: var(--watch); }
.state.broken { color: var(--broken); }
.state.ended  { color: var(--ink-soft); font-weight: 400; }

/* --- notices -------------------------------------------------------------- */

p.warn, p.ok, .alert {
    padding: .55rem .8rem;
    border-left: 4px solid;
    max-width: var(--measure);
    margin: 0 0 .7rem;
}

p.warn  { background: var(--watch-wash);   border-color: var(--watch); }
p.ok    { background: var(--settled-wash); border-color: var(--settled); }

.alert          { background: var(--paper); border-color: var(--rule-firm); margin: .2rem 0; }
.alert.critical { background: var(--broken-wash); border-color: var(--broken); }
.alert.high     { background: var(--broken-wash); border-color: var(--broken); }
.alert.warning  { background: var(--watch-wash);  border-color: var(--watch); }

p.meta { color: var(--ink-soft); font-size: .9rem; }

.text-danger, .validation-message {
    color: var(--broken);
    font-size: .86rem;
    display: block;
}

/* --- forms ---------------------------------------------------------------- */

p.field { margin: .6rem 0; max-width: var(--measure); }

p.field label {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-weight: 600;
    font-size: .9rem;
}

/* Checkboxes read as a sentence, so they sit beside their words. */
p.field label:has(> input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
    gap: .5rem;
    font-weight: 400;
    font-size: 1rem;
}

input, select, textarea {
    font: inherit;
    font-size: .95rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule-firm);
    padding: .35rem .5rem;
    max-width: 100%;
}

input:not([type="checkbox"]), select { width: 100%; }
td input:not([type="checkbox"]) { width: auto; min-width: 9rem; max-width: 14rem; }

input[type="checkbox"] { width: auto; accent-color: var(--ink); }

input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

input:disabled, select:disabled, button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.valid.modified:not([type=checkbox]) { border-color: var(--settled); }
.invalid { border-color: var(--broken); }

/* --- buttons -------------------------------------------------------------- */

button, a.button {
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    padding: .34rem .8rem;
    border: 1px solid var(--ink);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button:hover:not(:disabled), a.button:hover { background: var(--paper); }

/* The main action on a page is filled. One per view. Most are a form's submit;
   .primary is for the ones that are not, so a standalone button does not have to
   claim to be a submit button just to look like the thing you came here to do. */
button[type="submit"], button.primary, a.button {
    background: var(--ink);
    color: #fff;
}

button[type="submit"]:hover:not(:disabled),
button.primary:hover:not(:disabled),
a.button:hover {
    background: #0c1823;
    color: #fff;
}

/* Table-row actions are quiet: there can be eighty of them on screen and they
   are not what anyone is looking for. */
td button {
    font-weight: 400;
    font-size: .86rem;
    border-color: var(--rule-firm);
    color: var(--ink-soft);
    padding: .2rem .55rem;
}

td button:hover:not(:disabled) { color: var(--ink); border-color: var(--ink); }

/* Destructive confirmation. The one place outside a status that may be red,
   because it carries the same meaning. */
.end-room button, .confirming button:first-of-type {
    border-color: var(--broken);
    color: var(--broken);
    background: var(--surface);
}

.end-room button:hover:not(:disabled) { background: var(--broken-wash); }

/* --- sections ------------------------------------------------------------- */

section { margin: 0 0 1.6rem; }

section.event, section.config, section.build, section.published,
section.add, section.describe, section.revision {
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: .9rem 1.1rem;
}

dl.staged { margin: 0 0 1rem; display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
dl.staged dt { color: var(--ink-soft); font-size: .88rem; }
dl.staged dd { margin: 0; }

section > :first-child, .download > :first-child { margin-top: 0; }
section > :last-child { margin-bottom: 0; }

details summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
details[open] summary { margin-bottom: .6rem; }

/* --- the student page ----------------------------------------------------- */

/* Not the console. One person, one screen, no hurry, and quite possibly nervous.
   Wider measure, larger type, and the steps numbered because they genuinely are
   a sequence that has to happen in order. */
.download {
    max-width: 34rem;
    margin: 2.5rem auto;
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: 1.75rem 2rem 2rem;
}

.download h1 { font-size: 1.4rem; }
.download p { font-size: 1rem; }
.download h2 { font-size: 1rem; margin-top: 1.6rem; }
.download .hash { display: block; word-break: break-all; line-height: 1.6; }

.download ol { margin: 0 0 1rem; padding-left: 1.35rem; }
.download ol li { margin-bottom: .4rem; }

/* --- narrow screens ------------------------------------------------------- */

@media (max-width: 40rem) {
    .content { padding: 1rem .9rem 3rem; }
    .masthead { padding: .5rem .9rem; gap: .9rem; }
    .masthead .aside { margin-left: 0; }

    /* A roll cannot usefully reflow, so the page scrolls rather than crushing
       it. Done on the content area so no table needs a wrapper around it. */
    .content { overflow-x: auto; }
    table { min-width: 34rem; }
}

/* --- motion --------------------------------------------------------------- */

/* There is almost none to begin with: this screen is read, not browsed, and an
   animation on a page that refreshes every three seconds is a distraction in a
   room where something is going wrong. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* --- Blazor's own error strip --------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: .7rem 1.5rem;
    background: var(--broken);
    color: #fff;
    font-weight: 600;
}

#blazor-error-ui a { color: #fff; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

.blazor-error-boundary {
    background: var(--broken);
    color: #fff;
    padding: .8rem 1.1rem;
}

.blazor-error-boundary::after { content: "Something on this page failed to load."; }

/* --- pager ---------------------------------------------------------------- */

p.pager { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
p.pager span { color: var(--ink-soft); font-size: .9rem; padding: 0 .25rem; }

/* Student panel order: headings read as section breaks, as they do in the tool. */
table.panel-order tr.heading td { font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; background: rgba(127, 127, 127, 0.12); }
table.panel-order td.actions { white-space: nowrap; }
table.panel-order td.actions button { min-width: 2.2em; }
