/* ============================================================
   Kura Sushi — Cart Page Styles (mobile-first)
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #212121;
    background: #f8f8f8;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

html.no-scroll,
html.no-scroll body {
    overflow: hidden;
}

img { display: block; max-width: 100%; height: auto; }
button { cursor: pointer; font: inherit; border: none; background: none; }

/* --- Shared --- */
.btn-black {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #212121;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 24px;
    letter-spacing: 0.5px;
    transition: background 0.15s;
    width: 100%;
}
.btn-black:active { background: #000; }

/* ============================================================
   Header
   ============================================================ */
.cart-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.cart-header__back {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: #212121;
    text-decoration: none;
    border-radius: 50%;
    transition: background 0.15s;
}
.cart-header__back:active { background: #f0f0f0; }

.cart-header__logo { display: flex; align-items: center; }
.cart-header__logo img { height: 28px; width: auto; }

.cart-header__cart-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: #212121;
    border-radius: 50%;
    transition: background 0.15s;
}
.cart-header__cart-btn:active { background: #f0f0f0; }
.cart-header__cart-btn.is-pulsing {
    animation: cartButtonPulse 0.45s ease;
}

@keyframes cartButtonPulse {
    0% { transform: scale(1); }
    45% { transform: scale(1.14); }
    100% { transform: scale(1); }
}

.cart-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ed1c24;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
}

/* ============================================================
   Delivery Bar (collapsed)
   ============================================================ */
.delivery-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    gap: 12px;
}
.delivery-bar:active { background: #fafafa; }

.delivery-bar__content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.delivery-bar__pin {
    flex-shrink: 0;
    color: #212121;
    margin-top: 1px;
}

.delivery-bar__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.delivery-bar__address {
    font-size: 14px;
    font-weight: 600;
    color: #212121;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delivery-bar__time {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}
.delivery-bar__time:empty { display: none; }

.delivery-bar__edit {
    flex-shrink: 0;
    color: #999;
}

/* ============================================================
   Delivery Modal (bottom sheet)
   ============================================================ */
.delivery-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.5);
    align-items: flex-end;
    justify-content: center;
}
.delivery-overlay.is-open { display: flex; }

.delivery-modal {
    position: relative;
    width: 100%;
    max-height: 90vh;
    background: #fff;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.25s ease-out;
}

.delivery-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #eee;
}
.delivery-modal__header h2 {
    font-size: 18px;
    font-weight: 700;
}

.delivery-modal__close {
    width: 32px;
    height: 32px;
    font-size: 24px;
    line-height: 32px;
    text-align: center;
    color: #333;
    border-radius: 50%;
}
.delivery-modal__close:active { background: #f0f0f0; }

.delivery-modal__body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
}

.delivery-section {
    margin-bottom: 24px;
}

.delivery-label {
    font-size: 13px;
    font-weight: 600;
    color: #212121;
    margin-bottom: 8px;
    display: block;
}

.delivery-input-wrap {
    position: relative;
}

.delivery-input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.delivery-input {
    width: 100%;
    padding: 12px 12px 12px 38px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    background: #fff;
}
.delivery-input:focus { border-color: #212121; }

.delivery-restaurant {
    font-size: 12px;
    color: #999;
    margin-top: 8px;
    line-height: 1.4;
}

.delivery-section__title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}

.delivery-info {
    font-size: 13px;
    color: #666;
    margin-bottom: 16px;
}

/* Day Tabs */
.delivery-days {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 12px;
    margin-bottom: 4px;
}
.delivery-days::-webkit-scrollbar { display: none; }

.delivery-day {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border-radius: 10px;
    background: #f0f0f0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border: none;
    min-width: 64px;
}
.delivery-day__label {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
}
.delivery-day__date {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.7;
    line-height: 1.3;
}
.delivery-day.is-active {
    background: #212121;
    color: #fff;
}
.delivery-day.is-active .delivery-day__date { opacity: 0.8; }

/* Time Slots */
.delivery-slots {
    max-height: 280px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.delivery-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 4px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.1s;
}
.delivery-slot:active { background: #fafafa; }

.delivery-slot__radio {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #ccc;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s;
}
.delivery-slot.is-selected .delivery-slot__radio {
    border-color: #212121;
}
.delivery-slot.is-selected .delivery-slot__radio::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #212121;
}

.delivery-slot__time {
    font-size: 15px;
    font-weight: 500;
}

/* Footer */
.delivery-modal__footer {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    background: #fff;
}

.delivery-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   Category Nav Bar
   ============================================================ */
.cat-nav {
    position: sticky;
    top: 56px;
    z-index: 90;
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.cat-nav__track {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cat-nav__track::-webkit-scrollbar { display: none; }

.cat-nav__tab {
    flex: 0 0 auto;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    color: #555;
    background: #f0f0f0;
    transition: background 0.15s, color 0.15s;
}
.cat-nav__tab.is-active {
    background: #212121;
    color: #fff;
}

/* ============================================================
   Menu Sections
   ============================================================ */
.menu-sections {
    padding: 0 12px 120px;
}

.menu-section {
    scroll-margin-top: 110px;
    padding-top: 20px;
}

.menu-section__title {
    font-size: 20px;
    font-weight: 700;
    padding: 0 4px 12px;
    color: #212121;
}

/* --- Product Grid --- */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.menu-card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s;
}
.menu-card:active { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.menu-card.is-added {
    transform: translateY(-2px);
    box-shadow: 0 0 0 2px #ed1c24, 0 8px 18px rgba(0,0,0,0.12);
}

.menu-card__img-wrap {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 aspect ratio */
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite ease-in-out;
    overflow: hidden;
}
.menu-card__img-wrap.is-loaded {
    animation: none;
    background: #f5f5f5;
}
.menu-card__img-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s;
}
.menu-card__img-wrap.is-loaded img {
    opacity: 1;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.menu-card__body {
    padding: 8px 10px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.menu-card__name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.menu-card__price {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.menu-card__add {
    margin: 6px 10px 10px;
    padding: 8px 0;
    background: #212121;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transition: background 0.15s;
}
.menu-card__add:active { background: #000; }
.menu-card__add.is-added {
    background: #ed1c24;
}

/* ============================================================
   Product Modal
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.5);
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.is-open {
    display: flex;
}

.modal {
    position: relative;
    width: 100%;
    max-height: 92vh;
    background: #fff;
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: modalSlideUp 0.25s ease-out;
}

@keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding-bottom: 2px;
    color: #333;
    z-index: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.modal__img-wrap {
    width: 100%;
    padding-top: 100%;
    position: relative;
    background: #f5f5f5;
}
.modal__img-wrap .modal__img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal__body {
    padding: 20px 16px 24px;
}

.modal__name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal__desc {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 12px;
}

.modal__price {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* Quantity control */
.qty-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.qty-control__btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #212121;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding-bottom: 2px;
    color: #212121;
    background: #fff;
    transition: background 0.15s;
}
.qty-control__btn:active { background: #f0f0f0; }

.qty-control__value {
    font-size: 20px;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}

.modal__add-btn {
    margin-top: 4px;
}

/* ============================================================
   Off-Canvas Cart
   ============================================================ */
.offcanvas-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,0.5);
}
.offcanvas-backdrop.is-open { display: block; }

.offcanvas-cart {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 310;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
.offcanvas-cart.is-open {
    transform: translateX(0);
}

.offcanvas-cart__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px;
    border-bottom: 1px solid #eee;
}
.offcanvas-cart__header h2 {
    font-size: 18px;
    font-weight: 700;
}

.offcanvas-cart__close {
    width: 32px;
    height: 32px;
    font-size: 24px;
    line-height: 32px;
    text-align: center;
    color: #333;
    border-radius: 50%;
}
.offcanvas-cart__close:active { background: #f0f0f0; }

.offcanvas-cart__items {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px;
}

/* Empty state */
.offcanvas-cart__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 15px;
}

/* Cart item row */
.cart-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.cart-item__img {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f5f5f5;
}

.cart-item__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.cart-item__name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item__price {
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

.cart-item__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.cart-item__qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid #ccc;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding-bottom: 2px;
    color: #333;
    background: #fff;
}
.cart-item__qty-btn:active { background: #f0f0f0; }

.cart-item__qty {
    font-size: 14px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.cart-item__remove {
    font-size: 18px;
    color: #bbb;
    padding: 0 4px;
    margin-left: 4px;
}
.cart-item__remove:active { color: #ed1c24; }

/* Footer */
.offcanvas-cart__footer {
    padding: 16px;
    border-top: 1px solid #eee;
    background: #fff;
}

.offcanvas-cart__subtotal {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.offcanvas-cart__checkout {
    width: 100%;
    text-decoration: none;
    text-align: center;
}
.offcanvas-cart__checkout[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.cart-toast {
    position: fixed;
    left: 50%;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 500;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 8px;
    background: #212121;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.cart-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ============================================================
   Tablet (≥ 768px)
   ============================================================ */
@media (min-width: 768px) {
    .cart-header__back { display: flex; }
    .delivery-bar { padding: 12px 24px; }
    .delivery-modal {
        max-width: 480px;
        border-radius: 16px;
        margin: auto;
        max-height: 85vh;
    }
    .delivery-overlay.is-open { align-items: center; }
    .menu-sections { padding: 0 24px 120px; }
    .menu-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }

    .menu-card__name { font-size: 14px; }
    .menu-card__price { font-size: 14px; }

    .modal {
        max-width: 480px;
        border-radius: 16px;
        margin: auto;
        animation: modalFadeIn 0.2s ease-out;
    }

    .modal-overlay.is-open {
        align-items: center;
    }

    @keyframes modalFadeIn {
        from { opacity: 0; transform: scale(0.95); }
        to   { opacity: 1; transform: scale(1); }
    }
}

/* ============================================================
   Desktop (≥ 1024px)
   ============================================================ */
@media (min-width: 1024px) {
    .menu-sections { max-width: 1100px; margin: 0 auto; padding: 0 32px 120px; }
    .menu-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }

    .cat-nav__track { max-width: 1100px; margin: 0 auto; padding: 10px 32px; }

    .cart-header { padding: 0 32px; }

    .delivery-bar { max-width: 1100px; margin: 0 auto; padding: 12px 32px; }

    .menu-card__name { font-size: 14px; }

    .btn-black:hover { background: #333; }
    .menu-card__add:hover { background: #333; }
    .cart-header__back:hover { background: #f0f0f0; }
    .cart-header__cart-btn:hover { background: #f0f0f0; }
    .cat-nav__tab:hover:not(.is-active) { background: #e0e0e0; }
}
