/* The user guide - View.UserGuide's screen, and the guide itself (Util.UserGuideDocument) on screen
   and on paper. Scheduler-MobileUserGuide-Design.md sections 2 and 5.2.

   The screen's controls follow the Scheduler's theme through the --totm-* tokens (Modern.css). The
   guide itself is a page of paper: white, dark text, whatever the theme, on screen as in print.

   The phones inside it are Util.MobilePhoneSketch's drawings, styled by MobileHomeSettings.css,
   MobileJobSettings.css and TimesheetSettings.css inside .MpsSketchHost. Here they lose the settings
   screens' fixed height, since a guide shows the whole screen. */

/* ---- the screen */

.UgScreen {
    font-family: var(--totm-font, inherit);
    color: var(--totm-text, #1a1a1a);
}

.UgIntro {
    margin: 0 0 12px;
    color: var(--totm-text-muted, #5f6368);
}

.UgLayout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

@media (max-width: 1000px) {
    .UgLayout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.UgControls h3 {
    margin: 16px 0 6px;
    font-size: var(--totm-fs-sm, 13px);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--totm-text-muted, #5f6368);
}

.UgField {
    display: flex;
    align-items: center;
    gap: 8px;
}

.UgFieldLabel {
    font-weight: 600;
}

.UgField select {
    flex: 1;
    min-width: 0;
}

.UgHint {
    margin-top: 4px;
    font-size: var(--totm-fs-xs, 12px);
    color: var(--totm-text-muted, #5f6368);
}

.UgRoles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    align-items: center;
}

.UgRole {
    padding: 2px 8px;
    border: 1px solid var(--totm-border, #e3e5e9);
    border-radius: 999px;
    font-size: var(--totm-fs-xs, 12px);
}

.UgRoleOff {
    color: var(--totm-text-muted, #5f6368);
}

.UgRolesLink {
    font-size: var(--totm-fs-xs, 12px);
}

.UgSections {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.UgSectionTick {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.UgShowWhy {
    margin-top: 14px;
    font-size: var(--totm-fs-sm, 13px);
}

.UgMissing {
    margin: 0;
    padding-left: 18px;
    font-size: var(--totm-fs-sm, 13px);
    color: var(--totm-text-muted, #5f6368);
}

.UgMissingItem {
    margin-bottom: 4px;
}

.UgMissingItem b {
    color: var(--totm-text, #1a1a1a);
}

.UgActions {
    margin-top: 16px;
}

/* !important because Scheduler.css paints every button with !important. */
.UgScreen button.UgSavePdf {
    padding: 8px 14px !important;
    font-weight: 600 !important;
}

.UgPreview {
    min-width: 0;
    padding: 20px;
    background: var(--totm-border, #e3e5e9);
    border-radius: 8px;
    max-height: 75vh;
    overflow-y: auto;
}

.UgPreview.UgBusy {
    opacity: 0.5;
}

/* ---- the guide: a page of paper */

.UgDocument {
    max-width: 210mm;
    margin: 0 auto;
    padding: 18mm 16mm;
    background: #ffffff;
    color: #1a1a1a;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.UgCover h1 {
    margin: 0 0 4px;
    font-size: 24px;
    line-height: 1.25;
}

.UgCoverMeta {
    color: #5f6368;
    font-weight: 600;
}

.UgCoverNote {
    margin: 10px 0 0;
    padding: 8px 10px;
    background: #f6f7f9;
    border-left: 3px solid #1976d2;
    color: #3c4043;
    font-size: 12px;
}

.UgSection {
    margin-top: 22px;
}

.UgSection h2 {
    margin: 0 0 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid #1976d2;
    font-size: 18px;
}

.UgSection h3 {
    margin: 12px 0 4px;
    font-size: 14px;
}

.UgSection p {
    margin: 0 0 8px;
}

.UgSection ul {
    margin: 0 0 8px;
    padding-left: 20px;
    list-style: disc outside;
}

.UgSection ol {
    margin: 0 0 8px;
    padding-left: 22px;
}

/* Scheduler.css takes the bullet off every li. */
.UgSection li {
    display: list-item;
    list-style-type: disc;
}

.UgSection ol > li {
    list-style-type: decimal;
}

.UgSection li {
    margin-bottom: 3px;
}

.UgWhy {
    margin: -2px 0 8px;
    padding: 3px 8px;
    background: #fff8e1;
    color: #6d4c00;
    font-size: 12px;
}

/* Pictures float beside the words, the same on screen and on paper: Chromium splits a grid or flex
   item across printed pages, but moves a float's inline-block phones whole. The pictures come first
   in the section so the float starts level with its heading. */
.UgSectionBody {
    display: flow-root;
}

.UgPictures {
    float: right;
    width: 60mm;
    margin: 0 0 8px 18px;
}

/* A block with a picture of its own (a job's tab beside what is said about it): the picture floats
   right of the block's words, and the next block starts below both. */
.UgBlock {
    display: flow-root;
    margin: 6px 0 10px;
    break-inside: avoid;
}

.UgBlock + .UgBlock {
    padding-top: 8px;
    border-top: 1px solid #e3e5e9;
}

.UgPicture {
    display: inline-block;
    vertical-align: top;
    margin: 0 8px 8px 0;
    width: 58mm;
    break-inside: avoid;
}

.UgPicture figcaption {
    margin-top: 4px;
    text-align: center;
    font-size: 11px;
    color: #5f6368;
}

/* A guide shows the whole screen: no fixed height, no scrolling inside the phone. */
.UgPhone .MhsScreen,
.UgPhone .MjsScreen {
    height: auto;
    overflow: visible;
    border-width: 8px;
    border-radius: 22px;
    font-size: 11px;
}

.UgPhone .MhsPhoneBody,
.UgPhone .MjsPhoneBody {
    overflow: visible;
}

.UgPhone .TssPhone {
    width: auto;
}

/* ---- on paper */

/* Scheduler.css, which the print frame links for the phones, sets html and body to the window's
   height - and Chromium then prints one page. The guide's own page grows with it. */
html:has(> body.UgPrintBody),
body.UgPrintBody {
    height: auto !important;
    overflow: visible !important;
}

.UgPrintBody {
    margin: 0;
    background: #ffffff;
}

@page {
    size: A4;
    margin: 14mm;
}

@media print {
    .UgPrintBody .UgDocument {
        max-width: none;
        padding: 0;
        box-shadow: none;
    }

    .UgPrintBody .UgPageBreak {
        break-before: page;
    }

    /* A section with a picture is kept on one page: its heading and words go over with its phone,
       rather than a line left at the foot of one page and the phone alone on the next. Chromium
       breaks a float apart from the words around it whatever break-inside says, so such a section
       (.UgKeepTogether, set by Util.UserGuideDocument) and each block with its own picture are
       inline-blocks, which it moves to the next page whole. Text-only sections, and a section of
       blocks (a job's three tabs), still flow across pages. */
    .UgPrintBody .UgSection {
        break-inside: avoid;
    }

    .UgPrintBody .UgSection.UgKeepTogether,
    .UgPrintBody .UgBlock {
        display: inline-block;
        width: 100%;
        vertical-align: top;
    }

    /* Those inline-blocks are lines to the printer, and the default "orphans: 2" will not leave one
       alone at the foot of a page: Signing in, the only section after the cover, went to page 2 and
       left the cover on its own. Each is kept whole by break-inside already. */
    .UgPrintBody .UgDocument {
        orphans: 1;
        widows: 1;
    }

    /* A heading stays with what follows it. A paragraph only keeps itself whole: "break-after:
       avoid" on paragraphs chained a section's last line to the next section and pulled both over. */
    .UgPrintBody .UgSection h2,
    .UgPrintBody .UgSection h3 {
        break-after: avoid;
        break-inside: avoid;
    }

    .UgPrintBody .UgWords p,
    .UgPrintBody .UgWords li {
        break-inside: avoid;
    }

    .UgPrintBody .UgDocument,
    .UgPrintBody .UgPhone * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
