/* Free Promotional Item (Freebie Offers).
   Uses the plugin's existing theme variables so the promo inherits whatever
   colours the site has configured under Kayana Plugin > UI Settings. */

/* ---------------------------------------------------------- cart/checkout tag */

.ky-free-tag {
    display: inline-block;
    background: var(--success-bg, #dcfce7);
    color: var(--success-color, #28a745);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.ky-free-was {
    color: var(--text-tertiary, #adb5bd);
    font-weight: 400;
    margin-right: 6px;
}

.ky-free-price {
    color: var(--success-color, #28a745);
    font-weight: 700;
}

.ky-freebie-reason {
    font-size: 12px;
    color: var(--success-color, #28a745);
    line-height: 1.4;
}

/* ------------------------------------------------------------- banner cards */

.ky-freebie-banner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.ky-freebie-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color-light, #e9ecef);
    background: var(--bg-light-gray, #f3f4f6);
}

.ky-freebie-card.is-unlocked {
    border-color: var(--success-color, #28a745);
    background: var(--success-bg, #dcfce7);
}

.ky-freebie-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ky-freebie-gift {
    font-size: 22px;
    line-height: 1;
    flex: 0 0 auto;
}

.ky-freebie-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ky-freebie-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #2c3e50);
}

.ky-freebie-sub {
    font-size: 12px;
    color: var(--text-secondary, #5a6c7d);
    line-height: 1.4;
}

.ky-freebie-btn {
    flex: 0 0 auto;
    background: var(--accent-color, #000);
    color: var(--accent-contrast-text, #fff);
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.ky-freebie-link {
    flex: 0 0 auto;
    background: none;
    border: none;
    padding: 0;
    color: var(--text-link, #13606B);
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

/* -------------------------------------------------------------- picker modal */

.ky-freebie-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100000;
}

.ky-freebie-modal {
    background: var(--bg-container, #fff);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 10px 40px var(--shadow-light, rgba(0, 0, 0, .08));
}

.ky-freebie-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ky-freebie-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary, #2c3e50);
}

.ky-freebie-modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--text-secondary, #5a6c7d);
    cursor: pointer;
}

.ky-freebie-modal-note {
    margin: 8px 0 16px;
    font-size: 13px;
    color: var(--text-secondary, #5a6c7d);
    line-height: 1.5;
}

.ky-freebie-choices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.ky-freebie-choice {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 10px;
    background: var(--bg-container, #fff);
    cursor: pointer;
    text-align: left;
}

.ky-freebie-choice.is-chosen {
    border-color: var(--success-color, #28a745);
    background: var(--success-bg, #dcfce7);
}

.ky-freebie-choice img {
    width: 100%;
    height: 96px;
    object-fit: cover;
    border-radius: 6px;
}

.ky-freebie-choice-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #2c3e50);
}

.ky-freebie-choice-price {
    font-size: 12px;
    color: var(--text-tertiary, #adb5bd);
}

.ky-freebie-choice-price em {
    font-style: normal;
    font-weight: 700;
    color: var(--success-color, #28a745);
}

@media (max-width: 480px) {
    .ky-freebie-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .ky-freebie-btn,
    .ky-freebie-link {
        align-self: stretch;
        text-align: center;
    }
}

/* ------------------------------------------------- icons & size guards */

/* Font Awesome marker used in place of an emoji character. */
.ky-freebie-icon {
    color: var(--success-color, #28a745);
    margin-right: 6px;
    font-size: 1em;
    line-height: 1;
    vertical-align: baseline;
}

.ky-freebie-card.is-locked .ky-freebie-icon {
    color: var(--text-secondary, #5a6c7d);
}

.ky-freebie-gift .ky-freebie-icon {
    margin-right: 0;
    font-size: 20px;
}

/* Belt and braces: WordPress can still swap an emoji elsewhere for an
   <img class="emoji">, which inherits the summary's full-width img rule and
   renders enormous. Pin any such image to text size inside our rows. */
.ky-free-row img.emoji,
.ky-freebie-banner img.emoji,
.ky-freebie-modal img.emoji,
.ky-free-tag img.emoji {
    width: 1em !important;
    height: 1em !important;
    max-width: 1em !important;
    max-height: 1em !important;
    display: inline-block !important;
    vertical-align: -0.1em !important;
    margin: 0 0.15em !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* A free line must never let a missing/odd image stretch the row. Keeps the
   thumbnail the same size as the paid rows beside it. */
.ky-free-row .item-thumbnail,
.ky-free-row .ky-summary-item-info img,
.ky-free-row .item-details img,
.ky-free-row .item-name img {
    max-width: 48px !important;
    max-height: 48px !important;
    object-fit: cover;
}

.ky-free-row .item-name,
.ky-free-row .pfm-cart-item-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ------------------------------------------- menu page: offer rail ----- */

/* Anchor only. The heading keeps its own width and underline: the rail is
   lifted out of the flow and pinned to the right of the category block. */
.category_block.ky-has-offer {
    position: relative;
}

.ky-offer-rail {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    display: inline-flex;
    align-items: stretch;
    max-width: min(520px, 52%);
    border-radius: 999px;
    overflow: hidden;
    background: var(--bg-container, #fff);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .10), 0 0 0 1px rgba(0, 0, 0, .04);
    font-size: 13px;
    line-height: 1;
    transition: box-shadow .2s ease, transform .2s ease;
}

.ky-offer-rail:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .16), 0 0 0 1px rgba(0, 0, 0, .05);
}

/* The tag: deeper red at the tail, notched on its right edge. */
.ky-offer-tag {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: linear-gradient(135deg, #e0313c 0%, #b3111c 100%);
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 10px 24px 10px 16px;
    clip-path: polygon(0 0, 100% 0, calc(100% - 11px) 50%, 100% 100%, 0 100%);
}

.ky-offer-tag i {
    font-size: 13px;
    /* the gift nudges every few seconds so the strip catches the eye */
    animation: ky-offer-nudge 3.2s ease-in-out infinite;
}

.ky-offer-marquee {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 16px 0 6px;
    /* fade both ends so text slides in and out instead of being chopped */
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
}

.ky-offer-track {
    display: inline-flex;
    flex: 0 0 auto;
    white-space: nowrap;
    will-change: transform;
    /* the list is rendered twice, so -50% lands on the copy: seamless loop */
    animation: ky-offer-slide 20s linear infinite;
}

.ky-offer-rail:hover .ky-offer-track,
.ky-offer-rail:focus-within .ky-offer-track {
    animation-play-state: paused;
}

.ky-offer-msg {
    padding: 10px 26px 10px 0;
    color: var(--text-primary, #2c3e50);
    font-weight: 700;
    white-space: nowrap;
}

@keyframes ky-offer-slide {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

@keyframes ky-offer-nudge {
    0%, 82%, 100% { transform: rotate(0) scale(1); }
    88%           { transform: rotate(-14deg) scale(1.12); }
    94%           { transform: rotate(10deg) scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
    .ky-offer-track,
    .ky-offer-tag i {
        animation: none;
    }
    .ky-offer-msg + .ky-offer-msg {
        display: none;
    }
    .ky-offer-rail:hover {
        transform: none;
    }
}

/* Narrow screens: drop it back into the flow under the heading.
   Verified live on staging: .category_block's own grid (.card_container,
   the site's menu layout, not ours) does not wrap on mobile and renders at
   a fixed width far wider than the viewport (1293px at 375px wide). A plain
   width:100% inherits THAT broken parent width and pushes the rail off
   screen. Sizing against the viewport instead keeps the rail correct
   regardless of what its parent does. */
@media (max-width: 900px) {
    .ky-offer-rail {
        position: static;
        width: min(100%, calc(100vw - 32px));
        max-width: min(100%, calc(100vw - 32px));
        margin: 6px 0 14px;
        border-radius: 8px;
    }

    .ky-offer-tag {
        padding: 9px 18px 9px 14px;
        font-size: 11px;
    }

    .ky-offer-msg {
        padding: 9px 20px 9px 0;
        font-size: 13px;
    }

    /*
     * Not ours -- the site's own menu layout (.left_side_menu, in
     * kayana-website-ordering-meals-menu.css) is a flex child of a single-
     * column grid (.menu_menu) that never got a mobile override. CSS grid
     * items default to a MINIMUM size of their content's natural width
     * (an implicit `minmax(auto, ...)` floor); with a non-wrapping card
     * grid inside, that natural width is huge, so the ancestor grid track
     * sizes itself to fit it instead of the viewport -- verified live: the
     * whole chain (.menu_menu -> .left_side_menu -> .card_container) sat at
     * 1257px on a 375px screen, cropping every menu image on the right.
     *
     * min-width:0 removes that implicit floor and lets the flex item shrink
     * to its container's real width, which is all four ancestors needed.
     * Placed here (not in their file) so the freebie assets stay additive;
     * this rule has nothing to do with freebies and would apply even with
     * every freebie feature disabled.
     */
    .left_side_menu {
        min-width: 0 !important;
    }
}
