/* ============================================================
   APPLE DEPARTMENT STORE — multi-floor catalog UI
   Loaded after ../shared/store.css for header + modal base.
   ============================================================ */

:root {
    --dept-bg-1: #1a1a1f;
    --dept-bg-2: #0a0a0e;
    --dept-card: #ffffff;
    --dept-card-2: #f5f5f7;
    --dept-text: #1c1c1e;
    --dept-text-2: #6e6e73;
    --dept-line: rgba(255, 255, 255, 0.08);
    --dept-accent: #0071e3;        /* Apple blue */
    --dept-accent-dark: #0051a3;
    --grade-gen: #16a34a;   /* 정품 — green */
    --grade-copy: #ca8a04;  /* 카피 — amber */
    --grade-recyc: #2563eb; /* 재생 — blue */
}

/* Override vm-stage from shared to a dept-store-friendly dark */
.vm-stage {
    background:
        radial-gradient(900px 400px at 50% 0%, rgba(0, 113, 227, 0.06), transparent 60%),
        linear-gradient(180deg, var(--dept-bg-1) 0%, var(--dept-bg-2) 100%);
    color: #f5f5f7;
    padding-top: 64px;
    min-height: 100vh;
    overflow: hidden;
}

.dept-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    height: calc(100vh - 64px);
    overflow: hidden;
}

/* ---------- ELEVATOR (left rail) ---------- */
.elevator {
    background: rgba(8, 8, 12, 0.92);
    border-right: 1px solid var(--dept-line);
    display: flex; flex-direction: column;
    overflow-y: auto;
}
.elevator-head {
    padding: 16px 18px 12px;
    font-size: 10px; font-weight: 900; letter-spacing: 3px;
    color: var(--dept-accent);
    border-bottom: 1px solid var(--dept-line);
    text-transform: uppercase;
    flex-shrink: 0;
}
.elevator-list {
    flex: 1;
    padding: 12px 10px;
    display: flex; flex-direction: column-reverse;
    gap: 4px;
}
.floor-btn {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    border-radius: 4px;
    color: rgba(245, 245, 247, 0.78);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    font-family: inherit;
}
.floor-btn:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
}
.floor-btn.is-active {
    background: rgba(0, 113, 227, 0.14);
    border-left-color: var(--dept-accent);
    color: #fff;
}
.floor-btn .f-num {
    flex-shrink: 0;
    width: 32px;
    font-size: 11px; font-weight: 900; letter-spacing: 0.5px;
    color: var(--dept-accent);
    font-family: 'Inter', monospace;
}
.floor-btn.is-active .f-num { color: #4ea4ff; }
.floor-btn .f-emoji { font-size: 16px; flex-shrink: 0; }
.floor-btn .f-name {
    flex: 1;
    font-size: 13px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.floor-btn .f-count {
    font-size: 10px; font-weight: 800;
    color: rgba(245, 245, 247, 0.4);
    flex-shrink: 0;
}
.floor-btn.is-active .f-count { color: rgba(78, 164, 255, 0.85); }

/* ---------- FLOOR VIEW (right) ---------- */
.floor-view {
    overflow-y: auto;
    padding: 24px 32px 80px;
}
.floor-header {
    display: flex; align-items: flex-end; gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--dept-line);
}
.floor-header h1 {
    font-size: 28px; font-weight: 900; letter-spacing: -0.5px;
    color: #fff;
    display: flex; align-items: center; gap: 10px;
}
.floor-header h1 .emoji { font-size: 26px; }
.floor-header .floor-num {
    font-size: 12px; font-weight: 900; letter-spacing: 2.5px;
    padding: 4px 10px;
    background: var(--dept-accent);
    color: #fff;
    border-radius: 4px;
}
.floor-header .floor-count {
    font-size: 13px; font-weight: 700;
    color: var(--dept-text-2);
    margin-left: auto;
}

/* ---------- MODEL CHIPS ---------- */
.model-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 22px;
}
.chip {
    padding: 7px 13px;
    font-size: 11px; font-weight: 800; letter-spacing: 0.4px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(245, 245, 247, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.chip.is-active {
    background: var(--dept-accent);
    color: #fff;
    border-color: var(--dept-accent);
}

/* ---------- PRODUCT GROUPS ---------- */
.group { margin-bottom: 28px; }
.group-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 12px;
}
.group-head .label {
    font-size: 14px; font-weight: 900; letter-spacing: 0.3px;
    color: #fff;
}
.group-head .count {
    font-size: 11px; font-weight: 700;
    color: var(--dept-text-2);
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
}
.group-head .divider {
    flex: 1; height: 1px;
    background: var(--dept-line);
}

/* ---------- CARD GRID ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.product-card {
    position: relative;
    display: flex; flex-direction: column;
    padding: 12px 12px 10px;
    background: var(--dept-card);
    color: var(--dept-text);
    border-radius: 8px;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    cursor: pointer;
    /* Defer paint for cards offscreen — keeps 100+ cards from blocking the main thread */
    content-visibility: auto;
    contain-intrinsic-size: 0 180px;
}
.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25), 0 10px 22px rgba(0, 113, 227, 0.2);
    border-color: rgba(0, 113, 227, 0.4);
}
.product-card .grade {
    position: absolute;
    top: 8px; right: 8px;
    font-size: 9px; font-weight: 900; letter-spacing: 0.5px;
    padding: 2px 6px;
    color: #fff;
    border-radius: 3px;
    text-transform: uppercase;
}
.product-card .grade.gen   { background: var(--grade-gen); }
.product-card .grade.copy  { background: var(--grade-copy); }
.product-card .grade.recyc { background: var(--grade-recyc); }
.product-card .icon {
    width: 36px; height: 36px;
    margin-bottom: 6px;
    color: var(--dept-text-2);
    opacity: 0.85;
}
.product-card .thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    margin-bottom: 8px;
    background: #fafafa;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.product-card .thumb img {
    width: 100%; height: 100%;
    object-fit: contain;
    padding: 6px;
}
.product-card.has-thumb { padding-top: 10px; }
.product-card .name {
    font-size: 12px; font-weight: 800;
    color: var(--dept-text);
    line-height: 1.3;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card .meta {
    font-size: 10px; font-weight: 600;
    color: var(--dept-text-2);
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 28px;
}
.product-card .meta .dot { color: var(--dept-line); margin: 0 4px; }
.product-card .price-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: auto;
    gap: 8px;
}
.product-card .price {
    font-size: 14px; font-weight: 900;
    color: var(--dept-text);
    letter-spacing: -0.3px;
}
.product-card .price .currency {
    font-size: 11px; color: var(--dept-accent); font-weight: 700; margin-right: 1px;
}
.product-card .add {
    flex-shrink: 0;
    width: 30px; height: 30px;
    background: var(--dept-text);
    color: #fff;
    border: 0;
    border-radius: 50%;
    font-size: 18px; font-weight: 700; line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.12s ease;
    font-family: inherit;
}
.product-card .add:hover {
    background: var(--dept-accent);
    transform: scale(1.08);
}
.product-card .add:active { transform: scale(0.95); }

/* ---------- "더 보기" expand button ---------- */
.show-more {
    margin-top: 10px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 113, 227, 0.12);
    color: #4ea4ff;
    border: 1px dashed rgba(0, 113, 227, 0.45);
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px; font-weight: 800; letter-spacing: 0.6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.show-more:hover {
    background: rgba(0, 113, 227, 0.2);
    color: #fff;
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--dept-text-2);
}
.empty-state .icon { font-size: 36px; margin-bottom: 12px; }
.empty-state .title { font-size: 14px; font-weight: 800; color: #f5f5f7; margin-bottom: 6px; }
.empty-state .sub { font-size: 12px; }

/* ---------- LOADING ---------- */
.loading {
    padding: 80px 20px; text-align: center; color: var(--dept-text-2);
    font-size: 12px; font-weight: 700; letter-spacing: 1px;
}

/* ---------- CART DRAWER (modal) ---------- */
.cart-back {
    position: fixed; inset: 0; z-index: 150;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: stretch; justify-content: flex-end;
    animation: cartFade 0.25s ease-out;
}
@keyframes cartFade { from { opacity: 0; } to { opacity: 1; } }
.cart-panel {
    background: #fff;
    color: var(--dept-text);
    width: 100%; max-width: 420px;
    display: flex; flex-direction: column;
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
    animation: cartSlide 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cartSlide { from { transform: translateX(20px); } to { transform: translateX(0); } }
.cart-panel > header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #e5e5e5;
}
.cart-panel > header h2 {
    margin: 0;
    font-size: 16px; font-weight: 900;
}
.cart-panel > header button {
    width: 32px; height: 32px;
    border: 0; background: #f5f5f7;
    border-radius: 50%;
    font-size: 18px; cursor: pointer;
    font-family: inherit;
}
.cart-list {
    flex: 1; overflow-y: auto;
    padding: 8px 22px;
}
.cart-line {
    display: grid;
    grid-template-columns: 1fr auto auto 32px;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}
.cart-line .line-name {
    font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cart-line .line-qty {
    font-size: 12px; color: var(--dept-text-2); font-weight: 700;
}
.cart-line .line-sub {
    font-weight: 900; letter-spacing: -0.3px;
}
.cart-line .line-rm {
    width: 26px; height: 26px;
    border: 0; background: #f5f5f7;
    border-radius: 50%;
    font-size: 16px; color: #888;
    cursor: pointer;
    font-family: inherit;
}
.cart-line .line-rm:hover { background: #ffe0e0; color: #c00; }
.cart-panel > footer {
    padding: 18px 22px;
    border-top: 1px solid #e5e5e5;
    background: #fafafa;
}
.cart-total {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 14px;
}
.cart-total span { font-size: 13px; color: var(--dept-text-2); font-weight: 700; }
.cart-total strong { font-size: 22px; font-weight: 900; letter-spacing: -0.5px; }
.cart-checkout {
    width: 100%; height: 48px;
    background: var(--dept-text); color: #fff;
    border: 0; border-radius: 8px;
    font-size: 14px; font-weight: 900; letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}
.cart-checkout:hover { background: var(--dept-accent); }

/* ---------- TOAST ---------- */
.dept-toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translate(-50%, 80px); z-index: 200;
    background: #fff; color: var(--dept-text);
    padding: 12px 22px; border-radius: 999px;
    font-size: 13px; font-weight: 800; letter-spacing: 0.3px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
    pointer-events: none;
}
.dept-toast.is-shown {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- MOBILE ---------- */
@media (max-width: 768px) {
    .dept-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .elevator {
        border-right: 0;
        border-bottom: 1px solid var(--dept-line);
        max-height: 130px;
    }
    .elevator-list {
        flex-direction: row;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 10px;
    }
    .floor-btn {
        flex-shrink: 0;
        border-left: 0;
        border-bottom: 3px solid transparent;
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 12px;
        min-width: 120px;
    }
    .floor-btn.is-active {
        border-left: 0;
        border-bottom-color: var(--dept-accent);
    }
    .floor-view { padding: 16px 14px 80px; }
    .floor-header h1 { font-size: 20px; }
    .floor-header h1 .emoji { font-size: 20px; }
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
