/* ============================================================
   Research Hub — Public Site Stylesheet
   Design: Clean academic directory inspired by
   Semantic Scholar, OpenAlex, Scopus, OpenAI, Fireworks AI
   ============================================================ */

:root {
    /* Legacy admin references (kept for /admin compatibility) */
    --wits-blue: #043673;
    --wits-gold: #917248;

    /* Public-site tokens */
    --site-ink: #111827;
    --site-brand: #0d9488;
    --site-bg: #ffffff;
    --site-surface: #f9fafb;
    --site-border: #e5e7eb;
}

/* ---- Base ---- */
html { scroll-behavior: smooth; }

/* ---- Hero background (homepage) ---- */
.hero-gradient {
    position: relative;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(13, 148, 136, 0.07) 0%, transparent 70%),
        radial-gradient(ellipse 60% 40% at 80% 10%, rgba(13, 148, 136, 0.04) 0%, transparent 60%);
}
.hero-gradient::before {
    content: '';
    position: absolute;
    inset: -1px 0 0 0;
    background-image:
        linear-gradient(to right, #e5e7eb 1px, transparent 1px),
        linear-gradient(to bottom, #e5e7eb 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 95%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 95%);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ---- Transitions ---- */
input, select, textarea, button, a {
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* ---- Navigation (public) ---- */
.site-nav-link {
    border-radius: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4b5563;
}
.site-nav-link:hover { background: #f3f4f6; color: #111827; }
.site-nav-link.active { background: #f3f4f6; color: #111827; font-weight: 600; }

.mobile-nav-link {
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4b5563;
}
.mobile-nav-link:hover { background: #f3f4f6; }
.mobile-nav-link.active { background: #f3f4f6; color: #111827; }

/* ---- Dropdown ---- */
.dropdown-item {
    display: inline-flex;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
    border-radius: 0.5rem;
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    color: #374151;
}
.dropdown-item:hover { background: #f3f4f6; }
.site-shell .dropdown-item { color: #1f2937; }
.site-shell .dropdown-item:hover { background: #f3f4f6; }

/* ---- Admin sidebar ---- */
.admin-sidebar {
    width: 18rem;
    transition: width 0.2s ease;
}

@media (min-width: 1024px) {
    .admin-content {
        padding-left: 18rem;
        transition: padding-left 0.2s ease;
    }

    body.sidebar-collapsed .admin-sidebar { width: 5rem; }
    body.sidebar-collapsed .admin-content { padding-left: 5rem; }
    body.sidebar-collapsed .sidebar-label { display: none; }
    body.sidebar-collapsed .admin-nav-link { justify-content: center; }
    body.sidebar-collapsed .admin-sidebar > div:first-child { justify-content: center; }
    body.sidebar-collapsed .admin-sidebar > div:first-child a { justify-content: center; }
}

/* ---- Admin nav ---- */
.admin-nav-link {
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border-radius: 0.5rem;
    padding: 0.7rem 0.75rem;
    font-size: 1rem;
    color: #4b5563;
    position: relative;
}
.admin-nav-link:hover { background: #fff; color: #111827; }
.admin-nav-link.active { background: #fff; color: #0d9488; font-weight: 600; box-shadow: 0 1px 2px 0 rgba(0,0,0,0.04); }
.admin-nav-link i { font-size: 1.4rem; }

/* Collapse button: desktop only */
.sidebar-collapse-btn { display: none; }
@media (min-width: 1024px) {
    .sidebar-collapse-btn { display: flex; }
}

/* Collapse/expand SVG icon toggle */
.sidebar-icon-expand { display: none; }
body.sidebar-collapsed .sidebar-icon-collapse { display: none; }
body.sidebar-collapsed .sidebar-icon-expand { display: block; }

/* Tooltip on collapsed sidebar */
@media (min-width: 1024px) {
    body.sidebar-collapsed .admin-nav-link[data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 0.5rem;
        padding: 0.3rem 0.65rem;
        background: #111827;
        color: #fff;
        border-radius: 0.375rem;
        font-size: 0.75rem;
        font-weight: 500;
        white-space: nowrap;
        z-index: 100;
        pointer-events: none;
    }
}

/* ---- Home search (no focus ring) ---- */
#homeSearchForm input[type='search']:focus {
    --tw-ring-shadow: none;
    --tw-ring-color: transparent;
    box-shadow: none;
    border-color: transparent;
    outline: none;
}

/* ---- Forms ---- */
[type='text']:focus, [type='email']:focus, [type='url']:focus,
[type='password']:focus, [type='number']:focus, [type='date']:focus,
[type='search']:focus, [type='tel']:focus, textarea:focus, select:focus {
    --tw-ring-color: #0d9488;
    border-color: #0d9488;
}

.site-shell [type='text']:focus,
.site-shell [type='email']:focus,
.site-shell [type='url']:focus,
.site-shell [type='password']:focus,
.site-shell [type='number']:focus,
.site-shell [type='date']:focus,
.site-shell [type='search']:focus,
.site-shell [type='tel']:focus,
.site-shell textarea:focus,
.site-shell select:focus {
    --tw-ring-color: var(--site-brand);
    border-color: var(--site-brand);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

/* ---- Password / OTP ---- */
.password-requirements li { font-size: 0.8125rem; color: #6b7280; }
.password-requirements li.valid { color: #059669; }
.otp-single {
    letter-spacing: 0.45em;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 600;
}

/* ---- Step wizard ---- */
.step { display: none; }
.step.active { display: block; }

/* ---- Utilities ---- */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Custom dropdown (settings) ---- */
.cs-dropdown {
    position: relative;
}
.cs-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #111827;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cs-trigger:hover { border-color: #9ca3af; }
.cs-trigger:focus, .cs-trigger[aria-expanded="true"] {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.cs-menu {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 50;
    overflow-y: auto;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    padding: 0.25rem;
}
.cs-option {
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    color: #374151;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.1s ease;
}
.cs-option:hover { background: #f3f4f6; }
.cs-option.active { background: #f0fdfa; color: #0d9488; font-weight: 500; }

/* ---- Toast notification ---- */
.admin-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    background: #065f46;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.admin-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Research loading animation ---- */
.research-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    text-align: center;
}
.research-loading-icon {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid #e5e7eb;
    border-top-color: #0d9488;
    border-radius: 50%;
    animation: research-spin 0.8s linear infinite;
}
@keyframes research-spin {
    to { transform: rotate(360deg); }
}
.research-loading-msg {
    margin-top: 1rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    min-height: 1.5rem;
}
.research-loading-sub {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: #6b7280;
    min-height: 1.25rem;
}
.research-msg-fade-in {
    animation: research-fade-in 0.4s ease forwards;
}
.research-msg-fade-out {
    animation: research-fade-out 0.3s ease forwards;
}
@keyframes research-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes research-fade-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-4px); }
}
.research-loading-progress {
    margin-top: 1.25rem;
    width: 12rem;
    height: 3px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.research-loading-progress-bar {
    height: 100%;
    background: #0d9488;
    border-radius: 999px;
    animation: research-progress 45s ease-out forwards;
}
@keyframes research-progress {
    0% { width: 0; }
    20% { width: 30%; }
    50% { width: 55%; }
    80% { width: 75%; }
    100% { width: 90%; }
}

/* ---- Scrollable tabs (mobile) ---- */
.tabs-scroll {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent);
}
.tabs-scroll > * { flex-shrink: 0; }
.tabs-scroll::-webkit-scrollbar { display: none; }
.tabs-scroll.scrolled-end {
    mask-image: none;
    -webkit-mask-image: none;
}

/* ---- Print ---- */
@media print {
    nav, footer, .no-print { display: none !important; }
    body { background: white !important; }
}
