/* Base Styles */
body, html {
    background-color: #f4edd8;
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.selectLetter {
    transition: opacity 0.3s ease;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Layout Components */
.container {
    flex: 1 0 auto;
    margin: 2em auto;
}

/* Background Images */
.bg, .bgLT {
    height: 100vh;
    min-width: 100%;
    position: fixed;
    margin: auto;
}

.bg {
    opacity: 0.5;
}

.bgLT {
    opacity: 0.2;
}

/* Card Styles */
.card {
    padding: 2rem;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.card-title {
    color: #2c3e50;
    font-weight: 500;
}

/* Button Styles */
.btn {
    margin: 0.5rem;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Introduction Button Styles */
.btnIntro {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #0d6efd;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

.btnIntro:hover {
    background-color: #e9ecef;
    color: #0a58ca;
    text-decoration: underline;
}

/* Collapse/Expand Icon Animation */
.btn .bi-chevron-down,
.btnIntro .bi-chevron-down {
    transition: transform 0.3s ease;
}

.btn[aria-expanded="true"] .bi-chevron-down,
.btnIntro[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Table Styles */
.table {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    margin-bottom: 0;
}

.table th {
    font-weight: 500;
    color: #495057;
}

.table td {
    vertical-align: middle;
}

/* --- Full‑Text Search and Document Highlighting --- */
/* Inline highlight used by kwic:summarize and document pages */
.hi {
    background-color: #fff3cd; /* Bootstrap warning background tone */
    padding: 0 0.15em;
    border-radius: 0.2rem;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* Temporary stronger highlight applied on landing, then removed by JS */
.flash-hi {
    background-color: #ffe08a;
    box-shadow: 0 0 0 3px rgba(255, 224, 138, 0.6);
    transition: background-color 0.6s ease, box-shadow 0.6s ease;
}

/* Strong, temporary flash to make the match unmissable on landing */
.flash-hi-strong {
    background-color: #ffec66 !important;
    outline: 3px solid rgba(255, 216, 0, 0.8);
    box-shadow: 0 0 0 4px rgba(255, 236, 102, 0.7), 0 0 6px rgba(0,0,0,0.08);
    border-radius: 0.3rem;
    font-weight: 700;
    transform: scale(1.06);
    transition: background-color 0.4s ease, box-shadow 0.4s ease, transform 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    .flash-hi-strong {
        transform: none;
        transition: none;
    }
}

/* Keep KWIC snippet spans inline and tidy */
.previous, .following {
    white-space: normal;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* DataTables Specific */
#tours, #letters {
    visibility: hidden;
    background: white;
    opacity: 0.8;
}

.dataTables_wrapper {
    padding: 1rem;
    background-color: #fff;
    border-radius: 0.25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

table.dataTable {
    margin-top: 1rem !important;
}

/* Navigation Styles */
.navbar {
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-weight: 500;
}

.nav-item {
    padding-right: 20px;
}

.nav-link {
    padding: 0.5rem 1rem !important;
}

/* Dropdown Styles */
.dropdown-menu {
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
    border: none;
    margin-top: 0.125rem;
}

.dropdown-item-text {
    color: #6c757d;
    font-size: 0.875rem;
    padding: 0.25rem 1rem;
}

/* Form Styles */
.form-control {
    min-width: 200px;
}

/* Input Group Styles */
.input-group {
    max-width: 100%;
    margin: 1rem 0;
}

.input-group .form-control {
    border-right: 0;
}

.input-group .btn {
    margin: 0;
    padding: 0.375rem 0.75rem;
    border-left: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group .btn:hover {
    transform: none;
    box-shadow: none;
    background-color: #e9ecef;
    color: #000;
}

/* List Styles */
.list-group-item {
    border: none;
    padding: 0.75rem 0;
    background-color: transparent;
}

.list-unstyled li {
    margin-bottom: 0.5rem;
}

/* Typography */
p {
    text-align: justify;
}

.quote {
    margin-left: 3em;
}

/* Link Styles */
a {
    color: #0d6efd;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* External Link Icon */
a[target="_blank"]::after {
    content: "";
    width: 1em;
    height: 1em;
    margin: 0 0.2em;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%230d6efd" viewBox="0 0 16 16"><path d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z"/><path d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z"/></svg>');
    background-position: center;
    background-repeat: no-repeat;
    display: inline-block;
    vertical-align: middle;
}

/* Image Styles */
.ctimage {
    margin: 2em;
    max-width: 40% !important;
}

.ctimagecenter {
    text-align: center;
    max-width: 50%;
    margin: auto;
}

.ctimage figcaption,
.ctimagecenter figcaption {
    font-size: smaller;
    margin-top: 2px;
    text-align: justify;
}

/* Footer Styles */
.footer {
    border-top: 1px solid;
    flex-shrink: 0 !important;
    padding: 10px 0 5px;
    width: 100%;
    background-color: #a5b7c8;
    opacity: 0.8;
    margin-top: auto;
}

.footer img {
    padding-bottom: 0.5em;
    transition: opacity 0.3s ease;
}

.footer img:hover {
    opacity: 1 !important;
}

/* Scroll to Top Button */
#myBtn {
    position: fixed;
    bottom: 20px;
    right: 30px;
    z-index: 99;
    border: none;
    outline: none;
    background-color: #0d6efd;
    color: white;
    cursor: pointer;
    padding: 15px;
    border-radius: 50%;
    font-size: 18px;
    transition: all 0.3s ease;
    display: none;
}

#myBtn:hover {
    background-color: #0a58ca;
    transform: translateY(-2px);
}

/* Marginal notes for tours */
.line-container {
    display: flex;
    margin-bottom: 1rem;
    position: relative;
}

.content-area {
    flex: 1;
    padding-right: 2rem;
}

/* Only show the border when there's a right_column sibling */
.line-container:has(.right_column) .content-area {
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.right_column {
    width: 100px;
    margin-left: 0.5rem;
    padding-left: 0.5rem;
}

.marginal_note {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 1rem;
}

[id^="marginal_note_anchor_"] {
    color: #0d6efd;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.8em;
    vertical-align: super;
}

/* Responsive Design */
@media (max-width: 991.98px) {
    .right_column {
        width: 120px;
        margin-left: 1rem;
        padding-left: 0.75rem;
    }

    .marginal_note {
        font-size: 0.75em;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .card {
        margin: 1rem -0.5rem;
        border-radius: 0;
    }

    .table {
        font-size: 0.9rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
    }

    .ctimage {
        max-width: 100% !important;
        margin: 1em 0;
    }

    .ctimagecenter {
        max-width: 100%;
    }

    /* Stack marginal notes vertically on mobile */
    .line-container {
        flex-direction: column-reverse;
        margin-bottom: 0.5rem;
    }

    .content-area {
        padding-right: 0;
        border-right: none !important;
    }

    .right_column {
        width: 100%;
        margin-left: 0;
        margin-bottom: 0.15rem;
        padding: 0.15rem 0.4rem;
        border-left: 1px solid rgba(0, 0, 0, 0.15);
    }

    .marginal_note {
        font-size: 0.7em;
        line-height: 1.2;
        margin-bottom: 0.1rem;
        color: #777;
    }
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        padding: 1rem 0;
    }

    .form-control {
        margin: 1rem 0;
    }
}