/* Internal files page — scoped styles (prefix: .fl-)
   The brand blue comes from the site theme (--bs-primary in styles.css); the
   Roboto Slab font is inherited from the body. styles.css loads after this file,
   so every rule here is scoped under .fl-page to win over its element rules
   (`section` padding, `a` colour). */

.fl-page {
    --fl-primary: var(--bs-primary);
    --fl-primary-rgb: var(--bs-primary-rgb);
    --fl-primary-dark: #0987c2;
    --fl-ink: #1e293b;
    --fl-muted: #64748b;
    --fl-line: #e2e8f0;
    --fl-bg: #f4f8fb;
    --fl-chip-bg: #eef2f6;
    --fl-radius: 14px;
    --fl-shadow-hover: 0 12px 28px -14px rgba(2, 74, 110, .35);
    /* the site's navbar sticks to the top once the page scrolls: a category
       reached through an anchor starts below it, not under it */
    --fl-sticky-offset: 96px;
    background: var(--fl-bg);
    color: var(--fl-ink);
}

.fl-page [hidden] {
    display: none !important;
}

.fl-page .container {
    max-width: 1200px;
}

/* ---------- Title and search ---------- */
.fl-page .fl-hero {
    padding: 56px 0 32px;
    text-align: center;
}

.fl-hero__title {
    margin: 0 0 8px;
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 700;
    line-height: 1.2;
    color: var(--fl-ink);
}

.fl-hero__lead {
    margin: 0;
    font-size: 16px;
    color: var(--fl-muted);
}

.fl-search {
    position: relative;
    max-width: 640px;
    margin: 24px auto 0;
}

.fl-search__icon {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--fl-muted);
    pointer-events: none;
}

.fl-search__input {
    width: 100%;
    height: 56px;
    padding: 0 20px 0 52px;
    /* 16px keeps iOS from zooming into the field */
    font-size: 16px;
    color: var(--fl-ink);
    background: #fff;
    border: 1px solid var(--fl-line);
    border-radius: var(--fl-radius);
    box-shadow: 0 4px 16px -10px rgba(2, 74, 110, .25);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.fl-search__input::placeholder {
    color: var(--fl-muted);
}

.fl-search__input:focus {
    outline: none;
    border-color: var(--fl-primary);
    box-shadow: 0 0 0 4px rgba(var(--fl-primary-rgb), .18);
}

/* ---------- Category filter ---------- */
.fl-page .fl-body {
    padding: 0 0 80px;
}

.fl-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 40px;
}

.fl-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 8px 0 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--fl-ink);
    background: #fff;
    border: 1px solid var(--fl-line);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease, opacity .2s ease;
}

.fl-filter:hover {
    border-color: var(--fl-primary);
    color: var(--fl-primary-dark);
}

.fl-filter__count {
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--fl-muted);
    background: var(--fl-chip-bg);
    border-radius: 999px;
}

.fl-filter[aria-pressed="true"] {
    color: #fff;
    background: var(--fl-primary);
    border-color: var(--fl-primary);
}

.fl-filter[aria-pressed="true"] .fl-filter__count {
    color: #fff;
    background: rgba(255, 255, 255, .24);
}

/* while searching, a category with no match fades but stays reachable */
.fl-filter.is-empty:not([aria-pressed="true"]) {
    opacity: .55;
}

/* ---------- Categories ---------- */
.fl-page .fl-group {
    padding: 0;
    scroll-margin-top: var(--fl-sticky-offset);
}

.fl-group + .fl-group {
    margin-top: 48px;
}

.fl-group__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

/* a rule runs from the heading to the edge, so each category reads as a block */
.fl-group__head::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--fl-line);
}

.fl-group__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--fl-ink);
}

.fl-group__count {
    flex: none;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--fl-primary-dark);
    background: rgba(var(--fl-primary-rgb), .1);
    border-radius: 999px;
}

/* ---------- Document cards ---------- */
.fl-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.fl-grid__item {
    display: flex;
    min-width: 0;
}

.fl-page .fl-card {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px 16px 16px;
    color: var(--fl-ink);
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--fl-line);
    border-radius: var(--fl-radius);
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.fl-page .fl-card:hover {
    color: var(--fl-ink);
    border-color: rgba(var(--fl-primary-rgb), .5);
    box-shadow: var(--fl-shadow-hover);
    transform: translateY(-2px);
}

.fl-page .fl-card:focus-visible,
.fl-filter:focus-visible,
.fl-page .fl-empty .btn:focus-visible {
    outline: 3px solid var(--fl-primary);
    outline-offset: 3px;
}

.fl-card__icon {
    flex: none;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--bs-danger);
    background: rgba(var(--bs-danger-rgb), .1);
    border-radius: 10px;
}

.fl-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fl-card__name {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    /* some names are one long word (MagistraturaTHEORY_AND_…): break it rather than overflow */
    overflow-wrap: anywhere;
    transition: color .2s ease;
}

.fl-card:hover .fl-card__name {
    color: var(--fl-primary-dark);
}

.fl-card__meta {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--fl-muted);
}

.fl-card__arrow {
    flex: none;
    font-size: 14px;
    color: var(--fl-muted);
    transition: color .2s ease, transform .2s ease;
}

.fl-card:hover .fl-card__arrow {
    color: var(--fl-primary-dark);
    transform: translateX(4px);
}

/* ---------- Empty states ---------- */
.fl-empty {
    padding: 48px 16px;
    text-align: center;
    color: var(--fl-muted);
}

.fl-empty__icon {
    display: block;
    margin-bottom: 16px;
    font-size: 40px;
    opacity: .5;
}

.fl-empty__text {
    margin: 0 0 20px;
    font-size: 17px;
}

/* ---------- Columns ---------- */
@media (min-width: 768px) {
    .fl-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1200px) {
    .fl-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* on a phone the categories scroll sideways in one row instead of stacking */
@media (max-width: 767.98px) {
    .fl-page .fl-hero {
        padding: 40px 0 24px;
    }

    .fl-filters {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        margin: 0 -12px 32px;
        padding: 0 12px 4px;
        scrollbar-width: none;
    }

    .fl-filters::-webkit-scrollbar {
        display: none;
    }

    .fl-group + .fl-group {
        margin-top: 40px;
    }

    .fl-group__title {
        font-size: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fl-page .fl-card,
    .fl-card__arrow {
        transition: none;
    }

    .fl-page .fl-card:hover,
    .fl-card:hover .fl-card__arrow {
        transform: none;
    }
}
