/*
 * Project-specific layout and record styles.
 * The shared design system remains the visual source of truth.
 */

.hidden {
    display: none !important;
}

[hidden] {
    display: none !important;
}

.header-title-compact .header-title-line:last-child {
    color: var(--text-secondary);
}

/* Sidebar content and tab scrolling align with lagoons-ui */
.sidebar-content {
    height: auto;
    min-height: 0;
}

.tab-content {
    overflow-y: visible;
    padding-right: 0;
}

#statistics-tab.tab-content.active {
    overflow-y: visible;
}

.tab-button:focus-visible,
.mobile-toggle-btn:focus-visible,
.btn-secondary:focus-visible,
.mani-station-row:focus-visible,
.mani-photo-link:focus-visible,
.mani-fit-control:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.mani-full-button {
    width: 100%;
    margin-top: 0.5rem;
}

.wm-close:focus {
    outline: none;
}

.wm-close:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.search-result-item {
    appearance: none;
    border: 0;
}

.search-result-item[aria-selected="true"] {
    background: #eeeeea;
}

.search-result-meta {
    display: block;
    margin-top: 0.1rem;
}

.map-category-marker {
    width: 100%;
    height: 100%;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.32);
}

.leaflet-tooltip.custom-tooltip {
    padding: 0;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    opacity: 1 !important;
    overflow: hidden;
    pointer-events: auto;
}

.leaflet-tooltip.custom-tooltip .leaflet-tooltip-content {
    margin: 0;
    padding: 0;
}

.mani-fit-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    background: #fff;
    color: #111;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.mani-fit-control:hover {
    background: #f1f1ed;
}

.mani-fit-control svg {
    display: block;
}

/* ==========================================================================
   Leaflet Measurement Tool
   Journal-grade card readout and minimalist map control
   ========================================================================== */

.measurement-control {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 10px;
}

.measurement-control.leaflet-bar {
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    background: #ffffff;
    overflow: hidden;
}

.measurement-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
    margin: 0;
    border: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: #ffffff;
    color: #1f2937;
    cursor: pointer;
    line-height: 1;
    transition: background-color 140ms ease, color 140ms ease;
}

.measurement-btn:last-child {
    border-bottom: 0;
}

.measurement-btn:hover {
    background: #f4f4f2;
    color: #111827;
}

.measurement-btn.active {
    background: #111827;
    color: #ffffff;
}

.measurement-btn.active:hover {
    background: #1f2937;
    color: #ffffff;
}

.measurement-btn .measurement-icon {
    display: block;
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    pointer-events: none;
}

.measurement-clear-btn .measurement-icon {
    width: 14px;
    height: 14px;
}

.measurement-clear-btn:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.leaflet-container.measurement-active {
    cursor: crosshair !important;
}

.measurement-info {
    margin: 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    min-width: 230px;
    max-width: 290px;
    font-family: var(--font-sans, Inter, sans-serif);
    z-index: 1000;
}

.measurement-card {
    display: flex;
    flex-direction: column;
}

.measurement-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #f0f0ed;
    background: #fbfbfa;
}

.measurement-card-eyebrow {
    font-family: var(--font-sans, Inter, sans-serif);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-secondary, #6b7280);
}

.measurement-card-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}

.measurement-card-close:hover {
    background: #eeeeea;
    color: #111827;
}

.measurement-card-close svg {
    display: block;
    stroke: currentColor;
}

.measurement-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.65rem 0.75rem;
}

.measurement-metric-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.measurement-metric-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #4b5563;
}

.measurement-metric-value {
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 0.92rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #111827;
}

.measurement-unit {
    font-size: 0.76rem;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;
}

.measurement-unit-secondary {
    font-size: 0.72rem;
    font-weight: 400;
    color: #9ca3af;
}

.measurement-metric-count {
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    color: #6b7280;
}

.measurement-sub-row {
    padding-top: 0.25rem;
    border-top: 1px dashed #f0f0ed;
}

.measurement-card-footer {
    padding: 0.4rem 0.75rem;
    border-top: 1px solid #f0f0ed;
    background: #fbfbfa;
    font-family: var(--font-serif, "EB Garamond", Georgia, serif);
    font-style: italic;
    font-size: 0.76rem;
    color: #6b7280;
    text-align: center;
}

.loading {
    transition: opacity 160ms ease;
}

.lagoon-modal-content {
    width: min(72rem, calc(100vw - 2rem));
    max-height: min(90vh, 58rem);
}

.lagoon-modal-header .lagoon-modal-titleblock {
    min-width: 0;
}

.lagoon-modal-header h2 {
    margin: 0.1rem 0 0;
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-size: clamp(1.55rem, 3vw, 2.25rem);
    font-style: italic;
    font-weight: 500;
    line-height: 1.05;
}

.mani-gallery-section .lagoon-modal-section-head {
    margin-bottom: 0.85rem;
}

.mani-section-count {
    margin-left: 0.35rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-style: normal;
    font-variant-numeric: tabular-nums;
}

.mani-photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1rem;
}

.mani-photo-card {
    min-width: 0;
    max-width: 32rem;
    margin: 0;
    border: 1px solid var(--border-light);
    background: #fff;
}

.mani-photo-link {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #ededeb;
}

.mani-photo-card picture {
    display: block;
    width: 100%;
    height: 100%;
}

.mani-photo-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 220ms ease, transform 240ms ease;
}

.mani-photo-card img.is-loaded {
    opacity: 1;
}

.mani-photo-link:hover img {
    transform: scale(1.015);
}

.mani-photo-card figcaption {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.65rem;
    border-top: 1px solid var(--border-light);
    background: #fff;
}

.mani-photo-meta {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.mani-empty {
    padding: 1rem;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-family: var(--font-serif);
    font-style: italic;
}

.reference-section-copy p + p,
.reference-section-copy p + .notes-list {
    margin-top: 0.8rem;
}

/* Feature guide: the Mani field photograph is portrait, so crop it to the shared 16:9 frame. */
.mani-guide-figure img {
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
    object-position: center 38%;
}

/* ==========================================================================
   Photo viewer
   ========================================================================== */

.photo-viewer .photo-viewer-content {
    display: flex;
    flex-direction: column;
    width: min(64rem, calc(100vw - 2rem));
    max-width: none;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    padding: 0;
    overflow: hidden;
    background: #fff;
}

.photo-viewer-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 1rem 0.7rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.photo-viewer-heading {
    display: flex;
    flex: 1 1 auto;
    align-items: baseline;
    gap: 0.75rem;
    min-width: 0;
}

.photo-viewer-title {
    margin: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-style: italic;
    font-weight: 500;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-viewer-counter {
    flex: none;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.photo-viewer-full {
    flex: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    text-underline-offset: 3px;
}

.photo-viewer-header .modal-close {
    position: static;
    flex: none;
}

.photo-viewer-stage {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    margin: 0;
    background: #151515;
}

.photo-viewer-stage img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 9.5rem);
    max-height: calc(100dvh - 9.5rem);
    object-fit: contain;
    opacity: 0;
    transition: opacity 180ms ease;
}

.photo-viewer-stage img.is-loaded {
    opacity: 1;
}

.photo-viewer-caption {
    align-self: stretch;
    padding: 0.55rem 1.25rem;
    background: #fff;
    border-top: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.photo-viewer-nav {
    position: absolute;
    top: calc(50% - 1.5rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(255 255 255 / 92%);
    color: #111;
    cursor: pointer;
    transform: translateY(-50%);
    transition: background-color 140ms ease;
}

.photo-viewer-nav:hover {
    background: #fff;
}

.photo-viewer-nav:focus-visible,
.photo-viewer-full:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px #111;
}

.photo-viewer-prev {
    left: 1rem;
}

.photo-viewer-next {
    right: 1rem;
}

@media (max-width: 900px) {
    .mani-photo-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


@media (max-width: 768px) {
    .main-content {
        flex: 1 1 0;
        height: auto;
        min-height: 0;
        overflow: hidden;
    }

    .map-container {
        height: 100% !important;
        min-height: 0;
    }

    .sidebar-content {
        height: auto;
        min-height: 100%;
    }

    .tab-content {
        overflow-y: visible;
        padding-right: 0;
    }

    .photo-viewer .photo-viewer-content {
        width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }

    .photo-viewer-stage img {
        max-height: calc(100dvh - 7.5rem);
    }

    .photo-viewer-full {
        display: none;
    }

    .photo-viewer-nav {
        width: 2.5rem;
        height: 2.5rem;
    }

    .photo-viewer-prev {
        left: 0.5rem;
    }

    .photo-viewer-next {
        right: 0.5rem;
    }

    .measurement-info {
        margin: 8px;
        min-width: 200px;
        max-width: calc(100vw - 24px);
    }

    .measurement-card-body {
        padding: 0.5rem 0.65rem;
    }

    .measurement-metric-value {
        font-size: 0.86rem;
    }
}

@media (max-width: 560px) {
    .mani-photo-gallery {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mani-photo-card img,
    .photo-viewer-stage img {
        transition: none;
    }
}
