html, body {
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1a4f8b;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ----------------------------------------------------------- gantt chart */

.gantt-scroll {
    overflow-x: auto;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    background: var(--mud-palette-surface);
}

.gantt-inner {
    position: relative;
}

.gantt-header-row,
.gantt-row {
    display: flex;
    align-items: stretch;
}

.gantt-row {
    border-top: 1px solid var(--mud-palette-lines-default);
}

.gantt-row.gantt-selectable {
    cursor: pointer;
}

.gantt-row.gantt-selectable:hover {
    background: var(--mud-palette-action-default-hover);
}

.gantt-row.gantt-selected {
    background: var(--mud-palette-primary-hover);
}

.gantt-label-cell {
    flex: 0 0 130px;
    width: 130px;
    padding: 4px 8px;
    position: sticky;
    left: 0;
    background: var(--mud-palette-background-gray);
    border-right: 1px solid var(--mud-palette-lines-default);
    z-index: 3;
    font-size: 12px;
    line-height: 1.25;
    color: var(--mud-palette-text-primary);
}

/* ------------------------------------- window-height pages and the side inspector */

/* The Driver Duties and Bus Workings pages are exactly the window's height: title, toolbar, then the view, which
   takes the rest and scrolls INSIDE itself. The page as a whole never scrolls, so the view's horizontal scrollbar
   is always on screen instead of at the foot of every row. 80px = the dense app bar (48) + the layout's pa-4 top and bottom (32).
   Below a usable height it gives up and lets the page scroll, rather than squeezing the graph to nothing. */
.fit-page {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 80px);
    min-height: 420px;
}

/* the page's content and the inspector side by side; the content keeps min-width:0 so the gantt still scrolls */
.fit-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: stretch;
    gap: 16px;
}

.fit-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* the graph or the table: whatever height is left, with both scrollbars of its own */
.fit-scroll {
    flex: 1 1 auto;
    min-height: 0;
}

.fit-scroll > .gantt-scroll {
    height: 100%;
    overflow: auto;
    box-sizing: border-box;
}

/* the time axis stays at the top while the duty rows scroll under it */
.fit-scroll .gantt-header-row {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--mud-palette-surface);
}

.fit-scroll .gantt-header-row .gantt-label-cell {
    z-index: 5;
}

.fit-scroll > .mud-table {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.fit-scroll > .mud-table > .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.inspector {
    flex: 0 0 360px;
    width: 360px;
    padding: 12px 16px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* unpinned: over the right-hand side of the page, which keeps its full width */
.inspector.inspector--floating {
    position: fixed;
    top: 64px; /* the dense app bar plus the page padding */
    right: 16px;
    max-height: calc(100dvh - 80px);
    z-index: 1100;
}

.inspector.inspector--minimised {
    flex: 0 0 40px;
    width: 40px;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.inspector-rail-code {
    writing-mode: vertical-rl;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.inspector-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inspector-title {
    white-space: nowrap;
}

.inspector-figures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 12px;
    margin-top: 8px;
}

.inspector-figure-label {
    font-size: 11px;
}

.inspector-figure {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* each element: time, what it is and how long on one line, its description underneath */
.inspector-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 8px;
    padding: 4px 0;
    border-top: 1px solid var(--mud-palette-lines-default);
    font-size: 13px;
}

.inspector-row-time {
    font-variant-numeric: tabular-nums;
}

.inspector-row-name {
    font-weight: 600;
}

.inspector-row-detail {
    grid-column: 1 / -1;
    font-size: 12px;
}

/* a working's trip or activity: its move/remove/edit buttons, under the detail on the right */
.inspector-row-actions {
    grid-column: 1 / -1;
    justify-self: end;
    margin-top: -4px;
}

/* narrow windows: no room beside the page, so it always floats and fills the width */
@media (max-width: 900px) {
    /* the layout stays a flex row — it carries the view's height — but the inspector leaves it and floats */
    .inspector:not(.inspector--minimised) {
        position: fixed;
        top: 64px;
        left: 16px;
        right: 16px;
        width: auto;
        max-height: calc(100dvh - 80px);
        z-index: 1100;
    }

    .inspector.inspector--minimised {
        position: fixed;
        top: 64px;
        right: 16px;
        z-index: 1100;
    }
}

/* the duty graph's label: code on top, then the type chip and the legality mark on one line */
.duty-label-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.duty-label-badges .mud-chip.duty-type-chip {
    margin: 0;
    height: 18px;
    font-size: 11px;
}

.gantt-header-row .gantt-label-cell {
    background: var(--mud-palette-background-gray);
}

/* tall enough for a block to stack an end code over its minutes — see ScheduleGantt's BlockDetail */
.gantt-track {
    position: relative;
    height: 42px;
    flex: 0 0 auto;
}

/* a row carrying a sub-block lane (the trips under a duty's spells) grows to fit it, below the main blocks */
.gantt-track.gantt-track--lane {
    height: 56px;
}

.gantt-subblock {
    position: absolute;
    top: 40px;
    height: 14px;
    border-radius: 2px;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.25);
    opacity: 0.8;
    overflow: hidden;
    cursor: pointer;
}

.gantt-subblock.gantt-subblock--inert {
    cursor: default;
}

.gantt-subblock:hover {
    opacity: 1;
    outline: 2px solid var(--mud-palette-text-primary);
    z-index: 2;
}

/* the line name, centred in the bar; the bar's own overflow clips it if the name is longer than the trip */
.gantt-subblock-text {
    display: block;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    line-height: 12px;
    white-space: nowrap;
}

/* a relief point part-way along the trip: where the spell could be cut without touching the trip's ends */
.gantt-subblock-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: currentColor;
}

.gantt-header-row .gantt-track {
    height: 24px;
}

.gantt-hour-tick {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px solid var(--mud-palette-lines-default);
    font-size: 10px;
    color: var(--mud-palette-text-secondary);
    padding-left: 3px;
    pointer-events: none;
}

.gantt-block {
    position: absolute;
    top: 5px;
    height: 32px;
    border-radius: 3px;
    font-size: 10.5px;
    line-height: 32px;
    padding: 0 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
    color: #fff;
    box-sizing: border-box;
    cursor: pointer;
}

/* A block wide enough to say where it starts and ends: codes on the top row, their minutes underneath, each
   above the other so the pair reads as one thing. The middle column is what gives, since a clipped label costs
   less than a clipped time. */
.gantt-block--detail {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 1fr 1fr;
    align-items: center;
    column-gap: 3px;
    padding: 2px 4px;
    line-height: 1.15;
    font-size: 10px;
}

.gantt-block-code {
    font-weight: 600;
    white-space: nowrap;
}

.gantt-block-time {
    /* digits line up column-wise between rows, which is most of what makes a graph scannable */
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    opacity: 0.85;
}

.gantt-block-label {
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
    font-size: medium;
    padding-top: 4px;
}

.gantt-block:hover {
    outline: 2px solid var(--mud-palette-text-primary);
    z-index: 2;
}

.gantt-block[draggable="true"] {
    cursor: grab;
}

.gantt-row.gantt-drop-over .gantt-track {
    outline: 2px dashed var(--mud-palette-primary);
    outline-offset: -2px;
}
