/* ============================================
   NEBULA — дизайн-система (тёмно-зелёная тема)
   ============================================ */
:root {
    --bg: #0c0c12;
    --card-bg: rgba(24, 24, 37, 0.72);
    --card-solid: #181825;
    --accent: #7c3aed;
    --accent-soft: rgba(124, 58, 237, 0.16);
    --accent-bright: #8b5cf6;
    --text: #f1f1f6;
    --text-dim: #8a8a9e;
    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.12);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-pill: 40px;
    --font-body: "Inter", system-ui, sans-serif;
    --font-display: "Space Grotesk", "Inter", sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Тихое зелёное свечение по краям фона */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(60% 40% at 85% 110%, rgba(124, 58, 237, 0.10), transparent 70%),
        radial-gradient(50% 35% at 8% -5%, rgba(124, 58, 237, 0.07), transparent 70%);
    z-index: 0;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

::selection {
    background: var(--accent);
    color: #fff;
}

button {
    font-family: inherit;
}

/* ============ Шапка ============ */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: rgba(12, 12, 18, 0.72);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}

.header--scrolled {
    border-bottom-color: var(--border);
    background: rgba(12, 12, 18, 0.88);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
    gap: 16px;
}

.logo {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: 0.12em;
    color: var(--text);
    text-decoration: none;
}

.logo__dot {
    color: var(--accent);
}

.logo--sm {
    font-size: 1.05rem;
}

.header__tag {
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.header__actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}

.icon-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 20px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s var(--ease);
    transform: scale(0);
}

.cart-badge--visible {
    transform: scale(1);
}

.cart-badge--pulse {
    animation: badgePulse 0.4s var(--ease);
}

@keyframes badgePulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.45); }
    100% { transform: scale(1); }
}

/* ============ Герой ============ */
.hero {
    padding: 72px 0 40px;
}

.hero__title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.01em;
}

.hero__title em {
    font-style: normal;
    color: var(--accent);
}

.hero__sub {
    margin-top: 16px;
    max-width: 520px;
    color: var(--text-dim);
    font-size: 1rem;
}

/* ============ Фильтры ============ */
.filters {
    position: sticky;
    top: 72px;
    z-index: 40;
    padding: 16px 0 8px;
    background: rgba(12, 12, 18, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.filters__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.filters__categories {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.filter-btn {
    position: relative;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-pill);
    transition: color 0.25s var(--ease), background 0.25s var(--ease);
}

.filter-btn::after {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 5px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s var(--ease);
}

.filter-btn:hover {
    color: var(--text);
}

.filter-btn.active {
    color: var(--text);
    background: var(--accent-soft);
}

.filter-btn.active::after {
    transform: scaleX(1);
}

.filters__search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 240px;
    flex: 0 1 300px;
}

.filters__search-icon {
    position: absolute;
    left: 14px;
    width: 17px;
    height: 17px;
    color: var(--text-dim);
    pointer-events: none;
}

.filters__search input {
    width: 100%;
    padding: 11px 40px 11px 40px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.filters__search input::placeholder {
    color: var(--text-dim);
}

.filters__search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.filters__search-clear {
    position: absolute;
    right: 10px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease), color 0.2s var(--ease);
}

.filters__search-clear:hover {
    color: var(--text);
}

.filters__search-clear--visible {
    opacity: 1;
    pointer-events: auto;
}

.filters__meta {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-dim);
    letter-spacing: 0.04em;
}

/* ============ Каталог ============ */
.catalog {
    padding: 24px 0 80px;
}

.catalog__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}

.catalog__grid--fading {
    opacity: 0;
    transform: translateY(8px);
}

/* Карточка товара */
.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
    animation: cardIn 0.45s var(--ease) both;
    animation-delay: calc(var(--i, 0) * 35ms);
    display: flex;
    flex-direction: column;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border-color: var(--border-strong);
}

.product-card__media {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    aspect-ratio: 1 / 1;
    background: #10101a;
}

.product-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s var(--ease);
}

.product-card:hover .product-card__media img {
    transform: scale(1.045);
}

.product-card__stock {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: rgba(12, 12, 18, 0.72);
    backdrop-filter: blur(6px);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.product-card__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 12px;
}

.product-card__category {
    font-size: 0.72rem;
    color: var(--text-dim);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.product-card__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.1rem;
    margin-top: 4px;
}

.product-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 12px;
}

.product-card__price {
    color: var(--accent-bright);
    font-weight: 700;
    font-size: 1.15rem;
    font-family: var(--font-display);
}

.add-to-cart {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-pill);
    padding: 10px 18px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.2s var(--ease), transform 0.2s var(--ease), opacity 0.2s var(--ease);
}

.add-to-cart:hover:not(:disabled) {
    background: #6d28d9;
    transform: translateY(-1px);
}

.add-to-cart:active:not(:disabled) {
    transform: translateY(0) scale(0.97);
}

.add-to-cart:disabled {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: not-allowed;
}

.add-to-cart--wide {
    width: 100%;
    justify-content: center;
    margin-top: 12px;
}

/* Пустой результат */
.catalog__empty {
    text-align: center;
    padding: 80px 0;
}

.catalog__empty-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
}

.catalog__empty-sub {
    color: var(--text-dim);
    margin: 8px 0 24px;
}

/* ============ Кнопки общие ============ */
.btn {
    border-radius: var(--radius-pill);
    padding: 14px 24px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.btn-primary {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
}

.btn-primary:hover {
    background: #6d28d9;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.btn-ghost:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ============ Модальное окно товара ============ */
.product-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s var(--ease);
}

.product-modal--open {
    opacity: 1;
    pointer-events: auto;
}

.product-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 10, 0.75);
    backdrop-filter: blur(8px);
    cursor: pointer;
}

.product-modal__content {
    position: relative;
    background: var(--card-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.4s var(--ease);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6);
}

.product-modal--open .product-modal__content {
    transform: translateY(0) scale(1);
}

.product-modal__media {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    background: #10101a;
}

.product-modal__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-modal__stock {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: rgba(10, 15, 12, 0.8);
    backdrop-filter: blur(8px);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.product-modal__info {
    padding: 32px;
    display: flex;
    flex-direction: column;
}

.product-modal__category {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.product-modal__title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 8px;
    line-height: 1.15;
}

.product-modal__price {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-bright);
    margin-top: 12px;
}

.product-modal__desc {
    margin-top: 20px;
    color: var(--text-dim);
    font-size: 0.95rem;
    line-height: 1.7;
    flex: 1;
}

.product-modal__desc strong {
    color: var(--text);
}

.product-modal__actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

.product-modal__actions .add-to-cart {
    flex: 1;
    justify-content: center;
    padding: 14px 24px;
    font-size: 0.95rem;
}

.product-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(24, 24, 37, 0.9);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.product-modal__close:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.product-modal__close svg {
    width: 20px;
    height: 20px;
}

/* ============ Корзина ============ */
.cart-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(420px, 100vw);
    height: 100dvh;
    background: #12121c;
    border-left: 1px solid var(--border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(102%);
    transition: transform 0.38s var(--ease);
}

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

.cart-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.cart-panel__head h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
}

.cart-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.cart-panel__empty {
    padding: 48px 0;
    text-align: center;
    color: var(--text);
}

.cart-panel__empty-sub {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 6px;
}

.cart-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-item {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 12px;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    animation: cardIn 0.3s var(--ease) both;
}

.cart-item img {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
}

.cart-item__name {
    font-weight: 600;
    font-size: 0.92rem;
}

.cart-item__price {
    color: var(--text-dim);
    font-size: 0.84rem;
    margin-top: 2px;
}

.cart-item__controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.qty-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.cart-item__qty {
    min-width: 20px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
}

.cart-item__remove {
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 6px;
    border-radius: 50%;
    transition: color 0.2s var(--ease);
}

.cart-item__remove:hover {
    color: #f43f5e;
}

.cart-panel__foot {
    padding: 20px 24px 24px;
    border-top: 1px solid var(--border);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    color: var(--text-dim);
    font-size: 0.95rem;
}

.cart-total__sum {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

/* Подложка */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.6);
    backdrop-filter: blur(3px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s var(--ease);
}

.overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

/* ============ «Улетание» товара в корзину ============ */
.fly-img {
    position: fixed;
    z-index: 200;
    border-radius: var(--radius-md);
    object-fit: cover;
    pointer-events: none;
    transition: transform 0.6s cubic-bezier(0.5, -0.1, 0.3, 1), opacity 0.6s var(--ease);
}

/* ============ Тост ============ */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translate(-50%, 20px);
    background: #1c1c2b;
    border: 1px solid var(--accent);
    color: var(--text);
    padding: 14px 28px;
    border-radius: var(--radius-pill);
    font-size: 0.92rem;
    font-weight: 500;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.toast--visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ============ Подвал ============ */
.footer {
    border-top: 1px solid var(--border);
    padding: 28px 0;
}

.footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.footer__note {
    color: var(--text-dim);
    font-size: 0.82rem;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: #2a2a3c;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a3a52;
}

/* ============ Адаптив ============ */
@media (max-width: 900px) {
    .header__tag {
        display: none;
    }

    .hero {
        padding: 48px 0 28px;
    }

    .filters {
        top: 72px;
    }

    .filters__search {
        flex: 1 1 100%;
        order: 2;
    }

    .product-modal__content {
        grid-template-columns: 1fr;
    }

    .product-modal__media {
        aspect-ratio: 16 / 10;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .product-modal__info {
        padding: 24px;
    }

    .product-modal__title {
        font-size: 1.4rem;
    }
}

@media (max-width: 560px) {
    .catalog__grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .product-card {
        padding: 10px;
        border-radius: 14px;
    }

    .product-card__title {
        font-size: 0.95rem;
    }

    .product-card__price {
        font-size: 1rem;
    }

    .add-to-cart {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .product-card__row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .add-to-cart {
        justify-content: center;
    }

    .product-modal__content {
        max-height: 95vh;
    }

    .product-modal__info {
        padding: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
