/* The template trip page's sticky section menu (TripPage/TripSectionNav.razor,
   js/trip-section-nav.js; Florian, 27 November 2026). One bar for the whole page; the itinerary
   tabs become its sub-menu: docked under it on wide screens, rows of its list on phones.
   Colours from the trip page palette (css/trip-gallery.css). */

:root {
    --tsn-h: 52px;
    --tsn-tabs-h: 44px;
}

/* The site menu on a page with the bar (js/trip-section-nav.js sets html.tsn-head): it sticks, so
   it can slide away while the page scrolls down. When the page scrolls up, only its menu row
   comes back: the header is shifted up by the height of its toolbar (--tsn-head-shift), which
   shows again at the very top of the page (Florian, 30 November 2026). The bar, the tabs and
   what sticks under them sit --tsn-top lower while the menu row shows. Above the bar, so its
   own menus open over it. */
html.tsn-head .nav-container {
    position: sticky;
    top: 0;
    z-index: 1002;
    transform: translateY(var(--tsn-head-shift, 0px));
    transition: transform 0.25s ease;
}

html.tsn-head.tsn-head-still .nav-container {
    transition: none;
}

html.tsn-head.tsn-head-hidden .nav-container {
    transform: translateY(-100%);
}

.tsn {
    position: fixed;
    top: var(--tsn-top, 0px);
    left: 0;
    right: 0;
    z-index: 1001; /* above the itinerary tabs (1000), below the site's pop-ups */
    height: var(--tsn-h);
    box-sizing: border-box;
    background: #fff;
    border-bottom: 1px solid #E0E0E0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-family: Roboto, Helvetica, Arial, sans-serif;
    transform: translateY(-110%);
    visibility: hidden;
    transition: transform 0.2s ease, top 0.25s ease, visibility 0s linear 0.2s;
}

html.tsn-on .tsn {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease, top 0.25s ease;
}

/* The tabs follow the bar when the site menu comes and goes. */
#trip-detail-app:has(.tsn) .custom-tabs-header {
    transition: top 0.25s ease;
}

.tsn-inner {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 16px;
    height: 100%;
    /* The page column's own measure (.home-container: 90% wide, 32px gutters). */
    max-width: 90%;
    margin: 0 auto;
    padding: 0 32px;
    box-sizing: border-box;
}

.tsn-links {
    display: flex;
    align-items: stretch;
    gap: 28px;
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.tsn-links::-webkit-scrollbar {
    display: none;
}

.tsn-links li {
    display: flex;
    flex: 0 0 auto;
}

.tsn-links a {
    display: flex;
    align-items: center;
    padding: 0;
    border: 0;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    background: none;
    color: #3D3D3D;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}

.tsn-links a:hover {
    color: #D20158;
}

.tsn-links a.is-active {
    color: #D20158;
    font-weight: 700;
    border-bottom-color: #D20158;
}

/* The two actions at the right: Contact outlined, "Find your price" filled, an icon in each. */
.tsn-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 10px;
}

.tsn-contact,
.tsn-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tsn-contact svg,
.tsn-cta svg {
    flex: none;
}

.tsn-contact {
    height: 36px;
    padding: 0 16px;
    box-sizing: border-box;
    border: 1.5px solid #D20158;
    background: #fff;
    color: #B8014C;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.tsn-contact:hover {
    background: #FCE8F0;
}

.tsn-cta {
    flex: 0 0 auto;
    height: 36px;
    padding: 0 20px;
    border: 0;
    background: #D20158;
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tsn-cta:hover {
    background: #B8014C;
}

.tsn-links a:focus-visible,
.tsn-contact:focus-visible,
.tsn-cta:focus-visible,
.tsn-pick:focus-visible,
.tsn-sub button:focus-visible {
    outline: 2px solid #15559A;
    outline-offset: -2px;
}

/* The bar replaces the sticky facts strip: two bars at the top of the intro would overlap. */
#trip-detail-app:has(.tsn) .tg-facts {
    position: static;
}

/* The phone button and its list (below). On wide screens the button is hidden and the panel is
   not a box, so the links and the actions sit in the bar as before. */
.tsn-pick,
.tsn-links li.tsn-sub {
    display: none;
}

.tsn-panel {
    display: contents;
}

/* Wide screens: the tabs dock under the bar, slimmer and on paper so they read as its sub-menu.
   The active tab keeps its pink block (TripDetail.razor.css). */
@media (min-width: 768.02px) {
    #trip-detail-app:has(.tsn) .custom-tabs-header {
        top: calc(var(--tsn-top, 0px) + var(--tsn-h));
        height: var(--tsn-tabs-h);
        background-color: #F3EEE4;
        box-shadow: inset 0 -1px 0 #E0E0E0;
        /* The paper and its hairline run to both edges of the window, like the bar above
           (Florian, 30 November 2026); the tabs themselves stay on the page's column. A
           border image may paint outside the box without adding a sideways scroll. */
        border-image: linear-gradient(#F3EEE4 calc(100% - 1px), #E0E0E0 calc(100% - 1px)) fill 0 / 0 / 0 100vw;
        scrollbar-width: none;
    }

    #trip-detail-app:has(.tsn) .custom-tab-button {
        padding: 0 28px;
        font-size: 16px;
    }

    #trip-detail-app:has(.tsn) .custom-tab-button:hover {
        background-color: #E9E1D2;
    }

    #trip-detail-app:has(.tsn) .custom-tab-button.active,
    #trip-detail-app:has(.tsn) .custom-tab-button.active:hover {
        background-color: #D20158;
    }

    /* What used to sit under the 60px tab bar now sits under the bar and the tabs. */
    #trip-detail-app:has(.tsn) .custom-tabs {
        scroll-margin-top: var(--tsn-h);
    }

    #trip-detail-app:has(.tsn) [id^="day-"] {
        scroll-margin-top: calc(var(--tsn-h) + var(--tsn-tabs-h) + 8px);
    }

    #trip-detail-app:has(.tsn) .days-list {
        top: calc(var(--tsn-top, 0px) + var(--tsn-h) + var(--tsn-tabs-h));
        max-height: calc(100vh - var(--tsn-h) - var(--tsn-tabs-h));
    }

    #trip-detail-app:has(.tsn) .trip-right-column {
        top: calc(var(--tsn-top, 0px) + var(--tsn-h) + var(--tsn-tabs-h) + 20px);
    }
}

/* Phones (Florian, 30 November 2026): seven links and two buttons do not fit in one row. The bar
   is one button that names the section on screen; a tap opens the links, the itinerary's tabs
   and the two actions as a list under the bar (html.tsn-menu, set by the script). The itinerary
   tabs are no longer sticky here: one bar for the whole page. */
@media (max-width: 768px) {
    :root {
        --tsn-h: 48px;
    }

    .tsn-inner {
        display: block;
        max-width: none;
        padding: 0;
    }

    .tsn-pick {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        height: 100%;
        padding: 0 16px;
        box-sizing: border-box;
        border: 0;
        background: none;
        color: #3D3D3D;
        font: inherit;
        font-size: 16px;
        font-weight: 700;
        text-align: left;
        cursor: pointer;
    }

    .tsn-pick svg {
        flex: none;
    }

    .tsn-pick-label {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tsn-pick-chevron {
        transition: transform 0.2s ease;
    }

    html.tsn-menu .tsn-pick-chevron {
        transform: rotate(180deg);
    }

    .tsn-panel {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: calc(100vh - var(--tsn-h));
        max-height: calc(100dvh - var(--tsn-h));
        overflow-y: auto;
        overscroll-behavior: contain;
        background: #fff;
        border-top: 1px solid #E0E0E0;
        box-shadow: 0 14px 24px rgba(0, 0, 0, 0.16);
    }

    html.tsn-on.tsn-menu .tsn-panel {
        display: block;
    }

    .tsn-links {
        display: block;
        overflow: visible;
    }

    .tsn-links li,
    .tsn-links li.tsn-sub {
        display: block;
    }

    .tsn-links a,
    .tsn-sub button {
        display: flex;
        align-items: center;
        width: 100%;
        min-height: 48px;
        padding: 0 16px 0 13px;
        box-sizing: border-box;
        border: 0;
        border-left: 3px solid transparent;
        border-bottom: 1px solid #EEE;
        background: none;
        color: #3D3D3D;
        font: inherit;
        font-size: 16px;
        font-weight: 500;
        text-align: left;
        cursor: pointer;
    }

    .tsn-links a.is-active {
        border-left-color: #D20158;
        border-bottom-color: #EEE;
    }

    /* The itinerary's tabs, one step in under "Itinerary". */
    .tsn-sub button {
        min-height: 44px;
        padding-left: 37px;
        font-size: 15px;
        font-weight: 400;
    }

    .tsn-sub button.is-active {
        color: #D20158;
        font-weight: 700;
    }

    /* The two actions close the list, full width, with their words. */
    .tsn-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 16px;
    }

    .tsn-contact,
    .tsn-cta {
        justify-content: center;
        height: 46px;
        font-size: 15px;
    }

    /* The itinerary tabs stick under the bar on phones too, as the same slim paper band as on
       wide screens (Florian, 30 November 2026: he still wants them at hand while scrolling the
       itinerary; they also stay in the list under "Itinerary"). */
    #trip-detail-app:has(.tsn) .custom-tabs-header {
        top: calc(var(--tsn-top, 0px) + var(--tsn-h));
        height: var(--tsn-tabs-h);
        background-color: #F3EEE4;
        box-shadow: inset 0 -1px 0 #E0E0E0;
        border-image: linear-gradient(#F3EEE4 calc(100% - 1px), #E0E0E0 calc(100% - 1px)) fill 0 / 0 / 0 100vw;
        scrollbar-width: none;
    }

    #trip-detail-app:has(.tsn) .custom-tabs-header::-webkit-scrollbar {
        display: none;
    }

    #trip-detail-app:has(.tsn) .custom-tab-button.active,
    #trip-detail-app:has(.tsn) .custom-tab-button.active:hover {
        background-color: #D20158;
    }

    #trip-detail-app:has(.tsn) .custom-tabs {
        scroll-margin-top: var(--tsn-h);
    }

    #trip-detail-app:has(.tsn) [id^="day-"] {
        scroll-margin-top: calc(var(--tsn-h) + var(--tsn-tabs-h) + 8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tsn,
    html.tsn-on .tsn,
    .tsn-pick-chevron,
    html.tsn-head .nav-container,
    #trip-detail-app:has(.tsn) .custom-tabs-header {
        transition: none;
    }
}
