/* ==========================================
 * Analysis extras (analysis-extras.js): the version an analysis read, comments on an analysis,
 * and the analysis as a printed page / PDF
 * ========================================== */

/* ---------- "Gem teksten som udkast (valgfrit)" above the run button ---------- */
.analysis-version-name {
    display: grid;
    gap: 6px;
    margin-top: 16px;
}
.analysis-version-name label {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}
.analysis-version-optional {
    font-weight: 400;
    color: var(--muted);
}
.analysis-version-name input {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
}
.analysis-version-name input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 1px var(--ink);
}
.analysis-version-name input:disabled {
    opacity: .55;
}
.analysis-version-hint {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.45;
    color: var(--muted);
}

/* ---------- PDF button and "Medtag kommentarer" ---------- */
.analysis-actions-bar #btn-export-analysis-pdf {
    flex: none;
}
.analysis-pdf-comments {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--ink);
    cursor: pointer;
}
.analysis-pdf-comments input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--ink);
}

/* ---------- "Analyse af 2. udkast" over the shown analysis ---------- */
.analysis-version-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    margin: -12px 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--muted);
}
.analysis-version-text {
    color: var(--muted);
}
.analysis-version-link {
    min-height: 32px;
    padding: 0;
    background: none;
    border: none;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--line-strong);
    text-underline-offset: 3px;
    cursor: pointer;
}
.analysis-version-link:hover {
    text-decoration-color: var(--ink);
}
.analysis-version-compare {
    font-weight: 400;
}
.analysis-version-sep {
    color: var(--muted);
}

/* ---------- Comments under the analysis ---------- */
.analysis-comments {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--line-strong);
    font-family: var(--font-ui);
    color: var(--ink);
}
.analysis-comments .ac-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
}
.analysis-comments .ac-title {
    margin: 0;
    font-family: var(--font-title);
    font-size: 26px;
    font-weight: 400;
    line-height: 1.1;
    color: var(--ink);
}
.analysis-comments .ac-count {
    font-size: 14px;
    color: var(--muted);
}
.analysis-comments .ac-note {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
}
.analysis-comments .ac-list {
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
    display: grid;
    gap: 12px;
}
.analysis-comments .ac-item {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    min-width: 0;
}
.analysis-comments .ac-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    margin-bottom: 6px;
    font-size: 13px;
}
.analysis-comments .ac-author {
    font-weight: 600;
    color: var(--ink);
}
.analysis-comments .ac-date {
    color: var(--muted);
}
.analysis-comments .ac-quote {
    margin: 6px 0 8px;
    padding: 4px 0 4px 12px;
    border-left: 2px solid var(--line-strong);
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    font-style: italic;
    overflow-wrap: anywhere;
}
.analysis-comments .ac-body {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.analysis-comments .ac-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-top: 6px;
}
.analysis-comments .ac-link {
    min-height: 32px;
    padding: 0;
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.analysis-comments .ac-link:hover {
    color: var(--ink);
}
.analysis-comments .ac-link-danger:hover {
    color: var(--red);
}
.analysis-comments .ac-textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 88px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    resize: vertical;
}
.analysis-comments .ac-textarea:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 1px var(--ink);
}
.analysis-comments .ac-item .ac-textarea {
    margin-top: 4px;
}
.analysis-comments .ac-quote-draft {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px 12px;
    margin-bottom: 8px;
}
.analysis-comments .ac-quote-draft .ac-quote {
    flex: 1 1 240px;
    margin: 0;
    max-height: 7.5em;
    overflow: auto;
}
.analysis-comments .ac-form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 8px;
}
.analysis-comments .ac-hint {
    flex: 1 1 auto;
    font-size: 12px;
    color: var(--muted);
}
.analysis-comments .ac-btn {
    min-height: 40px;
    font-size: 13px;
}
.analysis-comments .ac-send {
    margin-left: auto;
}

/* Phones and touch: 44px targets, no keyboard hint */
@media (max-width: 850px), (pointer: coarse) {
    .analysis-version-link,
    .analysis-comments .ac-link,
    .analysis-comments .ac-btn {
        min-height: 44px;
    }
    .analysis-comments .ac-hint {
        display: none;
    }
    .analysis-version-name input,
    .analysis-comments .ac-textarea {
        font-size: 16px; /* no zoom on focus in iOS */
    }
}
@container analysis (max-width: 600px) {
    .analysis-comments {
        margin-top: 28px;
    }
    .analysis-comments .ac-btn {
        flex: 1 1 auto;
    }
    .analysis-comments .ac-send {
        margin-left: 0;
    }
    .analysis-pdf-comments {
        flex: 1 1 100%;
    }
}

/* ---------- The printed analysis (Eksportér som PDF) ----------
 * #print-analysis is filled by AnalysisExtras.exportPdf and only ever shown while printing with
 * html.printing-analysis set; everything else on the page is left out then. The script's own PDF
 * (html.pdf-pages) never sets that class, so the two don't meet. The page margins come from a
 * <style> the export adds for the print (the script's PDF prints with no margin). */
.print-analysis {
    display: none;
}
@media print {
    html.printing-analysis body > *:not(#print-analysis) {
        display: none !important;
    }
    html.printing-analysis,
    html.printing-analysis body {
        background: #ffffff !important;
        height: auto !important;
        overflow: visible !important;
    }
    html.printing-analysis #print-analysis {
        display: block !important;
        /* Light tokens, so the analysis styles print dark on white in either theme */
        --ink: #1E1B16;
        --muted: #5E5850;
        --line: #DAD5CB;
        --line-strong: #BDB6A8;
        --surface: #FFFFFF;
        --surface-2: #FAF9F6;
        --fill: #E9E5DD;
        --red: #962117;
        color: #1E1B16;
        background: #ffffff;
        font-family: var(--font-ui);
        font-size: 10.5pt;
        line-height: 1.5;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
.print-analysis .pa-head {
    margin: 0 0 8mm;
    padding-bottom: 5mm;
    border-bottom: 1px solid var(--line-strong);
}
.print-analysis .pa-kicker {
    margin: 0 0 2mm;
    font-size: 9pt;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.print-analysis .pa-title {
    margin: 0 0 4mm;
    font-family: var(--font-title);
    font-size: 26pt;
    font-weight: 400;
    line-height: 1.1;
    color: var(--ink);
}
.print-analysis .pa-meta {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 1mm 6mm;
    margin: 0;
    font-size: 9.5pt;
}
.print-analysis .pa-meta dt {
    margin: 0;
    font-weight: 600;
    color: var(--muted);
}
.print-analysis .pa-meta dd {
    margin: 0;
}
.print-analysis .pa-body {
    font-size: 10.5pt;
    line-height: 1.5;
}
.print-analysis .pa-body h1 { font-size: 18pt; }
.print-analysis .pa-body h2 { font-size: 14pt; }
.print-analysis .pa-body h3 { font-size: 12pt; }
.print-analysis .pa-body h1,
.print-analysis .pa-body h2,
.print-analysis .pa-body h3,
.print-analysis .pa-body h4 {
    break-after: avoid;
    page-break-after: avoid;
}
.print-analysis .pa-body blockquote,
.print-analysis .pa-body .analysis-dialogue-card,
.print-analysis .pa-body tr,
.print-analysis .pa-body .analysis-brief-recap,
.print-analysis .pa-comment {
    break-inside: avoid;
    page-break-inside: avoid;
}
.print-analysis .pa-body .table-responsive {
    overflow: visible;
}
.print-analysis .pa-body table {
    width: 100%;
    font-size: 9.5pt;
}
.print-analysis .pa-comments {
    margin-top: 10mm;
    padding-top: 5mm;
    border-top: 1px solid var(--line-strong);
}
.print-analysis .pa-comments-title {
    margin: 0 0 4mm;
    font-family: var(--font-title);
    font-size: 16pt;
    font-weight: 400;
    color: var(--ink);
    break-after: avoid;
    page-break-after: avoid;
}
.print-analysis .pa-comment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.print-analysis .pa-comment {
    margin: 0 0 4mm;
    padding: 3mm 4mm;
    border: 1px solid var(--line);
    border-radius: 2px;
}
.print-analysis .pa-comment-head {
    margin: 0 0 1.5mm;
    font-size: 9pt;
    color: var(--muted);
}
.print-analysis .pa-comment-head strong {
    color: var(--ink);
}
.print-analysis .pa-comment-quote {
    margin: 0 0 2mm;
    padding-left: 3mm;
    border-left: 2px solid var(--line-strong);
    font-style: italic;
    color: var(--muted);
}
.print-analysis .pa-comment-body {
    margin: 0;
}
.print-analysis .pa-footer {
    margin: 8mm 0 0;
    font-size: 8.5pt;
    color: var(--muted);
}
