/* Opt-in navigation only. Loaded after each page's existing stylesheet. */
:root { --ff-navigation-top:0px; --ff-navigation-height:60px; }
[data-sticky-navigation] {
    position:sticky;
    top:var(--ff-navigation-top);
    z-index:var(--ff-navigation-layer, 19);
    background:var(--ff-navigation-paper, #fff);
    box-shadow:0 5px 10px -8px #18232b55;
    min-width:0;
}
[data-navigation-tabs] {
    flex-wrap:nowrap;
    overflow-x:auto;
    overflow-y:hidden;
    overscroll-behavior-x:contain;
    min-width:0;
    max-width:100%;
    scrollbar-width:thin;
    -webkit-overflow-scrolling:touch;
}
[data-navigation-tabs] > button, [data-navigation-tabs] > a { flex:0 0 auto; white-space:nowrap; }
[data-navigation-tabs] > :focus-visible { outline-offset:-3px; }

/* Author home: preserve the existing collections, Browse control and button handlers. */
body[data-ff-navigation="author"] { --ff-navigation-layer:19; --ff-navigation-paper:var(--bg, #faf8f3); }
[data-ff-navigation="author"] .bar[data-sticky-navigation] {
    grid-template-columns:minmax(0,1fr) minmax(0,auto) minmax(0,1fr);
    padding-top:8px;
    padding-bottom:8px;
}
[data-ff-navigation="author"] #tabs { padding-block:4px 9px; margin-block:0; }
[data-ff-navigation="author"] #tabs button.active::after { bottom:0; }

/* Stories home: keep the experience drawer attached to its original row. */
body[data-ff-navigation="stories"] {
    --ff-navigation-layer:900;
    --ff-navigation-paper:var(--color-bg, #faf8f3);
    /* clip avoids creating an extra scroll container above the sticky row. */
    overflow-x:clip;
}
[data-ff-navigation="stories"] .section-header[data-sticky-navigation] {
    position:sticky;
    grid-template-columns:minmax(120px,1fr) minmax(0,auto) minmax(90px,1fr);
    gap:clamp(8px,2vw,32px);
    padding-top:8px;
    padding-bottom:8px;
}
[data-ff-navigation="stories"] .experience-nav {
    padding-block:4px 9px;
    justify-content:flex-start;
}
[data-ff-navigation="stories"] .experience-tab::after { bottom:0; }
[data-ff-navigation="stories"] .experience-panel {
    max-height:calc(100dvh - var(--ff-navigation-top) - var(--ff-navigation-height) - 12px);
    overflow-y:auto;
    overscroll-behavior:contain;
}

/* Desktop sidebars must clear the combined pinned header and navigation row. */
@media (min-width:901px) {
    [data-ff-navigation="author"] #browse,
    [data-ff-navigation="stories"] .browse-sidebar {
        top:calc(var(--ff-navigation-top) + var(--ff-navigation-height) + 16px);
        max-height:calc(100vh - var(--ff-navigation-top) - var(--ff-navigation-height) - 32px);
        max-height:calc(100dvh - var(--ff-navigation-top) - var(--ff-navigation-height) - 32px);
    }
}
@media (max-width:900px) {
    [data-ff-navigation="author"] .bar[data-sticky-navigation] { display:grid; grid-template-columns:minmax(0,1fr); gap:4px; }
    [data-ff-navigation="author"] .bar > div:first-child { display:flex; align-items:center; gap:12px; }
    [data-ff-navigation="author"] .bar h2 { font-size:1.4rem; }
    [data-ff-navigation="author"] #tabs { grid-column:1; gap:22px; }
    [data-ff-navigation="stories"] .section-header[data-sticky-navigation] { grid-template-columns:minmax(0,1fr) auto; gap:4px 12px; }
    [data-ff-navigation="stories"] .section-heading-group { grid-column:1; grid-row:1; min-width:0; }
    [data-ff-navigation="stories"] .section-title { font-size:1.25rem; }
    [data-ff-navigation="stories"] .view-controls { grid-column:2; grid-row:1; }
    [data-ff-navigation="stories"] .experience-nav { grid-column:1/-1; grid-row:2; gap:24px; }
}

/* Author home destination link: outside the horizontally scrolling authoring tabs. */
[data-ff-navigation="author"] .bar.has-stories-link {
    grid-template-columns:minmax(max-content,1fr) minmax(0,auto) minmax(max-content,1fr);
    column-gap:clamp(12px,2vw,28px);
}
[data-ff-navigation="author"] .author-explore-stories {
    grid-column:3;
    grid-row:1;
    justify-self:end;
    display:inline-flex;
    align-items:center;
    gap:0.4rem;
    min-height:44px;
    padding:8px 0 8px clamp(12px,1.5vw,24px);
    border-left:1px solid var(--bd, #e8e3da);
    color:var(--pd, #066);
    font:600 0.9375rem/1.25 var(--sans, sans-serif);
    white-space:nowrap;
    text-decoration:none;
}
[data-ff-navigation="author"] .author-explore-stories:hover > span:first-child {
    text-decoration:underline;
    text-underline-offset:3px;
}
[data-ff-navigation="author"] .author-explore-stories:focus-visible {
    outline:2px solid var(--p, #008b8b);
    outline-offset:3px;
}
@media (max-width:900px) {
    [data-ff-navigation="author"] .bar.has-stories-link {
        grid-template-columns:minmax(0,1fr) auto;
        column-gap:8px;
    }
    [data-ff-navigation="author"] .bar.has-stories-link > div:first-child {
        grid-column:1/-1;
        grid-row:1;
    }
    [data-ff-navigation="author"] .bar.has-stories-link #tabs {
        grid-column:1;
        grid-row:2;
    }
    [data-ff-navigation="author"] .author-explore-stories {
        grid-column:2;
        grid-row:2;
        padding-left:12px;
        font-size:0.875rem;
    }
}