/* The site's menu (layout/parts/nav-pill.php): a pill fixed at the top of every page.
   The full logo (wolf + wordmark), the four sections, and a red Call button.

   Folded (html.nav-compact): the logo, a round red phone and a hamburger; the four sections drop
   down in a panel under the pill. Phones and tablets (up to 1024px) are folded from the first
   paint (header.php); assets/js/nav-pill.js keeps it right as the window changes, and also folds
   it on a wider screen whenever the whole row does not fit (large text, a narrow window).
   nav-pill.js also adds .is-solid once the page scrolls and .is-open while the panel is open.

   Safari: the frosted glass is on a layer of its own (::before), not on the pill, because Safari
   draws a backdrop-filter element's children (the drop-down panel) badly; hover colours only
   apply to real pointers (on a phone a tap leaves them stuck); the button has no native look. */

:root {
    /* Where the pill sits, and how far down the page it reaches. --pill-clear is the distance from
       the top of the window to the pill's bottom edge: the page's content (main.css) and the
       homepage start below it. Logged in, WordPress' toolbar is fixed across the top, so the
       pill sits under that (--admin-bar-offset, main.css). */
    --pill-top: calc(var(--admin-bar-offset, 0px) + 14px);
    --pill-h: 56px;
    --pill-clear: calc(var(--pill-top) + var(--pill-h));
}
:root.nav-compact {
    --pill-top: calc(var(--admin-bar-offset, 0px) + 10px);
    --pill-h: 58px;
}

.pill {
    position: fixed;
    /* Over the page, under the "Skip to content" link (100000), WordPress' toolbar (99999) and
       the image viewer (a dialog, which the browser always puts on top) */
    z-index: 900;
    top: var(--pill-top);
    left: 50%;
    -webkit-transform: translateX(-50%);
            transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.15rem;
    box-sizing: border-box;
    height: var(--pill-h);
    max-width: calc(100% - 20px);
    padding: 4px 4px 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
/* The glass: see-through and blurred at the top of a page, solid once it scrolls or the menu
   is open (so nothing shows through) */
.pill::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
            backdrop-filter: blur(14px) saturate(1.4);
    box-shadow: 2px 4px 18px rgba(var(--distinct-primary-accent-color), 0.35);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    pointer-events: none;
}
.pill.is-solid::before,
.pill.is-open::before {
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 2px 4px 20px rgba(var(--distinct-primary-accent-color), 0.45);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .pill::before {
        background: rgba(255, 255, 255, 0.95);
    }
}

/* The pill's pictures are a logo and small icons: none of the theme's picture styling (style.css
   leaves out class "logo"; this is in case anything else reaches them) */
.pill img {
    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* ---------- The logo: the wolf (turned to face the name) and the wordmark ---------- */
.pill__logo {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
    height: 48px;
    margin-right: 0.6rem;
    padding-right: 0.3rem;
    border-radius: 999px;
}
.pill .pill__wolf {
    display: block;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    -webkit-transform: scaleX(-1);
            transform: scaleX(-1);
}
.pill .pill__word {
    display: block;
    flex: 0 0 auto;
    width: 122px;   /* 450 x 140 */
    height: auto;
}

/* ---------- The four sections ---------- */
/* In the row, the wrapper steps aside and the links sit in the pill's own line */
.pill__menu {
    display: contents;
}

.pill__link {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 0.4rem;
    height: 40px;
    padding: 0 0.95rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    /* The text grey, not the paler accent: small capitals need the 4.9:1 */
    color: var(--text-color, rgb(104, 114, 124));
    transition: background-color 0.2s ease, color 0.2s ease;
}
/* The icons are for the folded menu */
.pill .pill__link img {
    display: none;
    width: 22px;
    height: 22px;
}
/* The page you are in: a short red line underneath, like the site's red line */
.pill__link[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 5px;
    width: 1.1rem;
    height: 2px;
    -webkit-transform: translateX(-50%);
            transform: translateX(-50%);
    background: rgb(219, 35, 37);
    border-radius: 2px;
}

/* ---------- Call ---------- */
.pill__call {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
    height: 44px;
    margin-left: 0.35rem;
    padding: 0 1.2rem;
    border-radius: 999px;
    background: rgb(219, 35, 37);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    box-shadow: 1px 3px 10px rgba(219, 35, 37, 0.3);
    transition: background-color 0.2s ease;
}
.pill__call svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
}

/* ---------- The hamburger: only in the folded menu ---------- */
.pill__toggle {
    display: none;
}

/* Hover colours for a mouse only (a tap on a phone would leave them stuck on) */
@media (hover: hover) {
    .pill__link:hover {
        background: rgba(var(--distinct-primary-accent-color), 0.1);
        color: rgb(84, 92, 101);
    }
    .pill__call:hover {
        background: rgb(190, 28, 30);
    }
    .pill__toggle:hover {
        background: rgba(var(--distinct-primary-accent-color), 0.22);
    }
}

/* Keyboard: a clear ring around the link or button you have reached */
.pill a:focus-visible,
.pill button:focus-visible {
    outline: 2px solid var(--text-color, rgb(104, 114, 124));
    outline-offset: 2px;
}

/* No scripts and a narrow screen: the row wraps onto two lines rather than run off the screen */
@media (max-width: 1024px) {
    html:not(.js) .pill {
        flex-wrap: wrap;
        justify-content: center;
        height: auto;
        border-radius: 24px;
    }
}

/* ---------- Folded: logo, round red phone, hamburger; the sections in a panel underneath ---------- */
.nav-compact .pill {
    gap: 0.4rem;
    width: calc(100% - 20px);
    max-width: 30rem;
    padding: 4px 6px 4px 10px;
}
.nav-compact .pill__logo {
    /* the logo takes what the two buttons leave, and shrinks with the screen */
    flex: 0 1 auto;
    min-width: 0;
    gap: 0.4rem;
    margin-right: auto;
    padding-right: 0;
}
.nav-compact .pill .pill__wolf {
    width: clamp(32px, 11.5vw, 44px);
    height: clamp(32px, 11.5vw, 44px);
}
.nav-compact .pill .pill__word {
    width: clamp(84px, 31vw, 120px);
    min-width: 0;
    flex-shrink: 1;
}

.nav-compact .pill__call,
.nav-compact .pill__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
}
.nav-compact .pill__call span,
.nav-compact .pill__toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.nav-compact .pill__call svg {
    width: 19px;
    height: 19px;
}

/* The hamburger: three grey bars that turn into a cross while the menu is open */
.nav-compact .pill__toggle {
    -webkit-appearance: none;
            appearance: none;
    border: 0;
    background: rgba(var(--distinct-primary-accent-color), 0.12);
    color: var(--text-color, rgb(104, 114, 124));
    font: inherit;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background-color 0.2s ease;
}
.nav-compact .pill__toggle[aria-expanded="true"] {
    background: rgba(var(--distinct-primary-accent-color), 0.22);
}
.pill__bars {
    position: relative;
    display: block;
    width: 20px;
    height: 14px;
    pointer-events: none;
}
.pill__bars i {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.25s ease, opacity 0.2s ease, top 0.25s ease;
}
.pill__bars i:nth-child(1) { top: 0; }
.pill__bars i:nth-child(2) { top: 6px; }
.pill__bars i:nth-child(3) { top: 12px; }
.pill__toggle[aria-expanded="true"] .pill__bars i:nth-child(1) { top: 6px; -webkit-transform: rotate(45deg); transform: rotate(45deg); }
.pill__toggle[aria-expanded="true"] .pill__bars i:nth-child(2) { opacity: 0; }
.pill__toggle[aria-expanded="true"] .pill__bars i:nth-child(3) { top: 6px; -webkit-transform: rotate(-45deg); transform: rotate(-45deg); }

/* The panel under the pill: folded away until the hamburger opens it */
.nav-compact .pill__menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    border-radius: 22px;
    background: #fff;
    box-shadow: 2px 8px 28px rgba(var(--distinct-primary-accent-color), 0.45);
    visibility: hidden;
    opacity: 0;
    -webkit-transform: translateY(-8px);
            transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}
.nav-compact .pill.is-open .pill__menu {
    visibility: visible;
    opacity: 1;
    -webkit-transform: none;
            transform: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
}

.nav-compact .pill__link {
    gap: 0.9rem;
    height: 52px;
    padding: 0 1.1rem;
    border-radius: 14px;
    font-size: 0.9rem;
    -webkit-tap-highlight-color: transparent;
}
.nav-compact .pill .pill__link img {
    display: block;
    flex: 0 0 auto;
    -webkit-filter: drop-shadow(2px 3px 2px rgba(var(--distinct-primary-accent-color), 0.395));
            filter: drop-shadow(2px 3px 2px rgba(var(--distinct-primary-accent-color), 0.395));
}
/* The page you are in: the red line stands at the row's left */
.nav-compact .pill__link[aria-current="page"] {
    background: rgba(var(--distinct-primary-accent-color), 0.08);
    color: rgb(84, 92, 101);
}
.nav-compact .pill__link[aria-current="page"]::after {
    left: 0;
    top: 50%;
    bottom: auto;
    width: 3px;
    height: 1.4rem;
    -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
}

/* The narrowest phones (320px and under): slimmer gaps and buttons */
@media (max-width: 360px) {
    .nav-compact .pill {
        gap: 0.3rem;
        padding: 4px 5px 4px 8px;
    }
    .nav-compact .pill__logo {
        gap: 0.3rem;
    }
    .nav-compact .pill__call,
    .nav-compact .pill__toggle {
        width: 42px;
        height: 42px;
    }
}

/* High contrast colours: the user's own colours replace the pill's, so it gets an outline to
   keep its shape, and the red line under the current section is drawn in the highlight colour */
@media (forced-colors: active) {
    .pill,
    .nav-compact .pill__menu {
        border: 1px solid CanvasText;
        background: Canvas;
    }
    .pill::before {
        display: none;
    }
    .pill__call,
    .pill__toggle {
        border: 1px solid ButtonText;
    }
    .pill__link[aria-current="page"]::after {
        background: Highlight;
    }
}

/* No fading for people who ask their device for less motion */
@media (prefers-reduced-motion: reduce) {
    .pill::before,
    .pill__link,
    .pill__call,
    .pill__toggle,
    .pill__menu,
    .pill__bars i {
        transition: none !important;
    }
}

/* Paper: the menu is no use there */
@media print {
    .pill {
        display: none !important;
    }
}
