/*
  ----------------------------------------
  Application (Global styles)
  ----------------------------------------
*/

@layer styles {
    /* ----------------------------------------
       Homepage – Impeccable Plate
       ---------------------------------------- */

    /* Serif headings (Lora) for homepage */
    .ip-serif {
        font-family: var(--font-heading);
        font-weight: 700;
        line-height: 1.05;
    }

    /* Small all-caps eyebrow label */
    .ip-eyebrow {
        font-size: var(--text-sm);
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        margin: 0;
    }

    /* Pill badge */
    .ip-badge {
        display: inline-block;
        padding: 0.3em 0.85em;
        border-radius: 9999px;
        font-size: var(--text-sm);
        font-weight: 600;
        line-height: 1.6;
    }

    /* Hero: stacked on mobile, side-by-side on desktop */
    .ip-hero {
        display: flex;
        flex-direction: column;
        background: var(--white);
        overflow: hidden;

        @media (min-width: 768px) {
            flex-direction: row;
        }
    }

    .ip-hero-image,
    .ip-hero-copy {
        min-width: 0;
    }

    .ip-hero-image {
        display: flex;
        flex: 1 1 52%;
        background: var(--brand-2);
    }

    .ip-hero-carousel {
        position: relative;
        flex: 1;
        min-height: clamp(320px, 72vw, 520px);
        overflow: hidden;
        background: var(--brand-2);

        @media (min-width: 768px) {
            min-height: clamp(460px, 60vh, 620px);
        }
    }

    .ip-hero-slide {
        position: absolute;
        inset: 0;
        opacity: 0;
        pointer-events: none;
        transition: opacity 320ms ease;
    }

    .ip-hero-slide.is-active {
        opacity: 1;
        pointer-events: auto;
    }

    .ip-hero-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    /* Carousel navigation buttons */
    .ip-hero-slide-btn {
        position: absolute;
        bottom: 1rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.75rem;
        height: 2.75rem;
        background: rgb(15 15 15 / 0.28);
        color: white;
        border: 1px solid rgb(255 255 255 / 0.5);
        font-size: 1.75rem;
        line-height: 1;
        padding: 0 0 0.12rem;
        cursor: pointer;
        border-radius: 9999px;
        z-index: 2;
        backdrop-filter: blur(8px);
        opacity: 0;
        transition:
            opacity 200ms ease,
            transform 200ms ease,
            background 200ms ease;

        &:hover {
            transform: translateY(-1px);
            background: rgb(15 15 15 / 0.45);
        }

        @media (hover: none) {
            opacity: 1;
        }
    }

    .ip-hero-carousel:hover .ip-hero-slide-btn,
    .ip-hero-carousel:focus-within .ip-hero-slide-btn {
        opacity: 1;
    }

    .ip-hero-slide-prev { left: 1rem; }
    .ip-hero-slide-next { left: 4.25rem; }

    .ip-hero-copy {
        flex: 1 1 48%;
        display: flex;
        align-items: center;
        padding: clamp(2rem, 6vw, 4.5rem) clamp(1.5rem, 5vw, 4.5rem);
    }

    .ip-hero-copy-inner {
        max-width: 32rem;
        width: 100%;
    }

    /* How It Works steps: stacked on mobile, row on desktop */
    .ip-steps {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);

        @media (min-width: 768px) {
            flex-direction: row;
        }
    }

    .ip-step {
        display: flex;
        flex: 1;
        align-items: flex-start;
    }

    .ip-step-num {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.25rem;
        height: 2.25rem;
        border-radius: 9999px;
        font-weight: 700;
        font-size: var(--text-base);
        flex-shrink: 0;
    }

    /* Menu cards: stacked on mobile, 2-col on desktop */
    .ip-menu-cards {
        display: flex;
        flex-direction: column;
        gap: var(--space-md);

        @media (min-width: 640px) {
            flex-direction: row;
            align-items: stretch;
        }
    }

    .ip-menu-card {
        flex: 1;
    }

    .ip-menu-card-wide {
        flex: 1;
    }

    /* Order page grid: keep cards a consistent width and cap the row at 4 cards */
    .ip-order-grid {
        --ip-order-card-width: calc((100% - var(--space-sm)) / 2);
        display: grid;
        gap: var(--space-sm);
        width: 100%;
        grid-template-columns: repeat(auto-fill, minmax(var(--ip-order-card-width), var(--ip-order-card-width)));
        align-items: stretch;
        
        img {
            max-height: 100px;
        }

        @media (min-width: 640px) {
            img {
                max-height: initial;
            }
        }

        @media (min-width: 960px) {
            --ip-order-card-width: calc((100% - (2 * var(--space-sm))) / 3);
        }

        @media (min-width: 1280px) {
            --ip-order-card-width: calc((100% - (3 * var(--space-sm))) / 4);
        }
    }

    .ip-order-card {
        height: 100%;
    }

    /* Pickup window cards: always side-by-side */
    .ip-pickup-cards {
        display: flex;
        gap: var(--space-md);
    }

    .ip-pickup-card {
        flex: 1;
    }

    /* Benefits: stacked on mobile, 3-col on desktop */
    .ip-benefits {
        display: flex;
        flex-direction: column;
        gap: var(--space-md);

        @media (min-width: 768px) {
            flex-direction: row;
            align-items: stretch;
        }
    }

    .ip-benefit-card {
        flex: 1;
        border: 1px solid color-mix(in srgb, var(--brand-2) 10%, transparent);
    }

    /* Large decorative glyph icon */
    .ip-benefit-glyph {
        display: block;
        font-size: var(--text-2xl);
        color: var(--brand-2);
        line-height: 1;
    }

    /* Testimonials: stacked on mobile, 2-col on desktop */
    .ip-testimonials {
        display: flex;
        flex-direction: column;
        gap: var(--space-md);

        @media (min-width: 640px) {
            flex-direction: row;
        }
    }

    .ip-testimonial {
        flex: 1;
    }

    /* ----------------------------------------
       Desktop nav links */
    .desktop {
        display: flex;
        position: relative;
        align-items: center;
        gap: var(--space-md);
        height: 100%;
        min-height: var(--height-md);

        .nav-link {
            position: relative;
            display: flex;
            align-items: center;
            height: 100%;
            text-decoration: none;
            color: var(--darker);
            font-weight: 600;

            &.active::after {
                content: "";
                position: absolute;
                left: 0;
                right: 0;
                bottom: 0;
                height: 4px;
                background-color: var(--brand-1);
            }
        }
    }

    /* Mobile menu */
    .mobile {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: start;
        padding-top: var(--space-md);
        gap: 1rem;

        .nav-link {
            padding: 1rem;
            font-size: var(--text-lg);
            font-weight: var(--font-semibold);
            text-decoration: none;
            color: var(--white);

            &:active {
                background-color: var(--brand-1);
            }
        }
    }

    /* Crud Header (for tables, forms – also used in custom scaffolds /erb/scaffold/*) */
    .crud-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: var(--space-2xl);

        h3 {
            margin: 0;
        }
    }

    /* Menu Item Category Tabs */
    .item-category-tabs {
        padding-top: 1rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--midtone);
        display: block;

        .wrapper {
            display: flex;
            flex-wrap: wrap;
            flex-direction: row;
        }

        .tab-link {
            cursor: pointer;
            border-right: 1px solid var(--light);
            text-decoration: none;
            color: var(--midtone);
            transition: all 0.2s ease-in-out;
            margin-bottom: var(--space-2xs);

            img, .placeholder {
                display: none;
            }
            
            &:hover, &.active {
                color: var(--white) !important;
                background: var(--brand-1);
            }
            
            &:last-child {
                border-right: none;
            }
        }

        @media (max-width: 640px) {
            .wrapper {
                flex-wrap: nowrap;
                overflow-x: auto;
                gap: var(--space-3xs);
            }

            --thumbnail-width: 150px;
            --thumbnail-height: 80px;

            .tab-link {
                border: 0;
                white-space: nowrap;
                width: calc(var(--thumbnail-width) + 2 * var(--space-xs));
                text-align: center;
                display: flex;
                flex-direction: column;
                gap: var(--space-2xs);
                border-radius: var(--rounded-lg);

                .name {
                    text-overflow: ellipsis;
                    overflow: hidden;
                    white-space: nowrap;
                }

                img, .placeholder {
                    width: var(--thumbnail-width);
                    display: block;
                    max-width: initial;
                    height: var(--thumbnail-height);
                }

                .placeholder {
                    display: flex;
                }
                
                &:last-child {
                    border-bottom: none;
                }
            }
        }
    }

    /* Menu Order Cart */
    #cart {
        pointer-events: auto;
        position: absolute;
        right: 0;
        transition: opacity 0.2s ease-in-out;
        width: 30rem;
        height: 100%;

        .line-item-wrapper {
            padding-right: 1rem;
        }

        @media (max-width: 640px) {
            left: 0;
            width: 100%;
            height: 100%;

            .line-item-wrapper {
                max-height: initial;
                overflow-y: auto;
            }
        }
    }

    /* Front Display System */
    .fds-order-kanban {
        display: grid;
        grid-template-columns: repeat(3, minmax(320px, 1fr)) !important;
        gap: 1rem;
        position: relative;
        align-items: start;

        &:has(.kitchen-swim-lane.collapsible) {
        grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr) 3.75rem !important;
        }
        &:has(.kitchen-swim-lane.collapsible.show) {
            grid-template-columns: repeat(3, minmax(320px, 1fr)) !important;
        }
    }

    /* Kitchen Order Card */
    kitchen-order-card {
        display: block;
        height: min-content;
        cursor: grab;
        user-select: none;
        -webkit-user-select: none;

        &.kanban-chosen {
        opacity: 0.5;
        transform: scale(0.92);
        box-shadow: var(--shadow-lg);
        }

        &.kanban-ghost {
        opacity: 0.7;
        transform: scale(0.92);
        }

        &.kanban-drag {
        opacity: 0.7;
        transform: rotate(-3deg);
        }

        .kitchen-order-card {
            background: var(--dark);
        }

        .order-badge {
            border: none;
            border-radius: 50em;
            width: 5.5rem;
            padding: 0.5rem 0.75rem;
            text-align: center;
            font-size: 0.75rem;
        }

        .order-badge.now {
            background-color: var(--error);
        }

        .order-badge.lunch {
            background-color: var(--info);
        }

        .order-badge.dinner {
            background-color: var(--brand-3);
        }
    }

    /* Kitchen Swim Lane */
    .kitchen-swim-lane {
        border-top: var(--rounded-lg) solid;

        &.collapsible {
            max-width: 3.75rem;
            [data-kanban-target="lane"], .kcs-empty-state {
                display: none !important;
            }

            header {
                /* rotate 90 deg to right */
                transform: rotate(90deg);
                transform-origin: left top;
                position: relative !important;
                left: 2.5rem;
                top: 1.5rem !important;
                width: max-content;
                align-items: center;
                border-bottom: 0 !important;

                button {
                    transform: rotate(-90deg);
                }
                svg.collapse {
                    display: flex !important;
                }
                svg.expand {
                    display: none !important;
                }

                .scroll-arrows {
                    display: none !important;
                }
            }

            &.show {
                max-width: none;
                header {
                    /* rotate 90 deg to right */
                    transform: rotate(0deg);
                    left: initial;
                    top: 0 !important;
                    width: initial;
                    border-bottom: var(--border-sm) solid var(--midtone) !important;
                    
                    button {
                        transform: rotate(0deg);
                    }
                    
                    svg.collapse {
                        display: none !important;
                    }
                    
                    svg.expand {
                        display: flex !important;
                    }

                    .scroll-arrows {
                        display: flex !important;
                    }
                }
                [data-kanban-target="lane"], .kcs-empty-state {
                    display: flex !important;
                }
            }
        }
    
        &.open {
            border-color: var(--success);
        }
    
        &.preparing {
            border-color: var(--info);
        }
    
        &.ready {
            border-color: var(--warning);
        }
    
        &.picked-up {
            border-color: var(--midtone);
        }

        &.not-picked-up {
            border-color: var(--black);
        }

        /* Sortable drop zone — fill available space so empty lanes accept drops */
        .kcs-sortable-lane {
            min-height: 60vh;
            flex: 1;
        }

        .kcs-empty-state {
            margin-top: auto;
        }

        &.kanban-ghost {
            opacity: 0.35;
        }
    
        &.kanban-drag {
            cursor: grabbing;
        }
    }

    /* Checkout Review */
    .checkout-review {
        display: flex;

        .stripe-info {
            width: max-content;
        }

        .customer-info {
            max-width: fit-content;
        }

        .pickup-time-options {
            align-items: stretch;
        }

        .checkout-pickup-option,
        .checkout-complete-purchase {
            width: 100%;
        }

        .payment-icon {
            width: 3rem;
        }

        .customer-info, .order-info {
            display: flex;
            flex-direction: column;
            gap: var(--space-sm);
            width: fit-content;
        }

        .order-info {
            width: 300px;
        }

        @media (max-width: 640px) {
            display: grid;
            margin: initial !important;
            width: auto !important;
            grid-template-areas: 
                "name"
                "pickup-time"
                "line-item-wrapper"
                "total"
                "payment";

            .stripe-info {
                width: initial !important;
                display: flex !important;
                align-items: center !important;
                justify-content: center;
            }

            .payment-methods {
                display: none !important;
            }

            .customer-info, .order-info {
                display: contents;
            }

            .name {
                grid-area: name;
            }
            
            .pickup-time {
                grid-area: pickup-time;
            }

            .payment {
                grid-area: payment;
            }

            .line-item-wrapper {
                grid-area: line-item-wrapper;
            }

            .total {
                grid-area: total;
            }
        }
    }

    .menu-item-modal {
        .order-card {
            max-width: 700px;
            width: min-content;
            height: fit-content;
            max-height: 80dvh;
        }

        .item-image, .item-placeholder {
            max-height: 300px !important;
            min-width: 400px;
            aspect-ratio: 4 / 3;
            width: fit-content !important;
        }

        @media (max-width: 640px) {
            padding: 0 !important;
            background: var(--white) !important;
            align-items: start !important;

            .item-image, .item-placeholder {
                min-width: 100%;
                width: 100% !important;
            }

            .order-card {
                padding: 0 var(--space-sm) !important;
                width: 100%;
                height: 100%;
            }
        }
    }

    /* Menu Order Page */
    .menu-order-container {
        @media (max-width: 640px) {
            padding-top: var(--space-sm) !important;
            padding-left: var(--space-sm) !important;
            padding-right: var(--space-sm) !important;
        }
    }
}
