/* ============================================
   Components - Reusable UI Elements
   ============================================ */

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background-color var(--transition-normal),
                color var(--transition-normal),
                border-color var(--transition-normal);
    border: none;
    gap: 8px;
}

/* Плоская заливка брендовым цветом. До этого здесь стоял градиент
   #7c3aed → #6d28d9 со свечением: оба хекса не из палитры сайта, они
   больше нигде не встречались. */
.btn-primary {
    background-color: var(--primary-purple);
    color: white;
    border-radius: var(--radius-full);
    padding: 14px 32px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-normal),
                transform var(--transition-fast);
}

/* Один сигнал на наведение — цвет темнеет. Раньше их было три сразу:
   подъём, свечение и смена градиента. Нажатие отдельно отзывается
   сжатием (:active ниже). */
.btn-primary:hover {
    background-color: var(--primary-purple-hover);
}

/* Force white text on btn-primary in every state — overrides global
   `a:hover { color: var(--primary-purple); }` from base.css that
   otherwise turns the button text purple on a purple background. */
.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary:visited {
    color: #fff;
}

.btn-secondary,
.btn-light {
    background-color: var(--bg-purple-light);
    color: var(--primary-purple);
}

.btn-secondary:hover,
.btn-light:hover {
    background-color: #ddd6fe;
}

.btn-icon-circle {
    background: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--primary-purple);
}

/* Arrow Button — «пилюля», как на плитках категорий главной.
   Раньше был кружок 30×30; форма и поведение при наведении сведены к
   одному стилю по всему сайту. */
.arrow-btn {
    background: white;
    width: 48px;
    height: 30px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--primary-purple);
    transition: transform var(--transition-fast);
}

.arrow-btn:hover {
    transform: translateX(3px);
}

/* Support Button */
.support-btn {
    background-color: #f0eaff;
    color: #6a1b9a;
    padding: 12px 25px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: var(--text-xs);
    width: 100%;
    transition: background var(--transition-fast);
}

.support-btn:hover {
    background-color: #d1c4e9;
}

/* Action Buttons Group */
.action-buttons {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* ============================================
   Hero Structure (Shared)
   ============================================ */

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
}

.hero-badges {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.badge--pink {
    background-color: var(--accent-pink);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.price-block {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

html[lang="ru"] .price-block {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.current-price {
    font-weight: 700;
    font-size: var(--text-xl);
}

.old-price {
    text-decoration: line-through;
    color: var(--text-strikethrough);
    font-size: var(--text-base);
    font-weight: 400;
}

.installment {
    background: var(--bg-white);
    padding: 5px 15px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}

.hero-buttons {
    display: flex;
    gap: 15px;
    align-items: center;
}

.helper-text {
    font-size: var(--text-xs);
    color: var(--text-gray);
    max-width: 150px;
    line-height: 1.2;
}

.hero-image {
    position: relative;
}

.hero-desc {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: 40px;
    max-width: 540px;
    line-height: 1.5;
}

/* ============================================
   Cards
   ============================================ */

/* Base Card */
.card {
    background-color: var(--bg-white);
    border-radius: var(--radius-2xl);
    overflow: hidden;
}

/* Course Card */
.course-card {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-lighter);
    transition:
        transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1),
        box-shadow 0.35s ease,
        border-color 0.35s ease;
    cursor: pointer;
}

/* Наведение мягкое: без кольца — только лёгкий подъём, чуть заметный
   фиолетовый бордер и рассеянная тень. Кольцо осталось только у
   :focus-visible, где оно обязано быть контрастным. */
@media (hover: hover) {
    .course-card:hover {
        transform: translateY(-2px);
        border-color: color-mix(in srgb, var(--primary-purple) 30%, transparent);
        box-shadow: var(--shadow-hover-soft);
    }
}

.course-card:focus-visible,
.course-card:has(a:focus-visible) {
    outline: none;
    border-color: transparent;
    box-shadow:
        0 0 0 2px var(--primary-purple),
        0 14px 28px -10px color-mix(in srgb, var(--primary-purple) 28%, transparent),
        0 4px 10px rgba(17, 12, 46, 0.06);
}

.course-image-container {
    position: relative;
    height: 200px;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.course-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Длиннее карточки — зум читается как плавное движение, а не рывок */
    transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@media (hover: hover) {
    .course-card:hover .course-image {
        transform: scale(1.02);
    }

    .course-card:hover .course-title {
        color: var(--primary-purple);
    }
}

@media (prefers-reduced-motion: reduce) {
    .course-card,
    .course-image {
        transition-duration: 0.01ms;
    }

    .course-card:hover,
    .course-card:hover .course-image {
        transform: none;
    }
}

.course-content {
    padding: 16px 0;
}

.course-title {
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.4;
    color: #374151;
    transition: color var(--transition-fast);
}

/* Badges in Cards */
.badges {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Product Card */
.product-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-2xl);
    padding: 15px;
    position: relative;
}

.product-card.featured {
    border: 1px solid #FF80AB;
}

.badge-top {
    position: absolute;
    top: -10px;
    right: 10px;
    background: white;
    color: var(--accent-pink);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: var(--text-xs);
    border: 1px solid var(--accent-pink);
    font-weight: 600;
}

.card-img {
    width: 100%;
    height: 200px;
    background: var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 15px;
    object-fit: cover;
}

/* Info Card */
.info-card {
    background: var(--bg-white);
    padding: 20px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-lighter);
}

.card-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-purple-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-purple);
    font-size: var(--text-xl);
    flex-shrink: 0;
}

.card-text h4 {
    font-size: var(--text-sm);
    color: var(--text-gray);
    font-weight: 500;
}

.card-text p {
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--text-dark);
}

/* Feature Card */
.feature-card {
    background: var(--bg-white);
    border: 1px solid var(--border-gray);
    border-radius: 20px;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: 110px;
    transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;

    /* Start state for entrance animation */
    opacity: 0;
    transform: translateX(-40px) rotate(-6deg);
    will-change: transform, opacity;
}

.feature-card.in-view {
    opacity: 1;
    transform: translateX(0) rotate(0deg);
    transition:
        opacity .8s cubic-bezier(.2,.7,.2,1),
        transform .9s cubic-bezier(.2,.7,.2,1);
}
.feature-card:nth-child(1).in-view { transition-delay: 0s; }
.feature-card:nth-child(2).in-view { transition-delay: .15s; }
.feature-card:nth-child(3).in-view { transition-delay: .3s; }

.feature-card:hover {
    box-shadow: 0 10px 28px -16px rgba(20, 20, 30, .15);
    border-color: #e3e3e8;
}

.feature-icon {
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform .35s cubic-bezier(.2,.7,.2,1);
}

.feature-card:hover .feature-icon img {
    transform: rotate(-6deg) scale(1.06);
}

@media (prefers-reduced-motion: reduce) {
    .feature-card { opacity: 1; transform: none; }
    .feature-card.in-view { transition: none; }
}

@media (max-width: 768px) {
    .features-grid { grid-template-columns: 1fr; gap: 14px; }
    .feature-card { padding: 18px 20px; min-height: 96px; }
    .feature-icon { width: 60px; height: 60px; }
}

/* ============================================
   Features Bar
   ============================================ */

.features-bar {
    padding: 40px 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.feature-info h4 {
    font-size: var(--text-sm);
    color: var(--text-light);
    margin-bottom: 5px;
    font-weight: 400;
}

.feature-info p {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-dark);
}

/* Location Card */
.location-card {
    background-color: var(--bg-light);
    padding: 25px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.location-card:nth-child(odd) { background-color: #f8f6fb; }
.location-card:nth-child(even) { background-color: #fffcfc; }
.location-card:nth-child(3n) { background-color: #fcfaff; }

.location-card h3 {
    font-size: var(--text-base);
    font-weight: 600;
}

.location-card p {
    font-size: var(--text-sm);
    color: #444;
}

.location-card .time {
    margin-top: auto;
    color: var(--text-gray);
    font-size: var(--text-sm);
}

/* ============================================
   Accordion
   ============================================ */

.accordion-item {
    border-bottom: 1px solid var(--border-light);
}

.accordion-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    background: none;
    border: none;
    font-size: var(--text-base);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    color: var(--text-dark);
    transition: color var(--transition-fast);
}

.accordion-header:hover {
    color: var(--primary-purple);
}

.accordion-icon {
    color: var(--primary-purple);
    transition: transform var(--transition-normal);
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-gray);
    font-size: var(--text-sm);
    padding-bottom: 0;
}

.accordion-item.active .accordion-content {
    padding-bottom: 24px;
    max-height: 500px;
}

/* ============================================
   Price Card (Sidebar)
   ============================================ */

.price-card {
    background: var(--bg-white);
    border: 1px solid var(--border-lighter);
    border-radius: var(--radius-xl);
    padding: 30px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 20px;
}

.price-card h3 {
    margin-bottom: 20px;
}

.price-large,
.sidebar-price {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--primary-purple);
    margin-bottom: 15px;
}

.sidebar-badge {
    color: var(--accent-pink);
    font-size: var(--text-sm);
    font-weight: 600;
}

html[lang="ru"] .price-large .old-price,
html[lang="ru"] .sidebar-price .old-price {
    display: block;
    margin-top: 6px;
}

.installment-row,
.sidebar-installment {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-installment {
    background: var(--bg-light);
    padding: 10px;
    border-radius: var(--radius-sm);
    margin: 15px 0;
    align-items: center;
    gap: 10px;
    border: none;
}

.price-details,
.sidebar-details {
    margin: 20px 0;
    font-size: var(--text-sm);
    color: var(--text-gray);
}

.price-details div,
.sidebar-details p {
    margin-bottom: 10px;
}

.price-info-list {
    margin: 20px 0;
    font-size: var(--text-sm);
}

.price-info-item {
    margin-bottom: 12px;
    color: #555;
}

.price-info-item strong {
    display: block;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.pricing-buttons,
.sidebar-actions {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pricing-buttons .btn,
.sidebar-actions .btn {
    width: 100%;
}

.small-note {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ============================================
   Hero Card
   ============================================ */

.hero-card {
    background: var(--bg-purple-light);
    border-radius: var(--radius-2xl);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    height: 140px;
}

.hero-card-content {
    z-index: 1;
}

.hero-card h3 {
    font-size: var(--text-base);
    margin-bottom: 10px;
    font-weight: 600;
}

.hero-card img {
    height: 90%;
    position: absolute;
    right: 10px;
    bottom: 5%;
    object-fit: contain;
}

/* ============================================
   Video Card
   ============================================ */

.video-card {
    aspect-ratio: 9/16;
    background: #ccc;
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.video-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.video-card:hover img {
    transform: scale(1.05);
}

.video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(138, 79, 255, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    pointer-events: none;
}

/* Play Button */
.play-button {
    width: 60px;
    height: 60px;
    background: #8A8FFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--text-2xl);
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(138, 143, 255, 0.4);
}

.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: color-mix(in srgb, var(--primary-purple) 90%, transparent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* ============================================
   Offer Card
   ============================================ */

.offer-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform var(--transition-normal);
}

.offer-card:hover {
    transform: translateY(-5px);
}

.offer-img-wrapper {
    position: relative;
    height: 200px;
}

.offer-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.offer-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--accent-pink);
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    font-weight: 600;
}

.offer-content,
.offer-card-body {
    padding: 15px;
}

.offer-price {
    font-weight: 700;
    color: var(--primary-purple);
    margin-bottom: 5px;
}

.offer-old-price {
    text-decoration: line-through;
    color: #999;
    font-size: var(--text-xs);
    margin-left: 5px;
    font-weight: 400;
}

.offer-title {
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.4;
}

/* ============================================
   Responsive
   ============================================ */

/* ============================================
   Target Audience
   ============================================ */

.target-audience {
    padding: 80px 0;
}

.target-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 30px;
}

.target-main-card {
    background: #e9def7;
    border-radius: 28px;
    padding: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.target-image-wrapper {
    flex: 0 0 40%;
}

.target-main-card > img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 20px;
    box-shadow: none;
}

.target-main-card-text {
    padding: 16px 24px 24px;
}

/* Compact variant — image is small and shifted right, icon sits in empty
   top-left area, text stacks at bottom. Used on courses where the
   placeholder image is square/photo-like rather than a full-bleed banner. */
.target-main-card--shifted {
    padding: 28px 32px;
    min-height: 380px;
    gap: 16px;
}
.target-main-card--shifted > img {
    width: 56%;
    max-width: 320px;
    align-self: flex-end;
    border-radius: 16px;
    margin-top: -8px;
    object-fit: cover;
}
.target-main-card--shifted .target-main-card-text {
    padding: 0;
    margin-top: auto;
}

.target-main-card-text h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #15161a;
}

.target-main-card-text p {
    font-size: 1rem;
    color: #2b2c33;
    line-height: 1.55;
}

.target-text-content {
    text-align: left;
    flex: 1;
    padding: 16px 20px 20px 20px;
}

.target-text-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.target-main-card h3 {
    font-size: var(--text-xl);
    margin-bottom: 15px;
}

.target-small-cards {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.target-small-card {
    background: var(--bg-light);
    border-radius: var(--radius-xl);
    padding: 30px;
    flex: 1;
}

.target-small-card h3 {
    color: #15161a;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.target-small-card p {
    color: #2b2c33;
    font-size: 1rem;
    line-height: 1.55;
}

.icon-top {
    color: var(--primary-purple);
    font-size: var(--text-xl);
    margin-bottom: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 12px -6px rgba(122, 60, 240, 0.25);
}

.icon-top img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
}

.target-main-card .icon-top {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 2;
    background: #fff;
    margin: 0;
}

@media (max-width: 1024px) {
    .price-card {
        position: static;
        margin-top: 40px;
    }

    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .target-grid,
    .expert-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .btn {
        padding: 12px 20px;
        font-size: var(--text-sm);
        min-height: 44px;
    }

    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    /* Hero: stack to single column */
    .hero-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    /* Features bar: single column */
    .features-grid {
        grid-template-columns: 1fr;
    }

    /* Target audience: stacked */
    .target-grid {
        grid-template-columns: 1fr;
    }

    /* Program: single column, sidebar below */
    .program-container {
        grid-template-columns: 1fr;
    }

    .sticky-sidebar {
        position: static;
    }

    .price-card {
        position: static;
    }

    /* Expert: stacked */
    .expert-grid {
        grid-template-columns: 1fr;
    }

    /* Expert card padding reduction */
    .expert-card,
    .expert-card--secondary {
        padding: 30px;
    }

    .expert-icons {
        flex-wrap: wrap;
        gap: 20px;
    }

    /* Offers: 2 columns */
    .offers-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Standards footer stacked */
    .standards-footer {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .standards-right {
        text-align: center;
    }

    .standards-icons {
        justify-content: center;
    }

    .certificate-showcase {
        margin-bottom: 20px;
        overflow: hidden;
        border-radius: var(--radius-lg);
    }

    .certificate-img {
        height: 250px;
        object-fit: cover;
        object-position: 70% center;
    }

    /* Target audience padding */
    .target-audience {
        padding: 50px 0;
    }

    .target-small-card {
        padding: 24px;
    }

    .course-title {
        font-size: calc(var(--text-xl) * 0.95);
        line-height: var(--leading-snug);
    }

    .hero-card h3 {
        font-size: calc(var(--text-lg) * 0.95);
        line-height: var(--leading-snug);
    }

    .location-card h3 {
        font-size: calc(var(--text-lg) * 0.95);
    }

    .price-card h3 {
        font-size: calc(var(--text-2xl) * 0.95);
    }
}

/* ============================================
   Program Section (Accordion + Sidebar)
   ============================================ */

.program {
    /* padding-block, а не shorthand: иначе затирается горизонтальный
       отступ .container и текст липнет к краю экрана на мобильном. */
    padding-block: 60px;
}

.program-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 40px;
    position: relative;
}

.sticky-sidebar {
    height: fit-content;
}

@media (max-width: 992px) {
    .program-container {
        grid-template-columns: 1fr;
    }

    .sticky-sidebar {
        position: static;
    }
}

/* ============================================
   Standards Section
   ============================================ */

.standards {
    padding: 60px 0;
}

.certificate-showcase {
    margin-bottom: 40px;
}

.certificate-img {
    width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-gray);
    box-shadow: var(--shadow-certificate);
}

.standards-footer {
    background: var(--bg-light);
    border-radius: var(--radius-xl);
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.standards-right {
    text-align: right;
}

.standards-icons {
    display: flex;
    gap: 15px;
}

.standards-icons i {
    font-size: var(--text-2xl);
    color: var(--primary-purple);
    background: var(--bg-white);
    padding: 10px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
}

/* ============================================
   Expert Section
   ============================================ */

.expert {
    /* padding-block, а не shorthand: иначе затирается горизонтальный
       отступ .container и текст липнет к краю экрана на мобильном. */
    padding-block: 60px;
}

.expert-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.expert-card {
    background: var(--bg-light);
    padding: 40px;
    border-radius: var(--radius-xl);
    position: relative;
}

.expert-card--secondary {
    background: var(--bg-yellow);
    padding: 40px;
    border-radius: var(--radius-xl);
}

.expert-icons {
    display: flex;
    gap: 30px;
    margin-top: 40px;
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
}

.expert-icon-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--text-xs);
    color: var(--text-medium);
}

.expert-icon-item i {
    font-size: var(--text-lg);
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .expert-grid {
        display: block;
    }

    .expert-card,
    .expert-card--secondary {
        padding: 25px;
        margin-bottom: 16px;
        border-radius: var(--radius-lg);
    }

    .expert-icons {
        flex-wrap: wrap;
        gap: 16px;
        margin-top: 20px;
    }
}

/* ============================================
   Offers Section
   ============================================ */

.offers {
    padding: 60px 0 100px;
}

.offers-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 992px) {
    .offers-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .offers-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Course Grid
   ============================================ */

.course-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 60px;
}

/* ============================================
   Feature Box (Chinese Medicine)
   ============================================ */

.feature-box {
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-2xl);
    padding: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.feature-content {
    flex: 1;
    padding-right: 40px;
}

.feature-content h2 {
    font-size: var(--text-3xl);
    margin-bottom: 20px;
}

/* ============================================
   Цена в hero курса
   ============================================ */

/* Единый вид для всех курсов: слева платёж в рассрочку, справа полная
   стоимость. Разметка снята со страницы медицинского колледжа — там она
   появилась первой; здесь то же самое без привязки к .medicine-page,
   чтобы остальные курсы не расходились каждый по-своему. */
.hero-stats {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 34px;
    margin-bottom: 28px;
}

.hero-stat .lbl {
    font-size: 15px;
    color: var(--ink-body);
    margin-bottom: 8px;
}

.hero-stat .val {
    font-size: 26px;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
}

.hero-stat .val .old-price {
    margin-left: 10px;
    font-size: 17px;
    font-weight: 600;
}

.hero-stat.divide {
    border-left: 1px solid #d9d2ec;
    padding-left: 34px;
}

@media (max-width: 768px) {
    .hero-stats {
        gap: 18px;
        margin-bottom: 22px;
    }

    .hero-stat .lbl {
        font-size: 12.5px;
    }

    .hero-stat .val {
        font-size: 21px;
    }

    .hero-stat.divide {
        padding-left: 18px;
    }
}

/* Пара «Подробнее + Консультация» — тот же приём, что в баннере колледжа:
   первая кнопка ведёт на раздел, вторая открывает модалку мессенджеров. */
.feature-actions {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 4px;
}

.feature-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Базовые 24px рядом с крупной кнопкой теряются — в баннере колледжа
   кружки тоже увеличены. */
.feature-actions .btn-icon-circle {
    width: 28px;
    height: 28px;
    font-size: 13px;
}

.feature-actions__note {
    margin: 10px 0 0;
    font-size: var(--text-sm);
    color: var(--text-light);
}

.feature-visuals {
    flex: 1;
    display: flex;
    gap: 20px;
}

.video-thumb {
    position: relative;
    border-radius: var(--radius-xl);
    overflow: hidden;
    flex: 1;
    min-height: 300px;
}

.chart-img {
    flex: 0.8;
    min-height: 300px;
}

@media (max-width: 1024px) {
    .course-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .course-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .feature-box {
        flex-direction: column;
        padding: 30px;
    }

    .feature-content {
        padding-right: 0;
        margin-bottom: 30px;
    }

    .feature-visuals {
        flex-direction: column;
    }

    .video-thumb,
    .chart-img {
        min-height: 200px;
    }
}

@media (max-width: 576px) {
    .course-grid {
        grid-template-columns: 1fr;
    }

    /* Accordion: reduce spacing on mobile */
    .accordion {
        padding: 0 10px;
    }

    .accordion-header {
        padding: 16px 0;
        font-size: var(--text-sm);
    }

    .accordion-item.active .accordion-content {
        padding-bottom: 16px;
    }

    /* Expert: tighter padding on mobile */
    .expert-card,
    .expert-card--secondary {
        padding: 20px;
    }

    .expert-icons {
        gap: 12px;
        margin-top: 20px;
    }

    /* Offers: single column on small mobile */
    .offers-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Hero with full-width image card (collage PNG)
   PNG sits as an absolutely-positioned <img>, filling the card at its
   natural aspect ratio. Text overlays the empty left half on desktop.
   On mobile, the same <img> reflows on top, text stacks below.
   ============================================ */

.hero.hero--bg-image { padding: 24px 0 8px; }

.hero.hero--bg-image .hero-content {
    position: relative;
    max-width: 1240px;
    margin-inline: auto;
    aspect-ratio: 1240 / 470;
    background-color: #ffffff;
    border-radius: var(--radius-3xl);
    padding: 40px 56px;
    overflow: hidden;
    isolation: isolate;
    display: block;
}

.hero.hero--bg-image .hero-image {
    position: absolute;
    top: 0; right: 0; left: 0;
    width: 100%;
    z-index: 0;
    pointer-events: none;
    display: block;
}

.hero.hero--bg-image .hero-image .hero-blob {
    width: 100%;
    height: auto;
    background: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: block;
}

.hero.hero--bg-image .hero-image .hero-blob img {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    object-fit: none;
}

.hero.hero--bg-image .hero-text {
    position: relative;
    z-index: 1;
    max-width: 50%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: 100%;
    height: 100%;
}

.hero.hero--bg-image .hero-badges {
    display: inline-flex;
    align-items: stretch;
    background: #fff;
    border-radius: var(--radius-xl, 16px);
    padding: 12px 20px;
    gap: 20px;
    width: max-content;
    max-width: 100%;
    margin-bottom: 0;
}
/* .hero-stats носит margin-bottom для блочной вёрстки медколледжа. Здесь
   .hero-text — колонка с gap, и этот margin складывался с ним: под ценами
   набегало 46px против 14px между всеми остальными парами. Ритм задаёт
   только gap, поэтому margin'ы внутри карточки обнулены. */
.hero.hero--bg-image .hero-badges .hero-stats { margin-bottom: 0; }
.hero.hero--bg-image .hero-badges .price-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}
.hero.hero--bg-image .hero-badges .price-col + .price-col {
    padding-left: 20px;
    border-left: 1px solid #eadfe0;
}
.hero.hero--bg-image .price-col .hint-title { font-size: 13px; color: #2b2c33; line-height: 1.2; font-weight: 600; }
.hero.hero--bg-image .price-col .hint-value { font-size: 13px; color: #6c6e78; line-height: 1.2; }
.hero.hero--bg-image .badge.badge--pink {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #e63e7a;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 999px;
    letter-spacing: .01em;
}
.hero.hero--bg-image .badge.badge--pink i { font-size: 11px; }
.hero.hero--bg-image .price-block { display: flex; flex-direction: column; gap: 1px; }
.hero.hero--bg-image .current-price { font-size: 20px; font-weight: 700; line-height: 1.1; color: #15161a; }
.hero.hero--bg-image .old-price { font-size: 12px; color: #9a9ba3; text-decoration: line-through; }

.hero.hero--bg-image .hero-text h1 {
    font-size: clamp(28px, 3.2vw, 42px);
    line-height: 1.08;
    letter-spacing: -0.02em;
    font-weight: 700;
    margin: 0;
    color: #15161a;
}
.hero.hero--bg-image .hero-text h1 .hero-copyright-mark {
    font-size: .55em;
    color: #6c6e78;
    margin-left: .08em;
    vertical-align: .35em;
    font-weight: 500;
}
.hero.hero--bg-image .hero-text .hero-copyright-note { font-size: 13px; color: #6c6e78; margin: 0; }
.hero.hero--bg-image .hero-text .hero-desc {
    font-size: 13px;
    line-height: 1.45;
    color: #2b2c33;
    margin: 0;
    max-width: 46ch;
}

.hero.hero--bg-image .hero-buttons {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
    margin-top: auto;
}
.hero-buttons-note {
    color: #6c6e78;
    font-size: 13px;
    line-height: 1.35;
    flex: 0 1 14ch;
    min-width: 0;
    white-space: normal;
}

/* Иглоукалывание: его баннер 1240x510, а не 1240x470 — только для десктопа. */
@media (min-width: 769px) {
    .hero.hero--bg-image.hero--ratio-510 .hero-content { aspect-ratio: 1240 / 510; }
}

@media (max-width: 1024px) {
    .hero.hero--bg-image .hero-content { padding: 32px 32px; }
    .hero.hero--bg-image .hero-text { max-width: 58%; gap: 12px; }
    .hero.hero--bg-image .hero-text h1 { font-size: clamp(24px, 3.4vw, 34px); }
}

@media (max-width: 900px) {
    .hero-buttons-note { display: none; }
}

/* ============================================
   Мобильный hero курсов — одна карточка в цвет курса, по образцу
   медколледжа: картинка вбита в края карточки, цены без белой плашки,
   кнопки во всю ширину. Цвет задаётся переменной --hero-card-bg
   в CSS каждого курса (совпадает с фоном его мобильной картинки).
   ============================================ */
@media (max-width: 768px) {
    .hero.hero--bg-image .hero-content {
        aspect-ratio: auto;
        /* .hero-content выше — грид с gap:30px; здесь это колонка, и к gap
           прибавлялся ещё и нижний margin картинки: между ней и ценами
           набегало 52px. Расстояние задаёт только gap. */
        gap: 22px;
        background: var(--hero-card-bg, #f5f0ff);
        border-radius: var(--radius-3xl);
        overflow: hidden;
        padding: 22px;
        margin-inline: 20px;
        display: flex;
        flex-direction: column;
    }
    .hero.hero--bg-image .hero-text {
        max-width: 100%;
        padding: 0;
        order: 2;
        gap: 14px;
        height: auto;
    }
    .hero.hero--bg-image .hero-text h1 { font-size: clamp(24px, 7vw, 32px); }

    /* Картинка 829x858 (см. <picture> в курсах) уже скомпонована под телефон:
       кадрировать нечего, блок просто повторяет её пропорции и упирается
       в края карточки за счёт отрицательных полей. */
    .hero.hero--bg-image .hero-image {
        position: relative;
        inset: auto;
        top: auto; right: auto; left: auto;
        width: calc(100% + 44px);
        margin: -22px -22px 0;
        height: auto;
        aspect-ratio: 829 / 858;
        border-radius: 0;
        overflow: hidden;
        background-color: transparent;
        order: 1;
    }
    .hero.hero--bg-image .hero-image .hero-blob,
    .hero.hero--bg-image .hero-image .hero-blob picture,
    .hero.hero--bg-image .hero-image .hero-blob img { display: block; width: 100%; height: 100%; }
    /* face.css вешает на .hero-blob margin-top:40px для своего старого
       героя. Здесь картинка обязана упираться в край карточки. */
    .hero.hero--bg-image .hero-image .hero-blob { margin: 0; }
    .hero.hero--bg-image .hero-image .hero-blob img {
        object-fit: cover;
        object-position: center;
    }

    /* Цены — колонки с разделителем прямо на карточке, без белой плашки. */
    .hero.hero--bg-image .hero-badges {
        width: 100%;
        background: transparent;
        border-radius: 0;
        padding: 0;
    }

    /* Кнопки — столбиком во всю ширину карточки. */
    .hero.hero--bg-image .hero-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .hero.hero--bg-image .hero-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    .hero.hero--bg-image .hero-buttons-note {
        flex: none;
        text-align: center;
    }
}

/* На узком экране цены обязаны остаться в две колонки: перенос ставил вторую
   под первую вместе с её левой разделительной чертой, и та повисала
   вертикальной палкой посреди карточки. Вместо переноса даём колонкам
   сжиматься, а длинной сумме — переноситься внутри своей колонки. */
@media (max-width: 480px) {
    .hero.hero--bg-image .hero-badges { gap: 10px; }
    .hero.hero--bg-image .hero-stats { flex-wrap: nowrap; gap: 12px; }
    .hero.hero--bg-image .hero-stat { min-width: 0; }
    .hero.hero--bg-image .hero-stat .val {
        white-space: nowrap;
        font-size: clamp(14px, 4.2vw, 21px);
    }
    /* Старая цена уходит на свою строку: в строку с новой она не влезает,
       и перенос рвал сумму посреди числа. */
    .hero.hero--bg-image .hero-stat .val .old-price {
        display: block;
        margin-left: 0;
        font-size: 13px;
    }
    .hero.hero--bg-image .hero-stat.divide { padding-left: 12px; }
}

/* ============================================
   Бесплатный повтор — «приходите ещё раз»
   ============================================ */

/* Блок есть почти у каждого курса, поэтому живёт здесь, а не в page-specific
   файлах: пятьдесят копий одних и тех же сорока строк никому не нужны.
   Класс оставлен прежним (rx-*), чтобы не переписывать courses/reflex.html. */
.rx-again {
    background-color: var(--bg-purple-light);
    border-radius: var(--radius-2xl);
    padding: 48px 0;
    margin: 48px 0;
}

.rx-again__desc {
    max-width: 620px;
    margin: 0 0 32px;
    color: var(--ink-body);
    line-height: 1.55;
}

.rx-again__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.rx-again__card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 26px 28px;
}

.rx-again__card h3 {
    margin: 0 0 12px;
    font-size: var(--text-lg);
    color: var(--accent);
}

.rx-again__card p {
    margin: 0;
    color: var(--ink-body);
    line-height: 1.55;
}

@media (max-width: 768px) {
    .rx-again {
        padding: 32px 0;
        margin: 32px 0;
    }

    .rx-again__grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Слайдер документов в секции «Наши стандарты»
   ============================================ */

/* Стрелок нет — они перекрывали дипломы, листается точками и свайпом.
   Раньше правила лежали в reflex.css, но слайдер документов есть у каждого
   курса, поэтому переехали сюда. */
.standards .carousel {
    position: relative;
}

.standards .carousel-track {
    border-radius: var(--radius-2xl);
    overflow: hidden;
    background: var(--bg-purple-light);
}

.standards .carousel-track .slide {
    display: none;
}

.standards .carousel-track .slide.is-active {
    display: block;
}

.standards .carousel-track .slide img {
    width: 100%;
    height: auto;
    display: block;
}

.standards .car-dots {
    display: flex;
    gap: 9px;
    justify-content: center;
    margin-top: 22px;
}

.standards .car-dots button {
    width: 9px;
    height: 9px;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    background: #d6cdee;
    transition: background var(--transition-fast), width var(--transition-fast);
}

.standards .car-dots button.is-active {
    background: var(--accent);
    width: 26px;
    border-radius: 6px;
}

.standards-icons img {
    width: 40px;
    height: 40px;
}

/* ============================================
   Общие блоки страницы курса
   ============================================ */

/* Плашки-достижения и карточки доверия в секции «станьте профи». Раньше эти
   правила копировались в CSS каждого курса — на полусотне страниц это полсотни
   копий одного и того же. Классы оставлены прежними (sm-*), чтобы не переписывать
   уже сделанные страницы. */
.sm-perks {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--border-light);
}

.sm-perks__item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--text-sm);
    color: var(--ink-body);
    line-height: 1.35;
}

.sm-perks__item img {
    flex: none;
    width: 32px;
    height: 32px;
}

/* align-items: start — иначе карточка с фото тянется по высоте текстовой
   соседки и снимок обрезается до неразборчивой полосы. */
.sm-trust {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 20px;
    margin-top: 20px;
}

.sm-trust__card {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-2xl);
    padding: 26px 28px;
}

.sm-trust__card--warm {
    background: #fdf4e0;
    border-color: transparent;
}

.sm-trust__card h3 {
    margin: 0 0 12px;
    font-size: var(--text-lg);
    color: var(--ink);
}

.sm-trust__card p {
    margin: 0;
    color: var(--ink-body);
    line-height: 1.55;
}

.sm-trust__card ul {
    margin: 0;
    padding-left: 20px;
    color: var(--ink-body);
    line-height: 1.55;
}

.sm-trust__card li + li {
    margin-top: 8px;
}

/* Карточка только с фотографией — без внутренних полей */
.sm-trust__card--photo {
    padding: 0;
    overflow: hidden;
    border: none;
}

.sm-trust__card--photo img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

/* Широкий призыв с картинкой справа: у части курсов на референсе такой блок
   есть (география обучения, подготовка к аккредитации), у части нет. */
.le-geo {
    margin: 48px auto;
}

.le-geo__card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    background: var(--bg-purple-light);
    border-radius: var(--radius-2xl);
    overflow: hidden;
}

.le-geo__text {
    padding: 38px 40px;
}

.le-geo__text h2 {
    margin: 0 0 14px;
    font-size: var(--text-2xl);
    line-height: 1.25;
}

.le-geo__text p {
    margin: 0 0 12px;
    color: var(--ink-body);
    line-height: 1.55;
}

.le-geo__lead {
    color: var(--accent);
    font-weight: 500;
}

.le-geo__text .btn {
    margin-top: 8px;
}

.le-geo__note {
    margin-top: 16px;
    font-size: var(--text-sm);
}

.le-geo__art {
    position: relative;
    align-self: stretch;
    min-height: 260px;
}

.le-geo__art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (max-width: 900px) {
    .sm-perks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Рядом с текстом картинка сжималась в полоску и переставала читаться */
    .le-geo__card {
        grid-template-columns: 1fr;
    }

    .le-geo__art {
        min-height: 220px;
        order: -1;
    }
}

@media (max-width: 768px) {
    .sm-trust {
        grid-template-columns: 1fr;
    }

    .le-geo__text {
        padding: 28px 24px;
    }
}

/* ============================================
   Видео курса
   ============================================ */

/* Пропорцию задаёт сам ролик (--video-ratio — высота к ширине в процентах,
   снята со страницы-референса): ролики курсов сняты в разных форматах, и общая
   рамка 16:9 дала бы одним чёрные поля по бокам, другим сверху и снизу. */
.course-video {
    display: grid;
    gap: 22px;
    margin-bottom: 56px;
}

.course-video__frame,
.course-reel {
    position: relative;
    margin: 0;
    padding-top: var(--video-ratio, 56.25%);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--bg-placeholder);
}

.course-video__frame iframe,
.course-reel iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Видеозаметки студентов: ряд роликов под общим заголовком. Колонок столько,
   сколько роликов (--reels-cols), потому что три растянутых на всю ширину
   выглядят как ошибка вёрстки. */
.course-reels {
    margin-bottom: 56px;
}

.course-reels__grid {
    display: grid;
    grid-template-columns: repeat(var(--reels-cols, 4), minmax(0, 1fr));
    gap: 22px;
    margin-top: 28px;
}

@media (max-width: 900px) {
    .course-reels__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }
}

/* ============================================
   Course Filter
   ============================================ */

/* Панель фильтров каталога. До запуска course-filter.js скрыта атрибутом
   hidden: без скрипта чекбоксы ничего не делают, а каталог и так полный.
   Оба правила [hidden] обязательны: display у панели и у её частей перебивает
   браузерное скрытие. Без первого панель без JS висела бы на странице живой на
   вид и мёртвой, без второго на свёрнутых группах горели бы бейджи «0». */
.course-filter[hidden],
.course-filter [hidden] {
    display: none;
}

.course-filter {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
    margin-bottom: 40px;
    background-color: var(--bg-purple-light);
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-xl);
}

.course-filter__search {
    position: relative;
    display: flex;
    align-items: center;
}

/* Лупа нарисована инлайновым SVG, а не иконкой Font Awesome: подмножество
   собирается из глифов, которые уже стоят в разметке, и ради одного значка
   пересобирать оба шрифта незачем. */
.course-filter__icon {
    position: absolute;
    left: 18px;
    color: var(--text-light);
    font-size: var(--text-sm);
    pointer-events: none;
}

.course-filter__input {
    width: 100%;
    padding: 14px 18px 14px 44px;
    font-family: var(--font-main);
    font-size: var(--text-base);
    color: var(--text-primary);
    background-color: var(--bg-white);
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-full);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.course-filter__input::placeholder {
    color: var(--text-light);
}

.course-filter__input:focus {
    outline: none;
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-purple) 18%, transparent);
}

/* Строка панели: поиск тянется, кнопки групп встают справа и переносятся
   на следующую строку, когда места не хватает. */
.course-filter__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.course-filter__row .course-filter__search {
    flex: 1 1 260px;
}

.course-filter__groups {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Группа фильтра — <details>. На широком экране её список выпадает поверх
   каталога, на узком раскрывается внутри панели. */
.filter-group {
    position: relative;
}

.filter-group[open] {
    z-index: 6;
}

.filter-group__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--text-body);
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

/* Треугольник-маркер <details> рисуется браузером по-своему в каждом из них,
   поэтому убран, а состояние показывает своя стрелка. */
.filter-group__toggle::-webkit-details-marker {
    display: none;
}

.filter-group__toggle::marker {
    content: '';
}

@media (hover: hover) {
    .filter-group__toggle:hover {
        border-color: color-mix(in srgb, var(--primary-purple) 40%, transparent);
    }
}

.filter-group__toggle:focus-visible {
    outline: 2px solid var(--primary-purple);
    outline-offset: 2px;
}

.filter-group--active .filter-group__toggle {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
}

.filter-group__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background-color: var(--primary-purple);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    color: var(--bg-white);
}

.filter-group__chevron {
    color: var(--text-light);
    transition: transform var(--transition-fast);
}

.filter-group[open] .filter-group__chevron {
    transform: rotate(180deg);
}

.filter-group__body {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 260px;
    max-width: min(420px, 90vw);
    padding: 16px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* Ставит course-filter.js, когда список не помещается по правому краю. */
.filter-group__body--right {
    left: auto;
    right: 0;
}

.course-filter__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--text-body);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

/* Чекбокс не прячем display:none — так он выпадает из порядка обхода с
   клавиатуры. Оставляем его на месте нулевого размера, а видимое кольцо
   фокуса рисует сам чип. */
.filter-chip__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    margin: 0;
}

.filter-chip:has(.filter-chip__input:focus-visible) {
    outline: 2px solid var(--primary-purple);
    outline-offset: 2px;
}

@media (hover: hover) {
    .filter-chip:hover {
        border-color: color-mix(in srgb, var(--primary-purple) 40%, transparent);
    }
}

.filter-chip:has(.filter-chip__input:checked) {
    background-color: var(--primary-purple);
    border-color: var(--primary-purple);
    color: var(--bg-white);
}

.filter-chip__count {
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    color: var(--text-light);
}

.filter-chip:has(.filter-chip__input:checked) .filter-chip__count {
    color: color-mix(in srgb, var(--bg-white) 75%, transparent);
}

/* Вариант, который ничего не добавит к текущей выборке, остаётся кликабельным
   (его можно нажать, чтобы расширить выборку), но виден как пустой. */
.filter-chip--empty {
    opacity: 0.45;
}

/* Выбранное повторяется строкой под кнопками: варианты спрятаны в группах,
   и без неё непонятно, чем сужена выдача. */
.course-filter__applied {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-applied {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px 7px 14px;
    font-family: var(--font-main);
    font-size: var(--text-sm);
    color: var(--bg-white);
    background-color: var(--primary-purple);
    border: 0;
    border-radius: var(--radius-full);
    cursor: pointer;
}

.filter-applied__cross {
    font-size: var(--text-base);
    line-height: 1;
    color: color-mix(in srgb, var(--bg-white) 75%, transparent);
}

@media (hover: hover) {
    .filter-applied:hover .filter-applied__cross {
        color: var(--bg-white);
    }
}

.filter-applied:focus-visible {
    outline: 2px solid var(--primary-purple);
    outline-offset: 2px;
}

.course-filter__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-gray);
}

.course-filter__total {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.course-filter__reset {
    padding: 8px 16px;
    font-family: var(--font-main);
    font-size: var(--text-sm);
    color: var(--primary-purple);
    background: none;
    border: 1px solid color-mix(in srgb, var(--primary-purple) 35%, transparent);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

@media (hover: hover) {
    .course-filter__reset:hover {
        background-color: var(--bg-purple-muted);
    }
}

.course-filter__empty {
    margin: 0;
    font-size: var(--text-base);
    color: var(--text-body);
}

/* Карточка, отсеянная фильтром. Без этого правила display карточки перебивает
   атрибут hidden, и «скрытые» курсы остались бы на месте. */
.course-grid > [hidden] {
    display: none;
}

/* Курс, который нашёлся только по описанию, а не по названию карточки, встаёт
   в конец сетки. Порядок в разметке при этом не меняется: робот видит каталог
   в исходном порядке, переставляет их CSS. */
.course-grid > .course-card--weak {
    order: 1;
}

@media (max-width: 768px) {
    .course-filter {
        padding: 18px;
        gap: 16px;
    }

    .filter-chip {
        padding: 8px 14px;
    }

    /* На телефоне выпадающий список занял бы экран целиком, поэтому группа
       раскрывается внутри панели гармошкой и во всю её ширину. */
    .course-filter__groups {
        width: 100%;
        flex-direction: column;
        gap: 6px;
    }

    .filter-group__toggle {
        justify-content: space-between;
    }

    .filter-group__name {
        margin-right: auto;
    }

    .filter-group__body {
        position: static;
        min-width: 0;
        max-width: none;
        margin-top: 6px;
        padding: 12px;
        box-shadow: none;
        background-color: var(--bg-purple-light);
    }
}

/* На телефоне панель стоит перед каталогом, и каждый лишний ряд чипов —
   это ещё один экран до первой карточки. Ужимаем шаг и кегль. */
@media (max-width: 576px) {
    .course-filter {
        gap: 14px;
    }

    .course-filter__chips {
        gap: 6px;
    }

    .course-filter__legend {
        margin-bottom: 8px;
    }

    .filter-chip {
        padding: 7px 12px;
        gap: 6px;
        font-size: var(--text-xs);
    }

    .course-filter__input {
        padding: 12px 16px 12px 42px;
        font-size: var(--text-sm);
    }
}
