/**
 * Copyright (c) 2026 DNA Genics, S.L. All rights reserved.
 *
 * Shared Heritage layouts for Historical Atlas and Population Atlas.
 */

.hat-heritage {
    padding-top: calc(var(--nav-height, 72px) + 8px);
    color-scheme: light;
}

.hat-heritage .container {
    width: min(100%, 1320px);
    max-width: none;
    padding-inline: clamp(16px, 3vw, 40px);
}

.hat-heritage .hat-explorer__container {
    width: min(100%, 1560px);
}

.hat-heritage :is(h1, h2, h3, h4) { color: var(--hd-primary); }
.hat-heritage :focus-visible { outline: 2px solid var(--hat-gold-dark); outline-offset: 3px; }
.hat-heritage [hidden] { display: none !important; }

.hat-heritage .hat-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 31%);
    min-height: 0;
    max-width: 1400px;
    margin-inline: auto;
    border: 1px solid var(--hd-border);
    border-radius: var(--hd-radius);
    background: var(--hd-surface);
}

.hat-heritage .hat-hero::after { content: none; }
.hat-heritage .hat-hero__content {
    grid-column: 1;
    grid-row: 1;
    padding: clamp(24px, 5vw, 64px);
}

.hat-heritage .hat-hero__media {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    align-self: stretch;
    z-index: auto;
    background-color: var(--hd-sand);
    opacity: 1;
}

.hat-heritage .hat-hero h1,
.hat-heritage .hat-profile-hero h1,
.hat-heritage .hat-collection-hero h1 {
    font-size: clamp(2.55rem, 5.4vw, 5rem);
    letter-spacing: -.035em;
}

.hat-heritage .hat-statbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin-top: 1.75rem;
    padding: .5rem .85rem;
    border: 1px solid var(--hd-border);
    border-radius: 12px;
    background: var(--hd-cream);
}

.hat-heritage :is(.hat-profile-hero, .hat-collection-hero) {
    padding-block: clamp(24px, 4vw, 56px);
    background: var(--hd-cream);
}

.hat-heritage :is(.hat-section, .hat-detail-section, .hat-explorer) {
    padding-block: clamp(28px, 5vw, 64px);
}

.hat-heritage :is(.hat-name-card, .hat-collection-summary, .hat-collection-card,
    .hat-profile-card, .hat-related-report__card, .hat-location-card, .hat-map-panel,
    .hat-ai-panel, .hat-method-grid, .pat-study, .pat-chart, .pat-footer-note) {
    min-width: 0;
    border-radius: var(--hd-radius);
}

.hat-heritage :is(.hat-button, .hat-region-filter, .hat-filter-clear,
    .hat-section-links a, .pat-reset, .hat-profile-nav a, .hat-ai-suggestions button) {
    min-height: 44px;
    border-radius: 9px;
    white-space: normal;
}

.hat-heritage :is(.hat-button, .hat-collection-card, .hat-profile-card, .hat-related-profile-card):hover {
    transform: none;
}

.hat-heritage :is(.hat-directory-toolbar, .hat-filterbar, .pat-toolbar) {
    min-width: 0;
    padding: clamp(14px, 2vw, 24px);
    border: 1px solid var(--hd-border);
    border-radius: var(--hd-radius);
    background: var(--hd-surface);
}

.hat-heritage :is(.hat-filter-field, .pat-filter-field, .hat-search-field, .pat-search) { min-width: 0; }
.hat-heritage :is(.hat-filterbar, .pat-filters, .hat-directory-search) :is(input, select) {
    max-width: 100%;
    min-width: 0;
    min-height: 46px;
    border-radius: 8px;
}

.hat-heritage .hat-filterbar {
    grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) auto;
    align-items: end;
}

.hat-heritage .hat-filterbar > .hat-filter-clear { grid-column: auto; }

.hat-heritage .pat-filter-heading { margin: 0 0 .85rem; }
.hat-heritage .pat-regions [aria-current="page"] { color: #fff; }
.hat-heritage :is(.hat-section-links, .pat-map-actions, .pat-filter-actions) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .65rem 1rem;
}

.hat-heritage :is(.hat-section-links a, .hat-map-toolbar a, .pat-map-actions a) {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.hat-heritage :is(.hat-map-toolbar, .pat-map-header) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .55rem 1rem;
    padding: .75rem 1rem;
    background: var(--hd-surface);
}

.hat-heritage :is(.hat-map-toolbar, .pat-map-header) h3 { margin: 0; font-size: 1.4rem; }
.hat-heritage .hat-map-status {
    margin: 0;
    padding: .7rem 1rem;
    color: var(--hd-muted);
    font-size: .88rem;
}

.hat-heritage .hat-map-status:empty { display: none; }
.hat-heritage :is(.hat-map, .hat-location-map, .pat-map) {
    isolation: isolate;
    width: 100%;
    min-width: 0;
    min-height: 0;
    color-scheme: light;
}

.hat-heritage .hat-map-panel { top: calc(var(--nav-height, 72px) + 12px); }
.hat-heritage .hat-map { height: clamp(300px, calc(100dvh - 270px), 580px); }
.hat-heritage :is(.hat-location-map, .pat-map) { height: clamp(260px, 45vw, 410px); }
.hat-heritage .pat-map-block {
    overflow: hidden;
    margin-block: 1.25rem;
    border: 1px solid var(--hd-border);
    border-radius: var(--hd-radius);
}

.hat-heritage .pat-map-block .pat-map { margin: 0; border-inline: 0; }
.hat-heritage .leaflet-container { font-family: var(--hd-sans); }
.hat-heritage .leaflet-control-zoom a {
    width: 44px;
    height: 44px;
    line-height: 44px;
    color: var(--hd-primary);
    background: var(--hd-surface);
}

.hat-heritage .leaflet-popup-content {
    max-width: min(250px, calc(100vw - 92px));
    overflow-wrap: anywhere;
}

.hat-heritage .hat-profile-nav {
    top: var(--nav-height, 72px);
    background: var(--hd-surface);
}

.hat-heritage .hat-profile-nav .container { gap: .45rem 1rem; }
.hat-heritage .hat-profile-nav a { display: inline-flex; align-items: center; }
.hat-heritage :is(#collections-title, #hat-map-heading, #hat-profile-list, #profiles) {
    scroll-margin-top: calc(var(--nav-height, 72px) + 16px);
}

.hat-heritage :is(#pat-locations, #reference-map) {
    scroll-margin-top: calc(var(--nav-height, 72px) + 66px);
}

@media (max-width: 991.98px) {
    .hat-heritage .hat-filterbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hat-heritage .hat-map-panel { position: relative; top: auto; }
}

@media (max-width: 767.98px) {
    .hat-heritage .hat-hero { grid-template-columns: minmax(0, 1fr); border-radius: 0; }
    .hat-heritage .hat-hero__media { grid-column: 1; grid-row: 2; min-height: 130px; }
    .hat-heritage .hat-map { height: clamp(250px, 49dvh, 380px); }
    .hat-heritage .hat-profile-nav .container { padding-inline: 16px; }
}

@media (max-width: 479.98px) {
    .hat-heritage .hat-filterbar { grid-template-columns: minmax(0, 1fr); }
    .hat-heritage :is(.hat-statbar, .hat-collection-summary) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hat-heritage .pat-filter-actions .hat-button { flex: 1 1 9rem; }
}

@media print {
    .hat-heritage .hat-hero { display: block; border: 0; }
    .hat-heritage :is(.hat-hero__media, .hat-section-links, .hat-map-toolbar, .pat-map-header, .hat-map-status) {
        display: none;
    }
}
