* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


:root {
    --primary: #667eea;
    --primary-dark: #5568d9;
    --accent: #f39c12;
    --success: #27ae60;
    --danger: #e74c3c;
    --dark: #1a1a2e;
}


body {
    font-family: Arial, Helvetica, sans-serif;

    background: #f5f6fa;

    color: #333;

    overflow-x: hidden;
}


/* ==========================
   HEADER
   ========================== */

header {
    background: var(--dark);

    color: white;

    padding: 16px 6%;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 20px;

    flex-wrap: wrap;

    position: sticky;

    top: 0;

    z-index: 100;

    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
}


.logo {
    font-size: 24px;

    font-weight: bold;

    white-space: nowrap;
}


.search-box {
    display: flex;

    flex: 1;

    max-width: 420px;

    min-width: 180px;
}


.search-box input {
    flex: 1;

    padding: 9px 12px;

    border: none;

    border-radius: 6px 0 0 6px;

    font-size: 14px;
}


.search-box button {
    border: none;

    background: var(--primary);

    color: white;

    padding: 0 14px;

    border-radius: 0 6px 6px 0;

    cursor: pointer;

    transition: 0.2s;
}


.search-box button:hover {
    background: var(--primary-dark);
}


nav {
    display: flex;

    align-items: center;

    gap: 10px;
}


nav button {
    border: none;

    padding: 10px 16px;

    border-radius: 6px;

    cursor: pointer;

    font-size: 14px;

    transition: transform 0.15s, box-shadow 0.15s;
}


nav button:hover {
    transform: translateY(-2px);

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}


#loginButton {
    background: var(--primary);

    color: white;
}


#logoutButton {
    background: var(--danger);

    color: white;
}


.cart-button {
    background: var(--accent);

    color: white;

    position: relative;
}


.cart-button.bump {
    animation: cartBump 0.35s ease;
}


@keyframes cartBump {

    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.25); }
}


.user-name {
    font-weight: bold;

    margin-right: 5px;

    white-space: nowrap;
}


.hidden {
    display: none !important;
}


/* ==========================
   HERO (parallax)
   ========================== */

.hero {
    position: relative;

    min-height: 400px;

    display: flex;

    justify-content: center;

    align-items: center;

    text-align: center;

    color: white;

    overflow: hidden;
}


.hero-layer {
    position: absolute;

    inset: -30px;

    will-change: transform;

    transition: transform 0.1s ease-out;
}


.hero-layer-bg {
    background:
        linear-gradient(
            135deg,
            rgba(102, 126, 234, 0.9),
            rgba(118, 75, 162, 0.9)
        ),
        url("https://images.unsplash.com/photo-1441986300917-64674bd600d8?auto=format&fit=crop&w=1600&q=80");

    background-size: cover;

    background-position: center;
}


.hero-layer-glow {
    background:
        radial-gradient(
            circle at 30% 30%,
            rgba(255, 255, 255, 0.15),
            transparent 45%
        ),
        radial-gradient(
            circle at 75% 70%,
            rgba(243, 156, 18, 0.25),
            transparent 40%
        );
}


.hero-content {
    position: relative;

    z-index: 2;

    animation: heroFadeIn 0.8s ease;
}


@keyframes heroFadeIn {

    from {
        opacity: 0;
        transform: translateY(25px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


.hero h1 {
    font-size: 46px;

    margin-bottom: 12px;

    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}


.hero p {
    font-size: 18px;

    margin-bottom: 22px;

    opacity: 0.95;
}


.shop-now {
    padding: 13px 28px;

    border: none;

    border-radius: 8px;

    background: var(--accent);

    color: white;

    font-size: 16px;

    cursor: pointer;

    transition: transform 0.2s, box-shadow 0.2s;

    box-shadow: 0 8px 25px rgba(243, 156, 18, 0.4);
}


.shop-now:hover {
    transform: translateY(-3px) scale(1.03);

    box-shadow: 0 12px 30px rgba(243, 156, 18, 0.55);
}


/* ==========================
   CATEGORY BAR
   ========================== */

.category-bar {
    background: white;

    padding: 16px 6%;

    border-bottom: 1px solid #e5e5e5;

    position: sticky;

    top: 70px;

    z-index: 90;

    overflow-x: auto;
}


.category-list {
    display: flex;

    gap: 10px;

    flex-wrap: nowrap;
}


.category-chip {
    border: 1px solid #ddd;

    background: white;

    color: #444;

    padding: 8px 16px;

    border-radius: 20px;

    cursor: pointer;

    font-size: 14px;

    white-space: nowrap;

    transition: 0.2s;
}


.category-chip:hover {
    border-color: var(--primary);

    color: var(--primary);

    transform: translateY(-1px);
}


.category-chip.active {
    background: var(--primary);

    border-color: var(--primary);

    color: white;
}


/* ==========================
   PRODUCTS
   ========================== */

main {
    padding: 45px 6%;

    min-height: 500px;

    perspective: 1200px;
}


main > h2 {
    text-align: center;

    margin-bottom: 35px;

    font-size: 30px;
}


.products {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(220px, 1fr)
        );

    gap: 25px;
}


.product {
    background: white;

    border-radius: 12px;

    overflow: hidden;

    box-shadow:
        0 4px 15px
        rgba(0, 0, 0, 0.08);

    display: flex;

    flex-direction: column;

    transform-style: preserve-3d;

    will-change: transform;

    transition: transform 0.15s ease-out, box-shadow 0.3s;

    /* scroll-reveal starting state */
    opacity: 0;

    transform: translateY(30px);
}


.product.revealed {
    animation: revealCard 0.5s ease forwards;
}


@keyframes revealCard {

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


.product:hover {
    box-shadow:
        0 20px 40px
        rgba(0, 0, 0, 0.2);
}


.product img {
    width: 100%;

    height: 200px;

    object-fit: cover;

    transform: translateZ(20px);
}


.product-content {
    padding: 18px;

    display: flex;

    flex-direction: column;

    flex: 1;

    transform: translateZ(30px);
}


.product-category {
    display: inline-block;

    font-size: 11px;

    text-transform: uppercase;

    letter-spacing: 0.5px;

    color: var(--primary);

    font-weight: bold;

    margin-bottom: 6px;
}


.product h3 {
    margin-bottom: 8px;

    font-size: 18px;
}


.product-desc {
    color: #777;

    font-size: 13px;

    margin-bottom: 12px;

    flex: 1;
}


.product-price {
    color: #e67e22;

    font-size: 20px;

    font-weight: bold;

    margin-bottom: 15px;
}


.add-button {
    width: 100%;

    padding: 11px;

    background: var(--success);

    color: white;

    border: none;

    border-radius: 6px;

    cursor: pointer;

    font-size: 15px;

    transition: transform 0.15s, background 0.15s;
}


.add-button:hover {
    background: #219150;

    transform: translateY(-2px);
}


.add-button:active {
    transform: translateY(0) scale(0.97);
}


.no-products {
    grid-column: 1 / -1;

    text-align: center;

    color: #777;

    padding: 40px 0;
}


/* ==========================
   FLY-TO-CART GHOST IMAGE
   ========================== */

.fly-to-cart {
    position: fixed;

    z-index: 500;

    border-radius: 10px;

    pointer-events: none;

    object-fit: cover;

    transition:
        top 0.7s cubic-bezier(0.55, 0, 0.1, 1),
        left 0.7s cubic-bezier(0.55, 0, 0.1, 1),
        width 0.7s ease,
        height 0.7s ease,
        opacity 0.7s ease;
}


/* ==========================
   CART DRAWER
   ========================== */

.cart-drawer-overlay {
    display: none;

    position: fixed;

    inset: 0;

    background: rgba(0, 0, 0, 0.55);

    z-index: 200;

    opacity: 0;

    transition: opacity 0.3s ease;
}


.cart-drawer-overlay.open {
    display: block;

    opacity: 1;
}


.cart-drawer {
    position: fixed;

    top: 0;

    right: 0;

    height: 100vh;

    width: 420px;

    max-width: 92vw;

    background: white;

    z-index: 201;

    display: flex;

    flex-direction: column;

    transform: translateX(100%);

    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);

    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.25);
}


.cart-drawer.open {
    transform: translateX(0);
}


.cart-drawer-header {
    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 22px 24px;

    border-bottom: 1px solid #eee;
}


.cart-drawer-header h2 {
    font-size: 20px;
}


.close-button {
    border: none;

    background: #f0f0f5;

    width: 34px;

    height: 34px;

    border-radius: 50%;

    font-size: 16px;

    cursor: pointer;

    transition: 0.2s;
}


.close-button:hover {
    background: #e2e2ec;

    transform: rotate(90deg);
}


.cart-drawer-items {
    flex: 1;

    overflow-y: auto;

    padding: 10px 24px;
}


.cart-empty {
    text-align: center;

    color: #999;

    padding: 60px 10px;
}


.cart-empty-icon {
    font-size: 46px;

    margin-bottom: 10px;
}


.cart-item {
    display: flex;

    align-items: center;

    gap: 12px;

    padding: 14px 0;

    border-bottom: 1px solid #f0f0f0;

    animation: itemIn 0.25s ease;
}


@keyframes itemIn {

    from {
        opacity: 0;
        transform: translateX(15px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}


.cart-item img {
    width: 55px;

    height: 55px;

    border-radius: 8px;

    object-fit: cover;

    flex-shrink: 0;
}


.cart-item-info {
    flex: 1;

    min-width: 0;
}


.cart-item-name {
    font-weight: bold;

    font-size: 14px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.cart-item-price {
    color: #777;

    margin-top: 4px;

    font-size: 13px;
}


.quantity-controls {
    display: flex;

    align-items: center;

    gap: 8px;
}


.quantity-controls button {
    width: 26px;

    height: 26px;

    border: none;

    background: #eee;

    border-radius: 6px;

    cursor: pointer;

    transition: 0.15s;
}


.quantity-controls button:hover {
    background: var(--primary);

    color: white;
}


.remove-button {
    border: none;

    background: transparent;

    color: var(--danger);

    font-size: 16px;

    cursor: pointer;

    padding: 6px;

    transition: transform 0.15s;
}


.remove-button:hover {
    transform: scale(1.2);
}


.cart-drawer-footer {
    padding: 20px 24px 24px;

    border-top: 1px solid #eee;
}


.cart-total {
    display: flex;

    justify-content: space-between;

    align-items: center;

    font-size: 18px;

    margin-bottom: 16px;
}


.checkout-button {
    width: 100%;

    padding: 14px;

    background: var(--primary);

    color: white;

    border: none;

    border-radius: 8px;

    font-size: 16px;

    font-weight: bold;

    cursor: pointer;

    transition: transform 0.15s, background 0.15s;
}


.checkout-button:hover {
    background: var(--primary-dark);

    transform: translateY(-2px);
}


.checkout-button:disabled {
    opacity: 0.6;

    cursor: not-allowed;

    transform: none;
}


/* ==========================
   TOASTS
   ========================== */

.toast-container {
    position: fixed;

    bottom: 24px;

    right: 24px;

    z-index: 300;

    display: flex;

    flex-direction: column;

    gap: 10px;
}


.toast {
    background: var(--dark);

    color: white;

    padding: 14px 18px;

    border-radius: 8px;

    font-size: 14px;

    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);

    display: flex;

    align-items: center;

    gap: 10px;

    min-width: 220px;

    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}


.toast.success {
    border-left: 4px solid var(--success);
}


.toast.error {
    border-left: 4px solid var(--danger);
}


.toast.info {
    border-left: 4px solid var(--primary);
}


@keyframes toastIn {

    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}


@keyframes toastOut {

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}


/* ==========================
   FOOTER
   ========================== */

footer {
    background: var(--dark);

    color: white;

    text-align: center;

    padding: 25px;
}


/* ==========================
   MOBILE
   ========================== */

@media (max-width: 700px) {

    header {
        flex-direction: column;

        padding: 15px;
    }

    .search-box {
        max-width: 100%;

        order: 3;
    }

    nav {
        flex-wrap: wrap;

        justify-content: center;
    }

    .category-bar {
        top: 128px;
    }

    .hero h1 {
        font-size: 32px;
    }

    main {
        padding: 30px 5%;
    }

    .cart-drawer {
        width: 100vw;

        max-width: 100vw;
    }

    .toast-container {
        left: 16px;

        right: 16px;

        bottom: 16px;
    }

    .toast {
        min-width: 0;
    }
}
