@import url("fonts.css");
@import url("reset.css") layer(reset);

/* Cascade layers: the order below decides who wins a clash, later beats earlier,
   whatever the selector's specificity. reset < base < components < utilities */

@layer reset, base, components, utilities;

@media (prefers-reduced-motion: no-preference) {
    @view-transition { /* cross-fade between pages, CSS only; switched off with reduced motion */
        navigation: auto;
    }
}

@layer base { /* tokens and bare elements: no classes */
    /* Root variables: mobile values first, the breakpoints at the end only change tokens and placement */

    :root {
        /* colors: paper and brand, every tint is mixed from them */
        --bg: #f6f4ef;
        --fg: #4406fd;
        --blend: #fff;
        --soft: color-mix(in oklab, var(--fg) 82%, var(--bg)); /* secondary text, still 4.5:1 on paper */
        --rule: color-mix(in oklab, var(--fg) 20%, transparent);
        --tint: color-mix(in oklab, var(--fg) 6%, transparent);
        --spy: #b2ee00; /* difference-blended over --bg this reads as --fg, so the nav oval looks blue */
        --error: #b2ee00; /* lime: clear on the blue form, contrast over 6:1 */
        --blended: #090b10; /* what white in difference turns into over --bg: the header's real colour on pages with no video */
        --fill: var(--fg); /* selected or hovered fill (buttons, choices); blue boxes flip the pair */
        --on-fill: var(--bg);

        /* motion: every duration and curve */
        --dur-fast: 0.15s;
        --dur: 0.3s;
        --dur-slow: 0.5s;
        --dur-draw: 0.9s;
        --curve: ease;
        --curve-in: ease-in;
        --curve-out: ease-out;
        --curve-in-out: ease-in-out; /* symmetric: halfway in time is halfway in movement */
        --curve-scroll: linear; /* scroll-linked: progress must follow the scroll exactly */

        /* grid */
        --cols: 2;
        --gap: 1rem;

        /* spacing, always a multiple of the gap */
        --space-xs: calc(var(--gap) / 4);
        --space-sm: calc(var(--gap) / 2);
        --space-xl: calc(var(--gap) * 7); /* clears the bigger mobile logo */

        /* font families */
        --sans: "Instrument Sans", system-ui, sans-serif;
        --serif: "Instrument Serif", Georgia, serif;
        --mono: ui-monospace, "SF Mono", Menlo, monospace;

        /* font sizes */
        --text-xs: 0.75rem;
        --text-sm: 0.875rem;
        --text-base: 1rem;
        --text-lg: 1.25rem;
        --text-xl: 1.5rem;
        --text-2xl: 2rem;

        /* display sizes, fluid */
        --display-sm: clamp(2rem, 5vw, 4rem);
        --display-md: clamp(3rem, 15vw, 5rem); /* page and section titles grow with the screen width */
    }

    /* Global styles: elements only */

    html {
        font-synthesis: none;
    }

    @media (prefers-reduced-motion: no-preference) {
        html { scroll-behavior: smooth; }
    }

    ::selection {
        background-color: var(--fg);
        color: var(--bg);
    }

    body { /* a column at least as tall as the screen: main takes the spare height, so the footer always ends at the bottom */
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
        background-color: var(--bg);
        color: var(--fg);
        font-family: var(--sans);
        font-size: var(--text-base);
        line-height: 1.4;
    }

    a {
        color: inherit;
        text-decoration-line: underline; /* always there, so hover can fade it in; longhands because Safari drops the shorthand */
        text-decoration-color: transparent;
        text-underline-offset: 0.1em;
    }

    a,
    button,
    summary,
    dt,
    dd {
        transition: color var(--dur) var(--curve), background-color var(--dur) var(--curve), box-shadow var(--dur) var(--curve), text-decoration-color var(--dur) var(--curve);
    }

    @media (hover: hover) {
        a:hover {
            text-decoration-color: currentColor;
        }
    }

    a,
    button,
    summary,
    select,
    [type="checkbox"],
    [type="radio"],
    [type="checkbox"] + label,
    [type="radio"] + label { /* everything you can click shows the hand */
        cursor: pointer;
    }

    :focus-visible { /* keyboard focus always shows, in the colour of the text it sits on */
        outline: 2px solid currentColor;
        outline-offset: 3px;
    }

    main {
        flex: 1; /* fills the spare height on short pages; long pages just push the footer down */
    }

    ul,
    ol {
        padding: 0;
        list-style: none;
    }

    img {
        height: auto;
    }

    em,
    blockquote {
        font-family: var(--serif);
        font-style: italic;
    }

    h1,
    h2 {
        font-size: var(--display-md);
        font-weight: 400;
        line-height: 0.9;
        letter-spacing: -0.03em;
    }

    h3 {
        font-size: var(--text-2xl);
        font-weight: 400;
        letter-spacing: -0.02em;
    }

    figure {
        display: grid;
        gap: var(--space-sm);
    }

    option {
        color: var(--fg); /* the dropdown list is the system's white, not the form's blue */
    }
}

@layer components { /* every named block, with its breakpoints */
    /* Labels: one mono, uppercase voice for every bit of meta */

    small,
    .price-list dd,
    .pills,
    .plan__perks,
    .legal-nav,
    .form__legend,
    .choices__pill,
    .product-card__price,
    .site-header__street,
    .site-footer__address {
        font-family: var(--mono);
        font-size: var(--text-xs);
        font-style: normal;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    /* Shared components */

    .note { /* a note at the top of a list reads as secondary */
        color: var(--soft);
        font-family: var(--serif);
        font-size: var(--text-lg);
        font-style: italic;
    }

    .button { /* the oval call to action; --fill flips on blue boxes */
        justify-self: start;
        display: inline-block;
        padding: 0.35em 0.75em; /* in em, so the oval grows with the text */
        border: 1px solid currentColor;
        border-radius: 50%;
        background: none;
        color: inherit;
        font-family: var(--serif);
        font-size: max(1.2rem, calc(var(--display-sm) * 0.56)); /* in step with the spec titles (Weight, Grind…), a step below them */
        font-style: italic;
        text-decoration: none;
        cursor: pointer;
    }

    @media (hover: hover) {
        .button:hover {
            background-color: var(--fill);
            color: var(--on-fill);
        }
    }

    .pills {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-xs);
    }

    .pills li {
        padding: var(--space-xs) var(--space-sm);
        border: 1px solid currentColor;
        border-radius: 999px; /* pill: always fully round, whatever the text length */
    }

    /* Price lists: a rule between rows, never above the first one */

    .price-list {
        display: grid;
        grid-template-columns: 1fr auto;
    }

    .price-list dt,
    .price-list dd {
        padding-block: var(--space-sm);
    }

    .price-list dt ~ dt,
    .price-list dt ~ dt + dd { /* every row but the first: the section or summary above already draws that line */
        border-top: 1px solid var(--rule);
    }

    .price-list dd {
        padding-left: var(--gap); /* gap lives here so the rule under each row stays unbroken */
        text-align: right;
    }

    .extras {
        padding-top: var(--space-sm);
    }

    /* Rows and accordion heads: a faint tint on hover. The shadow pushes it past the text edge without moving the layout */

    @media (hover: hover) {
        .price-list dt:hover,
        .price-list dt:has(+ dd:hover) {
            background-color: var(--tint);
            box-shadow: calc(var(--space-sm) * -1) 0 var(--tint);
        }

        .price-list dd:hover,
        .price-list dt:hover + dd {
            background-color: var(--tint);
            box-shadow: var(--space-sm) 0 var(--tint);
        }

        .accordion[open] .accordion__head:hover,
        .accordion:not([open]):has(.accordion__head:hover) { /* closed: tint the whole item, so it meets the next line with no gap */
            background-color: var(--tint);
            box-shadow: var(--space-sm) 0 var(--tint), calc(var(--space-sm) * -1) 0 var(--tint);
        }
    }

    /* Accordion */

    .accordion + .accordion { /* a line between every two accordions, open or closed; never above the first, the section already draws one */
        border-top: 1px solid var(--rule);
    }

    .accordion__head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-block: var(--space-sm);
        list-style: none;
        cursor: pointer;
    }

    .accordion__head::-webkit-details-marker {
        display: none;
    }

    .accordion__head::after {
        content: "+";
        font-family: var(--mono);
    }

    .accordion[open] .accordion__head::after {
        content: "–";
    }

    .accordion__title {
        font-family: var(--serif);
        font-size: var(--display-sm);
        font-style: italic;
        line-height: 1;
        letter-spacing: -0.01em;
    }

    .accordion > :last-child { /* allowed: list rhythm inside a component. Whatever ends the open panel gets the air before the next line */
        padding-bottom: var(--gap);
    }

    .product .accordion p + .price-list { /* brewing note above its recipe */
        margin-top: var(--gap);
    }

    @media (prefers-reduced-motion: no-preference) {
        .accordion[open] > :not(.accordion__head) { /* only matches once open, so the fade replays on every opening */
            animation: reveal var(--dur-slow) var(--curve);
        }

        @supports (interpolate-size: allow-keywords) { /* Safari can't animate to auto height yet, it gets the fade alone */
            :root {
                interpolate-size: allow-keywords;
            }

            .accordion::details-content {
                block-size: 0;
                overflow: clip;
                transition: block-size var(--dur-slow) var(--curve), content-visibility var(--dur-slow) allow-discrete;
            }

            .accordion[open]::details-content {
                block-size: auto;
            }
        }
    }

    @keyframes reveal {
        from {
            opacity: 0;
            translate: 0 calc(var(--space-sm) * -1);
        }
    }

    /* Category photos, shared by the homepage accordion and the full menu page */

    .photo-coffee { --img: url("../Images/products/Kona_19.webp"); --tilt: -3deg; }
    .photo-bakery { --img: url("../Images/products/Kona_34.webp"); --tilt: 2deg; }
    .photo-toast { --img: url("../Images/products/Kona_27.webp"); --tilt: -2deg; }
    .photo-specials { --img: url("../Images/products/Kona_17.webp"); --tilt: 3deg; }
    .photo-brunch { --img: url("../Images/products/Kona_20.webp"); --tilt: -4deg; }
    .photo-drinks { --img: url("../Images/shop/Kona_16.webp"); --tilt: 2deg; --zoom: 400%; --focus: 64% 90%; } /* zoomed onto the cup of tea in the table shot */
    .photo-extras { --img: url("../Images/products/Kona_28.webp"); --tilt: -2deg; }

    /* Header: each piece is fixed on its own so the blend reaches the page below */

    .site-header__logo,
    .site-nav,
    .site-header__contact,
    .site-header__toggle {
        position: fixed;
        top: var(--gap);
        z-index: 10;
    }

    .site-header__logo {
        left: var(--gap);
        mix-blend-mode: difference;
    }

    .site-header__logo img {
        width: 5rem;
        filter: brightness(0) invert(1); /* white, so difference inverts it against whatever is behind */
    }

    .site-nav,
    .site-header__contact,
    .site-header__street,
    .site-header__toggle--close {
        display: none; /* mobile: nav and contact live in the menu panel */
    }

    @media (hover: hover) {
        .site-header__logo:hover,
        .site-header__toggle:hover {
            opacity: 0.6;
        }
    }

    .site-header__logo,
    .site-header__toggle {
        transition: opacity var(--dur) var(--curve);
    }

    .site-header__toggle--open {
        right: var(--gap);
        width: 4rem;
        color: var(--blend);
        mix-blend-mode: difference;
    }

    .site-nav__list {
        display: flex;
        gap: var(--gap);
    }

    /* Language switch, EN | ES: after the links and set apart, a setting rather than a page.
       Hidden until scripts/lang.js runs (it adds .has-lang), since without it the buttons do nothing */

    .site-nav__lang {
        display: none;
    }

    .has-lang .site-nav__lang {
        display: block;
    }

    .lang-switch {
        display: flex;
        gap: var(--space-sm);
        font-family: var(--mono);
        font-size: var(--text-sm);
        letter-spacing: 0.04em;
    }

    .lang-switch__button {
        padding: 0;
        border: 0;
        background: none;
        color: inherit;
        font: inherit;
        opacity: 0.7;
        transition: opacity var(--dur) var(--curve);
    }

    .lang-switch__button + .lang-switch__button {
        padding-left: var(--space-sm);
        border-left: 1px solid currentColor; /* the vertical line between EN and ES */
    }

    .lang-switch__button[aria-pressed="true"] {
        opacity: 1;
        text-decoration: underline;
        text-underline-offset: 0.25em;
    }

    @media (hover: hover) {
        .lang-switch__button:hover {
            opacity: 1;
        }
    }

    /* Header start position (tablet and desktop): at the very top the logo and the email/Instagram links sit 24px further in,
       then slide to their place over the first 120px of scroll. Scroll-linked, CSS only */

    @media (min-width: 48rem) and (prefers-reduced-motion: no-preference) { /* tablet and desktop only: phones keep the header still */
        @supports (animation-timeline: scroll()) {
            .site-header__logo,
            .site-header__contact {
                animation: var(--settle) var(--curve-scroll) both;
                animation-timeline: scroll(root);
                animation-range: 0 calc(var(--gap) * 5);
            }

            .site-header__logo { --settle: settle-left; }
            .site-header__contact { --settle: settle-right; }
        }
    }

    @keyframes settle-left {
        from { translate: 1.5rem 1.5rem; } /* 24px in from the left and the top */
    }

    @keyframes settle-right {
        from { translate: -1.5rem 1.5rem; } /* 24px in from the right and the top */
    }

    /* Hand-drawn oval: marks the current page, drawn as a stroke whose tail overshoots its start */

    .site-nav__link,
    .hero__link {
        position: relative;
        isolation: isolate; /* lets the oval sit behind the text without dropping behind the page */
        display: inline-block; /* gives the oval a real box to size against */
        white-space: nowrap; /* one line, or the oval turns into a circle */
    }

    .oval {
        position: absolute;
        top: -0.6em;
        left: -1em;
        z-index: -1;
        width: calc(100% + 2em);
        height: calc(100% + 1.2em);
        max-width: none; /* the reset caps svg at 100% */
        overflow: visible;
        fill: none;
        stroke: var(--fg);
        stroke-width: 1.5;
        stroke-linecap: round;
        stroke-dasharray: 1 2; /* pathLength="1", so 1 is the whole loop; the long gap keeps it hidden even when a wide link makes the browser measure the loop a little long */
        stroke-dashoffset: 1;
        pointer-events: none;
    }

    body:has(.hero) .site-nav .oval {
        stroke: var(--spy); /* difference-blended, lime reads as blue */
    }

    .oval path {
        vector-effect: non-scaling-stroke;
    }

    .oval--static { /* always fully drawn; the dash trick is mis-measured on wide ovals */
        stroke: currentColor;
        stroke-width: 2;
        stroke-dasharray: none;
    }

    /* On the homepage the oval follows the section in view, scroll-driven, no script */

    .site-nav__link[aria-current] .oval { /* current page: drawn, still when motion is reduced */
        stroke-dashoffset: 0;
    }

    @media (prefers-reduced-motion: no-preference) {
        @supports (animation-timeline: view()) {
            body {
                timeline-scope: --menu, --products, --about, --contact;
            }

            .menu { view-timeline-name: --menu; }
            .products { view-timeline-name: --products; }
            .about { view-timeline-name: --about; }
            .contact { view-timeline-name: --contact; }

            .site-nav .oval {
                animation: spy var(--curve-scroll);
                animation-range: entry 50% exit 50%; /* drawn while the section crosses the middle of the screen */
            }

            .site-nav__link--menu .oval { animation-timeline: --menu; }
            .site-nav__link--products .oval { animation-timeline: --products; }
            .site-nav__link--about .oval { animation-timeline: --about; }
            .site-nav__link--contact .oval { animation-timeline: --contact; }
        }

        .site-nav__link[aria-current] .oval { /* after the block above so it wins on the menu and product pages */
            animation: draw var(--dur-draw) var(--dur-fast) var(--curve-out) backwards;
        }
    }

    @keyframes draw {
        from { stroke-dashoffset: 1; }
    }

    @keyframes spy { /* scroll-linked: draws in, holds, rubs out as the section leaves */
        0%, 100% { stroke-dashoffset: 1; }
        12%, 88% { stroke-dashoffset: 0; }
    }

    /* Section scaffolding, shared by every band of every page */

    .section {
        display: grid;
        grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); /* minmax(0) so a long word can never widen the page */
        gap: var(--gap);
        align-content: start;
        padding: var(--space-xl) var(--gap); /* same space above and below every section, the hero sets its own */
    }

    .section + .section {
        border-top: 1px solid var(--rule);
    }

    .section__head {
        grid-column: 1 / -1;
    }

    .section__lead {
        max-width: 60ch; /* long enough that an intro line reads as one sentence, not a narrow column */
        margin-top: var(--gap);
        font-size: var(--text-lg);
        letter-spacing: -0.02em;
    }

    /* Spec: a titled row inside a section, title in the first column, content beside it */

    .spec {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: subgrid;
        padding-top: var(--space-sm);
        border-top: 1px solid var(--rule);
    }

    .spec > * {
        grid-column: 1 / -1;
    }

    .spec__title {
        font-family: var(--serif);
        font-size: var(--display-sm);
        font-style: italic;
        line-height: 1;
        letter-spacing: -0.01em;
    }

    .spec--text > :not(.spec__title) + * { /* running text: paragraphs and lists stacked with air between */
        margin-top: var(--gap);
    }

    .spec .extras { /* extras line under a price list, 24px on every screen */
        padding-top: 1.5rem;
    }

    /* Full pages (menu, privacy, legal): titles sit on top of their list on mobile */

    .page {
        padding-top: calc(var(--space-xl) + 2rem); /* starts 32px lower than the other sections */
    }

    .page .spec__title {
        padding-bottom: 1rem;
    }

    .spec--photo::before { /* small photo on the right, centred on the title row */
        content: "";
        grid-area: 1 / 1 / 2 / -1;
        justify-self: end;
        align-self: center;
        width: 6rem;
        aspect-ratio: 4 / 5;
        margin-block: var(--gap); /* even above and below so it stays centred, and the shadow clears the list */
        background: var(--img) var(--focus, center) / var(--zoom, cover);
        box-shadow: 0 1rem 2rem color-mix(in oklab, var(--fg) 25%, transparent);
        rotate: var(--tilt);
    }

    .spec--photo .spec__title {
        grid-row: 1;
        align-self: end; /* title sits on the photo's bottom edge */
    }

    /* Hero */

    .hero {
        min-height: 100dvh;
        grid-template-rows: 1fr auto 1fr; /* headline centred, the menu link keeps to the bottom */
        gap: 0;
        padding: var(--gap); /* paper frame around the video */
        color: var(--blend);
        text-align: center;
    }

    .hero__video {
        grid-area: 1 / 1 / -1 / -1;
        width: 100%;
        height: calc(100dvh - var(--gap) * 2);
        object-fit: cover;
        filter: brightness(0.75); /* keeps white type readable on bright frames */
    }

    @media (prefers-reduced-motion: reduce) {
        .hero { /* the poster frame, still, in place of the moving video */
            background: url("../Images/products/Kona_24.webp") center / cover content-box;
        }

        .hero__video {
            display: none;
        }
    }

    .hero::after { /* dark at the top, so the white blended header stays readable over light frames */
        content: "";
        position: relative;
        z-index: 1;
        grid-area: 1 / 1 / -1 / -1;
        background: linear-gradient(to bottom, rgb(0 0 0 / 0.8), rgb(0 0 0 / 0.4) 12%, rgb(0 0 0 / 0) 30%); /* near black under the nav: white in difference only stays white over dark */
        pointer-events: none;
    }

    .hero__head,
    .hero__cta {
        position: relative;
        z-index: 2; /* above the video's filter and the shade */
    }

    .hero__head {
        grid-area: 2 / 1 / 3 / -1;
        padding: var(--gap);
    }

    .hero__lead {
        margin-inline: auto; /* the lead has a max width, so centre the box too */
    }

    .hero__cta {
        grid-area: 3 / 1 / 4 / -1;
        align-self: end;
        justify-self: center;
        padding: 0 calc(var(--gap) * 2) calc(var(--gap) * 1.5); /* room for the oval inside the video */
        font-size: var(--text-xl);
    }

    /* Page transition: every page cross-fades the same way, no element morphs on its own */

    ::view-transition-group(*) {
        animation-duration: var(--dur-slow);
        animation-timing-function: var(--curve);
    }

    /* Paisano coffee: one row of cards that scrolls sideways */

    .product-row {
        grid-column: 1 / -1;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 70%;
        gap: var(--gap);
        margin-inline: calc(var(--gap) * -1); /* bleeds to the page edge */
        padding: 0 var(--gap) var(--gap);
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: var(--gap);
        scrollbar-width: thin;
        scrollbar-color: var(--rule) transparent;
    }

    .product-card {
        position: relative;
        display: grid;
        align-content: start;
        scroll-snap-align: start;
    }

    .product-card__img,
    .product-card::before,
    .product-card::after {
        grid-area: 1 / 1; /* overlay and arrow sit on the photo, the text flows below */
    }

    .product-card__img {
        width: 100%;
        aspect-ratio: 4 / 5;
        object-fit: cover;
    }

    .product-card::before {
        content: "";
        background-color: var(--fg);
        opacity: 0;
        transition: opacity var(--dur) var(--curve);
    }

    .product-card::after {
        content: "↗";
        align-self: start;
        justify-self: end;
        padding: var(--space-sm);
        color: var(--bg);
        font-size: var(--text-2xl);
        line-height: 1;
        opacity: 0;
        transition: opacity var(--dur) var(--curve);
    }

    @media (prefers-reduced-motion: no-preference) {
        .product-card::after { /* slides in from the corner; with reduced motion it only fades */
            translate: calc(var(--space-sm) * -1) var(--space-sm);
            transition: opacity var(--dur) var(--curve), translate var(--dur) var(--curve);
        }
    }

    .product-card:has(.product-card__link:focus-visible)::before {
        opacity: 0.25;
    }

    .product-card:has(.product-card__link:focus-visible)::after {
        opacity: 1;
        translate: 0 0;
    }

    @media (hover: hover) {
        .product-card:hover::before {
            opacity: 0.25;
        }

        .product-card:hover::after {
            opacity: 1;
            translate: 0 0;
        }
    }

    .product-card__title {
        margin-top: var(--space-sm);
        font-size: var(--text-lg);
    }

    .product-card__link {
        text-decoration-color: currentColor;
    }

    .product-card__link::after { /* stretches the title link over the whole card, photo included */
        content: "";
        position: absolute;
        inset: 0;
    }

    .product-card__notes {
        margin-top: var(--space-xs);
        color: var(--soft);
        font-size: var(--text-sm);
    }

    .product-card__price {
        margin-top: var(--space-xs);
        font-size: calc(var(--text-xl) * 0.75);
    }

    /* Menu accordion on the homepage */

    .menu {
        row-gap: 0;
    }

    .menu__head {
        padding-bottom: 2.5rem;
    }

    .menu__list { /* its own column, so the tall title beside it can't stretch the first accordion */
        grid-column: 1 / -1;
    }

    .menu__item {
        scroll-margin-top: var(--space-xl); /* where an opened category lands (scripts/menu.js): clear of the header, level with the sticky title */
    }

    .menu__item .accordion__head {
        padding-block: 2.5rem 1rem;
    }

    .menu__item .accordion__head + * { /* first thing under the title: 16px air on mobile, 24px on desktop */
        padding-top: 1rem;
    }

    .menu__item[open] .accordion__head { /* the open category keeps its hover tint, on touch screens too */
        background-color: var(--tint);
        box-shadow: var(--space-sm) 0 var(--tint), calc(var(--space-sm) * -1) 0 var(--tint);
    }

    .menu__extras {
        padding-top: var(--gap);
    }

    /* Loyalty cards: three plans, the featured one in brand blue */

    .plans__list {
        grid-column: 1 / -1;
        display: grid;
        gap: var(--gap);
    }

    .plan { /* a card that flips over: front with the offer, back with its stamp card. CSS only, a checkbox holds the state */
        --face: var(--bg);
        --face-back: color-mix(in oklab, var(--fg) 8%, var(--bg)); /* the stamp side: very light blue */
        --flip-time: calc(var(--dur-slow) / 2); /* hover tilt and flip, 0.25s */
        display: grid;
        perspective: 60rem;
        cursor: pointer; /* on the box that never tilts too, so the hand shows even where Safari misses the 3D layer */
    }

    .plan--featured {
        --face: var(--fg);
        --face-back: var(--fg); /* stays brand blue on both sides */
        --rule: color-mix(in oklab, var(--bg) 30%, transparent);
        --fill: var(--bg);
        --on-fill: var(--fg);
        color: var(--bg);
    }

    .plan__toggle { /* hidden but focusable: the "See the stamps" labels are the control */
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .plan__inner {
        display: grid;
        transform-style: preserve-3d;
        transform: rotateY(calc(var(--flip, 0deg) + var(--peek, 0deg)));
    }

    .plan__toggle:checked + .plan__inner {
        --flip: 180deg;
    }

    .plan__face {
        position: relative; /* the flip label stretches over the whole side */
        cursor: pointer; /* a click anywhere flips the card */
        grid-area: 1 / 1; /* front and back stacked, the card is as tall as the taller one */
        display: flex;
        flex-direction: column;
        gap: calc(var(--gap) * 0.75); /* a little tighter than other cards: the whole card is a fifth shorter */
        padding: var(--gap);
        border: 1px solid var(--rule);
        background-color: var(--face);
        transition: border-color var(--dur) var(--curve);
    }

    .plan--featured .plan__face {
        border-color: var(--fg);
    }

    .plan__back {
        --face: var(--face-back);
        visibility: hidden; /* only the side facing you is drawn, clickable and read out; works in every browser, unlike backface-visibility */
        transform: rotateY(180deg);
    }

    .plan__toggle:checked + .plan__inner .plan__front {
        visibility: hidden;
    }

    .plan__toggle:checked + .plan__inner .plan__back {
        visibility: visible;
    }

    .plan__back > *,
    .plan__toggle:checked + .plan__inner .plan__front > * {
        opacity: 0; /* the content of the side turning away */
    }

    .plan__toggle:checked + .plan__inner .plan__back > * {
        opacity: 1;
    }

    @media (hover: hover) {
        .plan:hover .plan__face {
            border-color: currentColor;
        }
    }

    @media (prefers-reduced-motion: no-preference) {
        .plan__inner {
            transition: transform var(--flip-time) var(--curve-in-out); /* edge-on exactly halfway, when the sides swap */
        }

        .plan__face { /* the sides swap halfway, when the card is edge-on */
            transition: border-color var(--dur) var(--curve), visibility 0s calc(var(--flip-time) / 2);
        }

        .plan__face > * { /* the side turning away fades its content out at once... */
            transition: opacity calc(var(--flip-time) * 0.4) var(--curve-out);
        }

        .plan__front > *,
        .plan__toggle:checked + .plan__inner .plan__back > * { /* ...and the side turning in fades in once it faces you */
            transition: opacity calc(var(--flip-time) * 0.4) var(--curve-in) calc(var(--flip-time) / 2);
        }

        .plan__toggle:checked + .plan__inner .plan__front > * {
            transition-delay: 0s;
        }

        @media (hover: hover) {
            .plan:hover .plan__inner {
                --peek: -8deg; /* a small turn on hover says the card can flip */
            }
        }
    }

    .plan__name {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        font-size: var(--text-2xl);
        letter-spacing: -0.02em;
    }

    .plan__price data {
        font-family: var(--serif);
        font-size: var(--display-sm);
        font-style: italic;
    }

    .plan__perks li {
        padding-block: var(--space-sm);
        border-top: 1px solid var(--rule);
    }

    .plan__cta { /* the button sits at the bottom, whatever the list length */
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-sm) var(--gap);
        margin-top: auto;
    }

    .plan__flip::after { /* a click anywhere on the card flips it */
        content: "";
        position: absolute;
        inset: 0;
    }

    .plan__cta .button {
        position: relative;
        z-index: 1; /* stays above the stretched flip area, so "Get the card" still works */
    }

    .plan__flip { /* only an icon: ↻ to turn the card, ← to turn it back. The checkbox's aria-label says what it does */
        font-size: var(--text-xl);
        line-height: 1;
        cursor: pointer;
    }

    .plan__flip span {
        display: inline-block; /* so it can turn */
    }

    @media (hover: hover) and (prefers-reduced-motion: no-preference) {
        .plan:hover .plan__flip span { /* one full, quick turn as the pointer arrives */
            rotate: 360deg;
            transition: rotate var(--dur-slow) var(--curve-out);
        }
    }

    .plan__toggle:focus-visible + .plan__inner .plan__flip { /* the checkbox is invisible, so its labels show the focus */
        outline: 2px solid currentColor;
        outline-offset: 3px;
    }

    /* Stamp card on the back: a ring per coffee, inked with the KONA logo (a coffee bean for the Bean club) */

    .plan__stamps { /* the space the rings can use: everything the back has left */
        flex: 1;
        min-height: 0;
        container-type: size; /* the back never grows taller than the front because of its rings */
    }

    .stamps { /* rings as big as both the width and the height allow, spread across the width */
        --stamp-cols: 5;
        --stamp-rows: 2;
        display: grid;
        grid-template-columns: repeat(var(--stamp-cols), auto);
        justify-content: space-between;
        align-content: center;
        gap: var(--space-sm);
        height: 100%;
    }

    .stamps--twenty {
        --stamp-rows: 4;
    }

    .stamps--months {
        --stamp-cols: 4;
        --stamp-rows: 3;
    }

    @container (orientation: portrait) { /* a narrow card: fewer columns, more rows */
        .stamps {
            --stamp-cols: 3;
            --stamp-rows: 4;
        }

        .stamps--twenty {
            --stamp-cols: 4;
            --stamp-rows: 5;
        }

        .stamps--months {
            --stamp-cols: 3;
            --stamp-rows: 4;
        }
    }

    .stamp {
        --ring: min(
            (100cqh - (var(--stamp-rows) - 1) * var(--space-sm)) / var(--stamp-rows),
            (100cqw - (var(--stamp-cols) - 1) * var(--space-sm)) / var(--stamp-cols)
        );
        position: relative;
        width: var(--ring);
        display: grid;
        place-content: center; /* Safari sizes the row to the text, so centre the row as well as the item */
        place-items: center;
        aspect-ratio: 1;
        border: 1px dashed var(--rule);
        border-radius: 50%;
        font-family: var(--mono);
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .stamp--done { /* double inked ring, like a rubber stamp */
        border: 2px solid currentColor;
        box-shadow: inset 0 0 0 3px var(--face), inset 0 0 0 4px currentColor;
    }

    .stamp--done::after { /* the ink: the logo, slightly tilted and not quite solid */
        content: "";
        position: absolute;
        inset: 22%;
        background-color: currentColor;
        mask: url("../Images/KONA%20LOGO.svg") center / contain no-repeat;
        opacity: 0.85;
        rotate: var(--ink-tilt, -8deg);
    }

    .stamp span { /* the month, centred in its ring, sized with it */
        font-size: max(0.625rem, var(--ring) * 0.18);
        line-height: 1;
    }

    .stamps--months .stamp--done span {
        opacity: 0.35; /* the month stays readable under the bean */
    }

    .stamps--months .stamp--done::after {
        inset: 18%;
        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg transform='rotate(-30 12 12)'%3E%3Cpath d='M11.2 2C6.4 2.4 5 7.6 5 12s1.6 9.6 6.2 10c-2-3.6 1.6-6.4 0-10s-2.2-6.4 0-10z'/%3E%3Cpath d='M12.8 2c2.2 3.6-1.6 6.4 0 10s2.2 6.4 0 10C17.4 21.6 19 16.4 19 12s-1.4-9.6-6.2-10z'/%3E%3C/g%3E%3C/svg%3E");
    }

    .stamp:nth-child(3n + 2) { --ink-tilt: 11deg; } /* allowed: each stamp lands at its own angle */
    .stamp:nth-child(3n + 3) { --ink-tilt: -17deg; } /* allowed: same */

    @media (prefers-reduced-motion: no-preference) {
        .plan__toggle:checked + .plan__inner .stamp--done::after { /* each stamp thumps down in turn as the card turns over */
            animation: stamp var(--dur) var(--curve-out) backwards;
            animation-delay: calc(var(--flip-time) + var(--i, 0) * var(--dur-fast) / 2);
        }

        .stamp:nth-child(2) { --i: 1; } /* allowed: the order the stamps land in */
        .stamp:nth-child(3) { --i: 2; } /* allowed: same */
        .stamp:nth-child(4) { --i: 3; } /* allowed: same */
        .stamp:nth-child(5) { --i: 4; } /* allowed: same */
        .stamp:nth-child(6) { --i: 5; } /* allowed: same */
        .stamp:nth-child(n + 7) { --i: 6; } /* allowed: the rest land together at the end */
    }

    @keyframes stamp {
        from {
            opacity: 0;
            scale: 1.8;
        }
    }

    /* Testimonials: a row of quotes that drifts sideways (.marquee), and a link to leave a Google review */

    .reviews {
        padding-bottom: 1.5rem; /* only here: 24px under the cards, so the row sits anchored on the line below */
    }

    .review {
        align-items: start;
        align-content: start;
        gap: var(--space-sm) var(--gap);
    }

    .marquee__item:nth-child(even) .review__photo { rotate: 2deg; } /* allowed: alternating tilt inside one component */

    /* The row bleeds to both screen edges. Without JavaScript it is a plain sideways scroll;
       scripts/marquee.js adds .marquee--live, copies the cards once for a seamless loop and drifts it */

    .marquee {
        grid-column: 1 / -1;
        margin-inline: calc(var(--gap) * -1);
        padding: var(--gap) var(--gap) 2px; /* room above for the tilted photos; 2px below so the scroll box never clips the name pills */
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    .marquee__track {
        display: flex;
        width: max-content;
    }

    .marquee__item { /* the row stretches every card to the tallest one */
        display: flex;
        width: clamp(21.5rem, 38vw, 32rem); /* about 35% wider than a third of the screen */
        padding-inline: calc(var(--gap) + 1rem) var(--gap); /* 16px more air after the line */
        border-left: 1px solid var(--rule);
    }

    .marquee .review {
        flex: 1;
        grid-template-rows: auto auto 1fr; /* photo, quote, then the rest of the height for the name */
    }

    .marquee .review__by {
        align-self: end; /* names and descriptions all on one baseline, whatever the quote's length */
    }

    .marquee--live {
        scrollbar-width: none; /* it moves by itself and by hand, the bar would only flicker */
        cursor: grab;
    }

    .marquee--live::-webkit-scrollbar {
        display: none;
    }

    .marquee.is-dragging {
        cursor: grabbing;
        user-select: none;
    }

    .marquee img {
        -webkit-user-drag: none; /* dragging moves the row, not a ghost of the photo */
    }

    .review__photo { /* the avatar: tilted with a soft shadow, like the menu photos, always on */
        width: 6rem;
        margin-bottom: var(--space-sm); /* the shadow clears the quote */
        aspect-ratio: 4 / 5;
        object-fit: cover;
        box-shadow: 0 0.75rem 1.5rem color-mix(in oklab, var(--fg) 25%, transparent);
        rotate: -3deg;
    }

    .review__quote {
        font-size: var(--text-2xl); /* a narrow card, so a step down from the display size */
        line-height: 1.1;
    }

    .review__by {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-sm);
    }

    .review__name { /* the name in a pill, like the product tags */
        padding: var(--space-xs) var(--space-sm);
        border: 1px solid currentColor;
        border-radius: 999px;
    }

    .review__meta {
        color: var(--soft);
    }

    /* About */

    .about__text,
    .about__quote {
        grid-column: 1 / -1;
    }

    .about__quote {
        font-size: var(--display-sm);
        line-height: 1;
    }

    .gallery { /* photo grid: storefront big, four small beside it */
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
        gap: var(--gap);
        padding-top: var(--gap);
    }

    .gallery__img {
        width: 100%;
        aspect-ratio: 4 / 5; /* no height: 100%, Safari measures it against the whole grid and the photos overlap */
        object-fit: cover;
    }

    .gallery__img--main {
        grid-column: 1 / -1;
    }

    /* Contact form */

    .form { /* one blue box, paper type, same minimal lines inside */
        --soft: color-mix(in oklab, var(--bg) 80%, var(--fg)); /* labels on the blue, 4.5:1 */
        --fill: var(--bg);
        --on-fill: var(--fg);
        grid-column: 1 / -1;
        display: grid;
        gap: var(--gap);
        padding: var(--gap);
        background-color: var(--fg);
        color: var(--bg);
        accent-color: var(--bg);
    }

    .form__group {
        display: grid;
        gap: var(--gap);
        min-width: 0;
        padding: 0;
        border: 0;
    }

    .form__legend {
        padding-bottom: var(--space-sm);
    }

    .form__topic { /* topic fields: hidden until the Topic dropdown picks them */
        display: none;
    }

    .form:has(option[value="general"]:checked) .form__topic--general,
    .form:has(option[value="beans"]:checked) .form__topic--beans,
    .form:has(option[value="work"]:checked) .form__topic--work,
    .form:has(option[value="cards"]:checked) .form__topic--cards {
        display: grid;
    }

    @media (prefers-reduced-motion: no-preference) {
        .form__topic {
            animation: reveal var(--dur-slow) var(--curve);
        }
    }

    .field__label {
        display: block;
        color: var(--soft);
        font-size: var(--text-sm);
    }

    .field__input {
        width: 100%;
        padding-block: var(--space-xs);
        border: 0;
        border-bottom: 1px solid var(--soft);
        border-radius: 0;
        background: none;
        color: inherit;
        transition: border-color var(--dur) var(--curve);
    }

    .field__input:focus {
        border-bottom-color: currentColor;
    }

    @media (hover: hover) {
        .field__input:hover,
        .choices__pill:hover {
            border-color: currentColor;
        }

        .check__box:hover {
            background-color: color-mix(in oklab, currentColor 30%, transparent);
        }
    }

    .field--select {
        position: relative;
    }

    .field--select .field__input {
        appearance: none;
        cursor: pointer;
    }

    .field--select::after { /* paper arrow in place of the system one */
        content: "↓";
        position: absolute;
        right: 0;
        bottom: var(--space-xs);
        pointer-events: none;
    }

    .choices { /* a row of pill choices */
        position: relative;
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-xs);
        min-width: 0;
        padding: 0;
        border: 0;
    }

    .choices__input { /* hidden but still focusable: the pill label is the control */
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .choices__pill {
        padding: var(--space-xs) var(--space-sm);
        border: 1px solid var(--soft);
        border-radius: 999px;
        cursor: pointer;
        transition: border-color var(--dur) var(--curve), background-color var(--dur) var(--curve), color var(--dur) var(--curve);
    }

    .choices__input:checked + .choices__pill {
        border-color: var(--fill);
        background-color: var(--fill);
        color: var(--on-fill);
    }

    .choices__input:focus-visible + .choices__pill { /* the input is invisible, so its label shows the focus */
        outline: 2px solid currentColor;
        outline-offset: 3px;
    }

    .check {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-sm);
    }

    .check__box { /* paper outline square, filled paper when ticked */
        flex: none;
        width: 1rem;
        height: 1rem;
        margin: 0;
        border: 1px solid currentColor;
        color: inherit; /* controls don't inherit text colour, so currentColor would be the system black */
        appearance: none;
        cursor: pointer;
        transition: background-color var(--dur) var(--curve);
    }

    .check__box:checked {
        background-color: currentColor;
        box-shadow: inset 0 0 0 3px var(--fg);
    }

    /* Form errors: only after the visitor has touched a field or tried to send */

    .field__error { /* the hint under each field, linked with aria-describedby */
        display: none;
        flex-basis: 100%;
        color: var(--error);
    }

    .field__input:user-invalid ~ .field__error,
    .check__box:user-invalid ~ .field__error {
        display: block;
        padding-top: var(--space-xs);
    }

    .field__input:user-invalid {
        border-bottom-color: var(--error);
    }

    .field:has(.field__input:user-invalid) .field__label,
    .check__box:user-invalid + .check__label {
        color: var(--error);
    }

    .check__box:user-invalid {
        border-color: var(--error);
    }

    /* Stamp card page: one blue card, ten rings, a scan screen to add stamps (scripts/stamps.js) */

    .stamp-page { /* everything on the page centred */
        justify-items: center;
        text-align: center;
    }

    .stamp-page .section__head {
        grid-column: 1 / -1;
    }

    .loyalty {
        grid-column: 1 / -1;
        display: grid;
        justify-items: center;
        gap: var(--gap);
        width: min(100%, 36rem);
    }

    .loyalty .section__lead {
        margin-inline: auto;
    }

    .loyalty__card { /* one side only, it doesn't flip; the content keeps its left alignment inside the centred card */
        --face: var(--fg);
        --rule: color-mix(in oklab, var(--bg) 30%, transparent);
        display: grid;
        gap: var(--gap);
        width: 100%;
        margin-block: 2rem; /* 32px of air above and below the card */
        padding: calc(var(--gap) * 1.5);
        background-color: var(--fg);
        box-shadow: 0 1.25rem 2.5rem color-mix(in oklab, var(--fg) 25%, transparent); /* fixed, never animated: cheap to draw */
        color: var(--bg);
        text-align: start;
    }

    @media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
        .loyalty__card { /* leans a few degrees toward the cursor (scripts/stamps.js sets the angles) */
            transform: perspective(60rem) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
            transition: transform var(--dur-slow) var(--curve-out); /* leaving: settles back flat, slowly */
            will-change: transform; /* its own layer, so Safari doesn't redraw the page while it moves */
        }

        .loyalty__card.is-tilting {
            transition-duration: 0.08s; /* following the cursor: a tiny ease, tight but not jittery */
        }
    }

    .loyalty__name {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        font-size: var(--text-2xl);
        letter-spacing: -0.02em;
    }

    .loyalty__stamps {
        grid-template-columns: repeat(5, 1fr); /* no flip card around it, so the rings simply share the width */
        height: auto;
    }

    .loyalty__stamps .stamp {
        width: auto;
    }

    .loyalty__count { /* the counter in a pill, like the product tags */
        padding: var(--space-xs) var(--space-sm);
        border: 1px solid currentColor;
        border-radius: 999px;
    }

    .stamp-page__sub {
        margin-top: var(--gap);
    }

    .loyalty__title {
        font-family: var(--serif);
        font-size: var(--display-sm);
        font-style: italic;
        line-height: 1;
    }

    .loyalty__done {
        display: grid;
        gap: var(--space-sm);
    }

    .loyalty__done[hidden],
    .loyalty__action[hidden] {
        display: none;
    }

    @media (prefers-reduced-motion: no-preference) {
        .stamp--new::after { /* the stamp that was just added thumps down */
            animation: stamp var(--dur) var(--curve-out) var(--dur-fast) backwards;
        }

        .loyalty__done:not([hidden]) {
            animation: reveal var(--dur-slow) var(--curve);
        }
    }

    /* Scan screen: full screen, blue, the camera in a square viewfinder */

    .scanner {
        --fill: var(--bg);
        --on-fill: var(--fg);
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        margin: 0;
        padding: var(--gap);
        border: 0;
        background-color: var(--fg);
        color: var(--bg);
    }

    .scanner[open] {
        display: grid;
        place-content: center;
        justify-items: center;
        gap: var(--gap);
        text-align: center;
    }

    .scanner::backdrop {
        background-color: var(--fg);
    }

    .scanner__title {
        font-family: var(--serif);
        font-size: var(--display-sm);
        font-style: italic;
        line-height: 1;
    }

    .scanner__view { /* the viewfinder: a square with a paper frame */
        position: relative;
        width: min(80vw, 20rem);
        aspect-ratio: 1;
        overflow: hidden;
        outline: 2px solid var(--bg);
        outline-offset: var(--space-sm);
        background-color: color-mix(in oklab, var(--bg) 10%, transparent);
    }

    .scanner__video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .scanner__view::after { /* the tick once the code is accepted, over the camera image */
        content: "✓";
        position: absolute;
        inset: 0;
        z-index: 2; /* the video paints on its own layer, so the tick has to sit above it explicitly */
        display: grid;
        place-items: center;
        background-color: var(--fg);
        font-size: var(--display-md);
        opacity: 0;
        transition: opacity var(--dur) var(--curve);
    }

    .scanner.is-ok .scanner__view::after {
        opacity: 1;
    }

    .scanner__status {
        font-family: var(--mono);
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .scanner.is-ok .scanner__status {
        font-family: var(--serif);
        font-size: var(--text-2xl);
        font-style: italic;
        text-transform: none;
        letter-spacing: 0;
    }

    @media (prefers-reduced-motion: no-preference) {
        .scanner__view::before { /* a line sweeping the frame while it looks for the code */
            content: "";
            position: absolute;
            inset-inline: 0;
            top: 0;
            z-index: 1;
            height: 2px;
            background-color: var(--bg);
            animation: sweep calc(var(--dur-slow) * 3) var(--curve-in-out) infinite alternate;
        }

        .scanner.is-ok .scanner__view::before {
            display: none;
        }
    }

    @keyframes sweep {
        to { translate: 0 min(80vw, 20rem); }
    }

    /* Confetti on a full card: light blue pieces falling once, CSS keyframes, placed by the script */

    .confetti {
        position: fixed;
        inset: 0;
        z-index: 30;
        overflow: hidden;
        pointer-events: none;
    }

    .confetti__piece {
        position: absolute;
        top: -1rem;
        left: var(--x);
        width: 0.5rem;
        height: 0.875rem;
        background-color: color-mix(in oklab, var(--fg) 45%, var(--bg));
        animation: confetti calc(var(--dur-slow) * 5) var(--curve-in) var(--delay) forwards;
    }

    .confetti__piece:nth-child(3n) { /* allowed: a mix of two blues */
        background-color: var(--fg);
    }

    @keyframes confetti {
        to {
            translate: var(--drift) 110vh;
            rotate: var(--spin);
        }
    }

    /* Product page */

    .product {
        align-items: start;
        padding-top: calc(var(--space-xl) + 2.5rem); /* 40px more air above the product than other sections */
        padding-bottom: var(--gap); /* the same as the button's distance from the screen edge: it stops without a jump */
    }

    .product__back,
    .product__head,
    .product__media,
    .product__info {
        grid-column: 1 / -1;
    }

    .product__img {
        width: 100%;
        max-height: 50rem; /* never taller than 800px, cover crops the rest */
        object-fit: cover;
    }

    .product__info {
        display: grid;
        grid-template-columns: subgrid;
        row-gap: var(--gap);
    }

    .product .choices {
        align-self: center;
        padding-top: var(--gap);
    }

    .product:has(.choices__input[value="250g"]:checked) .price-list [data-weight="1kg"],
    .product:has(.choices__input[value="1kg"]:checked) .price-list [data-weight="250g"] { /* only the price of the chosen weight shows */
        display: none;
    }

    .product__cta { /* Reserve a bag: sticks to the bottom-right corner while the product scrolls by,
                       then rests at the end of the product, so it can never cover the footer */
        position: sticky;
        bottom: var(--gap);
        z-index: 10;
        grid-column: 1 / -1;
        justify-self: end;
        margin-top: calc(var(--space-xl) / 2); /* room after the categories for the button to land in */
    }

    .product__cta .button { /* filled, so it reads over whatever scrolls under it */
        background-color: var(--fill);
        color: var(--on-fill);
        font-size: max(2.4rem, calc(var(--display-sm) * 0.56)); /* phones: twice the usual button, easy to hit */
        box-shadow: 0 0.75rem 1.5rem color-mix(in oklab, var(--fg) 25%, transparent);
    }

    @media (hover: hover) {
        .product__cta .button:hover {
            background-color: var(--bg);
            color: var(--fg);
        }
    }

    .product .spec {
        padding-top: calc(var(--space-sm) + 1.5rem); /* mobile: more air above each block so it reads better */
    }

    .product .spec--option { /* weight, grind, quantity, price: more air between the lines */
        padding-block: 1.5rem;
    }

    .product .pills {
        padding-top: var(--gap); /* the pills sit under the heading here, not beside it */
    }

    /* Footer */

    .site-footer {
        display: grid;
        grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
        align-items: center;
        gap: var(--space-sm) var(--gap);
        padding: var(--gap);
        background-color: var(--fg);
        color: var(--bg);
    }

    .site-footer__copy,
    .legal-nav,
    .site-footer__address {
        grid-column: 1 / -1;
    }

    .legal-nav__list {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .legal-nav__list li + li::before,
    .legal-nav::before { /* a | between the footer links; decorative, so screen readers skip it */
        content: "|" / "";
        margin-right: var(--space-sm);
    }

    .legal-nav::before {
        display: none; /* mobile: the links start their own line, nothing to separate from */
    }

    /* Mobile menu panel: the header becomes a full-screen panel through :target, no script.
       Kept below 48rem on purpose: a :target left in the URL must never take over a wider screen.
       Any link inside changes the target, so the panel closes on its own. */

    @media (width < 48rem) {
        body:has(.site-header:target) {
            overflow: hidden; /* the page stays put under the open menu */
        }

        .site-header:target {
            position: fixed;
            inset: 0;
            z-index: 20;
            display: grid;
            align-content: start;
            gap: calc(var(--gap) * 4);
            padding: calc(var(--gap) * 9) var(--gap) var(--gap);
            overflow-y: auto;
            background-color: var(--fg);
            color: var(--bg);
        }

        .site-header:target .site-nav,
        .site-header:target .site-header__contact,
        .site-header:target .site-header__street {
            position: static;
            display: grid;
            justify-items: start;
            color: inherit;
            mix-blend-mode: normal;
        }

        .site-header:target .site-nav__list {
            flex-direction: column;
            gap: 0;
            font-size: min(calc(var(--display-sm) * 2), 17vw); /* the longest Spanish link still fits a 320px phone */
            line-height: 1;
        }

        .site-header:target .oval {
            display: none; /* no ovals in the mobile menu panel */
        }

        .site-header:target .site-nav__link {
            white-space: normal; /* no oval to keep on one line, so a long link (Tarjeta de sellos) may wrap */
        }

        .site-header:target .site-nav__lang { /* first in the panel, with room below before the links */
            order: -1;
            align-self: start;
            margin: 0 0 calc(var(--gap) * 2);
        }

        .site-header:target .lang-switch {
            font-size: var(--text-xl);
        }

        .site-header:target .site-header__contact {
            font-family: var(--serif);
            font-size: calc(var(--text-2xl) * 2);
            font-style: italic;
            line-height: 1;
        }

        .site-header:target .site-header__street {
            margin-top: calc(var(--gap) * 2); /* short screens: right under the links, same left edge */
            font-style: normal;
        }

        @media (min-height: 44rem) {
            .site-header:target .site-header__street { /* tall enough: pinned to the bottom corner, clear of the links */
                position: fixed;
                bottom: var(--gap);
                left: var(--gap);
                margin-top: 0;
            }
        }

        .site-header:target .site-header__logo {
            mix-blend-mode: normal; /* difference on the blue panel would turn the logo lime */
        }

        .site-header:target .site-header__toggle--open {
            display: none;
        }

        .site-header:target .site-header__toggle--close {
            display: block;
            right: var(--gap);
            width: 4rem;
        }
    }

    /* Tablet: 48rem and up. Four columns, the desktop header, blocks still stacked under their titles */

    @media (min-width: 48rem) {
        :root {
            --cols: 4;
            --gap: 1.5rem;
            --space-xl: calc(var(--gap) * 5);
            --display-md: clamp(3rem, 9vw, 6.5rem);
        }

        .site-header__logo img {
            width: clamp(2.5rem, 5vw, 4rem);
        }

        .site-header__toggle--open {
            display: none;
        }

        .site-nav,
        .site-header__contact {
            display: block;
            color: var(--blended);
        }

        body:has(.hero) .site-nav,
        body:has(.hero) .site-header__contact { /* homepage: white in difference stays readable over the video and the blue blocks */
            color: var(--blend);
            mix-blend-mode: difference;
        }

        .site-nav {
            top: calc(var(--gap) * 2); /* 24px below the logo and email line */
            left: 50%;
            translate: -50% 0;
        }

        .site-nav__lang { /* tablet: no room beside the links, so centred under them */
            position: absolute;
            top: calc(100% + var(--space-sm));
            left: 50%;
            translate: -50% 0;
        }

        .site-header__contact {
            right: var(--gap);
            display: grid;
            justify-items: end;
            font-family: var(--serif);
            font-size: var(--text-lg);
            font-style: italic;
        }

        .hero {
            grid-template-rows: 1fr auto auto;
            text-align: start;
        }

        .hero__head {
            grid-area: 2 / 1 / 3 / 4;
        }

        .hero__lead {
            margin-inline: 0;
        }

        .hero__cta {
            grid-area: 2 / 4 / 3 / -1;
            justify-self: end;
            padding-top: var(--gap);
        }

        .product-row {
            grid-auto-columns: clamp(14rem, 22vw, 20rem);
        }

        .menu__item .accordion__head {
            padding-block: var(--space-sm);
        }

        .plans__list {
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }

        .gallery__img--main {
            grid-column: span 2;
            grid-row: span 2;
            align-self: stretch; /* fills its two rows */
            aspect-ratio: auto;
            contain: size; /* so its own tall shape doesn't stretch the rows */
        }

        .form {
            padding: calc(var(--gap) * 2);
        }

        /* Spec rows: title on the left half, content on the right half */

        .spec__title,
        .page .spec__title {
            grid-column: 1 / 3;
            padding-bottom: 0;
        }

        .spec > :not(.spec__title) {
            grid-column: 3 / -1;
        }

        .product .pills,
        .product .choices {
            align-self: center; /* centred on the heading beside it, and keeps the pills from stretching to its height */
            padding-top: 0;
        }

        .product .spec {
            padding-top: var(--space-sm);
        }

        .product .spec--option {
            padding-block: 1.5rem;
        }

        /* Product: photo and title side by side, the details full width below */

        .product__media {
            grid-column: 1 / 3;
            grid-row: 2; /* explicit, or auto-placement drops it below the title */
        }

        .product__head {
            grid-column: 3 / -1;
            grid-row: 2;
        }

        /* Full pages: the title runs down beside its list, with the photo under it */

        .page .spec {
            grid-template-rows: repeat(3, auto) 1fr; /* the empty last row soaks up the photo's extra height, so the list rows stay tight */
        }

        .page .spec__title {
            grid-row: 1 / -1;
            align-self: start;
        }

        .spec--photo::before {
            content: none;
        }

        .spec--photo .spec__title {
            margin-right: 1.5rem; /* 24px of air between the title column and the list */
            text-align: right; /* title and photo sit against the list, on the right of their column */
        }

        .spec--photo .spec__title::after { /* the photo under the title, tilted with a soft shadow */
            content: "";
            display: block;
            margin-left: auto;
            width: min(100%, 11.2rem);
            aspect-ratio: 4 / 5;
            margin-block: var(--gap) var(--space-sm);
            background: var(--img) var(--focus, center) / var(--zoom, cover);
            box-shadow: 0 1rem 2rem color-mix(in oklab, var(--fg) 25%, transparent);
            rotate: var(--tilt);
        }

        .site-footer { /* one row: copyright | legal links, address pushed right */
            display: flex;
            flex-wrap: wrap;
            gap: var(--space-sm);
        }

        .legal-nav {
            display: flex;
        }

        .legal-nav::before {
            display: inline;
        }

        .site-footer__address {
            margin-left: auto;
        }
    }

    /* Category photo right after each accordion title, tilted with a soft shadow and centred on the title row.
       It shows when the category is open; with a mouse, on hover too */

    .accordion__title {
        --photo-shift: -0.75rem; /* mobile: the title row has 40px above and 16px below, so centre on the row, not the text */
        --row-pad: 3.5rem; /* that 40px + 16px: the row is the title plus this */
        position: relative;
    }

    .accordion__title::after {
        content: "";
        position: absolute;
        top: calc(50% + var(--photo-shift));
        left: calc(100% + 1.5rem); /* 24px after the end of the title */
        z-index: 5;
        height: calc((100% + var(--row-pad)) * 1.1); /* 10% taller than the title row */
        aspect-ratio: 4 / 5;
        background: var(--img) var(--focus, center) / var(--zoom, cover);
        box-shadow: 0 0.75rem 1.5rem color-mix(in oklab, var(--fg) 25%, transparent);
        opacity: 0;
        transform: translateY(-50%) rotate(var(--tilt));
        pointer-events: none;
        transition: opacity var(--dur-fast) var(--curve);
    }

    .accordion[open] .accordion__title::after {
        opacity: 1;
    }

    @media (hover: hover) and (pointer: fine) {
        .accordion__head:hover .accordion__title::after {
            opacity: 1;
        }
    }

    @media (min-width: 48rem) {
        .accordion__title {
            --photo-shift: 0px; /* the row is even here, top and bottom. 0px, not 0: calc() rejects a unitless 0 next to a % */
            --row-pad: calc(var(--space-sm) * 2);
        }
    }

    @media (prefers-reduced-motion: no-preference) {
        .accordion__title::after { /* slides in from the left as it fades in, and back out */
            translate: -1.5rem 0;
            transition: opacity var(--dur-fast) var(--curve-out), translate var(--dur-fast) var(--curve-out);
        }

        .accordion[open] .accordion__title::after {
            translate: 0 0;
        }

        @media (hover: hover) and (pointer: fine) {
            .accordion__head:hover .accordion__title::after {
                translate: 0 0;
            }
        }
    }

    /* Desktop: 64rem and up. Titles on the left half, content on the right half */

    @media (min-width: 64rem) {
        :root {
            --display-md: clamp(2.5rem, 7vw, 6.5rem);
        }

        .site-nav__lang { /* desktop: beside Contact, set apart */
            position: static;
            translate: none;
            align-self: center;
            margin-left: 2rem; /* 32px on top of the gap between links */
        }

        .section__head {
            grid-column: 1 / 3;
        }

        .menu__head { /* stays in view while the accordion scrolls past */
            position: sticky;
            top: var(--space-xl);
            align-self: start;
            padding-bottom: 0;
        }

        .menu__more {
            margin-left: 1.5rem;
        }

        .menu__item .accordion__head + * {
            padding-top: 1.5rem;
        }

        .accordion__title::after {
            left: calc(100% + 2.5rem); /* 40px after the end of the title */
            height: calc((100% + var(--row-pad)) * 1.32); /* 20% larger than on smaller screens */
        }

        .menu__list,
        .about__text,
        .about__quote,
        .form {
            grid-column: 3 / -1;
        }

        .spec__title,
        .page .spec__title {
            grid-column: 1;
        }

        .spec > :not(.spec__title) {
            grid-column: 2 / -1;
        }

        .product__back {
            grid-column: 1 / -1;
        }

        .product__media {
            grid-row: 2 / span 2; /* beside the title and the details, whatever their length */
        }

        .product__info {
            grid-column: 3 / -1;
        }

    }
}

@layer utilities {
    /* Utilities: one job each, they always win */

    .link { /* a link inside a line of text keeps its underline */
        text-decoration-color: currentColor;
    }

    .icon-text { /* a Phosphor icon centred on its label */
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        line-height: 1;
    }

    .icon-text svg {
        width: 1.25em;
        height: 1.25em;
    }
}
