/* ==========================================================================
   Treks in Peru: page shell and local design tokens
   ========================================================================== */

/* The trekking page extends the established editorial palette and 7px shape language. */
.treks-page {
    --treks-ink: #171717;
    --treks-copy: #5d5d5d;
    --treks-muted: #6b6b6b;
    --treks-red: #f10100;
    --treks-red-deep: #b90201;
    --treks-line: #e8e8e4;
    --treks-soft: #f7f7f5;
    --treks-warm: #fffaf5;
    --treks-radius: 7px;
    overflow: clip;
    background-color: #ffffff;
    color: var(--treks-copy);
}

/* Text selection keeps the browser surface inside the brand palette. */
.treks-page ::selection {
    background-color: var(--treks-red);
    color: #ffffff;
}

/* Scrollbars use quiet neutral tracks and the primary action color. */
.treks-page {
    scrollbar-color: var(--treks-red) var(--treks-soft);
    scrollbar-width: thin;
}

/* WebKit scrollbars mirror the same restrained color treatment. */
.treks-page::-webkit-scrollbar {
    width: 10px;
}

/* WebKit scrollbar track remains visually subordinate. */
.treks-page::-webkit-scrollbar-track {
    background-color: var(--treks-soft);
}

/* WebKit scrollbar thumb uses the shared 7px radius. */
.treks-page::-webkit-scrollbar-thumb {
    border-radius: var(--treks-radius);
    background-color: var(--treks-red);
}

/* All keyboard focus states remain visible against light and dark sections. */
.treks-page a:focus-visible,
.treks-page button:focus-visible {
    outline: 3px solid rgba(241, 1, 0, 0.34);
    outline-offset: 3px;
    border-radius: var(--treks-radius);
}

/* Figures reset browser margins so editorial compositions align predictably. */
.treks-page figure {
    margin: 0;
}

/* ==========================================================================
   Shared hero and chapter navigation
   ========================================================================== */

/* The hero stays tall enough to establish the scale of the high Andes. */
.treks-page .tour-category-hero {
    min-height: 620px;
    height: clamp(620px, calc(100svh - 69px), 780px);
}

/* Landscape imagery is framed around the route and distant hikers. */
.treks-page .tour-category-hero-image {
    object-position: center 55%;
}

/* The longer hero statement retains a controlled measure beside the award mark. */
.treks-page .tour-category-hero-title {
    max-width: 15ch;
    font-family: "Metromedium", "Roboto", sans-serif;
    font-size: clamp(2.5rem, 5.3vw, 3.6rem);
    font-weight: 500;
    letter-spacing: -0.025em;
    line-height: 0.98;
    text-wrap: balance;
}

/* The page navigation inherits the existing sticky behavior and neutral edge. */
.treks-nav {
    border-bottom-color: var(--treks-line);
}

/* ==========================================================================
   Introductory editorial spread
   ========================================================================== */

/* The introduction pairs a readable argument with a tall field photograph. */
.treks-intro-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(380px, 1.1fr);
    align-items: center;
    gap: clamp(3.5rem, 8vw, 8rem);
}

/* Introductory copy keeps the optimal reading measure for longer paragraphs. */
.treks-intro-copy {
    max-width: 650px;
}

/* Tall route photography creates a decisive editorial opening after the hero. */
.treks-intro-media {
    position: relative;
    min-height: 680px;
    overflow: hidden;
    border-radius: var(--treks-radius);
    background-color: var(--treks-soft);
}

/* Introductory photography fills its tall frame without distorting the mountain range. */
.treks-intro-media img {
    width: 100%;
    height: 100%;
    min-height: 680px;
    object-fit: cover;
}

/* ==========================================================================
   Four-route index
   ========================================================================== */

/* The route index introduces the ranked feature stories on a warm paper surface. */
.treks-index-section {
    padding: clamp(4.5rem, 8vw, 7rem) 0;
    scroll-margin-top: 58px;
    background-color: var(--treks-warm);
}

/* Index heading stays centered without narrowing the route labels below it. */
.treks-index-heading {
    max-width: 820px;
    margin: 0 auto;
    text-align: center;
}

/* Route index is one continuous comparative rail rather than four floating cards. */
.treks-route-index {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 0;
    margin: clamp(3rem, 6vw, 5rem) 0 0;
    border-top: 1px solid var(--treks-line);
    border-bottom: 1px solid var(--treks-line);
    list-style: none;
}

/* Each route link uses dividers to preserve the continuous index treatment. */
.treks-route-index li + li {
    border-left: 1px solid var(--treks-line);
}

/* Index links stack ranking, title and direction in a generous target area. */
.treks-route-index a {
    position: relative;
    display: flex;
    min-height: 190px;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem;
    color: var(--treks-ink);
    text-decoration: none;
    transition: background-color 220ms ease, color 220ms ease;
}

/* Ranking labels remain compact because the sequence itself carries meaning. */
.treks-route-index a > span {
    color: var(--treks-red-deep);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.1em;
}

/* Route titles use the display face while staying compact enough for comparison. */
.treks-route-index strong {
    max-width: 18ch;
    font-family: "Metromedium", "Roboto", sans-serif;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.25;
}

/* Direction icon aligns with the lower edge of every index link. */
.treks-route-index i {
    color: var(--treks-red);
    font-size: 0.82rem;
    transition: transform 220ms ease;
}

/* Index hover makes the selected route visible without floating the link. */
.treks-route-index a:hover,
.treks-route-index a:focus-visible {
    background-color: #ffffff;
    color: var(--treks-red-deep);
}

/* Direction icon moves once as the authored interaction for the route index. */
.treks-route-index a:hover i,
.treks-route-index a:focus-visible i {
    transform: translateY(4px);
}

/* ==========================================================================
   Immersive featured route stories
   ========================================================================== */

/* Every route story keeps a consistent anchor offset beneath sticky navigation. */
.treks-feature {
    padding: clamp(2.5rem, 4vw, 3.5rem) 0;
    scroll-margin-top: 58px;
    background-color: #ffffff;
}

/* Alternating stories use a quiet neutral surface to pace the long page. */
.treks-feature.is-reversed {
    background-color: var(--treks-soft);
}

/* Feature layouts give photography and route content equal visual weight. */
.treks-feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: clamp(1.5rem, 2.5vw, 2.5rem);
}

/* Reversed route stories swap the visual and narrative columns on wide screens. */
.treks-feature.is-reversed .treks-feature-media {
    order: 2;
}

/* Feature media fills its half of the layout without adding excess vertical space. */
.treks-feature-media {
    position: relative;
    height: 100%;
    min-height: 560px;
    overflow: hidden;
    border-radius: var(--treks-radius);
    background-color: var(--treks-soft);
}

/* The image link fills the entire route media frame. */
.treks-feature-media > a {
    display: block;
    width: 100%;
    height: 100%;
}

/* Route images use a measured zoom on interaction. */
.treks-feature-media img {
    width: 100%;
    height: 100%;
    min-height: 560px;
    object-fit: cover;
    transition: transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Image hover maintains detail while signaling the linked route. */
.treks-feature-media:hover img,
.treks-feature-media:focus-within img {
    transform: scale(1.035);
}

/* The meaningful ranking remains compact over each photograph. */
.treks-feature-rank {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    border-radius: var(--treks-radius);
    background-color: var(--treks-red);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

/* Feature copy uses the full content column while preserving a readable line length. */
.treks-feature-copy {
    width: 100%;
    max-width: none;
}

/* Route headings use an editorial scale with restrained tracking. */
.treks-feature-copy h2 {
    max-width: 13ch;
    margin: 0;
    color: var(--treks-ink);
    font-family: "Metromedium", "Roboto", sans-serif;
    font-size: clamp(2.5rem, 4.4vw, 3.6rem);
    font-weight: 500;
    letter-spacing: -0.035em;
    line-height: 1;
    text-transform: none;
    text-wrap: balance;
}

/* Route facts use a two-column definition list with horizontal rules. */
.treks-feature-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 1.5rem 0;
    border-top: 1px solid var(--treks-line);
}

/* Each fact is separated by a baseline rather than a boxed card. */
.treks-feature-facts > div {
    padding: 1rem 0;
    border-bottom: 1px solid var(--treks-line);
}

/* Adjacent facts receive breathing room without vertical decorative borders. */
.treks-feature-facts > div:nth-child(odd) {
    padding-right: 1.25rem;
}

/* Even facts align with the second column using internal spacing only. */
.treks-feature-facts > div:nth-child(even) {
    padding-left: 1.25rem;
}

/* Fact labels use the interface label ramp. */
.treks-feature-facts dt {
    margin: 0;
    color: var(--treks-muted);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Fact values stay prominent without competing with the route title. */
.treks-feature-facts dd {
    margin: 0.35rem 0 0;
    color: var(--treks-ink);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.35;
}

/* The feature CTA is a text action with a brand-red baseline. */
.treks-feature-link {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    gap: 0.7rem;
    margin-top: 0.5rem;
    padding: 0.75rem 0;
    border-bottom: 2px solid var(--treks-red);
    color: var(--treks-ink);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: color 180ms ease, gap 180ms ease;
}

/* The route CTA reinforces forward movement without changing layout. */
.treks-feature-link:hover,
.treks-feature-link:focus-visible {
    gap: 1rem;
    color: var(--treks-red-deep);
}

/* ==========================================================================
   Reusable tour-best-card collection
   ========================================================================== */

/* The wider tour collection uses a quiet warm surface behind the shared cards. */
.treks-tour-collection {
    scroll-margin-top: 58px;
    background-color: var(--treks-warm);
}

/* Collection heading stays centered and readable above the denser grid. */
.treks-collection-heading {
    max-width: 860px;
    margin: 0 auto;
    text-align: center;
}

/* Shared tour cards form a responsive three-column decision grid. */
.treks-tour-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
    margin-top: clamp(3rem, 6vw, 5rem);
}

/* The existing tour cards retain their full component behavior inside this page. */
.treks-tour-grid .tour-best-card {
    min-width: 0;
}

/* Card titles keep enough height for a calm three-column alignment. */
.treks-tour-grid .tour-best-card-title {
    min-height: 5.5rem;
}

/* Long feature descriptions wrap without forcing card overflow. */
.treks-tour-grid .tour-best-card-feature-desc {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Tour footer actions remain compact on the three-column desktop grid. */
.treks-tour-grid .tour-best-card-button {
    padding-right: 1rem;
    padding-left: 1rem;
}

/* The original closing invitation is separated from the tour grid by a simple rule. */
.treks-source-closing {
    max-width: 960px;
    margin: clamp(3rem, 6vw, 5rem) auto 0;
    padding-top: 2rem;
    border-top: 1px solid var(--treks-line);
    color: var(--treks-ink);
    font-size: 1rem;
    line-height: 1.7;
    text-align: center;
}

/* The source contact sentence remains an inline editorial link. */
.treks-source-closing a {
    color: var(--treks-red-deep);
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* ==========================================================================
   Original two-video showcase
   ========================================================================== */

/* The footage section separates source videos from the warm tour collection. */
.treks-video-showcase {
    background-color: #ffffff;
}

/* Video heading keeps an editorial measure above the two-column grid. */
.video-grid-title {
    max-width: 18ch;
    margin: 0;
    color: var(--treks-ink);
    font-family: "Metromedium", "Roboto", sans-serif;
    font-size: clamp(2rem, 4vw, 3.6rem);
    font-weight: 500;
    letter-spacing: -0.035em;
    line-height: 1.05;
    text-wrap: balance;
}

/* Source footage uses two equal columns with a restrained editorial gap. */
.video-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(1.25rem, 2.5vw, 2.25rem);
    margin-top: clamp(2rem, 4vw, 3rem);
}

/* Responsive video frames preserve 16:9 media and the universal 7px radius. */
.video-grid-frame {
    position: relative;
    overflow: hidden;
    border-radius: var(--treks-radius);
    aspect-ratio: 16 / 9;
    background-color: var(--treks-ink);
}

/* Embedded players fill their media frame without borders or overflow. */
.video-grid-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ==========================================================================
   Responsive behavior
   ========================================================================== */

@media (max-width: 1199.98px) {
    /* Large tablets use a two-column tour grid for comfortable card widths. */
    .treks-tour-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Card titles no longer need desktop three-column height matching. */
    .treks-tour-grid .tour-best-card-title {
        min-height: 0;
    }
}

@media (max-width: 991.98px) {
    /* Tablet stacks the intro and route feature sections. */
    .treks-intro-grid,
    .treks-feature-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Stacked copy columns can use a wider readable measure. */
    .treks-intro-copy,
    .treks-feature-copy {
        max-width: 760px;
    }

    /* Reversed stories return to image-first order when stacked. */
    .treks-feature.is-reversed .treks-feature-media {
        order: 0;
    }

    /* Tablet route images remain immersive without consuming an entire viewport. */
    .treks-feature-media,
    .treks-feature-media img {
        min-height: 520px;
    }

    /* Four-route index becomes a balanced two-column rail. */
    .treks-route-index {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* The third route begins a second index row with a horizontal separator. */
    .treks-route-index li:nth-child(n + 3) {
        border-top: 1px solid var(--treks-line);
    }

    /* The third route starts the new row without a vertical divider. */
    .treks-route-index li:nth-child(3) {
        border-left: 0;
    }
}

@media (max-width: 767.98px) {
    /* Mobile hero remains tall enough for the shared statement and award. */
    .treks-page .tour-category-hero {
        min-height: 600px;
        height: 78svh;
    }

    /* Mobile hero title wraps cleanly above the chapter navigation. */
    .treks-page .tour-category-hero-title {
        max-width: 12ch;
        font-size: clamp(2.5rem, 11vw, 3.6rem);
    }

    /* Mobile intro image keeps a tall, place-led crop. */
    .treks-intro-media,
    .treks-intro-media img {
        min-height: 510px;
    }

    /* Route index becomes a single continuous list on small screens. */
    .treks-route-index {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Every route after the first is separated by a horizontal rule. */
    .treks-route-index li + li,
    .treks-route-index li:nth-child(n + 3) {
        border-top: 1px solid var(--treks-line);
        border-left: 0;
    }

    /* Mobile route links become compact horizontal rows. */
    .treks-route-index a {
        min-height: 0;
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr) 20px;
        align-items: center;
        gap: 1rem;
        padding: 1.25rem 0;
    }

    /* Mobile route titles use the available line width. */
    .treks-route-index strong {
        max-width: none;
    }

    /* Direction arrows point downward at the end of each route row. */
    .treks-route-index i {
        justify-self: end;
    }

    /* Route images shorten slightly while remaining the dominant content. */
    .treks-feature-media,
    .treks-feature-media img {
        min-height: 390px;
    }

    /* Route headings remain legible without excessive mobile wrapping. */
    .treks-feature-copy h2 {
        max-width: 15ch;
        font-size: clamp(2.5rem, 11vw, 3.6rem);
    }

    /* Tour cards stack into one readable decision column. */
    .treks-tour-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Video players stack on phones while preserving their natural ratio. */
    .video-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Single-column cards retain a comfortable maximum width. */
    .treks-tour-grid .tour-best-card {
        width: 100%;
        max-width: 520px;
        margin: 0 auto;
    }

}

@media (max-width: 420px) {
    /* Small phones simplify the two-column fact list to one vertical sequence. */
    .treks-feature-facts {
        grid-template-columns: minmax(0, 1fr);
    }

    /* All fact cells share identical padding in one-column mode. */
    .treks-feature-facts > div:nth-child(odd),
    .treks-feature-facts > div:nth-child(even) {
        padding-right: 0;
        padding-left: 0;
    }

    /* Shared card footer stacks when price and action no longer fit side by side. */
    .treks-tour-grid .tour-best-card-footer {
        align-items: stretch;
        flex-direction: column;
    }

    /* The card action fills the available width on the smallest screens. */
    .treks-tour-grid .tour-best-card-button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* Reduced-motion readers receive immediate route and image state changes. */
    .treks-route-index a,
    .treks-route-index i,
    .treks-feature-media img,
    .treks-feature-link {
        transition: none;
    }
}
