/* ===== Medical terms glossary — page-specific design =====
   Loaded after style.css + info-enhance.css. All visual only:
   no content is styled away, with JS disabled the page still
   renders every term in order. */

/* -----------------------------------------------------------------------
   SEARCH
   ----------------------------------------------------------------------- */
.search-filter-section {
    margin-bottom: 2.75rem;
}

.search-box {
    position: relative;
    max-width: 720px;
    margin: 0 auto 1.75rem;
}

.search-box .search-icon {
    position: absolute;
    inset-inline-start: 1.3rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #8aa6bd;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 1.05rem 3.4rem 1.05rem 3.4rem;
    font-size: 1.05rem;
    font-family: inherit;
    color: inherit;
    border: 1.5px solid rgba(51, 101, 138, 0.18);
    border-radius: 50px;
    background: #fff;
    box-shadow: 0 4px 18px rgba(51, 101, 138, 0.07);
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.search-box input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(51, 101, 138, 0.12), 0 4px 18px rgba(51, 101, 138, 0.08);
}

.search-clear {
    position: absolute;
    inset-inline-end: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(51, 101, 138, 0.08);
    color: var(--primary-blue);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.search-clear:hover {
    background: rgba(51, 101, 138, 0.16);
}

.search-clear svg {
    width: 14px;
    height: 14px;
}

.search-clear[hidden] {
    display: none;
}

/* -----------------------------------------------------------------------
   CATEGORY FILTER CHIPS
   ----------------------------------------------------------------------- */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
}

.category-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1.25rem;
    background: #fff;
    color: var(--primary-blue);
    border: 1.5px solid rgba(51, 101, 138, 0.22);
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.22s ease, border-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

.category-btn:hover {
    background: rgba(51, 101, 138, 0.07);
    border-color: rgba(51, 101, 138, 0.4);
}

.category-btn.active {
    background: linear-gradient(135deg, var(--primary-blue), #2f6d99);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(51, 101, 138, 0.28);
}

.category-btn .cat-count {
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(51, 101, 138, 0.1);
    color: var(--primary-blue);
    border-radius: 20px;
    padding: 0.1rem 0.55rem;
    line-height: 1.4;
}

.category-btn.active .cat-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

#resultsCounter {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.95rem;
    color: #64748b;
    min-height: 1.4em;
}

/* -----------------------------------------------------------------------
   CATEGORIES + TERM CARDS
   ----------------------------------------------------------------------- */
.terms-category {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.1rem;
    margin-bottom: 3.25rem;
    animation: termsFadeUp 0.6s ease;
}

.terms-category > .category-title {
    grid-column: 1 / -1;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-blue);
    font-size: 1.55rem;
    margin-bottom: 0.4rem;
    padding-bottom: 0.85rem;
    position: relative;
    border-bottom: 1px solid rgba(51, 101, 138, 0.14);
    text-align: right;
}

.category-title::after {
    content: '';
    position: absolute;
    bottom: -1px;
    inset-inline-start: 0;
    width: 64px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(to left, var(--primary-blue), #5d93b8);
}

.category-title .cat-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(51, 101, 138, 0.1), rgba(93, 147, 184, 0.16));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-blue);
}

.category-title .cat-icon svg {
    width: 21px;
    height: 21px;
}

.category-title .cat-chip {
    margin-inline-start: auto;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(51, 101, 138, 0.08);
    color: var(--primary-blue);
    border-radius: 20px;
    padding: 0.3rem 0.85rem;
    white-space: nowrap;
}

.term-item {
    position: relative;
    background: #fff;
    padding: 1.4rem 1.7rem;
    border-radius: 16px;
    border: 1px solid rgba(51, 101, 138, 0.1);
    box-shadow: 0 2px 10px rgba(15, 40, 70, 0.05);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    scroll-margin-top: 120px;
}

.term-item::before {
    content: '';
    position: absolute;
    top: 16px;
    bottom: 16px;
    inset-inline-start: 0;
    width: 4px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--primary-blue), #5d93b8);
    opacity: 0.5;
    transition: opacity 0.25s ease;
}

.term-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(51, 101, 138, 0.13);
    border-color: rgba(51, 101, 138, 0.22);
}

.term-item:hover::before {
    opacity: 1;
}

.term-item h3 {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 0.6rem;
    padding-inline-end: 2.2rem;
}

.term-item p {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.75;
    color: var(--text-gray, #475569);
}

/* copy-link button (JS injected) */
.term-link {
    position: absolute;
    top: 1.15rem;
    inset-inline-end: 1.1rem;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #9db4c6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.term-item:hover .term-link,
.term-link:focus {
    opacity: 1;
}

.term-link:hover {
    background: rgba(51, 101, 138, 0.08);
    color: var(--primary-blue);
}

.term-link.copied {
    color: #1d8a4e;
    opacity: 1;
}

.term-link svg {
    width: 15px;
    height: 15px;
}

/* deep-link arrival highlight */
.term-item:target {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(51, 101, 138, 0.16);
}

/* -----------------------------------------------------------------------
   EMPTY STATE (JS injected, hidden by default)
   ----------------------------------------------------------------------- */
.glossary-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    background: #fff;
    border: 1.5px dashed rgba(51, 101, 138, 0.3);
    border-radius: 16px;
    color: #64748b;
    margin-bottom: 3rem;
}

.glossary-empty svg {
    width: 38px;
    height: 38px;
    color: #9db4c6;
    margin-bottom: 0.75rem;
}

.glossary-empty p {
    margin: 0 0 1.25rem;
    font-size: 1.05rem;
}

.glossary-empty button {
    padding: 0.6rem 1.6rem;
    border: none;
    border-radius: 50px;
    background: var(--primary-blue);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease;
}

.glossary-empty button:hover {
    background: #27516f;
}

@keyframes termsFadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -----------------------------------------------------------------------
   RESPONSIVE + MOTION
   ----------------------------------------------------------------------- */
@media (max-width: 820px) {
    .terms-category {
        grid-template-columns: 1fr;
    }

    .category-title {
        font-size: 1.35rem;
    }

    .category-btn {
        font-size: 0.88rem;
        padding: 0.55rem 1rem;
    }

    .search-box input {
        font-size: 1rem;
    }

    /* always show the copy-link button on touch screens */
    .term-link {
        opacity: 0.65;
    }
}

@media (prefers-reduced-motion: reduce) {
    .terms-category {
        animation: none;
    }

    .term-item,
    .category-btn,
    .search-box input {
        transition: none;
    }
}
