/* ============================================================
   style.css — кастомные стили, анимации и адаптация
   Версия 3.3 — кнопка "Позвонить", фильтр в карусели
   ============================================================ */

/* ---------- Анимации для Alpine.js ---------- */
.scale-pop {
    animation: scalePop 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
@keyframes scalePop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.fade-out {
    animation: fadeOut 0.2s ease;
}
@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ---------- View Transitions API ---------- */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.5s;
    animation-timing-function: ease;
}
::view-transition-old(card-img-*) {
    animation: zoomOut 0.4s ease forwards;
}
::view-transition-new(card-img-*) {
    animation: zoomIn 0.4s ease forwards;
}
@keyframes zoomOut {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}
@keyframes zoomIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ---------- Скелетоны ---------- */
.skeleton {
    background: linear-gradient(90deg, #e0e0e0 25%, #f5f5f5 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}
@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Карточки ---------- */
.card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s ease;
}
.card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.15);
}

/* ---------- Кнопка «В избранное» ---------- */
.favorite-btn {
    transition: transform 0.2s ease, color 0.2s ease;
}
.favorite-btn:active {
    transform: scale(0.85);
}
.favorite-btn .particle-burst {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.favorite-btn .particle-burst::before,
.favorite-btn .particle-burst::after {
    content: '♥';
    position: absolute;
    font-size: 10px;
    color: red;
    opacity: 0;
    animation: burst 0.6s ease-out forwards;
}
.favorite-btn .particle-burst::before {
    top: -10px;
    left: 10px;
    animation-delay: 0.05s;
}
.favorite-btn .particle-burst::after {
    bottom: -10px;
    right: 10px;
    animation-delay: 0.1s;
}
@keyframes burst {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--tx, 20px), var(--ty, -30px)) scale(1.5); }
}
.favorite-btn .particle-burst::before { --tx: 15px; --ty: -20px; }
.favorite-btn .particle-burst::after { --tx: -15px; --ty: -25px; }

/* ============================================================
   БАННЕРЫ (КАК В ПИЦЦЕРИИ)
   ============================================================ */
.banner-slider {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 12px;
    background: #e2e8f0;
    aspect-ratio: 16/7;
    min-height: 120px;
}
.banner-slider .slides {
    display: flex;
    transition: transform 0.5s ease;
    height: 100%;
}
.banner-slider .slide {
    flex: 0 0 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.banner-slider .slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.banner-slider .slide .banner-text {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    max-width: 80%;
    backdrop-filter: blur(4px);
}
.banner-slider .banner-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 5;
}
.banner-slider .banner-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: 0.3s;
    border: 1px solid rgba(255,255,255,0.3);
}
.banner-slider .banner-dots .dot.active {
    background: white;
    transform: scale(1.3);
}
.banner-slider .banner-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.3);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    touch-action: manipulation;
}
.banner-slider .banner-arrow:hover {
    background: rgba(0,0,0,0.6);
}
.banner-slider .banner-arrow-left {
    left: 8px;
}
.banner-slider .banner-arrow-right {
    right: 8px;
}
@media (max-width: 640px) {
    .banner-slider .banner-arrow {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
}

/* ============================================================
   ФОТО В ОБЪЯВЛЕНИИ (КАК В ПИЦЦЕРИИ)
   ============================================================ */
.photo-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.4);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    backdrop-filter: blur(4px);
    touch-action: manipulation;
}
.photo-arrow:hover {
    background: rgba(0,0,0,0.7);
}
.photo-arrow-left {
    left: 8px;
}
.photo-arrow-right {
    right: 8px;
}
@media (max-width: 640px) {
    .photo-arrow {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }
}

/* ============================================================
   КАРУСЕЛЬ КАТЕГОРИЙ (С ФИЛЬТРОМ)
   ============================================================ */
.categories-carousel {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0.25rem 0.75rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.categories-carousel::-webkit-scrollbar {
    display: none;
}
.categories-carousel .cat-item {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #1e293b;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    border: 2px solid transparent;
    transition: all 0.2s;
    text-decoration: none;
}
.dark .categories-carousel .cat-item {
    background: #1e293b;
    color: #e2e8f0;
}
.categories-carousel .cat-item:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}
.categories-carousel .cat-item.active {
    background: #3b82f6;
    color: white;
    border-color: #2563eb;
}
.categories-carousel .filter-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #1e293b;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    border: 2px solid transparent;
    transition: all 0.2s;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.dark .categories-carousel .filter-btn {
    background: #1e293b;
    color: #e2e8f0;
}
.categories-carousel .filter-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

/* ============================================================
   КНОПКА ПОЗВОНИТЬ В КАРТОЧКЕ
   ============================================================ */
.card a[href^="tel:"] {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
    padding: 0.25rem 0.6rem !important;
    border-radius: 9999px !important;
    background: #10b981 !important;
    color: white !important;
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    transition: all 0.2s !important;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3) !important;
}
.card a[href^="tel:"]:hover {
    background: #059669 !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4) !important;
}
.card a[href^="tel:"]:active {
    transform: scale(0.95) !important;
}
.card a[href^="tel:"] svg {
    width: 0.8rem !important;
    height: 0.8rem !important;
}

/* ============================================================
   БОЛЬШАЯ КНОПКА СОЗДАТЬ
   ============================================================ */
.create-btn-full {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    color: white !important;
    background: linear-gradient(135deg, #3b82f6, #6366f1) !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3) !important;
    transition: all 0.3s !important;
    text-decoration: none !important;
}
.create-btn-full:hover {
    transform: scale(1.01) !important;
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.4) !important;
}
.create-btn-full:active {
    transform: scale(0.97) !important;
}

/* ============================================================
   СЕТКА ОБЪЯВЛЕНИЙ (АДАПТИВНАЯ)
   ============================================================ */
.ads-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) {
    .ads-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
}
@media (min-width: 768px) {
    .ads-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1024px) {
    .ads-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
}

/* ---------- Адаптация карточек на телефоне ---------- */
@media (max-width: 640px) {
    .ads-grid {
        gap: 0.6rem;
    }
    .card {
        border-radius: 1rem;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }
    .card .p-3 {
        padding: 0.5rem 0.6rem 0.6rem;
    }
    .card h3 {
        font-size: 0.7rem;
        line-height: 1.2;
        min-height: 1.7rem;
    }
    .card .text-lg {
        font-size: 0.8rem;
    }
    .card .text-xs {
        font-size: 0.55rem;
    }
    .card .favorite-btn .w-5 {
        width: 0.9rem;
        height: 0.9rem;
    }
    .card a[href^="tel:"] {
        font-size: 0.5rem !important;
        padding: 0.15rem 0.4rem !important;
    }
    .card a[href^="tel:"] svg {
        width: 0.6rem !important;
        height: 0.6rem !important;
    }
}

/* ---------- Утилиты ---------- */
.backdrop-blur-sm {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.dark-transition {
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}
[x-cloak] {
    display: none !important;
}

/* Стилизация скроллбара */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
.dark ::-webkit-scrollbar-track {
    background: #2d3748;
}
.dark ::-webkit-scrollbar-thumb {
    background: #4a5568;
}
.dark ::-webkit-scrollbar-thumb:hover {
    background: #718096;
}