/* ==========================================================================
   SportsCard Radar app promo + AdSense placements
   Отдельный файл: Tailwind (output.css) на проде не пересобирается.
   Все цвета — через CSS-переменные темы, поэтому dark mode работает сам.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Промо-баннер приложения
   -------------------------------------------------------------------------- */

.gs-promo {
    margin: 2rem 0;
    clear: both;
}

/* Внутри .prose — полностью сбрасываем типографику Tailwind Prose,
   иначе унаследованные margin/line-height раздувают баннер */
.prose .gs-promo,
.prose .gs-promo * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}
.prose .gs-promo {
    margin: 2rem 0 !important;
    line-height: 1.4;
}

.gs-promo__link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.125rem 1.25rem;
    border: 1px solid var(--gs-border, #e7e5e4);
    border-radius: var(--radius-lg, 1rem);
    /* Фоллбэк для браузеров без color-mix() */
    background: var(--gs-card, #fff);
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--gs-primary, #e11d48) 6%, transparent) 0%,
            transparent 55%),
        var(--gs-card, #fff);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, .05));
    text-decoration: none !important;
    color: inherit;
    transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
}

.gs-promo__link:hover {
    border-color: color-mix(in srgb, var(--gs-primary, #e11d48) 45%, var(--gs-border, #e7e5e4));
    box-shadow: 0 6px 20px color-mix(in srgb, var(--gs-primary, #e11d48) 14%, transparent);
    text-decoration: none !important;
}

.gs-promo__link:focus-visible {
    outline: 2px solid var(--gs-primary, #e11d48);
    outline-offset: 2px;
}

.gs-promo__icon {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .16);
    object-fit: cover;
    background: var(--gs-surface, #fafaf9);
}

.gs-promo__body {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
    flex: 1 1 auto;
}

.gs-promo__eyebrow {
    font-size: .6875rem;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--gs-primary, #e11d48);
}

.gs-promo__title {
    font-family: var(--font-display, inherit);
    font-weight: 700;
    font-size: 1.0625rem;
    line-height: 1.3;
    color: var(--gs-text, #1c1917);
}

.gs-promo__text {
    font-size: .875rem;
    line-height: 1.45;
    color: var(--gs-text-secondary, #57534e);
}

.gs-promo__cta {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .625rem 1.125rem;
    border-radius: 999px;
    background: var(--gs-primary, #e11d48);
    color: #fff;
    font-size: .875rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background .2s ease;
}

.gs-promo__link:hover .gs-promo__cta {
    background: var(--gs-primary-hover, #be123c);
}

.gs-promo__arrow {
    width: 1rem;
    height: 1rem;
    transition: transform .2s ease;
}

.gs-promo__link:hover .gs-promo__arrow {
    transform: translateX(3px);
}

/* Мобильная раскладка: CTA на всю ширину под текстом */
@media (max-width: 640px) {
    .gs-promo__link {
        flex-wrap: wrap;
        padding: 1rem;
        gap: .875rem;
    }
    .gs-promo__icon {
        width: 52px;
        height: 52px;
        border-radius: 13px;
    }
    .gs-promo__body {
        flex: 1 1 60%;
    }
    .gs-promo__title {
        font-size: 1rem;
    }
    .gs-promo__text {
        font-size: .8125rem;
    }
    .gs-promo__cta {
        flex: 1 0 100%;
        justify-content: center;
        padding: .75rem 1rem;
    }
}

/* Вариант «карточка» для сайдбара */
.gs-promo--card {
    margin: 0 0 1.25rem;
}

.gs-promo--card .gs-promo__link {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: .75rem;
    padding: 1.25rem;
}

.gs-promo--card .gs-promo__icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
}

.gs-promo--card .gs-promo__title {
    font-size: 1rem;
}

.gs-promo--card .gs-promo__cta {
    width: 100%;
    justify-content: center;
}

/* --------------------------------------------------------------------------
   2. Sticky-бар (mobile)
   -------------------------------------------------------------------------- */

.gs-promo-sticky {
    position: fixed;
    left: .75rem;
    right: .75rem;
    bottom: .75rem;
    z-index: 45;
    display: flex;
    align-items: stretch;
    padding: .5rem .625rem;
    border: 1px solid var(--gs-border, #e7e5e4);
    border-radius: 1rem;
    background: var(--gs-card, #fff);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
    opacity: 0;
    transform: translateY(120%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1), opacity .28s ease;
    /* Не залезаем под home-indicator на iOS */
    margin-bottom: env(safe-area-inset-bottom, 0);
}

.gs-promo-sticky.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Только мобильные — на десктопе работает карточка в сайдбаре */
@media (min-width: 1024px) {
    .gs-promo-sticky {
        display: none !important;
    }
}

.gs-promo-sticky__link {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex: 1 1 auto;
    min-width: 0;
    text-decoration: none !important;
    color: inherit;
}


.gs-promo-sticky__icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
}

/* Текст забирает всё свободное место — CTA прижимается к правому краю */
.gs-promo-sticky__text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.gs-promo-sticky__text strong {
    font-size: .8125rem;
    font-weight: 700;
    color: var(--gs-text, #1c1917);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gs-promo-sticky__text span {
    font-size: .75rem;
    color: var(--gs-text-secondary, #57534e);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gs-promo-sticky__cta {
    flex: 0 0 auto;
    align-self: center;
    padding: .5rem .875rem;
    border-radius: 999px;
    background: var(--gs-primary, #e11d48);
    color: #fff;
    font-size: .8125rem;
    font-weight: 700;
}

/* Плавающая кнопка ToC «Contents» уезжает выше, чтобы не перекрываться баром */
body.gs-has-promo-sticky #toc-mobile-btn {
    bottom: 5.5rem;
    transition: bottom .28s cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------------------------
   3. Микроанимации — привлечь взгляд, но не раздражать
   Цикл 7 с: движение занимает меньше секунды, остальное время — покой.
   -------------------------------------------------------------------------- */

/* Иконка приложения: короткий «кивок» раз в цикл */
@keyframes gs-promo-nudge {
    0%, 84%, 100% { transform: rotate(0) scale(1); }
    88%           { transform: rotate(-4deg) scale(1.06); }
    92%           { transform: rotate(3deg) scale(1.05); }
    96%           { transform: rotate(-1.5deg) scale(1.02); }
}

/* CTA: одна мягкая волна вокруг кнопки */
@keyframes gs-promo-ring {
    0%, 80% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
    84%     { box-shadow: 0 0 0 0 rgba(225, 29, 72, .38); }
    100%    { box-shadow: 0 0 0 9px rgba(225, 29, 72, 0); }
}

.gs-promo__icon,
.gs-promo-sticky__icon {
    animation: gs-promo-nudge 7s ease-in-out infinite;
    will-change: transform;
}

.gs-promo__cta,
.gs-promo-sticky__cta {
    animation: gs-promo-ring 7s ease-out infinite;
}

/* Наведение/нажатие — анимация уступает место прямому отклику */
.gs-promo__link:hover .gs-promo__icon,
.gs-promo-sticky__link:hover .gs-promo-sticky__icon {
    animation: none;
    transform: scale(1.07);
    transition: transform .2s ease;
}

.gs-promo__link:hover .gs-promo__cta,
.gs-promo-sticky__link:hover .gs-promo-sticky__cta {
    animation: none;
}

.gs-promo__link:active,
.gs-promo-sticky__link:active {
    transform: scale(.99);
}

/* Уважаем системную настройку «меньше движения» */
@media (prefers-reduced-motion: reduce) {
    .gs-promo__icon,
    .gs-promo-sticky__icon,
    .gs-promo__cta,
    .gs-promo-sticky__cta,
    .gs-promo-sticky {
        animation: none !important;
        transition: none !important;
    }
}

/* --------------------------------------------------------------------------
   4. AdSense-блоки
   -------------------------------------------------------------------------- */

.gs-adsense {
    margin: 2.25rem 0;
    clear: both;
    text-align: center;
    /* Резервируем высоту — без CLS при загрузке объявления */
    min-height: 280px;
    overflow: hidden;
}

.prose .gs-adsense,
.prose .gs-adsense * {
    margin-top: 0;
    margin-bottom: 0;
}
.prose .gs-adsense {
    margin: 2.25rem 0;
}

.gs-adsense .adsbygoogle {
    display: block;
    width: 100%;
}

/* Подпись «Advertisement» — прозрачность для пользователя и требование AdSense
   к разграничению рекламы и контента */
.gs-adsense::before {
    content: "Advertisement";
    display: block;
    margin-bottom: .5rem;
    font-size: .625rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--gs-text-muted, #a8a29e);
}

/* In-article: нативный формат внутри текста */
.gs-adsense--in-article {
    min-height: 250px;
    padding: .5rem 0;
    border-top: 1px solid var(--gs-border, #e7e5e4);
    border-bottom: 1px solid var(--gs-border, #e7e5e4);
}

/* Квадратный адаптивный: сайдбар и карточки приложений */
.gs-adsense--square {
    min-height: 250px;
    max-width: 336px;
    margin-left: auto;
    margin-right: auto;
}

.gs-adsense--sidebar {
    margin: 0 0 1.5rem;
    min-height: 250px;
}

/* Sticky-сайдбар: реклама остаётся в поле зрения при прокрутке ToC */
.gs-adsense--sidebar-sticky {
    position: sticky;
    top: 6rem;
}

@media (max-width: 640px) {
    .gs-adsense {
        margin: 1.75rem 0;
    }
}
