/*
 * Main menu dropdowns, the gallery and its lightbox. app.css is a precompiled Tailwind build
 * without the utilities these need, so they are styled here with its colour tokens.
 */

/* Desktop menu: an entry with sub-pages opens its dropdown on hover and on keyboard focus. */
.nav-item {
    position: relative;
}

.nav-item__caret {
    font-size: 1rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.nav-item:hover .nav-item__caret,
.nav-item:focus-within .nav-item__caret {
    transform: rotate(180deg);
}

.nav-dropdown {
    position: absolute;
    top: calc(100% - 1rem);
    left: 50%;
    z-index: 60;
    min-width: 13rem;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid oklch(var(--background-200));
    border-radius: 0.5rem;
    box-shadow: 0 16px 32px -16px rgb(0 0 0 / 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 0.5rem);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.nav-item:hover .nav-dropdown,
.nav-item:focus-within .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.nav-dropdown__link {
    display: block;
    padding: 0.625rem 0.875rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: oklch(var(--foreground-800));
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-dropdown__link:hover,
.nav-dropdown__link:focus-visible {
    background: oklch(var(--background-100));
    color: oklch(var(--primary-500));
}

/* Mobile menu: sub-pages are listed indented below their entry. */
.mobile-subnav-link {
    display: block;
    margin-top: -0.375rem;
    padding: 0.5rem 1rem 0.5rem 2rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

[data-mobile-menu].is-open {
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
}

/* Sections that the menu links to stay clear of the fixed header. */
.anchor-target {
    scroll-margin-top: 7rem;
}

/* Bottom padding of a section that follows one with its own padding (pb-12 md:pb-20). */
.section-end {
    padding-bottom: 3rem;
}

@media (min-width: 768px) {
    .section-end {
        padding-bottom: 5rem;
    }
}

/* Gallery: one grid per area, with a row of links to jump between the areas. */
.gallery-areas {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.gallery-areas a {
    padding: 0.5rem 1rem;
    border: 1px solid oklch(var(--background-200));
    border-radius: 9999px;
    background: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    color: oklch(var(--foreground-800));
    transition: border-color 0.15s ease, color 0.15s ease;
}

.gallery-areas a:hover {
    border-color: oklch(var(--primary-300));
    color: oklch(var(--primary-500));
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .gallery-grid--4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.gallery-tile {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 0.5rem;
    background: oklch(var(--background-100));
}

.gallery-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-tile:hover img,
.gallery-tile:focus-visible img {
    transform: scale(1.05);
}

.gallery-tile__caption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 1.5rem 0.75rem 0.625rem;
    background: linear-gradient(to top, rgb(0 0 0 / 0.6), transparent);
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.35;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gallery-tile:hover .gallery-tile__caption,
.gallery-tile:focus-visible .gallery-tile__caption {
    opacity: 1;
}

/* Lightbox for gallery images (site.js opens it; without JavaScript the link opens the image). */
.lightbox {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgb(0 0 0 / 0.92);
    color: #fff;
}

.lightbox::backdrop {
    background: rgb(0 0 0 / 0.92);
}

.lightbox[open] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox__figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: calc(100vw - 2rem);
    margin: 0;
}

.lightbox__image {
    max-width: 100%;
    max-height: calc(100vh - 8rem);
    object-fit: contain;
    border-radius: 0.375rem;
}

.lightbox__caption {
    margin-top: 0.875rem;
    max-width: 40rem;
    padding: 0 1rem;
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgb(255 255 255 / 0.85);
}

.lightbox__button {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 9999px;
    background: rgb(255 255 255 / 0.15);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.lightbox__button:hover,
.lightbox__button:focus-visible {
    background: rgb(255 255 255 / 0.3);
}

.lightbox__button--close {
    top: 1rem;
    right: 1rem;
}

.lightbox__button--prev,
.lightbox__button--next {
    top: 50%;
    transform: translateY(-50%);
}

.lightbox__button--prev {
    left: 0.75rem;
}

.lightbox__button--next {
    right: 0.75rem;
}

.lightbox__button[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .nav-dropdown,
    .nav-item__caret,
    .gallery-tile img {
        transition: none;
    }
}
