/* Public collection page — reuses ti-* (test-info.css) and mt-list-grid (my-tests.css) classes for
   the section/tests-grid layout. This file holds the page-specific header, the "Собрать случайный
   тест" call to action and the modal that goes with it.

   Loaded after test-info.css, so equal-specificity rules here intentionally win. */

/* Without the coloured hero the default translucent-white skeleton is invisible on the page
   background — give the loading placeholders a visible grey instead. */
.ti-card .ti-col-head .ti-skeleton,
.ti-card > .ti-skeleton {
    background: var(--gray-300);
}

/* ---------- Compact header (replaces the coloured hero) ---------- */

/* The collection header is the page bar: a white card rounded 20 with the way back, the path,
   the state chip, the title and the meta. No colour here, the covers carry it. */
.ti-col-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    background: var(--surface-raised);
    border-radius: 20px;
    margin: 0;
    padding: 14px 16px 18px;
    box-shadow: 0 2px 10px rgba(22, 30, 57, 0.06);
}

@media (min-width: 768px) {
    .ti-col-head {
        margin: 0;
        border-radius: var(--r-lg);
        padding: 16px 20px 20px;
    }
}

.ti-col-head__bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.ti-col-back {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: var(--gray-200);
    color: var(--text-gray-dark-color);
    cursor: pointer;
    transition: background-color .15s ease;
}

    .ti-col-back:hover {
        background: var(--gray-300);
    }

    .ti-col-back:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

.ti-col-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
}

/* Dark text on a light green tint — the brand green on tint fails WCAG AA. */
.ti-col-chip--published {
    background: var(--success-soft);
    color: var(--success);
}

.ti-col-title {
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 22px;
    line-height: 1.25;
    color: var(--text-dark-color);
    margin: 0;
    text-align: left;
    word-break: break-word;
    /* Titles go up to 128 characters — clamp to two lines so the header cannot push the page down. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ti-col-meta {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    color: var(--gray-600);
    margin: 0;
}

.ti-col-meta__dot {
    color: var(--gray-500);
}

.ti-col-author {
    max-width: 360px;
}

/* ---------- Call to action ---------- */

.ti-col-cta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

/* Two-line variant of .ti-pass: the action keeps its prominence and explains the pool size. */
.ti-col-collect {
    height: auto;
    min-height: 60px;
    padding: 10px 20px;
    align-items: center;
    gap: 12px;
    text-align: left;
}

    .ti-col-collect:disabled {
        background: var(--gray-300);
        color: var(--gray-600);
        cursor: default;
        filter: none;
        transform: none;
    }

    .ti-col-collect:disabled:hover {
        filter: none;
    }

    .ti-col-collect:focus-visible {
        outline: 2px solid var(--text-dark-color);
        outline-offset: 2px;
    }

.ti-col-collect__text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}

.ti-col-collect__title {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 16px;
    line-height: 22px;
}

.ti-col-collect__sub {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 12px;
    line-height: 16px;
    opacity: .9;
}

.ti-col-cta__note {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 18px;
    color: var(--gray-600);
    margin: 0;
}

/* ---------- Tests section extras ---------- */

.ti-col-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    margin-left: 8px;
    border-radius: 999px;
    background: var(--gray-200);
    color: var(--gray-600);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 12px;
    line-height: 22px;
    vertical-align: middle;
}

.ti-col-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 10px;
    background: var(--gray-200);
    color: var(--blue-color);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s ease;
}

    .ti-col-add:hover {
        background: var(--gray-300);
    }

    .ti-col-add:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

.ti-col-hidden {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 18px;
    color: var(--gray-600);
    margin: 0;
}

    .ti-col-hidden svg {
        flex: 0 0 auto;
    }

/* Per-card variant: sits directly under the test card it explains. The glyph plus the wording carry
   the state, so nothing here depends on colour alone. */
.ti-col-hidden--item {
    margin-top: 6px;
    padding-left: 2px;
    font-size: 12px;
    line-height: 16px;
}

/* ---------- "Собрать случайный тест" modal ---------- */

.crt-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 30, 57, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: 16px;
    box-sizing: border-box;
}

.crt-dialog {
    background: #FFFFFF;
    border-radius: 20px;
    padding: 20px;
    width: min(420px, 100%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
    box-sizing: border-box;
    outline: none;
}

.crt-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.crt-dialog__title {
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 18px;
    color: var(--text-dark-color);
    margin: 0;
}

.crt-dialog__close {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--gray-200);
    border-radius: 10px;
    color: var(--text-gray-dark-color);
    cursor: pointer;
}

.crt-hint {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    color: var(--gray-600);
    margin: 0 0 16px;
    line-height: 1.4;
}

.crt-presets {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.crt-preset {
    flex: 0 0 auto;
    min-width: 64px;
    height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid var(--gray-300);
    background: #FFFFFF;
    color: var(--text-dark-color);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

    .crt-preset:hover:not(:disabled) {
        background: var(--gray-200);
    }

    .crt-preset:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

    .crt-preset:disabled {
        opacity: .6;
        cursor: default;
    }

.crt-preset--selected {
    background: var(--blue-color);
    border-color: var(--blue-color);
    color: #FFFFFF;
}

    .crt-preset--selected:hover:not(:disabled) {
        background: var(--blue-600);
        border-color: var(--blue-600);
    }

.crt-error {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 13px;
    line-height: 18px;
    color: var(--danger);
    background: var(--danger-soft);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 16px;
}

.crt-dialog__foot {
    display: flex;
    gap: 12px;
}

.crt-cancel,
.crt-submit {
    flex: 1;
    height: 48px;
    border-radius: 12px;
    border: none;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}

.crt-cancel {
    background: var(--gray-200);
    color: var(--text-gray-dark-color);
}

.crt-submit {
    background: var(--green-color);
    color: #FFFFFF;
}

    .crt-submit:disabled,
    .crt-cancel:disabled {
        opacity: .6;
        cursor: default;
    }

    .crt-cancel:focus-visible,
    .crt-submit:focus-visible,
    .crt-dialog__close:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

/* ---------- Tablet / desktop ---------- */
@media (min-width: 768px) {

    .ti-col-title {
        font-size: 26px;
    }

    .ti-col-back {
        width: 44px;
        height: 44px;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {

    .ti-col-back,
    .ti-col-add,
    .ti-col-collect,
    .crt-preset {
        transition: none;
    }

        .ti-col-collect:active {
            transform: none;
        }

    .ti-skeleton {
        animation: none;
    }
}
