/* ============================================
   NPL Grant Intelligence Portal Styles
   Extends the main NPL design system
   ============================================ */

/* --- Access Gate --- */
.gate {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.gate__bg {
    position: absolute;
    inset: 0;
    background: var(--gradient-main);
    opacity: 0.12;
}

.gate__bg::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 40%, rgba(91, 134, 229, 0.3) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 40%, rgba(155, 89, 182, 0.28) 0%, transparent 50%);
    animation: heroPulse 12s ease-in-out infinite alternate;
}

.gate__overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 20%, var(--bg-dark) 75%);
}

.gate__content {
    position: relative;
    z-index: 2;
    max-width: 480px;
    padding: 0 24px;
}

.gate__logo {
    margin-bottom: 32px;
}

.gate__logo-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(91, 134, 229, 0.3), 0 0 120px rgba(155, 89, 182, 0.15);
}

.gate__title {
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 0%, rgba(91, 134, 229, 0.95) 50%, rgba(155, 89, 182, 0.95) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gate__subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    line-height: 1.6;
}

.gate__form {
    margin-bottom: 24px;
}

.gate__label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.gate__input-wrap {
    display: flex;
    gap: 8px;
}

.gate__input {
    flex: 1;
    padding: 16px 20px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 4px;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.gate__input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 20px rgba(91, 134, 229, 0.2);
}

.gate__input::placeholder {
    letter-spacing: 1px;
    text-transform: none;
    font-weight: 400;
    color: var(--text-muted);
}

.gate__btn {
    padding: 16px 28px;
    border-radius: 14px;
    border: none;
    background: var(--gradient-full);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    white-space: nowrap;
}

.gate__btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(91, 134, 229, 0.3);
}

.gate__error {
    display: none;
    margin-top: 12px;
    font-size: 14px;
    color: #e74c3c;
    font-weight: 500;
}

.gate__error.is-visible {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.gate__note {
    font-size: 13px;
    color: var(--text-muted);
}

.gate__note a {
    color: var(--blue-light);
    text-decoration: underline;
}

.gate.is-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* --- Portal Hero --- */
.portal-hero {
    padding: 140px 0 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.portal-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(91, 134, 229, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.portal-hero__badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 6px 18px;
    border-radius: 100px;
    background: var(--gradient-full);
    color: white;
    margin-bottom: 24px;
}

.portal-hero__title {
    font-size: clamp(36px, 5vw, 64px);
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1.05;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #fff 20%, var(--blue-light) 50%, var(--purple-light) 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.portal-hero__subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 48px;
    line-height: 1.6;
}

.portal-hero__stats {
    display: flex;
    justify-content: center;
    gap: 60px;
}

.portal-hero__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.portal-hero__stat-num {
    font-size: 42px;
    font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.portal-hero__stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* --- Grant Database --- */
.grants-db {
    background: var(--bg-section);
    border-top: 1px solid var(--glass-border);
}

.grants-filters {
    margin-bottom: 32px;
}

.grants-filters__search {
    width: 100%;
    padding: 16px 20px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    outline: none;
    margin-bottom: 16px;
    transition: border-color 0.3s ease;
}

.grants-filters__search:focus {
    border-color: var(--blue);
}

.grants-filters__search::placeholder {
    color: var(--text-muted);
}

.grants-filters__row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.grants-filters__select {
    flex: 1;
    min-width: 160px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.grants-filters__select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.grants-table-wrap {
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
}

.grants-loading {
    padding: 60px 24px;
    text-align: center;
    color: var(--text-muted);
}

.grants-loading__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--blue);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.grants-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.grants-table thead {
    border-bottom: 1px solid var(--glass-border);
}

.grants-table th {
    padding: 16px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.grants-table td {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: top;
}

.grants-table tbody tr {
    transition: background 0.2s ease;
}

.grants-table tbody tr:hover {
    background: rgba(91, 134, 229, 0.05);
}

.grants-table__title {
    font-weight: 600;
    color: var(--text-primary);
    max-width: 300px;
}

.grants-table__agency {
    font-weight: 500;
    white-space: nowrap;
}

.grants-table__status {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

.grants-table__status--open {
    background: rgba(46, 204, 113, 0.12);
    color: #2ecc71;
}

.grants-table__status--rolling {
    background: rgba(155, 89, 182, 0.12);
    color: var(--purple-light);
}

.grants-table__status--forecasted {
    background: rgba(91, 134, 229, 0.12);
    color: var(--blue-light);
}

.grants-table__status--closing {
    background: rgba(241, 196, 15, 0.12);
    color: #f1c40f;
}

.grants-table__link {
    color: var(--blue-light);
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.grants-table__link:hover {
    color: var(--purple-light);
}

.grants-empty {
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 15px;
}

.grants-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.grants-pagination__btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.grants-pagination__btn:hover,
.grants-pagination__btn.is-active {
    background: var(--gradient-main);
    border-color: transparent;
    color: white;
}

/* --- Screener Form --- */
.screener {
    position: relative;
}

.screener__intro {
    font-size: 17px;
    color: var(--text-secondary);
    max-width: 700px;
    line-height: 1.7;
    margin-bottom: 48px;
}

.screener-form {
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.screener-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.screener-form__group {
    display: flex;
    flex-direction: column;
}

.screener-form__label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.screener-form__hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
}

.screener-form__input,
.screener-form__select,
.screener-form__textarea {
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    -webkit-appearance: none;
}

.screener-form__input:focus,
.screener-form__select:focus,
.screener-form__textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 15px rgba(91, 134, 229, 0.15);
}

.screener-form__input::placeholder,
.screener-form__textarea::placeholder {
    color: var(--text-muted);
}

.screener-form__select option {
    background: var(--bg-dark);
}

.screener-form__textarea {
    resize: vertical;
    min-height: 80px;
}

/* STEM Chips */
.screener-form__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.screener-chip {
    padding: 8px 16px;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.screener-chip:hover {
    border-color: rgba(91, 134, 229, 0.4);
    color: var(--text-primary);
}

.screener-chip.is-selected {
    background: var(--gradient-main);
    border-color: transparent;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(91, 134, 229, 0.25);
}

.screener-form__submit {
    margin-top: 16px;
    align-self: flex-start;
}

/* Screener Success */
.screener-success {
    max-width: 600px;
    text-align: center;
    padding: 60px 0;
}

.screener-success__icon {
    margin-bottom: 24px;
}

.screener-success__title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
}

.screener-success__text {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

/* --- Responsive --- */
@media (max-width: 767px) {
    .gate__input-wrap {
        flex-direction: column;
    }

    .gate__title {
        font-size: 28px;
    }

    .portal-hero {
        padding: 120px 0 60px;
    }

    .portal-hero__stats {
        gap: 32px;
    }

    .portal-hero__stat-num {
        font-size: 32px;
    }

    .grants-filters__row {
        flex-direction: column;
    }

    .grants-filters__select {
        min-width: 100%;
    }

    .grants-table th:nth-child(5),
    .grants-table td:nth-child(5),
    .grants-table th:nth-child(6),
    .grants-table td:nth-child(6) {
        display: none;
    }

    .screener-form__row {
        grid-template-columns: 1fr;
    }

    .screener-form__submit {
        width: 100%;
    }
}

@media (max-width: 479px) {
    .portal-hero__stats {
        flex-direction: column;
        gap: 20px;
    }

    .grants-table th:nth-child(4),
    .grants-table td:nth-child(4) {
        display: none;
    }
}
