/* Custom CSS for SimplePDF output */

/* ===== COVER PAGE STYLING ===== */

/* Force white text on cover page */
h1.title-cover {
    color: #ffffff !important;
    font-size: 48px !important;
    font-weight: bold !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#cover .title-cover,
#cover h1,
#cover h2,
#cover .title,
#cover .subtitle-cover,
#cover .cover-middle,
#cover .meta,
#cover p,
.title-cover,
.cover-middle .title h1,
.cover-middle .title {
    color: #ffffff !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Ensure cover background is UiO blue */
#cover,
article#cover,
.cover,
.cover-page {
    background-color: #0d72c0 !important;
    background: #0d72c0 !important;
}

/* Override any gradients or overlays */
#cover .container {
    background-color: transparent !important;
}

/* Remove/override red top stripe/border on cover */
#cover::before,
#cover::after,
article#cover::before,
.cover::before,
.cover-page::before,
.cover .header,
.cover-page .header {
    background-color: #0d72c0 !important;
    border-top-color: #0d72c0 !important;
    border-color: #0d72c0 !important;
    border: none !important;
}

/* ===== PAGE NUMBERS IN BLUE ===== */

/* Override page number color to UiO blue */
@page {
    @bottom-center {
        color: #0d72c0 !important;
    }
    @bottom-right {
        color: #0d72c0 !important;
    }
    @bottom-left {
        color: #0d72c0 !important;
    }
}

/* Counter for page numbers in blue */
.pagenumber {
    color: #0d72c0 !important;
}

/* Links in UiO blue */
a {
    color: #0d72c0 !important;
}

/* ===== HIDE IMAGE LINK PATHS IN PDF ===== */

/* Completely hide image reference links */
a.image-reference,
a.reference.internal.image-reference,
figure a.reference,
a[href*="_images/"],
a[href$=".png"],
a[href$=".jpg"],
a[href$=".svg"] {
    /* Disable WeasyPrint link annotations */
    -weasy-link: none !important;

    /* Clear any string content */
    string-set: none !important;

    /* Make link invisible but keep image visible */
    color: transparent !important;
    text-decoration: none !important;
    border: none !important;
}

/* Remove ::before and ::after content */
a.image-reference::before,
a.image-reference::after,
a.reference.internal.image-reference::before,
a.reference.internal.image-reference::after,
figure a.reference::before,
figure a.reference::after {
    content: '' !important;
    display: none !important;
}

/* ===== CANVAS TABS (EXPANDED FOR PRINT) ===== */

/* Tabs are JavaScript-driven in Canvas, so canvas_tabs.py emits a stacked,
   fully expanded variant for the simplepdf builder. Style it to echo the
   on-screen tab look: a titled header strip above each panel. */

.canvas-tabs-pdf {
    margin-bottom: 2em;
}

.canvas-tab-pdf {
    /* Keep a tab's title with at least some of its content across page breaks */
    break-inside: avoid;
    margin-bottom: 0.75em;
}

.canvas-tab-pdf-title {
    margin: 0 !important;
    padding: 8px 16px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-bottom: none;
    font-weight: bold !important;
    break-after: avoid;
}

.canvas-tab-pdf-body {
    padding: 12px 16px;
    border: 1px solid #ddd;
    background-color: #ffffff;
}

.canvas-tab-pdf-body > :first-child {
    margin-top: 0 !important;
}

.canvas-tab-pdf-body > :last-child {
    margin-bottom: 0 !important;
}

/* ===== DO / DON'T GRID ===== */

/* .uio-grid-row is a flexbox, and the .col-lg sizing that makes its children
   share the row lives in an `@media only screen and (min-width: 992px)` block
   in common.css. WeasyPrint renders as print media, so those rules never
   apply: the flex items fall back to `flex: 0 1 auto`, size to their content,
   and run off the right edge. Lay the row out as a fixed 50/50 table instead,
   which WeasyPrint handles reliably. */

.uio-grid-row {
    display: table !important;
    table-layout: fixed !important;
    width: 100% !important;
    max-width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 10px 0 !important;
    break-inside: avoid;
}

.uio-grid-row > .uio-icon-box {
    display: table-cell !important;
    width: 50% !important;
    max-width: 50% !important;
    vertical-align: top !important;
    box-sizing: border-box !important;
}

/* ===== BILDEGRID (uio-grid) ===== */

/* Same story as .uio-grid-row above: .grid-row / .col-xs is Canvas' flexbox
   grid, which WeasyPrint lays out unreliably. Render each row as a fixed table
   whose cells share the width evenly, so 2-5 columns come out equal in the PDF
   too. table-layout: fixed with no width on the cells splits them evenly. */

.grid-row {
    display: table !important;
    table-layout: fixed !important;
    width: 100% !important;
    max-width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 10px 0 !important;
    break-inside: avoid;
}

.grid-row > .col-xs {
    display: table-cell !important;
    vertical-align: top !important;
    box-sizing: border-box !important;
}

.grid-row figure img {
    max-width: 100% !important;
}

/* ===== BASE FONT SIZE ===== */

/* Screen sizing (16px) is oversized on an A4 page. Scale the root down so all
   the rem- and percentage-based sizes follow; the cover keeps its own px
   sizes. */

html {
    font-size: 13px !important;
}

body,
#wiki_page_show,
#wiki_page_show p,
#wiki_page_show li {
    font-size: 13px !important;
}
