/**
 * Copyright (c) 2026 DNA Genics, S.L. All rights reserved.
 *
 * Historical Atlas source-reviewed profile and grounded AI guide styling.
 */

.hat-profile-hero {
    padding: 4.25rem 0 4.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--hat-border);
    background-color: #101612;
    background-image: url('/img/ui/backgrounds/homepage-deep-time-social.webp');
    background-position: right center;
    background-repeat: no-repeat;
    background-size: auto 100%;
    background-blend-mode: soft-light;
}

.hat-profile-hero__grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.62fr);
    gap: clamp(2.25rem, 6vw, 6rem);
    align-items: end;
}

.hat-profile-hero h1 {
    max-width: 980px;
    margin: 0.75rem 0 0.45rem;
    font-size: clamp(2.75rem, 5.8vw, 5.8rem);
    letter-spacing: -0.04em;
}

.hat-profile-hero__native-name {
    margin: 0 0 1.45rem;
    color: var(--hat-gold-light) !important;
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(1.15rem, 2vw, 1.5rem);
}

.hat-profile-hero__summary {
    max-width: 840px;
    margin: 0;
    color: #dad3c6 !important;
    font-size: 1.12rem;
    line-height: 1.65;
}

.hat-profile-hero__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 1.7rem;
}

.hat-profile-hero__badges > span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(13, 18, 16, 0.78);
    color: var(--hat-text-soft);
    font-size: 0.78rem;
}

.hat-profile-hero__badges .dna-icon {
    color: var(--hat-gold-light);
}

.hat-name-card {
    padding: 1.5rem;
    border: 1px solid var(--hat-border);
    border-top: 3px solid var(--hat-gold);
    background: rgba(20, 27, 23, 0.94);
}

.hat-name-card > .dna-icon {
    margin-bottom: 0.85rem;
    color: var(--hat-gold-light);
    font-size: 1.45rem;
}

.hat-name-card h2 {
    margin-bottom: 0.75rem;
    font-size: 1.35rem;
}

.hat-name-card p {
    font-size: 0.92rem;
}

.hat-name-card__label {
    margin: 1.15rem 0 0.35rem;
    color: var(--hat-muted) !important;
    font-size: 0.7rem !important;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hat-name-card ul {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--hat-text-soft);
    font-size: 0.88rem;
}

.hat-profile-nav {
    position: sticky;
    top: 64px;
    z-index: 900;
    border-bottom: 1px solid var(--hat-border);
    background: rgba(13, 18, 16, 0.96);
    backdrop-filter: blur(12px);
}

.hat-profile-nav .container {
    display: flex;
    gap: 1.35rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.hat-profile-nav a {
    flex: 0 0 auto;
    padding: 0.8rem 0;
    border-bottom: 2px solid transparent;
    color: var(--hat-muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
}

.hat-profile-nav a:hover,
.hat-profile-nav a:focus {
    border-bottom-color: var(--hat-gold);
    color: var(--hat-gold-light);
}

.hat-detail-section {
    padding: 6rem 0;
    scroll-margin-top: 120px;
}

.hat-detail-section--muted,
.hat-detail-section--related {
    border-top: 1px solid var(--hat-border);
    border-bottom: 1px solid var(--hat-border);
    background: var(--hat-bg-raised);
}

.hat-detail-heading {
    max-width: 790px;
    margin-bottom: 2.75rem;
}

.hat-detail-heading h2 {
    margin: 0.65rem 0 0.8rem;
    font-size: clamp(2rem, 4vw, 3.35rem);
}

.hat-detail-heading > p {
    margin: 0;
    font-size: 1.05rem;
}

.hat-overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
    gap: 1rem;
    align-items: stretch;
}

.hat-overview-copy {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.hat-overview-copy article {
    min-height: 215px;
    padding: 1.4rem;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: var(--hat-bg-card);
}

.hat-overview-copy article:last-child {
    grid-column: 1 / -1;
}

.hat-overview-copy article > .dna-icon {
    margin-bottom: 0.9rem;
    color: var(--hat-gold-light);
    font-size: 1.4rem;
}

.hat-overview-copy h3 {
    margin-bottom: 0.65rem;
    font-size: 1.25rem;
}

.hat-overview-copy p {
    margin: 0;
}

.hat-location-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--hat-border);
    background: var(--hat-bg-card);
}

.hat-location-map {
    width: 100%;
    height: calc(100% - 105px);
    min-height: 390px;
    background: #111814;
}

.hat-location-card__body {
    min-height: 105px;
    padding: 0.9rem 1rem;
    border-top: 1px solid var(--hat-border);
}

.hat-location-card__body strong {
    color: var(--hat-text);
}

.hat-location-card__body p {
    margin: 0.25rem 0 0;
    color: var(--hat-muted);
    font-size: 0.76rem;
    line-height: 1.4;
}

.hat-facts-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

.hat-facts-grid article {
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: #111713;
}

.hat-fact-label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--hat-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.hat-facts-grid strong {
    display: block;
    color: var(--hat-gold-light);
    font-family: "Playfair Display", Georgia, serif;
    font-size: 1.35rem;
    line-height: 1.2;
}

.hat-facts-grid p {
    margin: 0.65rem 0;
    font-size: 0.86rem;
}

.hat-fact-source {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    color: var(--hat-muted);
    font-size: 0.71rem;
}

.hat-fact-source a,
.hat-timeline__sources a {
    margin-left: 0.2rem;
    font-weight: 700;
    text-decoration: none;
}

.hat-timeline {
    position: relative;
    max-width: 900px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hat-timeline::before {
    content: "";
    position: absolute;
    top: 0.5rem;
    bottom: 0.5rem;
    left: 8px;
    width: 1px;
    background: var(--hat-border-strong);
}

.hat-timeline li {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 1.2rem;
    padding-bottom: 2.3rem;
}

.hat-timeline li:last-child {
    padding-bottom: 0;
}

.hat-timeline__marker {
    position: relative;
    z-index: 1;
    width: 17px;
    height: 17px;
    margin-top: 0.35rem;
    border: 4px solid var(--hat-bg-raised);
    border-radius: 50%;
    background: var(--hat-gold);
    box-shadow: 0 0 0 1px var(--hat-gold-dark);
}

.hat-timeline__content {
    padding: 0 0 0.5rem;
}

.hat-timeline time {
    color: var(--hat-gold-light);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hat-timeline h3 {
    margin: 0.25rem 0 0.55rem;
    font-size: 1.35rem;
}

.hat-timeline p {
    margin: 0;
}

.hat-timeline__sources {
    margin-top: 0.45rem;
}

.hat-culture-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.68fr) minmax(0, 1.32fr);
    gap: 1rem;
}

.hat-language-card {
    padding: 1.5rem;
    border: 1px solid var(--hat-border);
    background: var(--hat-bg-card);
}

.hat-language-card > .dna-icon {
    margin-bottom: 1rem;
    color: var(--hat-gold-light);
    font-size: 1.7rem;
}

.hat-language-card h3 {
    font-size: 1.35rem;
}

.hat-language-card ul {
    margin: 1rem 0;
    padding-left: 1.1rem;
    color: var(--hat-text-soft);
}

.hat-cultural-highlights {
    display: grid;
    gap: 0.7rem;
}

.hat-cultural-highlights article {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 0.8rem;
    align-items: start;
    padding: 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: #111713;
}

.hat-cultural-highlights .dna-icon {
    margin-top: 0.25rem;
    color: #73b9aa;
}

.hat-cultural-highlights p {
    margin: 0;
}

.hat-cultural-caution {
    margin: 1rem 0 0;
    padding: 1rem 1.15rem;
    border-left: 3px solid var(--hat-jade);
    background: var(--hat-bg-raised);
    color: var(--hat-muted) !important;
    font-size: 0.86rem;
}

.hat-detail-section--ai {
    border-top: 1px solid var(--hat-border);
    border-bottom: 1px solid var(--hat-border);
    background: #101713;
}

.hat-ai-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(420px, 1.2fr);
    gap: clamp(2rem, 7vw, 6rem);
    align-items: start;
}

.hat-ai-grid h2 {
    margin: 0.7rem 0 1rem;
    font-size: clamp(2rem, 4vw, 3.3rem);
}

.hat-ai-grid > div:first-child > p {
    font-size: 1.05rem;
}

.hat-ai-boundaries {
    display: grid;
    gap: 0.55rem;
    margin-top: 1.4rem;
}

.hat-ai-boundaries > span {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--hat-text-soft);
    font-size: 0.88rem;
}

.hat-ai-boundaries .dna-icon {
    color: #76c0b2;
}

.hat-ai-panel {
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--hat-border-strong);
    background: var(--hat-bg-card);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
}

.hat-ai-panel label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--hat-text);
    font-weight: 700;
}

.hat-ai-panel textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    padding: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    outline: 0;
    background: #0c110e;
    color: var(--hat-text);
    font: inherit;
}

.hat-ai-panel textarea:focus {
    border-color: var(--hat-gold);
    box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.14);
}

.hat-ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.7rem 0;
}

.hat-ai-suggestions button {
    padding: 0.35rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 999px;
    background: transparent;
    color: var(--hat-text-soft);
    font-size: 0.76rem;
}

.hat-ai-suggestions button:hover,
.hat-ai-suggestions button:focus {
    border-color: var(--hat-gold);
    color: var(--hat-gold-light);
}

.hat-ai-privacy {
    margin: 0 0 0.85rem;
    color: var(--hat-muted) !important;
    font-size: 0.76rem;
    line-height: 1.4;
}

.hat-ai-status {
    min-height: 1.4rem;
    margin-top: 0.85rem;
    color: var(--hat-muted);
    font-size: 0.82rem;
}

.hat-ai-status--error {
    color: #e2a2a2;
}

.hat-ai-answer {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--hat-border);
}

.hat-ai-answer__label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.8rem;
    color: var(--hat-gold-light);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hat-ai-answer__text {
    color: var(--hat-text);
    line-height: 1.7;
    white-space: pre-line;
}

.hat-ai-answer__notice {
    margin: 1rem 0 0;
    color: var(--hat-muted) !important;
    font-size: 0.75rem;
}

.hat-ai-answer__sources {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.8rem;
}

.hat-ai-answer__sources a {
    font-size: 0.78rem;
    text-decoration: none;
}

.hat-source-list {
    display: grid;
    gap: 0.65rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hat-source-list li {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--hat-bg-card);
}

.hat-source-id {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--hat-border-strong);
    border-radius: 50%;
    color: var(--hat-gold-light);
    font-weight: 700;
}

.hat-source-list h3 {
    margin: 0 0 0.25rem;
    font-family: "Source Sans 3", sans-serif;
    font-size: 1rem;
    font-weight: 700;
}

.hat-source-list h3 a {
    text-decoration: none;
}

.hat-source-list p {
    margin: 0;
    color: var(--hat-muted);
    font-size: 0.78rem;
}

.hat-source-disclaimer {
    margin-top: 1rem;
    padding: 1rem 1.15rem;
    border-left: 3px solid var(--hat-gold);
    background: #111713;
    color: var(--hat-muted);
    font-size: 0.82rem;
}

.hat-review-date {
    margin: 1rem 0 0;
    color: var(--hat-muted) !important;
    font-size: 0.78rem;
}

.hat-related-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.hat-related-grid > a {
    display: flex;
    min-height: 190px;
    flex-direction: column;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: var(--hat-bg-card);
    text-decoration: none;
    transition: border-color 0.18s ease, transform 0.18s ease;
}

.hat-related-grid > a:hover,
.hat-related-grid > a:focus {
    border-color: var(--hat-border-strong);
    transform: translateY(-1px);
}

.hat-related-grid > a > span:first-child {
    color: var(--hat-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hat-related-grid strong {
    margin-top: 0.6rem;
    color: var(--hat-text);
    font-family: "Playfair Display", Georgia, serif;
    font-size: 1.35rem;
}

.hat-related-grid small {
    margin-top: 0.25rem;
    color: var(--hat-gold-light);
}

.hat-related-grid__action {
    margin-top: auto;
    color: var(--hat-gold-light) !important;
    font-size: 0.82rem !important;
    font-weight: 700;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

.hat-location-map .leaflet-control-zoom a {
    border-color: #3b453e;
    background: #171f1a;
    color: var(--hat-text);
}

.hat-location-map .leaflet-control-attribution {
    background: rgba(13, 18, 16, 0.86);
    color: #aaa59b;
}

.hat-location-map .leaflet-control-attribution a {
    color: var(--hat-gold-light);
}

.hat-map-marker {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 2px solid #f1d27d;
    border-radius: 50% 50% 50% 8px;
    background: #b78310;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
    color: #171109;
    font-weight: 700;
    transform: rotate(-45deg);
}

.hat-map-marker span {
    transform: rotate(45deg);
}

@media (max-width: 991.98px) {
    .hat-profile-hero__grid,
    .hat-overview-grid,
    .hat-culture-grid,
    .hat-ai-grid {
        grid-template-columns: 1fr;
    }

    .hat-name-card {
        max-width: 680px;
    }

    .hat-location-map {
        height: 430px;
    }

    .hat-facts-grid,
    .hat-related-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .hat-profile-hero {
        padding: 3rem 0 3.5rem;
        background-image: none;
    }

    .hat-profile-nav {
        top: 56px;
    }

    .hat-detail-section {
        padding: 4.2rem 0;
    }

    .hat-overview-copy,
    .hat-facts-grid,
    .hat-related-grid {
        grid-template-columns: 1fr;
    }

    .hat-overview-copy article:last-child {
        grid-column: auto;
    }

    .hat-location-map {
        height: 360px;
        min-height: 0;
    }
}

@media (max-width: 480px) {
    .hat-profile-hero__badges {
        align-items: stretch;
        flex-direction: column;
    }

    .hat-profile-hero__badges > span {
        border-radius: 3px;
    }

    .hat-ai-panel {
        padding: 1rem;
    }

    .hat-source-list li {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hat-related-grid > a {
        transition: none;
    }
}

@media print {
    .hat-profile-nav,
    .hat-detail-section--ai,
    .hat-location-map {
        display: none;
    }

    .hat-detail-section {
        padding: 2rem 0;
    }
}
