/* Mobile Navigation Menu */
@media (max-width: 991.98px) {
    #mainNav {
        margin-top: 1rem;
    }

    #mainNav .d-flex {
        border-top: 1px solid #dee2e6;
        padding-top: 0.5rem;
    }

    #mainNav a {
        border-bottom: 1px solid #f0f0f0;
    }

    #mainNav a:last-child {
        border-bottom: none;
    }
}

/* Ensure nav is always visible on desktop */
@media (min-width: 992px) {
    #mainNav {
        display: flex !important;
    }
}

/* Gallery grid tweaks */
.gallery-item img {
    transition: transform .3s ease, filter .3s ease;
    display: block;
    width: 100%;
    height: auto;
}

.gallery-item a {
    text-decoration: none;
}

.gallery-item:hover img {
    transform: scale(1.05);
    filter: brightness(.9);
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: block;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.lightbox.d-none {
    display: none;
}

.lightbox:not(.d-none) {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .8);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .25s ease;
}

.lightbox:not(.d-none) .lightbox-backdrop {
    opacity: 1;
}

.lightbox-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    background: #fff;
    padding: 1rem 1.25rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 1rem 2.5rem -0.5rem rgba(0, 0, 0, .5);
    animation: lb-pop .35s cubic-bezier(.4, 0, .2, 1);
}

.lightbox-content img {
    display: block;
    border-radius: 8px;
    margin: 0 auto;
}

#lightbox-caption {
    color: #333;
    font-size: 1rem;
    letter-spacing: .3px;
    max-width: 70ch;
    margin-left: auto;
    margin-right: auto;
}

.lightbox img {
    max-height: 80vh;
    width: auto;
    height: auto;
}

@keyframes lb-pop {
    0% {
        transform: translate(-50%, -50%) scale(.92);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@media (min-width: 992px) {
    .lightbox-content {
        max-width: 60vw;
    }
}

@media (max-width: 576px) {
    .lightbox-content {
        max-width: 95vw;
        width: 95vw;
        padding: .75rem .75rem 1rem;
    }

    .lightbox-content img {
        width: 100%;
        height: auto;
    }
}

/* Thumbnail styles */
.gallery-thumb-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    /* 600x400 ratio */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease, filter .3s ease;
}

.gallery-item:hover .gallery-thumb-img {
    transform: scale(1.05);
    filter: brightness(.9);
}

/* Lightbox navigation buttons */
.lb-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, .45);
    color: #fff;
    border: none;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: background .25s ease, transform .25s ease;
    z-index: 5;
}

.lb-nav-btn:hover {
    background: rgba(0, 0, 0, .65);
}

.lb-prev {
    left: .5rem;
}

.lb-next {
    right: .5rem;
}

@media (max-width: 576px) {
    .lb-nav-btn {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.15rem;
    }
}

/* Lightbox dots */
.lb-dots {
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: .4rem;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .4);
    transition: background .2s ease;
}

.carousel-dot.active {
    background: #fff;
}

.home-news {
    list-style: none;
    padding-left: 0;
}

/* Notes grid */
.gallery-thumb-placeholder {
    aspect-ratio: 3 / 2;
    background: #f7f7f8;
    border: 1px solid #ececef;
    border-radius: 4px;
    transition: background .25s ease;
}

.gallery-item:hover .gallery-thumb-placeholder {
    background: #eeeef0;
}

/* Notes article — code, figures, headings */
.notes-content h2 {
    font-size: 1.35rem;
    font-weight: 400;
    margin-top: 2.2rem;
    margin-bottom: 0.8rem;
}

.notes-content h3 {
    font-size: 1.15rem;
    font-weight: 400;
    margin-top: 1.8rem;
    margin-bottom: 0.6rem;
}

.notes-content pre {
    background: #f7f7f8;
    border: 1px solid #ececef;
    border-radius: 6px;
    padding: 0.85rem 1rem;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.55;
}

.notes-content code {
    background: #f3f3f4;
    color: #c7254e;
    padding: 0.12em 0.36em;
    border-radius: 3px;
    font-size: 0.88em;
}

.notes-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

.notes-content img,
.notes-content figure img {
    max-width: min(100%, 640px);
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 4px;
}

.notes-content figure {
    margin: 1.5rem 0;
}

.notes-content figure figcaption {
    text-align: center;
    color: #6c757d;
    font-size: 0.88em;
    margin-top: 0.5rem;
}

.notes-content blockquote {
    border-left: 3px solid #dcdce0;
    margin: 1.2rem 0;
    padding: 0.4rem 1rem;
    color: #555;
    background: #fafafb;
}

.notes-content table {
    width: auto;
    margin: 1rem 0;
    font-size: 0.92em;
}

.notes-content table th,
.notes-content table td {
    padding: 0.4rem 0.85rem;
    border: 1px solid #ececef;
}

.notes-content table th {
    background: #f7f7f8;
    font-weight: 500;
}

.notes-content a {
    color: #1a4d8c;
    text-decoration: none;
    border-bottom: 1px solid rgba(26, 77, 140, 0.25);
}

.notes-content a:hover {
    border-bottom-color: rgba(26, 77, 140, 0.7);
}