/* Morrison Sites. */
/* The cast: decorative creatures that turn up on scroll and tap (js/characters.js, js/menu.js, js/whales.js, js/banner.js).
   Each is a one-colour mask from images/ (whale, whale-sleeping, crab, bottle), set as a versioned custom property
   in functions.php with the bare file as the fallback. Transforms and opacity only, never filters; all still under reduced
   motion, and all hidden in print. */

/* inc/menu.php: the sleeping pod. From 768px a pod of sperm whales sleeps under each section's photo, upright the way sperm
   whales really sleep; the pod shares the photo's grid cell and its water sticks just below the sticky photo. At a section's
   end both stop against its bottom edge and meet, so the photo (and its placeholder) sits above the pod. */
.menu-pod {
    display: none;
}

@media (min-width: 48rem) {
    .menu-section--photo > .menu-section-photo {
        grid-column: 1;
        grid-row: 1;
        z-index: 1;
    }

    .menu-section--photo > .menu-section-body {
        grid-column: 2;
        grid-row: 1;
    }

    /* Padding and cqi in percent of the column: the photo is 4:5, so it stands 125% of the column tall. */
    .menu-pod {
        display: block;
        grid-column: 1;
        grid-row: 1;
        align-self: stretch;
        container-type: inline-size;
        padding-top: calc(125% + 1.5rem);
        overflow: clip;
        pointer-events: none;
    }

    .menu-pod-water {
        position: sticky;
        top: calc(var(--md-menu-stick) + 1rem + 125cqi + 1.5rem);
        display: flex;
        justify-content: center;
        align-items: flex-end;
        gap: 1.25rem;
        height: 8.5rem;
    }
}

/* A whale is its upright box; its body is the mask turned 80deg so the head (left in the art) points up. */
.pod-whale {
    --w: 5.4rem;
    position: relative;
    display: inline-block;
    flex: none;
    width: calc(var(--w) * 296.3 / 433.74);
    height: var(--w);
    animation: md-pod-bob 4.2s ease-in-out infinite;
}

.pod-whale:nth-child(2) {
    --w: 4.6rem;
    margin-bottom: 1.25rem;
    animation-duration: 3.6s;
    animation-delay: -1.2s;
}

.pod-whale:nth-child(3) {
    --w: 5rem;
    margin-bottom: 0.5rem;
    animation-duration: 4.8s;
    animation-delay: -2.4s;
}

.pod-whale--calf.pod-whale {
    --w: 3rem;
    margin-bottom: 0.25rem;
    animation-duration: 3s;
}

.pod-whale-body {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--w);
    height: calc(var(--w) * 296.3 / 433.74);
    translate: -50% -50%;
    rotate: 80deg;
    background-color: var(--md-awning-color);
    -webkit-mask: var(--md-mask-whale-sleeping, url("../images/whale-sleeping.svg")) center / contain no-repeat;
    mask: var(--md-mask-whale-sleeping, url("../images/whale-sleeping.svg")) center / contain no-repeat;
}

/* Two z's drift up from the head, one after the other. */
.pod-z {
    position: absolute;
    left: 70%;
    top: -0.4rem;
    font-family: var(--md-font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
    text-transform: none;
    letter-spacing: 0;
    color: var(--md-muted-color);
    opacity: 0;
    animation: md-pod-z 3.2s ease-out infinite;
}

.pod-z + .pod-z {
    animation-delay: 1.6s;
}

/* Stirring: a slow roll in its sleep, and back. */
.pod-whale.is-stirring .pod-whale-body {
    animation: md-pod-roll 1.8s ease-in-out;
}

@keyframes md-pod-bob {
    0%, 100% { translate: 0 0.2rem; }
    50% { translate: 0 -0.25rem; }
}

@keyframes md-pod-z {
    0% { opacity: 0; translate: 0 0; scale: 0.6; }
    20% { opacity: 1; }
    100% { opacity: 0; translate: 0.9rem -1.6rem; scale: 1.25; }
}

@keyframes md-pod-roll {
    0%, 100% { rotate: 80deg; }
    40% { rotate: 58deg; translate: -50% -56%; }
    70% { rotate: 92deg; }
}

/* Phones: no photo column, so a small sleeper dozes at the end of each top-level section title. */
.menu-heading-whale {
    display: none;
}

@media (max-width: 47.9375rem) {
    .menu-heading-whale.pod-whale {
        --w: 1.7rem;
        display: inline-block;
        margin-left: 0.75rem;
        vertical-align: middle;
        animation-duration: 3.4s;
    }

    .menu-heading-whale .pod-z {
        font-size: 0.6rem;
    }
}

/* inc/menu.php: on touch screens a tapped dish's whale leaps up beside its name and dives away again (js/menu.js). Absolute
   at its place after the name, so it takes no room; with a mouse, css/blocks.css keeps its hover version. */
@media (hover: none), (pointer: coarse) {
    .menu-item-whale {
        display: inline-block;
        position: absolute;
        width: 1.9rem;
        aspect-ratio: 434 / 296;
        margin-left: 0.4rem;
        background-color: var(--md-accent-color);
        -webkit-mask: var(--md-mask-whale, url("../images/whale.svg")) center / contain no-repeat;
        mask: var(--md-mask-whale, url("../images/whale.svg")) center / contain no-repeat;
        opacity: 0;
        pointer-events: none;
    }

    .menu-list > .menu-item.is-leaping .menu-item-whale {
        animation: md-leap-tap 1.1s cubic-bezier(0.3, 0.7, 0.4, 1) both;
    }
}

@keyframes md-leap-tap {
    0% { opacity: 0; transform: translate(-0.4rem, 0.75rem) rotate(35deg) scale(0.5); }
    35% { opacity: 1; transform: translate(0.1rem, -0.6rem) rotate(-10deg) scale(1.05); }
    65% { opacity: 1; transform: none; }
    100% { opacity: 0; transform: translate(0.7rem, 0.9rem) rotate(40deg) scale(0.6); }
}

/* blocks/whales.php: a tapped whale blows a spout, and the whales ahead of it turn back to look (js/whales.js). */
.whale-wrap {
    position: relative;
    display: block;
    flex: none;
    pointer-events: auto;
    cursor: pointer;
}

.whale {
    transition: transform 300ms ease;
}

.whale-wrap.is-looking .whale {
    transform: none;
}

/* At the blowhole: the flipped whale's curl sits about 80% across and 20% down. */
.whale-spout {
    position: absolute;
    left: 78%;
    bottom: 80%;
    font-size: calc(var(--md-whale-h) / 4);
}

.whale-spout span {
    position: absolute;
    width: 0.32em;
    height: 0.32em;
    border-radius: 50%;
    background-color: var(--md-awning-color);
    opacity: 0;
    animation: md-spout 900ms ease-out var(--delay, 0ms) both;
}

@keyframes md-spout {
    0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
    15% { opacity: 1; }
    45% { opacity: 1; transform: translate(calc(var(--dx) * 0.4), -2.6em) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), -0.8em) scale(0.7); }
}

/* blocks/banner.php: a whale breaches over the awning (js/banner.js). Its window sits on the shaded slope and clips the whale
   to above it, so it rises out of the awning and dives back in. */
.banner-breach {
    position: absolute;
    left: 22%;
    bottom: calc(100% + 0.53em);
    width: 5em;
    height: 3.2em;
    overflow: hidden;
    pointer-events: none;
}

.banner-breach-whale {
    position: absolute;
    left: 0.4em;
    bottom: 0;
    width: 2.2em;
    aspect-ratio: 434 / 296;
    background-color: var(--md-awning-color);
    -webkit-mask: var(--md-mask-whale, url("../images/whale.svg")) center / contain no-repeat;
    mask: var(--md-mask-whale, url("../images/whale.svg")) center / contain no-repeat;
    transform: translate(0, 130%);
}

.banner-breach.is-breaching .banner-breach-whale {
    animation: md-breach 1.5s cubic-bezier(0.35, 0, 0.35, 1) both;
}

/* Flipped to face right, the way the leap goes: nose up on the way out, nose down on the way back in. */
@keyframes md-breach {
    0% { transform: translate(0, 130%) rotate(-50deg) scaleX(-1); }
    45% { transform: translate(1.1em, -0.3em) rotate(-5deg) scaleX(-1); }
    100% { transform: translate(2.3em, 130%) rotate(55deg) scaleX(-1); }
}

/* blocks/awards.php: the plaques swing into place like frames being hung, one after another, and their wheel seals turn. */
.js .awards-list.fade-up .award {
    transform-origin: 50% -1rem;
}

.js .awards-list.fade-up.visible .award {
    animation: md-plaque-swing 1.3s cubic-bezier(0.3, 0.6, 0.4, 1) calc(var(--i, 0) * 140ms) both;
}

.js .awards-list.fade-up.visible .award::after {
    animation: md-seal-turn 1.6s cubic-bezier(0.2, 0.7, 0.3, 1) calc(var(--i, 0) * 140ms + 300ms) both;
}

@keyframes md-plaque-swing {
    0% { opacity: 0; transform: translateY(-1.25rem) rotate(9deg); }
    30% { opacity: 1; transform: translateY(0) rotate(-6deg); }
    55% { transform: rotate(3.5deg); }
    78% { transform: rotate(-1.5deg); }
    100% { opacity: 1; transform: none; }
}

@keyframes md-seal-turn {
    from { rotate: -270deg; }
    to { rotate: 0deg; }
}

/* js/characters.js: bubbles rise from the end of a section title as it arrives. A zero-width slot, so nothing reflows. */
.heading-bubbles {
    position: relative;
    display: inline-block;
    width: 0;
    height: 0;
}

.heading-bubbles span {
    position: absolute;
    left: calc(0.35em + var(--x, 0em));
    bottom: 0.3em;
    width: var(--size, 0.3em);
    height: var(--size, 0.3em);
    box-sizing: border-box;
    border: max(1.5px, 0.06em) solid var(--md-accent-color);
    border-radius: 50%;
    opacity: 0;
    animation: md-bubble 1.6s ease-out var(--delay, 0ms) both;
}

@keyframes md-bubble {
    0% { opacity: 0; translate: 0 0; scale: 0.4; }
    20% { opacity: 0.55; }
    80% { opacity: 0.55; translate: 0.2em -1.5em; scale: 1; }
    100% { opacity: 0; translate: 0.25em -1.8em; scale: 1.5; }
}

/* footer.php: the crab sits on the footer's top edge. It waits off the right-hand end until the footer arrives, then scuttles to
   --crab-x (js/characters.js); the footer clips it sideways only. */
footer {
    position: relative;
    overflow-x: clip;
}

.footer-crab {
    position: absolute;
    left: 0;
    bottom: calc(100% - 0.3rem);
    width: 3.25rem;
    aspect-ratio: 400 / 260;
    background-color: var(--md-accent-color);
    -webkit-mask: var(--md-mask-crab, url("../images/crab.svg")) center / contain no-repeat;
    mask: var(--md-mask-crab, url("../images/crab.svg")) center / contain no-repeat;
    translate: var(--crab-x, 110vw) 0;
    visibility: hidden;
    cursor: pointer;
    transition: translate 1.6s cubic-bezier(0.45, 0.05, 0.4, 1);
}

.footer-crab.is-here {
    visibility: visible;
}

.footer-crab.is-walking {
    animation: md-crab-scuttle 0.16s ease-in-out infinite alternate;
}

@keyframes md-crab-scuttle {
    from { rotate: -7deg; }
    to { rotate: 7deg; }
}

/* js/characters.js: the back-to-top whale swims up the screen trailing bubbles, and splashes at the top. */
.to-top-flyer {
    position: fixed;
    z-index: 7;
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    color: var(--md-text-color);
    pointer-events: none;
}

.to-top-flyer svg {
    display: block;
    width: 2.2rem;
    height: auto;
    fill: currentColor;
    transform: scaleX(-1) rotate(-12deg);
}

.swim-bubble {
    position: fixed;
    z-index: 7;
    width: 0.55rem;
    height: 0.55rem;
    margin: -0.275rem;
    box-sizing: border-box;
    border: 2px solid var(--md-accent-color);
    border-radius: 50%;
    pointer-events: none;
    animation: md-swim-bubble 0.9s ease-out both;
}

@keyframes md-swim-bubble {
    from { opacity: 0.7; scale: 0.4; }
    to { opacity: 0; scale: 1.3; translate: 0 -1.5rem; }
}

.swim-splash {
    position: fixed;
    z-index: 7;
    width: 0;
    height: 0;
    pointer-events: none;
}

.swim-splash span {
    position: absolute;
    width: 0.4rem;
    height: 0.4rem;
    margin: -0.2rem;
    border-radius: 50%;
    background-color: var(--md-awning-color);
    animation: md-splash 0.7s ease-out both;
}

@keyframes md-splash {
    from { opacity: 1; transform: rotate(var(--angle)) translateX(0) scale(1); }
    to { opacity: 0; transform: rotate(var(--angle)) translateX(2.2rem) scale(0.4); }
}

/* js/characters.js: when the contact form sends, a bottle pops up from the waves and bobs away; then the sea ebbs. */
.form-sea {
    position: relative;
    height: 4.5rem;
    margin-top: 1rem;
    overflow: hidden;
    animation: md-sea-ebb 0.4s ease-in 4.8s both;
}

/* Scalloped waves in the awning's blue, rolling sideways. */
.form-sea::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.1rem;
    background: radial-gradient(circle at 0.8rem -0.25rem, transparent 0.8rem, var(--md-awning-color) 0.85rem) 0 0 / 1.6rem 100% repeat-x;
    animation: md-waves 1.6s linear infinite;
}

.form-sea-bottle {
    position: absolute;
    left: 1rem;
    bottom: 0.55rem;
    width: 4rem;
    aspect-ratio: 400 / 160;
    background-color: var(--md-accent-color);
    -webkit-mask: var(--md-mask-bottle, url("../images/bottle.svg")) center / contain no-repeat;
    mask: var(--md-mask-bottle, url("../images/bottle.svg")) center / contain no-repeat;
    animation:
        md-bottle-away 4.6s ease-in-out both,
        md-bottle-bob 0.9s ease-in-out infinite alternate;
}

@keyframes md-waves {
    to { background-position-x: 1.6rem; }
}

@keyframes md-bottle-away {
    0% { left: 1rem; translate: 0 2rem; opacity: 0; }
    15% { left: 1rem; translate: 0 0; opacity: 1; }
    88% { opacity: 1; }
    100% { left: 100%; translate: 0 0; opacity: 0; }
}

@keyframes md-bottle-bob {
    from { rotate: -9deg; }
    to { rotate: 7deg; }
}

@keyframes md-sea-ebb {
    to { height: 0; margin-top: 0; }
}

/* blocks/open-sign.php: a sign hung on two chains from a hook. Gold with navy type when open (9.8:1), cream when gone fishing.
   It swings as it arrives and when tapped, and flips over when the hours change it (js/characters.js). */
.open-sign {
    --md-chain: 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin: 0 0 1.5rem;
}

.open-sign-board {
    position: relative;
    min-width: 10rem;
    margin: var(--md-chain) 0 0;
    padding: 0.55rem 1.1rem;
    box-sizing: border-box;
    background-color: var(--md-bg-color);
    border: 3px solid var(--md-accent-color);
    color: var(--md-text-color);
    font-family: var(--md-font-heading);
    font-weight: 900;
    font-size: 1.15rem;
    line-height: 1.2;
    letter-spacing: 0.06em;
    text-align: center;
    text-transform: uppercase;
    transform-origin: 50% calc(-1 * var(--md-chain));
}

.open-sign.is-open .open-sign-board {
    background-color: var(--md-gold-color);
}

/* The chains: two navy lines from the hook down to the board's top corners. */
.open-sign-board::before {
    content: "";
    position: absolute;
    left: 18%;
    right: 18%;
    bottom: calc(100% + 3px);
    height: var(--md-chain);
    background:
        linear-gradient(to bottom right, transparent calc(50% - 1px), var(--md-accent-color) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) left / 50% 100% no-repeat,
        linear-gradient(to bottom left, transparent calc(50% - 1px), var(--md-accent-color) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) right / 50% 100% no-repeat;
}

/* The hook. */
.open-sign-board::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 3px + var(--md-chain) - 0.25rem);
    width: 0.5rem;
    height: 0.5rem;
    translate: -50% 0;
    background-color: var(--md-accent-color);
}

.open-sign-line,
footer .open-sign-line {
    margin: 0.5rem 0 0;
    color: var(--md-muted-color);
}

.open-sign.is-swinging .open-sign-board {
    animation: md-sign-swing 1.6s cubic-bezier(0.3, 0.6, 0.4, 1);
}

.open-sign.is-flipping .open-sign-board {
    animation: md-sign-flip 0.6s ease-in-out;
}

@keyframes md-sign-swing {
    0%, 100% { rotate: 0deg; }
    15% { rotate: 8deg; }
    40% { rotate: -6deg; }
    62% { rotate: 3.5deg; }
    82% { rotate: -1.5deg; }
}

@keyframes md-sign-flip {
    0%, 100% { transform: perspective(20rem) rotateX(0deg); }
    50% { transform: perspective(20rem) rotateX(90deg); }
}

/* The footer's smaller sign, under the hours. */
.open-sign--small {
    --md-chain: 1rem;
    margin: 0.25rem 0 1rem;
}

.open-sign--small .open-sign-board {
    min-width: 0;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
}

/* Under reduced motion the cast holds still: the pod sleeps, the crab rests, and the one-off moments don't happen. */
@media (prefers-reduced-motion: reduce) {
    .pod-whale,
    .pod-whale-body,
    .pod-z,
    .whale,
    .footer-crab,
    .js .awards-list.fade-up.visible .award,
    .js .awards-list.fade-up.visible .award::after,
    .open-sign-board {
        animation: none;
        transition: none;
    }

    .pod-z {
        opacity: 0.8;
    }

    .pod-z + .pod-z {
        translate: 0.6rem -0.9rem;
    }

    .whale-wrap {
        cursor: default;
    }
}

@media print {
    .menu-pod,
    .menu-heading-whale,
    .footer-crab,
    .open-sign,
    .heading-bubbles,
    .form-sea {
        display: none;
    }
}
