<style th:inline="css">
    .tennis-bg {
        background: linear-gradient(rgba(44,62,80,0.9), rgba(44,62,80,0.9)),
                    url([(${cdn != null ? cdn + backgroundImageUrl : backgroundImageUrl})]);
        background-size: cover;
        background-position: center;
        color: white;
    }

    .hero-section {
        padding: 120px 0 90px;
        position: relative;
        overflow: hidden;
    }

    .hero-title {
        font-size: 3.5rem;
        font-weight: 800;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    }

    .ball-animation {
        position: absolute;
        width: 80px;
        height: 80px;
        border-radius: 50%;
        animation: ball-bounce 3s infinite alternate;
        opacity: 0.15;
        pointer-events: none;
    }

    @keyframes ball-bounce {
        0%   { transform: translateY(0) rotate(0deg); }
        100% { transform: translateY(-300px) rotate(360deg); }
    }

    .ball-1 { top: 35%; left: 7%;    background: var(--tennis-green);  animation-delay: 0s; }
    .ball-2 { top: 55%; right: 10%;  background: var(--tennis-orange); animation-delay: 1s; }
    .ball-3 { bottom: 15%; left: 22%; background: #3498db;             animation-delay: 2s; }

    .card-hover {
        transition: transform 0.3s, box-shadow 0.3s;
        border: none;
        border-radius: 15px;
        overflow: hidden;
    }

    .card-hover:hover {
        transform: translateY(-8px);
        box-shadow: 0 15px 30px rgba(0,0,0,0.12);
    }

    .club-card  { border-top: 4px solid var(--tennis-green); }
    .event-card { border-top: 4px solid var(--tennis-orange); }

    .btn-tennis-green {
        background: var(--tennis-green);
        color: #fff;
        border: none;
        border-radius: 8px;
        padding: 6px 16px;
        font-size: 0.875rem;
        font-weight: 600;
        transition: background 0.2s;
    }
    .btn-tennis-green:hover { background: #27ae60; color: #fff; }

    .gallery-slider-home {
        position: relative;
        width: 100%;
        height: 300px;
        overflow: hidden;
        background: #f0f2f4;
    }

    .gallery-slider-home .gallery-slider-track {
        display: flex;
        height: 100%;
        transition: transform 0.4s ease;
    }

    .gallery-slider-home .gallery-slider-track img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        flex-shrink: 0;
    }

    .gallery-slider-home .gallery-slider-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0,0,0,0.5);
        color: white;
        border: none;
        border-radius: 50%;
        width: 36px;
        height: 36px;
        font-size: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 2;
    }

    .gallery-slider-home .gallery-slider-btn:hover { background: rgba(0,0,0,0.7); }
    .gallery-slider-home .gallery-slider-btn.prev { left: 8px; }
    .gallery-slider-home .gallery-slider-btn.next { right: 8px; }

    .gallery-slider-home .gallery-slider-dots {
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 6px;
        z-index: 2;
    }

    .gallery-slider-home .gallery-slider-dots span {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(255,255,255,0.5);
        cursor: pointer;
    }

    .gallery-slider-home .gallery-slider-dots span.active { background: white; }

    @media (max-width: 768px) {
        .hero-title   { font-size: 2.2rem; }
        .hero-section { padding: 60px 0 50px; }
        .hero-img     { display: none; }
    }
</style>

<!-- ── Hero ── -->
<section class="tennis-bg hero-section">
    <div class="ball-animation ball-1"></div>
    <div class="ball-animation ball-2"></div>
    <div class="ball-animation ball-3"></div>
    <div class="container">
        <div class="row align-items-center">
            <div class="col-lg-6">
                <h1 class="hero-title mb-4">Найдите свой теннисный клуб</h1>
                <p class="lead mb-4" style="opacity:0.85">
                    Сотни клубов, кортов и мероприятий в одном месте
                </p>
                <div class="d-flex flex-wrap gap-3">
                    <a href="#clubs-section" class="btn btn-tennis">
                        <i class="bi bi-search me-2"></i>Найти клуб
                    </a>
                    <a href="/admin" class="btn btn-outline-light">
                        <i class="bi bi-building-add me-2"></i>Для организаций
                    </a>
                </div>
            </div>
            <div class="col-lg-6 hero-img mt-4 mt-lg-0">
                <img th:src="${cdn != null ? cdn + heroImageUrl : heroImageUrl}"
                     class="img-fluid rounded-3 shadow-lg" alt="Теннисный корт">
            </div>
        </div>
    </div>
</section>

<!-- ── Clubs ── -->
<section id="clubs-section" class="py-5 bg-light">
    <div class="container">
        <div class="row mb-4">
            <div class="col-lg-8 mx-auto text-center">
                <h2 class="fw-bold mb-2">Теннисные клубы</h2>
                <p class="text-muted">Найдите идеальный клуб для тренировок и игр</p>
            </div>
        </div>
        <div id="home-clubs-container"></div>
    </div>
</section>

<!-- ── Events ── -->
<section id="events-section" class="py-5">
    <div class="container">
        <div class="row mb-4">
            <div class="col-lg-8 mx-auto text-center">
                <h2 class="fw-bold mb-2">Ближайшие мероприятия</h2>
                <p class="text-muted">Турниры, тренировки и лагеря</p>
            </div>
        </div>
        <div id="home-events-container"></div>
    </div>
</section>

<!-- ── Gallery ── -->
<section id="gallery-section" class="py-5 bg-light">
    <div class="container">
        <div class="row mb-4">
            <div class="col-lg-8 mx-auto text-center">
                <h2 class="fw-bold mb-2">Галерея</h2>
                <p class="text-muted">Фотоотчёты с мероприятий и турниров</p>
            </div>
        </div>
        <div id="home-gallery-container">
            <div th:if="${latestGalleryPost != null}"
                 class="gallery-post-preview"
                 th:data-images="${latestGalleryPost.imageUrls != null ? #strings.arrayJoin(latestGalleryPost.imageUrls, ',') : ''}">
                <div class="row g-0 align-items-center">
                    <div class="col-md-6">
                        <div id="home-gallery-slider" class="gallery-slider-home"></div>
                    </div>
                    <div class="col-md-6">
                        <div class="p-4">
                            <h3 class="fw-bold mb-2" th:text="${latestGalleryPost.title}"></h3>
                            <div class="text-muted small mb-3">
                                <i class="bi bi-calendar3 me-1"></i>
                                <span th:text="${#temporals.format(latestGalleryPost.publishedAt != null ? latestGalleryPost.publishedAt : latestGalleryPost.createdAt, 'dd MMMM yyyy')}"></span>
                            </div>
                            <div class="text-muted mb-3" th:if="${latestGalleryPost.content != null}"
                                 th:text="${#strings.length(latestGalleryPost.content) > 200 ? #strings.substring(latestGalleryPost.content, 0, 200) + '...' : latestGalleryPost.content}"></div>
                            <a href="/gallery" class="btn btn-tennis">
                                <i class="bi bi-images me-2"></i>Показать больше
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            <div th:unless="${latestGalleryPost != null}" class="text-center py-4 text-muted">
                <i class="bi bi-images fs-1 d-block mb-3 opacity-50"></i>
                <p>Следите за обновлениями в галерее!</p>
                <a href="/gallery" class="btn btn-sm btn-outline-secondary">Перейти в галерею</a>
            </div>
        </div>
    </div>
</section>

<!-- ── CTA ── -->
<section class="py-5" style="background:linear-gradient(135deg,#2c3e50 0%,#34495e 100%);color:white">
    <div class="container text-center">
        <h2 class="fw-bold mb-3">Вы владелец теннисного клуба?</h2>
        <p class="lead mb-4" style="opacity:0.8">Разместите свой клуб и привлекайте новых игроков</p>
        <a href="/admin" class="btn btn-tennis btn-lg px-5">
            <i class="bi bi-plus-circle me-2"></i>Добавить клуб
        </a>
    </div>
</section>

<script type="module" src="/js/site/pages/home/home.js"></script>
