/* ————
Report Navigation: List block with the 'Report Navigation' style (js/gutenberg-ext.js).
Main sections, with nested lists as indented subsections; js/report-nav.js highlights the
section being read. Selectors start with .wp-block-list.is-style-report-nav (and use !important
where needed) to override the general list styles in bits-and-pieces.css.
——— */

.wp-block-list.is-style-report-nav,
.wp-block-list.is-style-report-nav .wp-block-list {
    display: flex;
    flex-direction: column;
    gap: calc(var(--one-spacer) / 2);
    padding-left: 0 !important;
    list-style: none;
}

.wp-block-list.is-style-report-nav li,
.wp-block-list.is-style-report-nav li:not(:first-child) {
    list-style: none;
    margin: 0 !important;
    padding-left: 0;
}

/* Subsections */
.wp-block-list.is-style-report-nav .wp-block-list {
    margin-top: calc(var(--one-spacer) / 2) !important;
    padding-left: var(--one-spacer) !important;
    font-size: 0.875em;
}

.wp-block-list.is-style-report-nav a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

/* Once report-nav.js is running (front end only, so the editor shows every link at full strength),
   dim everything except the section being read: its main section and all of that section's subsections */
.wp-block-list.is-style-report-nav.is-scrollspy-ready a {
    opacity: 0.5;
}

/* Only the section being read shows its subsections (report-nav.js marks its list item .is-current-section;
   none before the first section). Front end only, so the editor shows them all */
.wp-block-list.is-style-report-nav.is-scrollspy-ready > li:not(.is-current-section) > .wp-block-list {
    display: none;
}

/* ...plus any section tabbed into, so keyboard users can reach its subsections too (not on hover) */
.wp-block-list.is-style-report-nav.is-scrollspy-ready > li:focus-within > .wp-block-list {
    display: flex;
}

.wp-block-list.is-style-report-nav.is-scrollspy-ready a:hover,
.wp-block-list.is-style-report-nav.is-scrollspy-ready a:focus-visible,
.wp-block-list.is-style-report-nav.is-scrollspy-ready a.is-active,
.wp-block-list.is-style-report-nav.is-scrollspy-ready > li.is-current-section a {
    opacity: 1;
}

/* The section being read: its main section in medium, and the subsection (if it's in one) in bold */
.wp-block-list.is-style-report-nav.is-scrollspy-ready > li.is-current-section > a {
    font-weight: 500;
}

.wp-block-list.is-style-report-nav.is-scrollspy-ready .wp-block-list a[aria-current] {
    font-weight: 700;
}

/* ————
The nav itself, its progress bar and the hamburger, all added by report-nav.js (so the editor and
no-JS visitors just see the list):
  <div.report-nav>                   sticky wrapper: hamburger/X button
  <div.report-nav-panel>             the nav, a sibling right after the wrapper
    <div.report-nav-body>
      <div.report-nav-sections>
        <span.report-nav-progress>   progress bar: track (::before) and fill (::after)
        <ul>                         the list
      <div.report-nav-downloads>     download buttons, if any (inc/reports.php; .has-downloads on the panel)
Both the wrapper and the panel take no space in the page, so they float over the content.

The wrapper sticks to the top left of the screen once scrolled to, and its hamburger opens the panel.
The nav sits in the same place whether the panel is open or not: the panel's left padding from the
screen edge, just below the hamburger.

Wide screens (1280px and up): the closed panel still shows the nav, beside the text, sticking to the
top of the screen down to the end of the report content (report-nav.js slides it up with the end:
--report-nav-shift). With download buttons it runs the height of the screen, the list at the top and
the buttons at the bottom. Opening it puts the List block's background behind the nav, over everything.

Smaller screens: the hamburger opens the panel as a side panel sliding in from the left.

Over the page (the wide-screen nav and the closed hamburger), everything is white with
mix-blend-mode: difference (like the logo and nav on birds.local), so it inverts whatever is behind
it: dark over the light page, light over dark images. A sticky element is its own stacking context,
so the blend goes on the wrapper and the panel themselves; a blend on something inside them would
only mix with them. That's also why the panel sits next to the wrapper instead of inside it, so the
side panel isn't inverted as it slides away.

The open side panel shows the List block's own Color settings, read by report-nav.js:
--report-nav-bg        list background -> panel background
--report-nav-text      list text color -> panel text, and the X

Progress bar: as tall as the list, filled in the text color over a faint track, from the top down to
--report-nav-fill: reading progress through the report content (0-100%), set by report-nav.js
——— */

/* White surface behind the page for the difference blend to invert against (the browser's default white
   canvas doesn't count, so white areas would leave the white nav invisible). Added once by
   report-nav.js, first in <body>, so it's painted below the Section Hero images (also z-index -1) */
.report-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: #fff;
    pointer-events: none;
}

.report-nav,
.report-nav-panel {
    --report-nav-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--two-spacer));
}

/* z-index 60: the menu button stays over everything that passes over the nav beside the text on wide screens
   (z-index 51: cards, images and Faded Edges sections, css/custom-report.css) */
.report-nav {
    position: sticky;
    top: var(--report-nav-top);
    z-index: 60;
    box-sizing: border-box;
    height: 0;
    padding: 0 var(--global--spacing-horizontal);
}

.report-nav:not(.is-open) {
    mix-blend-mode: difference;
}

.report-nav.is-open {
    z-index: 200; /* the X above the panel (190) */
}

.entry-content > .report-nav {
    margin-top: 0;
    margin-bottom: 0;
}

/* Just the icon: no outline or background. White, inverted by the wrapper's blend while closed */
.report-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* icon lines up with the screen edge spacing; the button stays a 48px tap target */
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

/* Open: the X takes the list's text color, and stays at the top left of the panel even if the nav
   hadn't reached the top yet */
.report-nav.is-open .report-nav-toggle {
    position: fixed;
    top: var(--report-nav-top);
    left: var(--global--spacing-horizontal);
    color: var(--report-nav-text, var(--wp--preset--color--black));
}

.report-nav-toggle-icon {
    width: 24px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask: url('../../icons/menu-filled.svg') center / contain no-repeat;
    mask: url('../../icons/menu-filled.svg') center / contain no-repeat;
}

.report-nav.is-open .report-nav-toggle-icon {
    -webkit-mask-image: url('../../icons/close-filled.svg');
    mask-image: url('../../icons/close-filled.svg');
}

/* Smaller screens: a full-height panel that slides in from the left, behind the X */
.report-nav-panel {
    position: fixed;
    top: var(--wp-admin--admin-bar--height, 0px);
    bottom: 0;
    left: 0;
    z-index: 190; /* above the site header (100), below the open wrapper's X (200) */
    box-sizing: border-box;
    --report-nav-panel-width: 290px; /* the one place to change the panel width */
    width: min(var(--report-nav-panel-width), 100%);
    padding: calc(var(--two-spacer) + 48px + var(--two-spacer)) var(--two-spacer) var(--four-spacer) var(--global--spacing-horizontal);
    overflow-y: auto; /* long navs scroll inside the panel */
    background: var(--report-nav-bg, var(--wp--preset--color--white));
    color: var(--report-nav-text, var(--wp--preset--color--black));
    visibility: hidden; /* also keeps the closed panel's links out of the tab order */
    transform: translateX(-100%);
    transition: transform 0.3s ease, visibility 0s linear 0.3s;
}

/* It's a direct child of the content (right after the wrapper), so undo the content column's sizing and spacing */
.entry-content > .report-nav-panel,
.report-nav-panel.alignfull {
    width: min(var(--report-nav-panel-width), 100%);
    max-width: none;
    margin: 0;
}

.report-nav-panel.is-open {
    visibility: visible;
    transform: none;
    transition: transform 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
    .report-nav-panel,
    .report-nav-panel.is-open {
        transition: none;
    }
}

/* Progress bar down the left of the list, as tall as the list */
.report-nav-panel {
    --report-nav-bar-width: 4px;
    --report-nav-bar-gap: 20px; /* between the bar and the list */
    --report-nav-track-opacity: 0.2;
}

.report-nav-sections {
    position: relative;
    padding-left: calc(var(--report-nav-bar-width) + var(--report-nav-bar-gap));
}

.report-nav-progress {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--report-nav-bar-width);
    pointer-events: none;
}

.report-nav-progress::before,
.report-nav-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: currentColor;
}

.report-nav-progress::before {
    bottom: 0;
    opacity: var(--report-nav-track-opacity);
}

.report-nav-progress::after {
    height: var(--report-nav-fill, 0%);
}

/* The list in the nav: the panel carries the list's background now, so the list itself drops it (and the padding
   WordPress adds with it) */
.report-nav-panel .wp-block-list.is-style-report-nav {
    gap: 10px;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    font-size: var(--wp--preset--font-size--medium);
    line-height: 1.25;
}

.report-nav-panel .wp-block-list.is-style-report-nav .wp-block-list {
    gap: 4px;
    margin-top: 10px !important;
    padding-right: 0 !important;
}

/* A little more room below a section's subsections, before the next section */
.report-nav-panel .wp-block-list.is-style-report-nav > li:not(:last-child) > .wp-block-list {
    margin-bottom: 10px !important;
}

/* Download buttons (inc/reports.php): outlined in the text color, filled on hover. Below the list in the side panel;
   at the bottom of the screen on wide screens (below). Without report-nav.js, below the list in the text column */
.report-nav-downloads {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--one-spacer);
}

.report-nav-panel .report-nav-downloads {
    margin-top: var(--four-spacer);
}

.report-nav-download {
    padding: 4px 10px 5px;
    border: 1px solid;
    border-radius: 5px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: var(--wp--preset--font-size--medium);
    line-height: 1.25;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Filled on hover: the text color behind, and the panel background (or the page, on wide screens) for the text */
.report-nav-download:hover,
.report-nav-download:focus-visible {
    background-color: var(--report-nav-text, var(--wp--preset--color--black));
    color: var(--report-nav-bg, var(--wp--preset--color--white));
}

/* Wide screens: the nav always shows beside the text, under the menu button, in the same place as in the open panel
   (and on smaller screens): the panel's left padding from the screen edge, just below the button. Section Heroes and
   Cover blocks pass over it (report-nav.js clips it where they are), and so do cards, images and Faded Edges sections
   (css/custom-report.css); the menu button stays on top. Opening the menu keeps the nav where it is and puts the
   List block's background behind it as a full-height panel over everything, like the panel on smaller screens */
@media screen and (min-width: 1280px) {
    .report-nav-panel {
        /* Where the nav's top is on screen: the panel's top padding, below the menu button */
        --report-nav-content-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--two-spacer) + 48px + var(--two-spacer));
        /* The panel's width less its padding, but no closer to the text column than its gap */
        --report-nav-body-width: min(var(--report-nav-panel-width) - var(--global--spacing-horizontal) - var(--two-spacer), (100vw - var(--responsive--aligndefault-width)) / 2 - var(--global--spacing-horizontal) - var(--three-spacer));
        visibility: visible;
        transform: none;
    }

    /* Closed: beside the text, sticking to the top of the screen down to the end of the report content. White with
       mix-blend-mode: difference, so it inverts whatever is behind it. It sticks at the same height as the menu button
       (the wrapper just before it, at the same place in the page), and the nav sits below the button inside it (see
       .report-nav-body), so the two stay apart before they're stuck too */
    .report-nav-panel:not(.is-open),
    .entry-content > .report-nav-panel:not(.is-open),
    .report-nav-panel.alignfull:not(.is-open) {
        --report-nav-track-opacity: 0.1;
        position: sticky;
        top: var(--report-nav-top);
        bottom: auto;
        z-index: 50;
        width: auto;
        height: 0;
        margin: 0;
        padding: 0;
        overflow: visible;
        background: none;
        color: #fff;
        mix-blend-mode: difference;
        transition: none;
    }

    /* Open: the full-height panel, as wide as the nav plus its padding, its background fading in */
    .report-nav-panel.is-open,
    .entry-content > .report-nav-panel.is-open,
    .report-nav-panel.alignfull.is-open {
        width: calc(var(--report-nav-body-width) + var(--global--spacing-horizontal) + var(--two-spacer));
        padding-bottom: var(--three-spacer); /* the nav's bottom stays where it is when closed */
        transition: none;
        animation: report-nav-reveal 0.2s ease;
    }

    /* A column the height of the screen when there are download buttons, which sit at the bottom; only the list and
       the buttons take clicks, not the space between them */
    .report-nav-body {
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        gap: var(--three-spacer);
        width: var(--report-nav-body-width);
        max-height: calc(100vh - var(--report-nav-content-top) - var(--three-spacer));
        pointer-events: none;
    }

    /* Closed: below the menu button (the button's height and the gap under it, the same as the open panel's top
       padding), --report-nav-shift slides it up with the end of the report content, and report-nav.js clips it where
       a Section Hero or Cover passes over it */
    .report-nav-panel:not(.is-open) .report-nav-body {
        position: relative;
        top: calc(48px + var(--two-spacer));
        margin-left: var(--global--spacing-horizontal);
        transform: translateY(var(--report-nav-shift, 0px));
    }

    .report-nav-panel.is-open .report-nav-body {
        clip-path: none !important;
    }

    /* The menu button slides up with the nav at the end of the report content (--report-nav-shift, report-nav.js) */
    .report-nav:not(.is-open) .report-nav-toggle {
        transform: translateY(var(--report-nav-shift, 0px));
    }

    .report-nav-panel.has-downloads .report-nav-body {
        height: calc(100vh - var(--report-nav-content-top) - var(--three-spacer));
    }

    .report-nav-sections,
    .report-nav-downloads {
        pointer-events: auto;
    }

    .report-nav-sections {
        min-height: 0;
        overflow-y: auto; /* long navs scroll */
        scrollbar-width: thin;
    }

    .report-nav-panel .report-nav-downloads {
        flex-shrink: 0;
        margin-top: auto;
    }

    /* Closed: white, for the blend (the list's own colors are for the open panel); hovered buttons fill white with
       black text, which the blend turns into the page color on the inverse of it */
    .report-nav-panel:not(.is-open) .wp-block-list.is-style-report-nav,
    .report-nav-panel:not(.is-open) .wp-block-list.is-style-report-nav a {
        color: #fff !important;
    }

    .report-nav-panel:not(.is-open) {
        --report-nav-text: #fff !important;
        --report-nav-bg: #000 !important;
    }
}

@keyframes report-nav-reveal {
    from {
        background-color: transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    .report-nav-panel.is-open {
        animation: none !important;
    }
}

@media (prefers-reduced-motion: no-preference) {
    html:has(.is-style-report-nav) {
        scroll-behavior: smooth;
    }
}

@media print {
    .report-nav,
    .report-nav-panel {
        display: none !important;
    }
}
