/* Global safety and app overrides (kept) */
html, body, .mud-root, .mud-theme-provider, #app {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* defensive */
    background-color: #000;
    color: #fff;
}

/* --- Gallery: responsive masonry using CSS columns --- */
/* Default: 3 columns (landscape) */
.gallery {
    column-count: 3;
    column-gap: 16px;
    padding: 12px 5%;
    box-sizing: border-box;
    width: 100%;
    margin: 0 auto;
}

/* Portrait orientation (or narrow viewports): 2 columns */
@media (orientation: portrait), (max-width: 900px) {
    .gallery {
        column-count: 2;
    }
}

/* Each tile must be inline-block to work inside columns and avoid being split */
.tile {
    display: inline-block;      /* required for column layout */
    width: 100%;                /* take full column width */
    margin: 0 0 16px;           /* bottom gap between tiles */
    break-inside: avoid;        /* modern */
    -webkit-column-break-inside: avoid;
    -moz-column-break-inside: avoid;
    page-break-inside: avoid;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 8px;
    background: transparent;
}

/* Images scale to tile (columns) width and preserve aspect ratio */
.tile img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: 6px;
}

/* Optional caption styling */
.tile-caption {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #ddd;
    text-align: center;
}

/* Small screens: tighter gaps */
@media (max-width: 600px) {
    .gallery {
        column-gap: 10px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .tile {
        margin-bottom: 10px;
    }
}

/* Navigation: active button underline and separators
   Highly specific selectors to cover MudButton rendered as <button> or <a>,
   and to handle inner label structures and aria-current. */
.mud-button-root.nav-active,
a.mud-button-root.nav-active,
.mud-button-root.mud-active,
a.mud-button-root[aria-current="page"],
.mud-nav-link[aria-current="page"],
.nav-active.mud-button-root {
    text-decoration: underline !important;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    color: #fff !important;
}

/* If MudBlazor renders label spans inside the button, target them too */
.mud-button-root.nav-active .mud-button-label,
a.mud-button-root.nav-active .mud-button-label,
.mud-nav-link[aria-current="page"] .mud-button-label,
.nav-active .mud-button-label {
    text-decoration: underline !important;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    color: #fff !important;
}

/* Also underline anchors directly when aria-current is set (NavLink fallback) */
a[aria-current="page"] {
    text-decoration: underline !important;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    color: #fff !important;
}

/* Separator styling between nav items */
.nav-sep {
    margin: 0 8px;
    color: #888;
    align-self: center;
    user-select: none;
}

/* Defensive: ensure no global horizontal scroll from root elements */
html, body, .mud-root, .mud-theme-provider, #app {
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Photo dialog tweaks for MudDialog */
.photo-dialog-content {
    position: relative;
    padding: 12px;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.photo-dialog-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 28px;
    z-index: 3000;
}

.photo-dialog-image {
    max-width: 100%;
    max-height: calc(100vh - 96px);
    object-fit: contain;
    display: block;
    border-radius: 6px;
}
