/* PDF export dialog ("Eksporter PDF", print-options.js) and the marks it adds to the printed
   pages. Only #modal-print-options and po- classes; nothing here changes an existing rule.
   Dialog colours come from the theme tokens in styles.css. */

/* ---------- Dialog ---------- */

/* Above the phone drawers (z-index 1500), below the toasts (9999). Pinned near the top, so the
   dialog grows downwards when a mode shows more and the radio just clicked stays put. */
#modal-print-options.modal-backdrop {
    z-index: 1600;
    align-items: flex-start;
    padding-top: 5vh;
}
#modal-print-options .po-dialog {
    width: min(560px, 96vw);
    max-width: 96vw;
    max-height: min(calc(95vh - 16px), 900px);
    overflow: hidden;
}
#modal-print-options .po-dialog:focus {
    outline: none;
}
#modal-print-options [hidden] {
    display: none !important;
}
#modal-print-options .po-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    gap: 20px;
}

.po-group {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.po-group legend {
    padding: 0;
    margin-bottom: 8px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

/* One row per choice: the whole row is the click target, at least 44 px high */
.po-choice,
.po-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 44px;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-ui);
    cursor: pointer;
}
.po-check {
    border-color: transparent;
    padding: 11px 4px;
}
.po-choice:hover,
.po-check:hover {
    border-color: var(--line-strong);
}
.po-choice:has(input:checked) {
    border-color: var(--ink);
    background: var(--surface-2);
}
.po-choice:has(input:disabled) {
    cursor: not-allowed;
    opacity: .55;
}
.po-choice:has(input:disabled):hover {
    border-color: var(--line);
}
.po-choice input,
.po-check input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--ink);
    cursor: inherit;
}
.po-choice-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.po-choice-title,
.po-check-title {
    font-size: 14px;
    line-height: 1.4;
}
.po-choice-title {
    font-weight: 600;
}
.po-choice-hint {
    font-size: 13px;
    line-height: 1.4;
    color: var(--muted);
}

#modal-print-options .po-note {
    margin: 0 0 4px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}
#modal-print-options .po-error {
    margin: 4px 0 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--red);
}

/* Character picker: names as on the page (Courier), counts in the UI font */
.po-char-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 264px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 4px;
}
.po-char-list li + li {
    border-top: 1px solid var(--line);
}
.po-char-list .po-check {
    align-items: center;
    border: 0;
    border-radius: 0;
    padding: 0 12px;
}
.po-char-list .po-check input {
    margin: 0;
}
.po-char-list .po-check:has(input:checked) {
    background: var(--surface-2);
}
.po-char-text {
    min-width: 0;
    padding: 10px 0;
    font-size: 14px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.po-char-name {
    font-family: var(--font-editor);
    font-weight: 700;
}
.po-char-meta {
    color: var(--muted);
}

/* Phone (same breakpoint as MOBILE_QUERY in app.js): the dialog fills the screen */
@media (max-width: 850px) {
    #modal-print-options.modal-backdrop {
        padding: 0;
        height: 100vh;
        height: 100dvh;
    }
    #modal-print-options .po-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
    }
    #modal-print-options .modal-header {
        padding: 8px 8px 8px 16px;
    }
    #modal-print-options .po-body {
        padding: 16px;
    }
    .po-char-list {
        max-height: none;
        overflow: visible;
    }
    #modal-print-options .modal-footer {
        padding: 12px 16px;
    }
    #modal-print-options .modal-footer .btn {
        flex: 1;
    }
}

/* ---------- Marks on the printed pages ----------
   These classes exist only on the copies exportPDF lays out (in the hidden A4 frame and
   #print-pages), never in the editor. They are not limited to print because the frame lays the
   pages out with the screen rules; the sizes match the print rules in styles.css. */

/* "· · · scene 4–7 udeladt · · ·": an action line, centred */
.editor-text-area div.element.po-omitted {
    text-align: center !important;
    margin-left: 0 !important;
    width: auto !important;
}

/* Scene number from the whole script, in both margins beside the heading */
.editor-text-area div.element.po-numbered {
    position: relative !important;
}
.po-scene-no {
    position: absolute;
    top: 0;
    white-space: nowrap;
    font: inherit;
}
.po-scene-no-left {
    right: calc(100% + 0.5in);
}
.po-scene-no-right {
    left: calc(100% + 0.3in);
}

/* "Fremhæv karakterens replikker": the character's cue and dialogue in bold */
.editor-text-area div.element.po-highlight {
    font-weight: 700 !important;
}

/* "Tag replikken før med som stikord": someone else's line, grey and labelled */
.editor-text-area div.element.po-cue {
    color: #6B665E !important;
}
.po-cue-label {
    text-transform: none;
    font-style: italic;
    font-weight: 400;
}

/* ---------- Title page: "Medtag titelblad" when it differs from the editor ---------- */
@media print {
    html.po-title-off .title-page-sheet {
        display: none !important;
    }
    /* Same as the print rule for a shown title page in styles.css */
    html.po-title-on .title-page-sheet.hidden {
        display: flex !important;
        flex-direction: column !important;
        page-break-after: always !important;
        break-after: always !important;
        width: 210mm !important;
        height: 297mm !important;
        box-sizing: border-box !important;
        padding: 50.8mm 25.4mm 25.4mm 25.4mm !important;
        margin: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border: none !important;
        position: relative !important;
    }
}
