/*
 * Nav circle.
 *
 * The circle deliberately protrudes above the sticky bar and overlaps the band
 * behind it — that is the design. What was broken is how it was expressed: four
 * breakpoint blocks each restated a size plus two negative margins, and the
 * numbers were not self-consistent (margin-bottom exceeded the element height,
 * so it pulled following content further up than its own box, clipping page
 * content behind the bar on phones).
 *
 * Now the negative margins are *derived* from the size and a single
 * --nav-peek overlap budget, so the sum is always exactly zero: the circle
 * contributes nothing to flow and protrudes by --nav-peek, at every width.
 */
/*
 * The circle no longer carries negative margins on the front page. It used to
 * hang out of the top of the bar by 54.5% of its own height, which is what made
 * it read as an egg jammed into the bar's top edge; it is now an ordinary
 * centred grid item in the three-column hero. Inner pages position it against
 * the bar's bottom edge instead — see below.
 */
.navcircle {
    height: var(--nav-size-full);
    width: var(--nav-size-full);
    border-radius: 50%;
    margin-inline: auto;
    overflow: visible;
    /*
     * Deliberately animates the box, not a transform, even though animating
     * width/height is normally the wrong call.
     *
     * This element hosts a p5 <canvas>. p5 watches it with a ResizeObserver and
     * re-renders at the new pixel size, so growing the box keeps the slice
     * labels sharp. `transform: scale()` would resample a 260px canvas up to
     * 560px — a 2.15x blow-up of already-rasterised text, which is visibly
     * soft. The cost is a reflow of one isolated, out-of-flow element on hover
     * only; the benefit is legible navigation. Keep it this way.
     */
    transition: width 0.4s ease, height 0.4s ease, margin-top 0.4s ease;
    background-color: white;
    box-shadow: 0px 0px 60px 15px rgba(255, 255, 255, 1);
}

/*
 * Front page: the circle rides up over the top edge of the white bar and sits
 * across the boundary with the tree band.
 *
 * The negative margin is what lets it protrude while the bar's height is still
 * set by the panels either side — the circle's own height would otherwise make
 * the white band far taller than its content needs.
 *
 * The reason this reads as a disc and not as the egg it did before: a solid
 * white ring plus a soft drop shadow. Without them the lower half dissolved
 * into the white bar and only the part over the photograph had an edge, so the
 * silhouette people actually saw was the top arc closed off by the bar — an
 * egg. The ring gives it a continuous outline against both surfaces.
 */
body.home .navcircle {
    height: var(--nav-size-home);
    width: var(--nav-size-home);
    margin-top: calc(var(--nav-size-home) * -0.38);
    /*
     * A white bloom, and no dark shadow at all.
     *
     * This is what makes the circle read as part of the white bar rather than
     * an object sitting on top of it: below the boundary the bloom is white on
     * white and simply is not there, so the lower half of the disc dissolves
     * into the bar, while the upper half gets a soft halo that lifts it off the
     * photograph. A drop shadow cannot do that — it traced the full
     * circumference, including the half standing on white, which is exactly the
     * seam that made it look stuck on.
     *
     * The ring itself is this element's own white background: the pie is drawn
     * at PIE_SCALE of the box (navcircle.js), leaving (1 - PIE_SCALE) / 2 of
     * the diameter as ring — 5%, about 18px at 361px — with a single clean
     * anti-aliased edge. Change the ring there, not here. An earlier
     * attempt stacked `0 0 0 10px #fff` in front to thicken it, which painted a
     * second, separately-rasterised white circle and left a hairline seam
     * between the two.
     */
    box-shadow: 0 0 34px 14px rgba(255, 255, 255, 0.92);
}

/*
 * Inner pages: the bar is dark, so the circle's own fill and its bloom follow
 * it. Left white, the bloom showed as a pale halo hanging over the bar's top
 * edge — the "white shadow sticking into the navbar" on scroll.
 */
body:not(.home) .navcircle {
    background-color: var(--navbar-bg);
    /*
     * A soft drop shadow and a faint bloom, neither with any spread.
     *
     * This was a 24px blur with 7px of spread in the bar's own grey. On the
     * old, lighter #565d64 that passed; once the bar took the footer's
     * charcoal it drew a hard dark ring round the disc, on the photograph and
     * on the white page alike — "too aggressive", in the customer's words. The
     * dark disc already stands out on its own, so the shadow only has to
     * soften its edge.
     */
    box-shadow:
        0 3px 22px rgba(0, 0, 0, 0.26),
        0 0 40px color-mix(in srgb, var(--navbar-bg) 22%, transparent);
}

/* p5 injects a <canvas>; as an inline element it sits on the text baseline and
   adds ~6px below the circle, spilling past the round box. */
.navcircle canvas {
    display: block;
    max-width: 100%;
}

/*
 * Inner pages: smaller resting circle, pinned to the bottom of the sticky bar.
 *
 * The negative-margin trick above works only while the bar is tall enough to
 * contain the circle's downward extent. The bar is a slim strip, so the circle
 * is positioned against it instead — bottom-anchored, horizontally centred.
 * Growing on hover then happens upward and outward from a fixed bottom edge
 * for free, with no margin arithmetic to keep in sync and no effect on flow.
 */
body:not(.home) .navcircle {
    position: absolute;
    left: 50%;
    bottom: var(--nav-bottom-inset);
    transform: translateX(-50%);
    margin: 0;
    height: var(--nav-size);
    width: var(--nav-size);
}

body:not(.home) .navcircle:hover {
    height: var(--nav-size-full);
    width: var(--nav-size-full);
}

/* Hover-to-expand is unreachable with a finger and its expanded size would
   cover the page content it is sitting on. Touch devices keep the resting size. */
@media (hover: none), (pointer: coarse) {
    body:not(.home) .navcircle:hover {
        height: var(--nav-size);
        width: var(--nav-size);
    }
}

@media (prefers-reduced-motion: reduce) {
    .navcircle {
        transition: none;
    }
}
