@import url("https://fonts.googleapis.com/css2?family=Onest:wght@100..900&display=swap");

* {
    font-family: "Onest", Arial, sans-serif;
    box-sizing: border-box;
    color: #333333;
    caret-color: transparent;
}

body {
    margin: 0;
    background: #f6f7f8;
}

.course-content {
    background-color: #f6f7f8;
    min-height: 100vh;
    display: flex;
    justify-content: center; /* по горизонтали */
}

footer.container {
    background: white;
}

footer hr {
    border-top: 3px solid #f6f7f8;
}

.course-block {
    width: 100%;
    max-width: 70rem;
    margin-top: 7.2rem;
    padding: 0;
    margin-bottom: 5rem;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.course-title {
    text-align: center;
    margin: 0 auto 1.45rem;
    width: 75%;
    font-size: 1.85rem;
    font-weight: 650;
    line-height: 1.08;
    letter-spacing: -.035em;
}

.course-section {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    align-items: center;

    background-color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-radius: 15px;
    padding: 1.3rem;
    padding-top: 2.5rem;

    position: relative;

    --node-cover-bg: #ffffff;
}

.course-section > * {
    position: relative;
    z-index: 1;
}

/* SVG-дорога */
.course-road {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* чтобы клики шли по карточкам */
    z-index: 0;
}

.course-road path {
    fill: none;
    stroke: var(--road-color, #c9e8ff);
    stroke-width: 4;
    stroke-linecap: round;

    /* ПУНКТИР */
    stroke-dasharray: 4 6;
    transition: stroke 0.25s ease;
}

/* -------------------- карточки -------------------- */

.course-card {
    display: flex;
    align-items: center;
    justify-content: center;

    width: min-content;
    min-width: 9rem;
    max-width: 12rem;

    padding: 0.5rem;

    background: white;
    border-radius: 16px;
    text-decoration: none;

    transition: 0.5s ease;

    position: relative;
    z-index: 1; /* выше дороги */
}

.course-card__content {
    min-width: 0;
    max-width: 100%;
}

.course-card h3 {
    font-family: "Onest", Arial, sans-serif;
    margin: 0;

    font-weight: 550;
    font-size: 1.075rem;
    line-height: 1.1;
    text-align: center;

    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
}

.course-card h2 {
    font-family: "Onest", Arial, sans-serif;
    margin: 0;

    font-weight: 550;
    font-size: 1.175rem;
    line-height: 1.2;
    text-align: center;

    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
}

/* положение основных узлов */


.course-card--second {
    transform: none;
}



/* дети */
.course-card--child {
    width: min-content;
    min-width: 9rem;
    max-width: 12rem;

    opacity: 1;
    transform: translateX(4.5rem);
}


/* Базовый / Продвинутый уровень теперь являются обычными
   текстовыми разделителями, а не карточками дороги. */
.course-level-heading {
    align-self: center;
    position: relative;
    z-index: 2;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: max-content;
    max-width: 100%;
    margin: 0;
    padding: 0 0.45rem;

    background: var(--node-cover-bg);
}

.course-level-heading h2 {
    margin: 0;

    font-family: "Onest", Arial, sans-serif;
    font-size: 1.175rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;

    white-space: nowrap;
}


/* Логические группы уровня не создают дополнительную flex-обёртку. */
.course-stage__children {
    display: contents;
}

/* скрытие детей */
.is-hidden {
    display: none !important;
}

/* Цвета */
.course-card--spring {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    background-color: #d1e9c6;
}

.course-card--java {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    background-color: #c9e8ff;
}

.course-card--sql {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    background-color: #fff0b8;
}

.course-card--algorithms {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    background-color: #ffcaca;
}



/* -------------------- toggle -------------------- */

.card-with-toggle {
    position: relative;

    width: min-content;
    min-width: 9rem;
    max-width: 12rem;
}

.course-card--has-toggle {
    padding-left: 0.5rem;
    padding-right: 2rem;
}

.course-toggle.is-in-card {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);

    width: 1.5rem;
    height: 1.5rem;

    border: none;
    border-radius: 999px;
    padding: 0;

    background: none;
    cursor: pointer;

    font-weight: 700;
    line-height: 1;

    display: grid;
    place-items: center;

    z-index: 2;
}

.course-toggle:focus,
.course-toggle:focus-visible {
    outline: none;
    box-shadow: none;
}

.course-toggle.is-in-card img {
    width: 1.1rem;
    height: 1.1rem;
    display: block;
    transition: transform 0.35s ease;
}

.course-toggle.is-in-card[aria-expanded="true"] img {
    transform: rotate(-180deg);
}

.to-buttons{
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 0 0 2rem;
    flex-wrap: wrap;
    align-items: stretch;
}

/* чтобы внутренние блоки не ломали flex */

.to-buttons__auth{
    min-width: 0;
    width: 100%;
    display: block;
}

.to-cards-wrapper{
    min-width: 0;
    position: relative;
    width: 100%;
    margin: 0 auto;
    /* 11rem = ширина карточки, 1.5rem = gap, 1rem*2 = padding у to-cards */
    max-width: calc(11rem * 4 + 1.5rem * 3 + 1rem * 2);
}

.to-cards-viewport{
    border-radius: 18px;
    overflow: hidden;
}

.to-cards{
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 0.75rem 1rem;
    min-width: 0;
    justify-content: flex-start; /* как на questions */
    scrollbar-width: none;
}

.to-cards::-webkit-scrollbar{ display:none; }

.to-cards .track-progress{
    flex: 0 0 11rem;
    max-width: 11rem;
}

.to-cards.is-centered{
    justify-content: center;
}

/* стрелки */

.to-scroll-btn{
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    cursor: pointer;
    z-index: 10;

    display: flex;
    align-items: center;
    justify-content: center;

    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
    transition-delay: .25s;
}

.to-cards-wrapper:hover .to-scroll-btn{
    opacity: 1;
    pointer-events: auto;
    transition-delay: .15s;
}

.to-scroll-btn--left{ left: 5px; }
.to-scroll-btn--right{ right: 5px; }

.to-scroll-btn .chev{
    width: 24px;
    height: 24px;
    display: block;
}

/* любой узел дороги — якорь */
[data-road-node]{
    position: relative;
}

/* иконка статуса */
[data-road-node] .course-card__check{
    display: none;
    position: absolute;

    right: 0;
    bottom: 0;

    transform: translate(33%, 33%);
    width: 18px;
    height: 18px;

    background: url("/images/check.png") no-repeat center / contain;
    pointer-events: none;
    z-index: 5;
}

/* completed = показываем */
[data-road-node].is-completed .course-card__check{
    display: block;
}


/* ---------- progress card ---------- */
.track-progress{
    max-width: 11rem;
    display: flex;
    gap: 0.9rem;

    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);

    padding: 0.75rem;
    align-items: center;
}

.track-progress__info{
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
}

.track-progress__header{
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.track-progress__title-text{
    font-weight: 650;
    font-size: 1.1rem;
}

.track-progress__logo{
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.track-progress__meta{
    display: flex;
    justify-content: space-between;
    font-size: 0.92rem;
    opacity: 0.9;
}

.track-progress__bar{
    width: 100%;
    height: 0.5rem;
    border-radius: 999px;
    background: #eef0f2;
    overflow: hidden;
}

.track-progress__bar-fill{
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: #7cb261; /* можно потом под track */
    transition: width 0.35s ease;
}

.track-progress__btn{
    margin-top: 0.2rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;

    height: 2.2rem;
    border-radius: 12px;
    font-weight: 650;
    font-size: 0.95rem;

    background: #eef0f2;
    color: #333333;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.track-progress__btn:hover{
    transform: translateY(-1px);
}

.track-progress__btn.is-disabled{
    pointer-events: none;
    opacity: 0.75;
}

.course-toggle__icon {
    width: 1.1rem;
    height: 1.1rem;
    display: block;

    background-color: #6b7280;

    mask: url("/images/course-page-images/chevron-white.svg")
          no-repeat center / contain;

    -webkit-mask: url("/images/course-page-images/chevron-white.svg")
                  no-repeat center / contain;

    transition:
        transform 0.35s ease,
        background-color 0.2s ease;
}

.course-toggle.is-in-card[aria-expanded="true"] .course-toggle__icon {
    transform: rotate(-180deg);
}


.course-card--system-design {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    background-color: #ddd8ff;
}


.course-premium-fire {
    position: static;

    width: 18px;
    height: 18px;
    margin-left: 0.12rem;

    display: block;
    flex: 0 0 auto;
    object-fit: contain;

    opacity: 0.75;
    transform: none;
    pointer-events: none;
    z-index: 6;
}


/* Разница между старым gap 1.3rem и новым 0.85rem */
:root {
    --course-gap-extra: 0.45rem;
}


/* Заголовок уровня -> первая тема:
   сохраняем увеличенное расстояние. */
.course-stage__children > .card-with-toggle:first-child {
    margin-top: var(--course-gap-extra);
}


/* Тема -> первая раскрытая подтема:
   тоже оставляем старое большое расстояние */
.course-stage__children >
.card-with-toggle +
.course-card--child:not(.is-hidden) {
    margin-top: var(--course-gap-extra);
}


/* Последняя раскрытая подтема -> следующая тема:
   сохраняем разделение групп */
.course-stage__children >
.course-card--child:not(.is-hidden):has(+ .card-with-toggle) {
    margin-bottom: var(--course-gap-extra);
}


/* Расстояние перед следующим текстовым заголовком уровня. */
.course-stage__children + .course-level-heading {
    margin-top: 1.45rem;
}

/* ===== RESPONSIVE PASS ===== */
.course-content {
    padding-left: clamp(1.25rem, 3vw, 2rem);
    padding-right: clamp(1.25rem, 3vw, 2rem);
}

@media (max-width: 700px) {
    .course-block {
        margin-top: 6.5rem;
        margin-bottom: 3rem;
    }

    .course-title {
        width: 100%;
    }
    .to-buttons {
        margin-bottom: 1.5rem;
    }

    .course-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.25rem;
    }

    .course-section {
        padding: 2rem 1rem 1.25rem;
        overflow: hidden;
    }

    .course-level-heading h2 {
        white-space: normal;
    }

    .course-card--child {
        transform: translateX(2.25rem);
    }
}

@media (max-width: 380px) {
    .course-card--child {
        transform: translateX(1.5rem);
    }
}

