/**
 * Article Page Styles for MyTheme
 * Styles for embedded HTML galley iframe and additional article layout.
 */

/* Inline (non-iframe) HTML galley content rendered directly inside the page */
.html-galley-inline {
    width: 100%;
    margin: 1rem 0;
    line-height: 1.8;
    color: #2c2c2c;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure all text within html-galley-inline uses the same color */
.html-galley-inline,
.html-galley-inline * {
    color: #2c2c2c;
}

/* Ensure lists and list items also use the same color */
.html-galley-inline ul,
.html-galley-inline ol,
.html-galley-inline li,
.html-galley-inline ul li,
.html-galley-inline ol li,
.html-galley-inline li * {
    color: #2c2c2c !important;
}

.html-galley-inline img,
.html-galley-inline table,
.html-galley-inline iframe,
.html-galley-inline video {
    max-width: 100%;
    height: auto;
}

.html-galley-inline table {
    display: table;
    border-collapse: collapse;
    margin: 1rem 0;
    width: 100%;
}

.html-galley-inline table thead,
.html-galley-inline table tbody,
.html-galley-inline table tfoot {
    display: table-row-group;
}

.html-galley-inline table tr {
    display: table-row;
}

.html-galley-inline table th,
.html-galley-inline table td {
    display: table-cell;
    border: 1px solid #dee2e6;
    padding: .5rem .75rem;
    vertical-align: top;
}

.html-galley-inline h1,
.html-galley-inline h2,
.html-galley-inline h3,
.html-galley-inline h4 {
    margin-top: 1.5rem;
    line-height: 1.35;
    font-weight: 700;
    color: #0d4261;
}

.html-galley-inline h1 { font-size: 2rem; }
.html-galley-inline h2 { font-size: 1.6rem; }
.html-galley-inline h3 { font-size: 1.3rem; }
.html-galley-inline h4 { font-size: 1.1rem; }

/* Offset for anchor jumps so headings are not hidden under sticky elements */
.html-galley-inline h1,
.html-galley-inline h2,
.html-galley-inline h3,
.html-galley-inline h4,
.html-galley-inline h5,
.html-galley-inline h6 {
    scroll-margin-top: 90px;
}

/* Article Index (clickable list of full-text headings) */
/* Sticky wrapper — keeps the index visible in the start column while scrolling.
   The start column renders on the right in Arabic (RTL) and on the left in English (LTR). */
.article-index-sticky {
    position: sticky;
    top: 90px;
    z-index: 5;
}

.article-index-sticky .article-index-card .card-body {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

#article-index .article-index-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

#article-index .article-index-item {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #f0f0f0;
}

#article-index .article-index-item:last-child {
    border-bottom: none;
}

#article-index .article-index-item a {
    display: block;
    padding: .5rem .25rem;
    color: #0d4261;
    text-decoration: none;
    transition: color .15s ease, background-color .15s ease;
}

#article-index .article-index-item a:hover {
    color: #8a1538;
    background-color: #f8f9fa;
}

/* Indent nested heading levels (uniform size/weight/colour; this is an index) */
#article-index .article-index-level-1 a { font-size: 1rem; font-weight: 400; }
#article-index .article-index-level-2 a { padding-inline-start: 1.25rem; font-size: 1rem; font-weight: 400; }
#article-index .article-index-level-3 a { padding-inline-start: 2.5rem; font-size: 1rem; font-weight: 400; }
#article-index .article-index-level-4 a,
#article-index .article-index-level-5 a,
#article-index .article-index-level-6 a { padding-inline-start: 3.75rem; font-size: 1rem; font-weight: 400; }

/* Footnotes (inline [fn]...[/fn] markers rendered in the full-text body) */
.html-galley-inline .fn-ref {
    font-size: .75em;
    line-height: 0;
    font-weight: 700;
}

.html-galley-inline .fn-ref a {
    color: #8a1538;
    text-decoration: none;
    padding: 0 .1em;
}

.html-galley-inline .fn-ref a:hover {
    text-decoration: underline;
}

.html-galley-inline .article-footnotes {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.html-galley-inline .footnotes-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0d4261;
    margin-bottom: .75rem;
}

.html-galley-inline .footnotes-list {
    list-style: none;
    padding-inline-start: 0;
    margin: 0;
    font-size: .9rem;
    line-height: 1.7;
    color: #3a3a3a;
}

.html-galley-inline .footnotes-list .footnote-item {
    margin-bottom: .5rem;
    scroll-margin-top: 90px;
}

.html-galley-inline .footnotes-list .fn-number-link {
    color: #8a1538;
    font-weight: 700;
    text-decoration: none;
    margin-inline-end: .35rem;
}

.html-galley-inline .footnotes-list .fn-number-link:hover {
    text-decoration: underline;
    color: #0d4261;
}

/* Footnote popover (shown when a reference is clicked) */
.fn-popover {
    position: absolute;
    z-index: 1080;
    max-width: 360px;
    min-width: 200px;
    background: #ffffff;
    border: 1px solid #d6d6d6;
    border-top: 3px solid #8a1538;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
    padding: 0;
    animation: fn-popover-in .12s ease-out;
}

@keyframes fn-popover-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fn-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .35rem .6rem;
    border-bottom: 1px solid #eee;
}

.fn-popover-number {
    font-weight: 700;
    color: #8a1538;
    font-size: .9rem;
}

.fn-popover-number::before {
    content: "#";
    opacity: .5;
    margin-inline-end: 1px;
}

.fn-popover-close {
    border: 0;
    background: transparent;
    color: #6c757d;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 .15rem;
}

.fn-popover-close:hover {
    color: #8a1538;
}

.fn-popover-body {
    padding: .6rem .75rem;
    font-size: .9rem;
    line-height: 1.7;
    color: #3a3a3a;
    max-height: 50vh;
    overflow-y: auto;
}

.fn-popover-body p:last-child {
    margin-bottom: 0;
}

/* Give clickable references an affordance */
.html-galley-inline .fn-ref a {
    cursor: pointer;
}

/* Compact full-text card placed in the right sidebar (col-lg-3) */
.sidebar-fulltext-card .sidebar-fulltext-body {
    max-height: 600px;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.6;
    padding-right: .25rem;
}

.sidebar-fulltext-card .sidebar-fulltext-body img,
.sidebar-fulltext-card .sidebar-fulltext-body table {
    max-width: 100%;
    height: auto;
}

/* HTML Galley Embed Container */
.html-galley-embed {
    position: relative;
    width: 100%;
    margin: 1rem 0;
    border: none;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #fff;
}

.html-galley-embed .galley-iframe {
    width: 100%;
    min-height: 70vh;
    height: 800px;
    border: none;
    display: block;
}

/* PDF Galley Embed Container */
.pdf-galley-embed {
    position: relative;
    width: 100%;
    margin: 1rem 0;
    border: none;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #fff;
}

.pdf-galley-embed .galley-iframe-pdf {
    width: 100%;
    min-height: 70vh;
    height: 800px;
    border: none;
    display: block;
}

/* Action icons in sidebar */
.legislation-details .action-item .action-icon {
    font-size: 1.25rem;
    color: #8a1538;
    margin: 0 0.5rem;
}

.legislation-details .action-item .action-text {
    color: #0d4261;
    font-size: 0.95rem;
}

/* TOC list links */
.toc-list a {
    color: #0d4261;
    text-decoration: none;
}

.toc-list a:hover {
    color: #8a1538;
}

.toc-list .list-group-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-list .list-group-item h3 {
    margin: 0;
    font-size: 0.95rem;
}

/* Usage Statistics Charts */
#article-stats-charts .card-body {
    overflow: hidden;
}

.chart-wrapper {
    margin-bottom: 1rem;
}

.chart-wrapper:last-child {
    margin-bottom: 0;
}

.chart-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #0d4261;
    margin-bottom: 0.5rem;
}

.chart-label i {
    margin-right: 0.3rem;
}

[dir="rtl"] .chart-label i {
    margin-right: 0;
    margin-left: 0.3rem;
}

.chart-canvas-box {
    position: relative;
    width: 100%;
    height: 200px;
    background: #fafbfc;
    border: 1px solid #eceae3;
    border-radius: 0.5rem;
    padding: 0.5rem;
    box-sizing: border-box;
}

.chart-canvas-box canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Responsive */
@media (max-width: 991.98px) {
    .html-galley-embed .galley-iframe,
    .pdf-galley-embed .galley-iframe-pdf {
        min-height: 50vh;
        height: 500px;
    }
    .legal-article-page .contents-card,
    .legal-article-page .legislation-details {
        margin-bottom: 1.5rem;
    }
    .chart-canvas-box {
        height: 160px;
    }
}

/* DOI display */
.article-doi {
    padding-top: 0.5rem;
    margin-top: 0.35rem;
    border-top: 1px solid #eceae3;
}

.article-doi a {
    color: #0d4261;
    text-decoration: none;
    word-break: break-all;
    font-size: 0.85rem;
}

.article-doi a:hover {
    color: #8a1538;
    text-decoration: underline;
}

/* ORCID inline icon next to author name */
.article-author .orcid-link {
    display: inline-flex;
    align-items: center;
    vertical-align: top;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.article-author .orcid-link:hover {
    opacity: 1;
}

/* ORCID full URL row */
.article-orcid {
    padding: 0.15rem 0;
}

.article-orcid .orcid-full-link {
    color: #0d4261;
    text-decoration: none;
    font-size: 0.82rem;
    word-break: break-all;
}

.article-orcid .orcid-full-link:hover {
    color: #8a1538;
    text-decoration: underline;
}

[dir="rtl"] .article-author .orcid-link img {
    margin-inline-start: 0.5em;
    margin-inline-end: 0;
}

/* RTL adjustments */
[dir="rtl"] .toc-list .list-group-item {
   /* flex-direction: row-reverse;
    justify-content: flex-end;
    */
}
[dir="rtl"] .toc-list .list-group-item i.bi-chevron-left::before {
    transform: none !important;
}

/* ============ Design-match additions ============ */

/* === Citation Style Language (CSL) plugin card === */
#article-how-to-cite .card-body {
    overflow: visible;
}

.csl-output-wrapper {
    overflow: visible;
}

.csl-output-wrapper .item.citation {
    margin: 0;
    padding: 0;
}

.csl-output-wrapper .citation_formats {
    position: relative;
}

.csl-output-wrapper .citation_formats_list[aria-hidden="false"] {
    display: block;
}

.csl-output-wrapper .sub_item.citation_display {
    margin: 0;
    padding: 0;
}

.csl-output-wrapper .sub_item.citation_display > .label {
    display: none;
}

.csl-output-wrapper #citationOutput {
    background: var(--moj-light-color, #f8f9fa);
    border: 1px solid var(--moj-ash-color, #eceae3);
    border-radius: var(--btn-radius, 0.5rem);
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--moj-text-color, #212529);
    margin-bottom: 1rem;
}

.csl-output-wrapper .citation_formats_button {
    background: var(--moj-navyLight-trans, #cfd9df66);
    border: 1px solid var(--moj-navyMid-trans, #cfd9df);
    border-radius: var(--btn-radius, 0.5rem);
    color: var(--moj-primary-color, #3d6881);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.csl-output-wrapper .citation_formats_button:hover {
    background: var(--moj-navy-color, #0d4261);
    color: #fff;
    border-color: var(--moj-navy-color, #0d4261);
}

.csl-output-wrapper .citation_formats_list {
    background: #fff;
    border: 1px solid var(--moj-ash-color, #eceae3);
    border-radius: var(--btn-radius, 0.5rem);
    margin-top: 0.5rem;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.csl-output-wrapper .citation_formats_list .label {
    color: var(--moj-primary-color, #3d6881);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.65rem 1.25rem 0.35rem;
    margin: 0;
    background: var(--moj-light-color, #f8f9fa);
    border-top: none;
    border-bottom: 1px solid var(--moj-ash-color, #eceae3);
}

.csl-output-wrapper .citation_formats_list .label:first-child {
    border-top: none;
}

.csl-output-wrapper .citation_formats_styles {
    list-style: none;
    margin: 0;
    padding: 0;
}

.csl-output-wrapper .citation_formats_styles li {
    border-bottom: none;
}

.csl-output-wrapper .citation_formats_styles li:last-child {
    border-bottom: none;
}

.csl-output-wrapper .citation_formats_styles li a,
.citation_display .citation_formats_styles a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.25rem;
    color: var(--moj-text-color, #212529);
    font-size: 0.85rem;
    text-decoration: none;
    border-bottom: none;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.csl-output-wrapper .citation_formats_styles li a:hover,
.citation_display .citation_formats_styles a:hover {
    background: var(--moj-navyLight-trans, #cfd9df33);
    color: var(--moj-secondary-color, #8a1538);
    border-left-color: var(--moj-primary-color, #3d6881);
    border-bottom: none;
}

.csl-output-wrapper .citation_formats_styles li a .fa {
    display: none;
}

/* Override plugin's border-bottom on citation style links */
.citation_display .citation_formats_styles li:last-child a {
    border-bottom: none;
}

.csl-output-wrapper .citation_formats_list .label ~ .citation_formats_styles li a::before {
    content: "\2913  ";
    font-weight: 700;
    color: var(--moj-navy-color, #0d4261);
}

/* Article header banner: ensures background extends to wrap the breadcrumb area */
.article-header-banner .breadcrumb-wraper {
    padding: 1rem 0 1.5rem;
    background: transparent;
}

/* Share-on-social action item hover */
.action-item-share:hover {
    color: var(--moj-primary-color, #0d4261);
}

/* === How-to-cite plugin restyling to match theme card system === */
.citation_format_style,
.citation_formats {
    margin-top: 1rem;
}
.cmp_citation,
.citation_format_style {
    background: #f7f9fb;
    border: 1px solid #e6edf2;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-family: inherit;
}
.cmp_citation .citation-output,
.citation_format_style .citation-output {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #2d3a45;
}
.cmp_citation_format_options select,
.citation_formats select {
    border: 1px solid #e6edf2;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    background: #fff;
}

/* === Arabic footer alignment fix === */
[dir="rtl"] .csl-output-wrapper .citation_formats_styles li a {
    border-left: none;
    border-right: 3px solid transparent;
}
[dir="rtl"] .csl-output-wrapper .citation_formats_styles li a:hover {
    border-left-color: transparent;
    border-right-color: var(--moj-primary-color, #3d6881);
}

[dir="rtl"] .moj-footer .copyright .row > [class*="col-"] {
    text-align: right;
}
[dir="rtl"] .moj-footer .copyright .legal-links {
    justify-content: flex-start;
}

/* Author meta tighter spacing per design */
.info-card .author-box {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}
.info-card .author-box .icon-wraper {
    color: var(--moj-primaryLight-color, #6b8a9c);
}
