/* ========================================
   DOCUMENT STYLES - Constitution Content
   ======================================== */

/* Document wrapper - all styles below apply only within constitution content */
.constitution-document {
    line-height: 1.6;
}

.constitution-document .chapter {
    background: white;
    padding: 2rem;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 25px;
    border-left: 4px solid transparent; /* Invisible border to maintain layout */
    margin-left: 4px; /* Account for the border width */
    border-bottom: 1px solid #e0e0e0;
    scroll-margin-top: 15px;
}

.constitution-document .section {
    background: transparent;
    padding: 0;
    margin-bottom: 20px;
    border-left: none;
    margin-left: 0;
    border-bottom: none;
    scroll-margin-top: 15px;
}

.constitution-document h2 {
    font-size: 1.4em;
    color: #005ea5;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
    margin-bottom: 20px;
    margin-top: 30px;
    font-weight: 600;
    margin-top: 0;
    padding-top: 10px;
    position: relative;
    scroll-margin-top: 15px;
}

.constitution-document h3 {
    color: #333;
    font-size: 1.1em;
    margin-top: 25px;
    margin-bottom: 15px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: -0.01em;
    position: relative;
    scroll-margin-top: 15px;
}

.constitution-document p {
    margin-bottom: 15px;
    line-height: 1.7;
    font-size: 16px;
    color: #333;
}

/* List styling - inspired by legislation.gov.uk */
.constitution-document ul {
    margin: 1em 0;
    padding-left: 1rem;
    font-size: 16px;
    line-height: 1.6;
    list-style: none;
}

.constitution-document li {
    position: relative;
    margin-bottom: 0.5em;
    padding-left: 1.5em;
    line-height: 1.6;
    color: #333;
}

.constitution-document li::before {
    content: "•";
    color: #005ea5;
    font-weight: bold;
    position: absolute;
    left: 0;
    width: 1em;
    text-align: center;
}

/* Nested lists */
.constitution-document ul ul {
    margin: 0.5em 0;
    padding-left: 0;
}

.constitution-document ul ul li {
    padding-left: 2em;
    font-size: 0.95em;
}

.constitution-document ul ul li::before {
    content: "◦";
    color: #666;
    font-size: 0.9em;
}

/* Third level nested lists */
.constitution-document ul ul ul {
    margin: 0.25em 0;
}

.constitution-document ul ul ul li {
    padding-left: 2.5em;
    font-size: 0.9em;
}

.constitution-document ul ul ul li::before {
    content: "▪";
    color: #999;
    font-size: 0.8em;
}

/* Ordered lists */
.constitution-document ol {
    margin: 1em 0;
    padding-left: 0;
    font-size: 16px;
    line-height: 1.6;
    list-style: none;
    counter-reset: list-counter;
}

.constitution-document ol li {
    position: relative;
    margin-bottom: 0.5em;
    padding-left: 2em;
    line-height: 1.6;
    color: #333;
    counter-increment: list-counter;
}

.constitution-document ol li::before {
    content: counter(list-counter) ".";
    color: #005ea5;
    font-weight: bold;
    position: absolute;
    left: 0;
    width: 1.5em;
    text-align: right;
    font-size: 1em;
}

/* Point lists (ordered lists with point elements) - use ::marker only, not ::before */
.constitution-document ol.constitution-point-list {
    list-style-type: lower-alpha !important; /* Override list-style: none, use browser ::marker */
    list-style-position: outside !important;
    padding-left: 2em;
    counter-reset: none; /* Don't use counter */
}

.constitution-document ol.constitution-point-list li {
    counter-increment: none !important; /* Don't use counter */
    padding-left: 0.5em;
}

.constitution-document ol.constitution-point-list li::before {
    content: none !important; /* Remove ::before pseudo-element */
}

/* Nested ordered lists */
.constitution-document ol ol {
    margin: 0.5em 0;
    counter-reset: list-counter;
}

.constitution-document ol ol li {
    padding-left: 2.5em;
    font-size: 0.95em;
}

.constitution-document ol ol li::before {
    content: counter(list-counter, lower-alpha) ".";
    color: #666;
    font-size: 0.95em;
    width: 2em;
}

/* Mixed lists (ul inside ol or vice versa) */
.constitution-document ol ul,
.constitution-document ul ol {
    margin: 0.5em 0;
}

.constitution-document ol ul li,
.constitution-document ul ol li {
    padding-left: 2em;
    font-size: 0.95em;
}

.constitution-document ol ul li::before {
    content: "•";
    color: #666;
    font-size: 0.9em;
    width: 1.5em;
}

.constitution-document ul ol li::before {
    content: counter(list-counter, lower-alpha) ".";
    color: #666;
    font-size: 0.95em;
    width: 2em;
}

/* Better spacing for lists that follow paragraphs or headings */
.constitution-document p + ul,
.constitution-document p + ol,
.constitution-document h3 + ul,
.constitution-document h3 + ol {
    margin-top: 1em;
}

.constitution-document h2 + ul,
.constitution-document h2 + ol {
    margin-top: 1.25em;
}

/* Lists that precede paragraphs */
.constitution-document ul + p,
.constitution-document ol + p {
    margin-top: 1.25em;
}

/* General section styling - only for sections without specific classes */
section:not(.chapter):not(.section) {
    margin-bottom: 30px;
}

/* Summary page specific styling */
#summary-page section {
    margin-bottom: 0;
    border-bottom: none;
    padding-top: 0;
}

/* AkomaNtoso cross-reference links */
.constitution-document .ref-link {
    color: #0066cc;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.2s ease;
}

.constitution-document .ref-link:hover {
    color: #004499;
    text-decoration: none;
}

.constitution-document .ref-link:active {
    color: #003366;
}

.constitution-document .constitution-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    border: 1px solid #ccc;
    font-size: 14px;
    position: relative;
    cursor: pointer;
}

.constitution-document .constitution-table::before {
    content: "🔗";
    opacity: 0;
    transition: opacity 0.2s ease;
    position: absolute;
    left: -25px;
    top: 1em;
    font-size: 0.7em;
    color: #999;
}

.constitution-document .constitution-table:hover::before {
    opacity: 1;
}

.constitution-document .constitution-table th,
.constitution-document .constitution-table td {
    border: 1px solid #ccc;
    padding: 12px 15px;
    text-align: left;
    vertical-align: top;
}

.constitution-document .constitution-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #005ea5;
}

.constitution-document .constitution-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.constitution-document .constitution-table tr:hover {
    background-color: #e8f4fd;
}

.constitution-document .remark {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #005ea5;
    border-radius: 0;
    padding: 15px;
    margin: 20px 0;
    color: #333;
    font-style: italic;
}

/* Highlighting styles for different element types */
.constitution-document .chapter.highlighted {
    border-left-color: #ff8c00 !important;
    padding-left: 10px !important;
    margin-left: 26px !important;
    padding-top: 0px !important;
    margin-top: 32px !important;
}

.constitution-document .section.highlighted {
    border-left: 3px solid #ff8c00 !important; /* Orange left border */
    padding-left: 12px !important; /* Space between border and text */
    margin-left: -15px !important; /* Offset padding + border width to keep text in same position */
}

.constitution-document .constitution-paragraph.highlighted {
    border-left: 3px solid #ff8c00 !important; /* Orange left border */
    padding-left: 12px !important; /* Space between border and text */
    margin-left: -15px !important; /* Offset padding + border width to keep text in same position */
}

.constitution-document .remark em {
    font-style: italic;
}

/* Paragraph and table linking styles */
.constitution-document .constitution-paragraph {
    margin-bottom: 1rem;
    line-height: 1.6;
    scroll-margin-top: 15px;
}

.constitution-document .section-content section>* {
    padding-left: 1rem;
}

.constitution-document .section-content section>h2 {
    padding-left: 0 !important;
    margin-left: 1rem;
}

.constitution-document .heading-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.constitution-document .heading-link:hover {
    color: #005ea5;
    text-decoration: underline;
}

/* Better spacing for nested elements */
.constitution-document p + ul,
.constitution-document h3 + ul {
    margin-top: 10px;
}

.constitution-document p + table,
.constitution-document h3 + table {
    margin-top: 15px;
}

/* Hover links for headings and subheadings only */
.constitution-document h2 .heading-link::before,
.constitution-document h3 .heading-link::before {
    content: "🔗" !important;
    opacity: 0 !important;
    transition: opacity 0.2s ease !important;
    position: absolute !important;
    left: -35px !important;
    top: 1px !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #999 !important;
    font-size: 0.8em !important;
}

.constitution-document h2 .heading-link:hover::before,
.constitution-document h3 .heading-link:hover::before {
    opacity: 1 !important;
}

/* Remove hover links from paragraphs */
.constitution-document .constitution-paragraph::before {
    display: none;
}

/* Enhanced search results */
.constitution-document .search-result {
    background: white;
    padding: 10px;
    margin: 5px 0;
    border-radius: 4px;
    border: 1px solid #ddd;
    transition: background-color 0.2s ease;
}

.constitution-document .search-result:hover {
    background: #f8f9fa;
}

.constitution-document .search-result a {
    text-decoration: none;
    color: inherit;
}

/* Search input enhancements */
.constitution-document #search-input {
    transition: border-color 0.2s ease;
}

.constitution-document #search-input:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Collapsible parts styling */
.part-toggle {
    background: none;
    border: none;
    padding: 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    font-size: 14px;
    color: #333;
    transition: color 0.2s ease;
}

.part-toggle:hover {
    color: #005ea5;
}

.part-toggle .toggle-icon {
    margin-right: 8px;
    font-size: 12px;
    transition: transform 0.2s ease;
    min-width: 12px;
}

.part-chapters {
    margin-top: 4px;
}

.part-chapters li {
    margin-bottom: 2px;
}

.part-chapters a {
    padding: 4px 0;
    display: block;
    text-decoration: none;
    color: #666;
    font-size: 13px;
    transition: color 0.2s ease;
}

.part-chapters a:hover {
    color: #005ea5;
}

/* Image styling for inline display */
.constitution-document .constitution-image {
    max-width: 100%;
    height: auto;
    display: inline-block;
    vertical-align: middle;
    margin: 0.5em 0;
    transition: opacity 0.2s ease;
}

/* Only make images clickable on larger screens */
@media (min-width: 768px) {
    .constitution-document .constitution-image {
        cursor: pointer;
    }
    
    .constitution-document .constitution-image:hover {
        opacity: 0.9;
    }
}

.constitution-document .constitution-image[height] {
    /* Preserve aspect ratio when height is specified */
    height: auto;
}

.constitution-document .constitution-image[width] {
    /* Allow width to be set but ensure it doesn't overflow */
    max-width: 100%;
}

/* Ensure images in paragraphs display inline */
.constitution-document .constitution-paragraph .constitution-image {
    display: inline-block;
    vertical-align: middle;
    margin: 0.25em 0.5em;
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.image-modal[aria-hidden="false"] {
    display: flex;
}

.image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10001;
    padding: 2rem;
    box-sizing: border-box;
}

.image-modal-close {
    position: absolute;
    top: -2.5rem;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease;
    z-index: 10002;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.image-modal-close:focus {
    outline: 2px solid #005ea5;
    outline-offset: 2px;
}

.image-modal-img {
    max-width: 100%;
    max-height: 85vh;
    height: auto;
    width: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.image-modal-caption {
    margin-top: 1rem;
    color: #fff;
    text-align: center;
    font-size: 0.9rem;
    max-width: 100%;
    padding: 0 1rem;
}

/* (info class removed) */
