/* ── EPTRI Funding & Regulation – Public Styles ──────────────────────────── */

:root {
    --eptri-navy:    #1a2e5a;
    --eptri-blue:    #2563a8;
    --eptri-accent:  #e8f0fb;
    --eptri-border:  #d0d8e8;
    --eptri-text:    #1d2433;
    --eptri-muted:   #6b7a99;
    --eptri-radius:  6px;
    --eptri-shadow:  0 8px 40px rgba(26,46,90,.22);
    /* Below navbar: top uses % of viewport height (fixed); margin-top uses % of overlay width */
    --eptri-overlay-top: 6%;
    --eptri-popup-margin-top: 6%;
    /* Headroom for max-height (overlay slice + margin; tweak on theme if clipped) */
    --eptri-modal-vertical-reserve: 20vh;
    --eptri-modal-pad-y: 24px;
}

/* ── Wrapper ─────────────────────────────────────── */
.eptri-public-wrap { font-family: inherit; color: var(--eptri-text); }

/* ── Toolbar ─────────────────────────────────────── */
.eptri-toolbar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    margin-bottom: 16px;
}
.eptri-search {
    flex: 1 1 260px; min-width: 200px; max-width: 400px;
    padding: 9px 14px;
    border: 1.5px solid var(--eptri-border);
    border-radius: var(--eptri-radius);
    font-size: .95rem; color: var(--eptri-text);
    outline: none; transition: border-color .2s;
    background: #fff;
}
.eptri-search:focus { border-color: var(--eptri-blue); }
.eptri-topic-filter {
    padding: 9px 14px;
    border: 1.5px solid var(--eptri-border);
    border-radius: var(--eptri-radius);
    font-size: .95rem; color: var(--eptri-text);
    background: #fff; cursor: pointer;
    outline: none; transition: border-color .2s;
}
.eptri-topic-filter:focus { border-color: var(--eptri-blue); }

/* ── Table ───────────────────────────────────────── */
.eptri-table-wrapper {
    overflow-x: auto;
    border-radius: var(--eptri-radius);
    border: 1px solid var(--eptri-border);
}
.eptri-pub-table {
    width: 100%; border-collapse: collapse;
    font-size: .92rem; background: #fff;
}
.eptri-pub-table thead th {
    background: var(--eptri-navy); color: #fff;
    padding: 12px 14px; text-align: left; white-space: nowrap;
    font-weight: 600; font-size: .88rem; letter-spacing: .02em;
}
.eptri-pub-table thead th.sortable { cursor: pointer; user-select: none; }
.eptri-pub-table thead th.sortable:hover { background: #243e75; }
.sort-icon::after         { content: ' ⇅'; opacity: .5; font-size: .8em; }
.sort-asc  .sort-icon::after { content: ' ↑'; opacity: 1; }
.sort-desc .sort-icon::after { content: ' ↓'; opacity: 1; }
.eptri-pub-table tbody tr {
    border-bottom: 1px solid var(--eptri-border);
    transition: background .15s; cursor: pointer;
}
.eptri-pub-table tbody tr:last-child { border-bottom: none; }
.eptri-pub-table tbody tr:hover { background: var(--eptri-accent); }
.eptri-pub-table tbody tr:nth-child(even) { background: #f7f9fc; }
.eptri-pub-table tbody tr:nth-child(even):hover { background: var(--eptri-accent); }
.eptri-pub-table td {
    padding: 11px 14px; vertical-align: top;
    max-width: 240px; word-break: break-word;
}
.eptri-badge {
    display: inline-block; padding: 2px 10px; border-radius: 20px;
    font-size: .78rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap;
}
.eptri-badge-open        { background: #d1fae5; color: #065f46; }
.eptri-badge-closed      { background: #fee2e2; color: #991b1b; }
.eptri-badge-forthcoming { background: #fef3c7; color: #92400e; }
.eptri-badge-default     { background: #e5e7eb; color: #374151; }
.eptri-pub-loading { text-align:center; color:var(--eptri-muted); padding:32px!important; font-style:italic; }

/* ══════════════════════════════════════════════════════
   OVERLAY + MODAL
   
   Overlay starts at --eptri-overlay-top (default 6% of viewport
   height); popup has --eptri-popup-margin-top (default 6%). High
   z-index; JS moves overlay to body. .eptri-popup-body scrolls.
   ══════════════════════════════════════════════════════ */

.eptri-overlay {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: var(--eptri-overlay-top);
    bottom: 0;
    /* Above aggressive theme headers (e.g. Divi ~99999) */
    z-index: 2147483646;
    background: rgba(0, 0, 0, 0.55);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: var(--eptri-modal-pad-y) 16px var(--eptri-modal-pad-y);
    box-sizing: border-box;
}

.eptri-popup {
    position: relative;
    width: 100%;
    max-width: 720px;
    max-height: calc(100vh - var(--eptri-modal-vertical-reserve) - (var(--eptri-modal-pad-y) * 2));
    max-height: calc(100dvh - var(--eptri-modal-vertical-reserve) - (var(--eptri-modal-pad-y) * 2));
    background: #ffffff;
    border-radius: 10px;
    box-shadow: var(--eptri-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: var(--eptri-popup-margin-top) auto 0;
    flex-shrink: 0;
    min-height: 0;
}

/* ── Modal header ────────────────────────────────── */
.eptri-popup-header {
    background: #1a2e5a;
    border-radius: 10px 10px 0 0;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.eptri-popup-header h3 {
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    color: #ffffff !important;
    text-shadow: none !important;
    letter-spacing: normal !important;
}

.eptri-popup-close {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    color: #ffffff !important;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    opacity: .7;
    transition: opacity .15s;
    flex-shrink: 0;
}
.eptri-popup-close:hover { opacity: 1; }

/* ── Modal body ──────────────────────────────────── */
.eptri-popup-body {
    padding: 22px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
}

/* ── Detail grid ─────────────────────────────────── */
.eptri-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 24px;
}
.eptri-detail-item { display: flex; flex-direction: column; gap: 3px; }
.eptri-detail-item.full { grid-column: 1 / -1; }
.eptri-detail-label {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--eptri-muted);
}
.eptri-detail-value { font-size: .93rem; color: var(--eptri-text); line-height: 1.5; }
.eptri-detail-value a { color: var(--eptri-blue); word-break: break-all; }
.eptri-detail-value a:hover { text-decoration: underline; }

@media (max-width: 640px) {
    .eptri-detail-grid { grid-template-columns: 1fr; }
}
