:root {
    --historical-brown: #61200E;
    --historical-dark-bg: #333333;
    --historical-light-gray: #C0C0C0;
    --historical-black: #000000;
    --focus-outline: 3px solid #0a58ca; /* Bootstrap primary-ish */
    --focus-bg: #fff;
    --focus-shadow: 0 0 0 4px rgba(13, 110, 253, 0.35);
}

* {
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: "Segoe UI Light", "☺Segoe", "Segoe UI", Segoe, Arial, Verdana, sans-serif;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    font-size: 18px;
    _width: 70%;
    color: #61200E;
    margin: 0 auto 0;
    max-width: 100%;
    text-align: center;
}

/* Skip to main content link: visually hidden until focused */
.skip-link {
    position: absolute;
    top: -60px;
    left: 0;
    background: var(--focus-bg);
    color: #000;
    padding: 10px 16px;
    z-index: 10000;
    border: 2px solid transparent;
    border-radius: 6px;
    box-shadow: none;
    transition: top 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.skip-link:focus,
.skip-link:active,
.skip-link:focus-visible {
    top: 10px;
    border-color: #0a58ca;
    outline: var(--focus-outline);
    background: #e7f1ff;
    box-shadow: var(--focus-shadow);
}

/* Visible focus styles for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: var(--focus-outline);
    outline-offset: 2px;
    box-shadow: var(--focus-shadow);
}

/* Ensure focused elements are not clipped in flex containers */
:focus-visible {
    scroll-margin-top: 1.5rem; /* helps when skipping down under sticky headers */
}

h1 {
    font-family: "Segoe UI Light", "☺Segoe", "Segoe UI", Segoe, Arial, Verdana, sans-serif;
    font-size: 54px;
    font-weight: normal;
    line-height: 1;
    color: #61200E;
}

h2 {
    font-family: "Segoe UI Light", "☺Segoe", "Segoe UI", Segoe, Arial, Verdana, sans-serif;
    font-size: 26px;
    font-weight: bold;
    line-height: 1.5;
    font-weight: 800;
    padding-bottom: 10px;
}

h3 {
    font-family: "Segoe UI Light", "☺Segoe", "Segoe UI", Segoe, Arial, Verdana, sans-serif;
    font-size: 20px;
    line-height: 1.5;
    font-weight: bold;
    text-align: left;
}

/* Ensure visual consistency for page titles regardless of heading level */
.historical-heading {
    font-family: "Segoe UI Light", "☺Segoe", "Segoe UI", Segoe, Arial, Verdana, sans-serif;
    font-size: 26px;
    line-height: 1.5;
    font-weight: 800;
    padding-bottom: 10px;
}

/* When used on h1, override the very large default h1 size */
h1.historical-heading {
    font-size: 26px;
    line-height: 1.5;
    font-weight: 800;
}

p {
    font-family: "Segoe UI Light", "☺Segoe", "Segoe UI", Segoe, Arial, Verdana, sans-serif;
    font-size: 16px;
    font-weight: normal;
    line-height: 1.5;
    text-align: left;
}

a {
    color: #61200E;
    text-decoration: none;
}

    a:visited {
        color: #333333;
    }

    a:active {
        color: #61200E;
        text-decoration: underline;
    }

    a:hover {
        color: #61200E;
        text-decoration: underline;
    }

/* Main container takes available space */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Content area fills remaining space */
.content-area {
    flex: 1;
    min-height: 0; /* Important for flexbox */
}

/* Make the row take full height */
.full-height-row {
    height: 100%;
    display: flex;
    align-items: stretch;
}

    /* Ensure columns stretch to full height */
    .full-height-row > .col,
    .full-height-row > .col-auto,
    .full-height-row > [class*="col-"] {
        display: flex;
        flex-direction: column;
    }

/* Footer should stay at bottom */
footer {
    margin-top: auto;
}

@media (max-width: 768px) {
    .full-height-row {
        min-height: auto;
        flex-direction: column;
    }

    .view-images-container {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
    }
}

/* Headings with Original Styling */
.historical-title {
    font-family: "Segoe UI Light", "Segoe UI", sans-serif;
    font-size: 54px;
    font-weight: bold;
    color: var(--historical-brown);
}

.historical-heading {
    font-family: "Segoe UI Light", "Segoe UI", sans-serif;
    font-size: 26px;
    font-weight: 800;
    color: var(--historical-brown);
    line-height: 1.5;
    text-align: left;
    margin: 0;
    padding-bottom: 10px;
}

.historical-subheading {
    font-family: "Segoe UI Light", "Segoe UI", sans-serif;
    font-size: 20px;
    font-weight: bold;
    color: var(--historical-brown);
    text-align: left;
    margin: 0;
}

/* Content Text with Original Styling */
.historical-content p {
    font-size: 16px;
    text-align: left;
    color: var(--historical-brown);
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* Navigation Links with Original Styling */
.historical-nav {
    line-height: 1.8;
}

.historical-link {
    color: var(--historical-brown);
    text-decoration: none;
    font-size: 18px;
    display: block;
}

.historical-link:hover {
    color: var(--historical-brown);
    text-decoration: underline;
}

.historical-link:visited {
    color: #333333;
}

/* Historical Dates List */
.historical-dates {
    text-align: left;
    color: var(--historical-brown);
}

.historical-dates li {
    font-size: 18px;
}

/* VIEW IMAGES Container */
.view-images-container {
    background-color: #333333;
    min-height: 200px;
}

.view-images-container a {
    color: #C0C0C0;
    font-size: 16px;
    text-decoration: none;
    display: inline-block;
    padding: 4px 0;
}

.view-images-container a:hover {
    color: #fff;
    text-decoration: none;
}

.view-images-container a:visited {
    color: #FF6A00;
}

/* Background images should cover full height */
.sidebar {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.sidebar-background-color {
    background-color: #892708;
}

/* Tree View Styling using Pure CSS */
.tree-view-accordion {
    font-family: "Segoe UI", Arial, sans-serif;
}

/* Ensure accordion doesn't push container height */
.tree-view-accordion {
    height: 100%;
    overflow: visible;
}

.tree-view-accordion .accordion-item {
    background-color: transparent;
    border: none;
    text-align: start;
}

.tree-view-accordion .accordion-header {
    margin-bottom: 0;
    padding-top: 8px;
    padding-bottom: 0;
}

.tree-view-accordion .accordion-button {
    background-color: transparent;
    border: none;
    color: #C0C0C0;
    font-size: 13px;
    padding: 2px 0;
    box-shadow: none;
    text-align: left;
    position: relative;
}

.tree-view-accordion .accordion-button:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.tree-view-accordion .accordion-button:focus {
    box-shadow: none;
    border: none;
}

.tree-view-accordion .accordion-button::after {
    display: none;
}

.tree-view-accordion .accordion-button:not(.collapsed) {
    background-color: transparent;
    color: #C0C0C0;
}

/* Tree icon styling */
.tree-icon {
    display: inline-block;
    width: 20px;
    margin-right: 3px;
    font-family: monospace;
}

.tree-icon::before {
    content: "[+]";
}

.accordion-button:not(.collapsed) .tree-icon::before {
    content: "[-]";
}

/* Tree content styling */
.tree-view-accordion .accordion-body {
    background-color: transparent;
    padding: 0 0 0 20px;
}

.tree-content a {
    display: block;
    color: #C0C0C0;
    text-decoration: none;
    padding: 2px 0 2px 20px;
    font-size: 12px;
}

.tree-content a:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.tree-content a:visited {
    color: #FF6A00;
}

/* Override Bootstrap transitions for instant collapse */
.tree-view-accordion .accordion-collapse {
    transition: none;
}

.tree-view-accordion .accordion-collapse.collapsing {
    transition: none;
    height: auto !important;
}

/* Direct link tree nodes (no children) */
.tree-node-link {
    display: block;
    color: #C0C0C0;
    text-decoration: none;
    padding: 2px 0 !important;
    font-size: 13px !important;
    position: relative;
    width: 100%;
}

.tree-node-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.tree-node-link:visited {
    color: #C0C0C0;
}

/* Empty tree icon for non-expandable items */
.tree-icon-empty {
    display: inline-block;
    width: 20px;
    margin-right: 3px;
}

/* Bootstrap Carousel Customization for Historical Look */
.carousel {
    background-color: var(--historical-black);
}

.carousel-item img {
    max-height: 400px;
    object-fit: contain;
    background-color: var(--historical-black);
}

.carousel-caption {
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 20px;
    border-radius: 0;
    bottom: 0;
    left: 0;
    right: 0;
    position: relative;
}

.carousel-caption p {
    font-size: 18px;
    color: white;
    margin: 0;
}

.image-grid-bg {
    background-color: #792308 !important;
    color: #fff !important;
}

/* Seadragon Container Styling */
.seadragon-container {
    height: 350px;
    background-color: var(--historical-black);
    border: 1px solid var(--historical-black);
    color: white;
    margin: 0 auto;
    width: 100%;
}

/* Header Customization */
header.bg-dark {
    background-color: var(--historical-dark-bg) !important;
    font-size: 14px;
}

header a {
    color: var(--historical-light-gray) !important;
}

/* Footer Customization */
footer.bg-dark {
    background-color: var(--historical-dark-bg) !important;
    color: var(--historical-light-gray) !important;
}

/* Responsive adjustments for mobile */
@media screen and (max-width: 1200px) {
    .historical-title {
        font-size: 30px;
    }

    .historical-heading {
        font-size: 16px;
        padding-bottom: 6px;
    }

    .historical-subheading {
        font-size: 14px;
    }

    .historical-content p,
    .historical-link,
    .historical-dates li {
        font-size: 14px;
    }

    .seadragon-container {
        height: 250px;
    }
}

@media screen and (max-width: 768px) {
    .historical-title {
        font-size: 24px;
    }

    .seadragon-container {
        height: 200px;
    }
}

@media screen and (max-width: 991px) {
    /* Stack the Seadragon container above content on mobile */
    .float-end {
        float: none !important;
        margin-bottom: 1rem;
        width: 100%;
    }
}