/* SOUND DEVICES STYLES */
/* Custom rules for Flatrock Theme */

:root {
    /* Custom SD Colors */
    --sd-orange: #f57b20;
    --sd-orange-dark: #9c4807;
    --sd-white: #fff;
    --sd-black: #000;
    --sd-black-alt: #171717;
    --sd-grey-light: #a5a5a6;
    --sd-grey-dark: #636466;
    --sd-blue-info: #1b50f7;
}

/* SD PAGE BREAK FOR ARTICLES */
@media print {
    .page-break {
        break-after: page;
        page-break-after: always;
    }
}

/* Experimental - SD MEDIA PRINT STYLES */
/* Takes Table Of Contents and formats it, places it before article */
@media print {
    /* Page + global resets */
    @page {
        size: Letter; /* change to A4 if preferred */
        margin: 18mm 15mm; /* top/bottom, left/right */
    }

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Prevent pagination blockers from ancestors (overflow/transform) */
    html,
    body,
    .lt-article-page,
    .lt-article-page .lt-container,
    .lt-article-page .lt-container-inner,
    .lt-article-page .lt-article-container {
        overflow: visible !important;
        transform: none !important;
        box-sizing: border-box !important;
    }

    /* Hide site chrome that shouldn't print */
    header.lt-topbar,
    .lt-hero-unit,
    .lt-breadcrumbs-wrapper,
    .lt-article-subscribe,
    .lt-article-vote,
    .lt-footer,
    .lt-scroll-to-top,
    .lt-article-container__sidenav,
    .lt-toc-mobile,
    .share,
    .lt-attachment-list__item,
    .sd-remove-metadata-for-print {
        display: none !important;
    }

    /* Keep admin/preview bars out of print (without affecting layout indices) */
    #navbar-container,
    #preview-bar-container,
    [id^="preview-bar"],
    [class*="preview-bar"] {
        position: fixed !important;
        top: -200vh !important;
        left: 0 !important;
        right: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        border: 0 !important;
        box-shadow: none !important;
        z-index: -1 !important;
        display: block !important; /* avoid display:none side-effects */
        visibility: hidden !important;
    }

    /* Layout order: TOC first, then article */
    .lt-article-page .lt-article-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 18pt !important;
        min-height: 0 !important;
    }

    /* Unhide a TOC that the theme hides in print */
    .lt-article-page .lt-article-container__sidebar.lt-d-print-none,
    .lt-article-page .lt-article-container__sidebar .lt-d-print-none {
        display: block !important;
        visibility: visible !important;
    }

    /* --- CRITICAL: Make TOC a formatting context + page break on the flex item --- */
    .lt-article-page .lt-article-container__sidebar {
        order: -1 !important; /* TOC first */
        width: 100% !important;
        margin: 0 0 16pt 0 !important;
        position: static !important;
        float: none !important;

        /* Ensure real height in print so the break is honored */
        display: table !important; /* highly reliable in print engines */
        table-layout: fixed !important;

        /* Single, intentional split after TOC */
        break-after: page !important;
        page-break-after: always !important;
    }

    /* Neutralize sticky/fixed/scroll boxes inside TOC + give it breathing room */
    .lt-article-page .lt-article-container__sidebar .lt-toc,
    .lt-article-page .lt-article-container__sidebar .lt-toc--container {
        position: static !important;
        top: auto !important;
        bottom: auto !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        background: transparent !important;
        box-shadow: none !important;
        border: 0 !important;
        padding-left: 16pt !important;
        padding-right: 16pt !important;
    }

    /* TOC heading: replace theme label with a predictable one */
    .lt-article-page .lt-article-container__sidebar .lt-toc--title {
        color: transparent !important;
        font:
            700 18pt/1.2 "Times New Roman",
            Times,
            serif;
        margin: 0 0 10pt 0 !important;
    }

    .lt-article-page .lt-article-container__sidebar .lt-toc--title::before {
        content: "Contents";
        color: #000;
    }

    .lt-article-page .lt-article-container__sidebar .lt-toc--current {
        display: none !important;
    }

    /* TOC list: force single, stable column */
    .lt-article-page .lt-article-container__sidebar .lt-toc--list {
        display: block !important;
        column-count: 1 !important;
        column-gap: 0 !important;
        column-fill: auto !important;
        list-style: decimal;
        list-style-position: outside;
        padding-left: 20pt !important;
        margin: 0 !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* Keep entries intact across pages; flexible leaders */
    .lt-article-page .lt-article-container__sidebar .lt-toc--item {
        break-inside: avoid !important;
        -webkit-column-break-inside: avoid !important;
        page-break-inside: avoid !important;
        margin: 0;
        padding: 0;
    }

    .lt-article-page .lt-article-container__sidebar .lt-toc--link {
        display: flex !important;
        align-items: baseline !important;
        gap: 6pt !important;
        text-decoration: none !important;
        color: #000 !important;
        font:
            11pt/1.25 "Times New Roman",
            Times,
            serif;
        padding: 3pt 0;
        position: static !important;
    }

    .lt-article-page .lt-article-container__sidebar .lt-toc--link span {
        flex: 0 1 auto !important;
        min-width: 0 !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
    }

    .lt-article-page .lt-article-container__sidebar .lt-toc--link::after {
        content: "" !important; /* dotted leader that flexes */
        flex: 1 1 auto !important;
        border-bottom: 1px dotted #aaa !important;
        transform: translateY(-1px);
        max-width: 100% !important;
    }

    .lt-article-page .lt-article-container__sidebar .lt-toc--item-h1 .lt-toc--link {
        font-weight: 700;
    }

    .lt-article-page .lt-article-container__sidebar .lt-toc--item-h2 .lt-toc--link {
        padding-left: 8pt;
    }

    .lt-article-page .lt-article-container__sidebar .lt-toc--item-h3 .lt-toc--link {
        padding-left: 16pt;
        font-style: italic;
    }

    /* 2) Article starts on a fresh page after the TOC */
    .lt-article-page .lt-article-container__article {
        order: 0 !important;
        break-before: page !important; /* defensive: ensures fresh page */
        page-break-before: always !important; /* legacy alias */
        clear: both !important;
        position: static !important;
        float: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Article typography */
    .lt-article-page .lt-article__title {
        font:
            700 20pt/1.2 "Times New Roman",
            Times,
            serif;
        margin: 0 0 12pt 0 !important;
        page-break-after: avoid !important;
    }

    .lt-article-page .lt-article__body {
        font:
            11pt/1.35 "Times New Roman",
            Times,
            serif;
    }

    /* General print polish */
    a[href]::after {
        content: ""; /* don't print raw URLs */
    }

    img {
        max-width: 100% !important;
        page-break-inside: avoid !important;
    }

    pre,
    code,
    table,
    blockquote {
        page-break-inside: avoid !important;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        page-break-after: avoid !important;
        orphans: 3;
        widows: 3;
    }
}

/* PRINT — Full-width article content & no gutters */
@media print {
    /* Let the main wrappers expand to the printable box */
    html,
    body {
        width: auto !important;
        max-width: none !important;
    }

    /* Common outer wrappers used by the theme/layout */
    .lt-article-page,
    .lt-article-page .lt-container,
    .lt-article-page .lt-container-inner,
    .lt-article-page .lt-article,
    .lt-article-page .lt-article-container {
        width: auto !important;
        max-width: none !important; /* nuke theme's 720–960px caps */
        margin-left: 0 !important;
        margin-right: 0 !important; /* center constraints -> full width */
        padding-left: 0 !important;
        padding-right: 0 !important; /* remove side gutters in print */
        box-sizing: border-box !important;
        align-items: stretch !important; /* ensure flex children fill width */
    }

    /* The article itself should occupy the whole line */
    .lt-article-page .lt-article-container__article {
        width: 100% !important;
        max-width: none !important;
        float: none !important;
        position: static !important;
        clear: both !important;
    }

    /* Guard against any multi-column styles applied by the theme */
    .lt-article-page .lt-article__body,
    .lt-article-page .lt-article-container__article,
    .lt-article-page .lt-article__content {
        column-count: 1 !important;
        column-gap: 0 !important;
        columns: auto !important;
    }

    /* Media and tables: scale to fit printable width (no clipping) */
    .lt-article-page img,
    .lt-article-page table {
        max-width: 100% !important;
        width: 100% !important; /* if your theme sets fixed px widths */
        height: auto !important;
    }

    /* Keep TOC fix intact (no change), but ensure it doesn't constrain width */
    .lt-article-page .lt-article-container__sidebar {
        width: 100% !important; /* already used for the clean page split */
        max-width: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Fixes odd WYSIWYG top-line table style */
table.wysiwyg-table-resized tr:first-child td {
    border-top: none;
}

/* SD ARTICLE LINK COLORS */
.lt-article a {
    color: var(--sd-black-alt);
    text-decoration: underline solid var(--color-link-hover) 0.125em;
    text-decoration-skip-ink: all;
}

.lt-article a:hover,
.lt-article a:focus {
    color: var(--color-link-hover);
    text-decoration: underline solid var(--color-link-hover) 0.125em;
    text-decoration-skip-ink: all;
}

/* ALPHABETICAL LIST STYLE */
.sd-alpha {
    counter-reset: list;
}

.sd-alpha > li {
    counter-increment: list;
}

/* UPPER-ALPHA MARKERS */
/* For when you want an ordered list with letters */
.rte-enhanced .sd-alpha > li:before {
    content: counter(list, upper-alpha);
    color: var(--list-bullet-bg, var(--color-brand-primary-inverse));
    background-color: var(--list-bullet-bg, var(--color-text-primary));
    font-weight: bold;
    margin-right: 0.5em;
}

/* NESTED ALPHABETIC STYLE */
/* Adds lower-case letters when order list is nested under sd-alpha */
.rte-enhanced .sd-alpha ol {
    counter-reset: sublist;
}

.rte-enhanced .sd-alpha ol > li {
    counter-increment: sublist;
}

.rte-enhanced .sd-alpha ol > li:before {
    content: counter(sublist, lower-alpha); /* a, b, c... */
    color: var(--list-bullet-bg, var(--color-brand-primary-inverse));
    background-color: var(--list-bullet-bg, var(--color-text-primary));
    margin-right: 0.5em;
}

/* Increase H1 size in article */
.lt-article {
    & h1 {
        font-size: 3rem;
    }
}

/* Slightly reduce TOC height, blend gradient at bottom */
.lt-toc--list {
    height: 80vh;
    border-radius: 4px;
    scrollbar-color: oklch(0.3042 0 0) transparent;
    -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 98%, transparent 100%);
}

/* TOC H1 Adjustments*/
.lt-toc--item-h1 {
    & .lt-toc--link {
        font-weight: bold;
        font-size: var(--text-base);
    }
}

/* TOC H2 Adjustments */
.lt-toc--item-h2 {
    & .lt-toc--link {
        margin-left: 20px;
    }
}

/* TOC H3 Adjustments */
.lt-toc--item-h3 {
    /* Add indent into list item */
    & .lt-toc--link {
        margin-left: 40px;
    }
}

/* Navbar Search*/
.nav-search {
    min-width: 50%;
}

@media (max-width: 991px) {
    .nav-search {
        min-width: 0;
    }
}

.sd-mb-12 {
    margin-bottom: 20px;
}

.lt-mobile-search-backdrop {
    position: absolute;
    inset: 0;
    z-index: -1;
}

input[type="submit"] {
    font-size: var(--text-base);
}

a.lt-toc--link.is-active,
a.lt-toc--link.is-active:hover {
    color: var(--sd-black);
}

@media only screen and (max-width: 768px) {
    h5.lt-card__heading {
        font-size: var(--text-xl);
    }

    .lt-topbar {
        font-size: var(--text-xl);
    }

    .lt-hero-unit input[type="search"] {
        font-size: var(--text-lg);
        text-overflow: ellipsis;
    }
}
