/**
 * Rich layout helpers for Historia + Travel (mobile-first).
 * Uses local fonts from /shared/fonts/; external images allowed via <img src>.
 */

@import url("https://unpkg.com/leaflet@1.9.4/dist/leaflet.css");

:root {
    --rich-radius: 14px;
    --rich-radius-lg: 20px;
    --rich-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
    --rich-touch: 44px;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body.rich-page {
    font-size: clamp(1rem, 2.8vw, 1.0625rem);
}

/* --- Navigation: horizontal scroll on narrow screens --- */
.nav-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 10px 12px;
    scroll-padding: 12px;
}

.nav-scroll::-webkit-scrollbar {
    height: 6px;
}

.nav-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.nav-scroll a,
.nav-scroll button {
    flex: 0 0 auto;
    min-height: var(--rich-touch);
    display: inline-flex;
    align-items: center;
    padding: 0 16px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 999px;
    white-space: nowrap;
}

/* --- Hero with optional background image --- */
.rich-hero {
    position: relative;
    min-height: min(72vh, 520px);
    display: flex;
    align-items: flex-end;
    padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 32px);
    color: #fff;
    background-size: cover;
    background-position: center;
    isolation: isolate;
}

.rich-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(
        to top,
        rgba(15, 23, 42, 0.92) 0%,
        rgba(15, 23, 42, 0.45) 45%,
        rgba(15, 23, 42, 0.25) 100%
    );
    z-index: 0;
}

.rich-hero__inner {
    position: relative;
    z-index: 1;
    max-width: 720px;
    width: 100%;
}

.rich-hero__kicker {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.85;
    margin-bottom: 10px;
}

.rich-hero__kicker a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

.rich-hero h1 {
    font-size: clamp(1.85rem, 7vw, 3.25rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 12px;
    text-wrap: balance;
}

.rich-hero p {
    font-size: clamp(0.95rem, 3.5vw, 1.1rem);
    line-height: 1.55;
    opacity: 0.92;
    max-width: 38em;
}

/* --- Media + attribution --- */
.figure-photo {
    margin: clamp(20px, 4vw, 32px) 0;
    border-radius: var(--rich-radius-lg);
    overflow: hidden;
    box-shadow: var(--rich-shadow);
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.figure-photo img {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(70vh, 560px);
    object-fit: cover;
    object-position: center;
}

.figure-photo figcaption,
.figcaption {
    padding: 12px 16px 14px;
    font-size: 0.8rem;
    line-height: 1.45;
    color: #64748b;
    background: #f8fafc;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.figure-photo figcaption a,
.figcaption a {
    color: #0d9488;
    font-weight: 600;
}

/* --- Embedded map (OpenStreetMap) --- */
.map-embed {
    position: relative;
    width: 100%;
    border-radius: var(--rich-radius-lg);
    overflow: hidden;
    box-shadow: var(--rich-shadow);
    border: 1px solid rgba(0, 0, 0, 0.08);
    aspect-ratio: 16 / 11;
    min-height: 220px;
    max-height: 480px;
}

.map-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Leaflet: OSM raster tiles + vector overlays (markers, lines, polygons) */
.map-embed.map-leaflet {
    aspect-ratio: unset;
    min-height: 280px;
    height: min(440px, 58vh);
    max-height: 520px;
}

.map-embed.map-leaflet.map-leaflet--compact {
    height: min(300px, 42vh);
    max-height: 360px;
    min-height: 220px;
}

.map-embed.map-leaflet .leaflet-container {
    width: 100%;
    height: 100%;
    font-family: inherit;
    border-radius: inherit;
}

.map-embed.map-leaflet .leaflet-control-attribution {
    font-size: 10px;
    max-width: 100%;
    white-space: normal;
    line-height: 1.25;
}

.map-embed--tall {
    aspect-ratio: 4 / 5;
    max-height: 560px;
}

@media (min-width: 768px) {
    .map-embed {
        aspect-ratio: 16 / 9;
    }
}

/* --- Movies --- */
.section-movies {
    margin: clamp(28px, 5vw, 48px) 0;
    padding: clamp(18px, 3vw, 26px);
    border-radius: var(--rich-radius-lg);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.section-movies h2 {
    font-size: clamp(1.15rem, 4vw, 1.35rem);
    margin-bottom: 6px;
}

.section-movies > p.sub {
    font-size: 0.88rem;
    color: #64748b;
    margin-bottom: 18px;
}

.movie-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 520px) {
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 860px) {
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
}

.movie-card {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: #fff;
    border-radius: var(--rich-radius);
    border: 1px solid rgba(0, 0, 0, 0.06);
    align-items: flex-start;
    min-height: var(--rich-touch);
}

.movie-card img {
    width: 72px;
    height: 104px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #e2e8f0;
}

.movie-card__body h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.25;
}

.movie-card__body p {
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.45;
    margin-bottom: 8px;
}

.movie-card__body a {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0d9488;
    text-decoration: none;
}

.movie-card__body a:hover {
    text-decoration: underline;
}

/* --- Content width --- */
.rich-wrap {
    max-width: 920px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 40px) clamp(14px, 4vw, 24px) clamp(48px, 8vw, 80px);
}

.rich-prose p {
    margin-bottom: 1em;
    color: #334155;
    max-width: 65ch;
}

.rich-prose p:last-child {
    margin-bottom: 0;
}

/* --- Topic cards with thumb (historia index) --- */
.topic-rich {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(16px, 3vw, 22px);
}

@media (min-width: 640px) {
    .topic-rich {
        grid-template-columns: repeat(2, 1fr);
    }
}

.topic-rich a {
    display: grid;
    grid-template-columns: minmax(100px, 32%) 1fr;
    gap: 0;
    text-decoration: none;
    color: inherit;
    border-radius: var(--rich-radius-lg);
    overflow: hidden;
    box-shadow: var(--rich-shadow);
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (max-width: 480px) {
    .topic-rich a {
        grid-template-columns: 1fr;
    }
}

.topic-rich a:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
}

.topic-rich a .thumb {
    min-height: 140px;
    background-size: cover;
    background-position: center;
}

.topic-rich a .body {
    padding: 18px 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.topic-rich a .body h3 {
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: #0f172a;
}

.topic-rich a .body p {
    font-size: 0.88rem;
    color: #64748b;
    line-height: 1.5;
}

.topic-rich a .tag {
    margin-top: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9a3412;
}

/* Travel teal variant */
body.travel-rich .topic-rich a .tag {
    color: #0f766e;
}

/* --- Sticky subnav variant --- */
.subnav-sticky {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body.hist-rich .subnav-sticky {
    background: rgba(250, 249, 247, 0.94);
}

/* --- External content note --- */
.external-note {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 8px;
    line-height: 1.4;
}
