/* Boss Croker's Thanksgiving Hours Popup Banner & Turkey Drag Animation */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Base (closed / exit) state for native top-layer <dialog> */
.thanksgiving-dialog {
    margin: auto;
    padding: 24px;
    border: none;
    background: transparent;
    color: var(--color-text, #f0f0f0);
    max-width: min(96vw, 920px);
    max-height: 96dvh;
    overflow: hidden;
    opacity: 0;

    transition-property: opacity, scale, display, overlay;
    transition-duration: 0.26s;
    transition-timing-function: ease-out;
    transition-behavior: allow-discrete;

    @media (prefers-reduced-motion: no-preference) {
        scale: 0.94;
    }
}

.thanksgiving-dialog:modal {
    overscroll-behavior: contain;
}

/* Backdrop base & transitions */
.thanksgiving-dialog::backdrop {
    overflow: hidden;
    overscroll-behavior: contain;
    background-color: rgb(5 10 6 / 0);
    backdrop-filter: blur(0px);

    transition-property: background-color, backdrop-filter, display, overlay;
    transition-duration: 0.35s;
    transition-timing-function: ease-out;
    transition-behavior: allow-discrete;
}

/* Open state (excluding fallback exit phase) */
:is(.thanksgiving-dialog[open]):where(:not([data-closing])) {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;

    @starting-style {
        opacity: 0;
    }

    @media (prefers-reduced-motion: no-preference) {
        scale: 1;
        animation: turkey-haul-in 2.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;

        @starting-style {
            scale: 1;
        }
    }

    &::backdrop {
        background-color: rgb(5 10 6 / 0.8);
        backdrop-filter: blur(4px);

        @starting-style {
            background-color: rgb(5 10 6 / 0);
            backdrop-filter: blur(0px);
        }
    }
}

/* Keep flex layout active while [data-closing] runs fallback exit animation */
.thanksgiving-dialog[open][data-closing] {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (prefers-reduced-motion: reduce) {
    .thanksgiving-dialog,
    .thanksgiving-dialog::backdrop {
        transition-duration: 0.12s;
    }
}

/* Rig holding the pulling turkey + rope + wooden banner */
.thanksgiving-rig {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
}

/* Turkey + Rope SVG Container */
.turkey-puller-wrap {
    position: relative;
    z-index: 3;
    width: clamp(100px, 16vw, 190px);
    margin-right: -11px;
    margin-bottom: clamp(8px, 3vh, 26px);
    flex-shrink: 0;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.65));
}

.turkey-puller-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

/* Framed Banner Card */
.thanksgiving-card {
    position: relative;
    z-index: 2;
    border-radius: 12px;
    border: 3px solid #d4af37;
    background: #2b180a;
    box-shadow:
        0 22px 55px rgba(0, 0, 0, 0.88),
        0 0 28px rgba(255, 179, 0, 0.22),
        inset 0 0 0 1px rgba(255, 230, 160, 0.35);
    transform-origin: 0% 65%;

    @media (prefers-reduced-motion: no-preference) {
        .thanksgiving-dialog[open] & {
            animation: banner-tug-sway 2.65s ease-in-out forwards;
        }
    }
}

.thanksgiving-card picture {
    display: block;
    line-height: 0;
}

.thanksgiving-banner-img {
    display: block;
    width: min(640px, 68vw, calc((100dvh - 5rem) * 1024 / 764));
    height: auto;
    aspect-ratio: 1024 / 764;
    border-radius: 9px;
    object-fit: cover;
}

/* Dismiss (X) Button */
.thanksgiving-close {
    position: absolute;
    top: -15px;
    right: -15px;
    z-index: 5;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #ffb300;
    background: #141e15;
    color: #fff8e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.85);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, scale 0.18s ease;
}

.thanksgiving-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    pointer-events: none;
}

.thanksgiving-close:hover {
    background: #b71c1c;
    border-color: #ffd54f;
    color: #ffffff;
    scale: 1.08;
}

.thanksgiving-close:active {
    scale: 0.96;
}

.thanksgiving-close:focus-visible {
    border-radius: 50%;
    outline: 2px solid #ffcc00;
    outline-offset: 3px;
}

/* SVG Sub-part Transform Origins */
.turkey-actor {
    transform-origin: 62px 112px;
}

.turkey-tail {
    transform-origin: 78px 80px;
}

.turkey-wing {
    transform-origin: 60px 76px;
}

.turkey-head-group {
    transform-origin: 40px 68px;
}

.turkey-wattle {
    transform-origin: 24px 52px;
}

.turkey-leg-front {
    transform-origin: 50px 106px;
}

.turkey-leg-back {
    transform-origin: 64px 105px;
}

.turkey-ropes {
    transform-origin: 175px 82px;
}

/* Motion Choreography — Opt-in for users with no reduced-motion preference */
@media (prefers-reduced-motion: no-preference) {
    .thanksgiving-dialog[open] .turkey-actor {
        animation:
            turkey-waddle-bob 0.31s ease-in-out 8,
            turkey-lean-pull 2.65s ease-out forwards;
    }

    .thanksgiving-dialog[open] .turkey-leg-front {
        animation: turkey-step-front 0.31s ease-in-out 8;
    }

    .thanksgiving-dialog[open] .turkey-leg-back {
        animation: turkey-step-back 0.31s ease-in-out 8;
    }

    .thanksgiving-dialog[open] .turkey-tail {
        animation: turkey-tail-fan 0.31s ease-in-out 8, turkey-tail-proud 0.55s ease-out 2.48s 1;
    }

    .thanksgiving-dialog[open] .turkey-wing {
        animation: turkey-wing-effort 0.31s ease-in-out 8;
    }

    .thanksgiving-dialog[open] .turkey-head-group {
        animation: turkey-head-peck 0.31s ease-in-out 8;
    }

    .thanksgiving-dialog[open] .turkey-wattle {
        animation: turkey-wattle-swing 0.31s ease-in-out 8;
    }

    .thanksgiving-dialog[open] .turkey-ropes {
        animation: turkey-rope-tension 0.31s ease-in-out 8;
    }
}

/* Keyframes: Hauling from off-screen right to center with subtle heave-ho rhythm */
@keyframes turkey-haul-in {
    0% {
        translate: 105vw 0;
    }
    22% {
        translate: 68vw 0;
    }
    45% {
        translate: 36vw 0;
    }
    68% {
        translate: 12vw 0;
    }
    88% {
        translate: -10px 0;
    }
    95% {
        translate: 4px 0;
    }
    100% {
        translate: 0 0;
    }
}

@keyframes banner-tug-sway {
    0% {
        rotate: 1.4deg;
    }
    18% {
        rotate: -0.9deg;
    }
    36% {
        rotate: 1.3deg;
    }
    54% {
        rotate: -0.8deg;
    }
    72% {
        rotate: 1.1deg;
    }
    88% {
        rotate: -0.7deg;
    }
    96% {
        rotate: 0.3deg;
    }
    100% {
        rotate: 0deg;
    }
}

@keyframes turkey-lean-pull {
    0%,
    82% {
        rotate: -9deg;
    }
    92% {
        rotate: 4deg;
    }
    100% {
        rotate: 0deg;
    }
}

@keyframes turkey-waddle-bob {
    0%,
    100% {
        translate: 0 0;
    }
    50% {
        translate: 0 -6px;
    }
}

@keyframes turkey-step-front {
    0%,
    100% {
        rotate: 0deg;
        translate: 0 0;
    }
    25% {
        rotate: 28deg;
        translate: -3px -4px;
    }
    75% {
        rotate: -24deg;
        translate: 2px 0;
    }
}

@keyframes turkey-step-back {
    0%,
    100% {
        rotate: 0deg;
        translate: 0 0;
    }
    25% {
        rotate: -26deg;
        translate: 2px 0;
    }
    75% {
        rotate: 26deg;
        translate: -3px -4px;
    }
}

@keyframes turkey-tail-fan {
    0%,
    100% {
        rotate: 0deg;
    }
    50% {
        rotate: 6deg;
    }
}

@keyframes turkey-tail-proud {
    0%,
    100% {
        scale: 1;
        rotate: 0deg;
    }
    50% {
        scale: 1.09;
        rotate: 5deg;
    }
}

@keyframes turkey-wing-effort {
    0%,
    100% {
        rotate: 0deg;
    }
    50% {
        rotate: 8deg;
    }
}

@keyframes turkey-head-peck {
    0%,
    100% {
        translate: 0 0;
        rotate: 0deg;
    }
    50% {
        translate: -4px 1px;
        rotate: -4deg;
    }
}

@keyframes turkey-wattle-swing {
    0%,
    100% {
        rotate: 0deg;
    }
    50% {
        rotate: 16deg;
    }
}

@keyframes turkey-rope-tension {
    0%,
    100% {
        rotate: 0deg;
    }
    50% {
        rotate: 1.8deg;
    }
}

/* Mobile adjustments so the banner stays large and readable while keeping the turkey visible */
@media (max-width: 640px) {
    .thanksgiving-dialog {
        padding: 20px 16px;
        max-width: 98vw;
    }

    .turkey-puller-wrap {
        width: 68px;
        margin-right: -14px;
        margin-bottom: 4px;
    }

    @media (prefers-reduced-motion: no-preference) {
        .thanksgiving-dialog[open] .turkey-puller-wrap {
            animation: turkey-mobile-tuck 2.65s ease-out forwards;
        }
    }

    .thanksgiving-banner-img {
        width: min(72vw, calc((100dvh - 4.5rem) * 1024 / 764));
    }

    .thanksgiving-close {
        top: -12px;
        right: -10px;
        width: 40px;
        height: 40px;
    }
}

@keyframes turkey-mobile-tuck {
    0%,
    76% {
        translate: -16px 0;
    }
    100% {
        translate: 0 0;
    }
}
