/* =========================================================
   FINAS Achievements — Publications Library  v1
   ========================================================= */

:root {
  --fach-teal:      #1a9b7b;
  --fach-teal-d:    #0e7a60;
  --fach-teal-pale: #edf8f4;
  --fach-blue:      #1d5fa6;
  --fach-orange:    #c96b0a;
  --fach-gold:      #a87800;
  --fach-green:     #1e7a42;
  --fach-purple:    #6d28d9;
  --fach-red:       #c0392b;

  --fach-ink:    #0f172a;
  --fach-ink-2:  #334155;
  --fach-muted:  #64748b;
  --fach-muted2: #94a3b8;
  --fach-canvas: #f1f3f5;
  --fach-white:  #ffffff;
  --fach-border: #e2e8f0;
  --fach-border2:#cbd5e1;

  --fach-shadow:    0 1px 3px rgba(15,23,42,.07), 0 4px 14px rgba(15,23,42,.05);
  --fach-shadow-md: 0 6px 24px rgba(15,23,42,.13);
  --fach-r: 14px;
}

.fach, .fach * { box-sizing: border-box; margin: 0; padding: 0; }
.fach { color: var(--fach-ink); background: var(--fach-canvas); width: 100%; padding: 28px 24px 60px; }

/* ── GRID ────────────────────────────────────────────────── */
.fach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  align-items: stretch;
}

/* ── BASE CARD ───────────────────────────────────────────── */
.fach-card {
  background: var(--fach-white);
  border-radius: var(--fach-r);
  border: 1px solid var(--fach-border);
  box-shadow: var(--fach-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .15s, transform .15s;
  position: relative;
}
.fach-card:hover { box-shadow: var(--fach-shadow-md); transform: translateY(-3px); }

/* coloured top stripe */
.fach-card::before {
  content: '';
  display: block;
  height: 4px;
  width: 100%;
  flex-shrink: 0;
}
.fach-card--document::before { background: var(--fach-blue); }
.fach-card--featured::before { background: linear-gradient(90deg, var(--fach-teal), var(--fach-blue)); }

/* inner */
.fach-card-inner {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* ── CARD TOP ROW ────────────────────────────────────────── */
.fach-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ── BADGE ───────────────────────────────────────────────── */
.fach-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .7px;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 3px 8px;
  white-space: nowrap;
}
.fach-badge svg { flex-shrink: 0; }

.fach-badge--document          { background: #ddeeff; color: var(--fach-blue); }
.fach-badge--research          { background: #f0ebff; color: var(--fach-purple); }
.fach-badge--executive-summary { background: var(--fach-teal-pale); color: var(--fach-teal-d); }
.fach-badge--report            { background: #fff0e0; color: var(--fach-orange); }
.fach-badge--brief             { background: #e0f5e9; color: var(--fach-green); }

/* ── FEATURED LABEL ──────────────────────────────────────── */
.fach-featured-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--fach-teal-d);
  background: var(--fach-teal-pale);
  border: 1px solid #b2e4d8;
  border-radius: 4px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* ── TITLE ───────────────────────────────────────────────── */
.fach-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--fach-ink);
}
.fach-title--featured {
  font-size: 17px;
  font-weight: 700;
  color: #0f2a4a;
}

/* ── EXCERPT (featured only) ─────────────────────────────── */
.fach-excerpt {
  font-size: 13.5px;
  color: var(--fach-muted);
  line-height: 1.75;
  flex: 1;
}

/* ── ORG ROW ─────────────────────────────────────────────── */
.fach-org-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--fach-border);
  margin-top: auto;
}

.fach-av {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--fach-white);
  border: 2px solid var(--fach-white);
  flex-shrink: 0;
  text-transform: uppercase;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}

.fach-org-name {
  font-size: 12.5px;
  color: var(--fach-muted);
  font-weight: 500;
  line-height: 1.4;
  min-width: 0;
}

/* ── ACTION BUTTONS ──────────────────────────────────────── */
.fach-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.fach-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background .12s, transform .12s, box-shadow .12s, color .12s;
  white-space: nowrap;
}
.fach-btn svg { flex-shrink: 0; }

.fach-btn--context {
  background: var(--fach-canvas);
  border: 1.5px solid var(--fach-border2);
  color: var(--fach-ink-2);
}
.fach-btn--context:hover {
  background: #ddeeff;
  border-color: var(--fach-blue);
  color: var(--fach-blue);
}

.fach-btn--primary {
  background: var(--fach-teal);
  color: var(--fach-white);
  box-shadow: 0 2px 8px rgba(26,155,123,.22);
}
.fach-btn--primary:hover {
  background: var(--fach-teal-d);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(26,155,123,.32);
  color: var(--fach-white);
  text-decoration: none;
}

.fach-btn--disabled {
  background: var(--fach-canvas);
  border: 1.5px solid var(--fach-border2);
  color: var(--fach-muted2);
  cursor: default;
  box-shadow: none;
}

/* ── CONTEXT MODAL ───────────────────────────────────────── */
.fach-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.fach-modal-overlay.is-open {
  display: flex;
  animation: fach-fade .15s ease;
}

@keyframes fach-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fach-modal {
  background: var(--fach-white);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(15,23,42,.22);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: fach-up .18s ease;
  overflow: hidden;
}

@keyframes fach-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fach-modal-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--fach-border);
  flex-shrink: 0;
}

.fach-modal-pretitle {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--fach-teal);
  margin-bottom: 5px;
}

.fach-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fach-ink);
  line-height: 1.45;
}

.fach-modal-close {
  width: 32px; height: 32px;
  min-width: 32px;
  border: none;
  background: var(--fach-canvas);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--fach-muted);
  transition: background .12s, color .12s;
  margin-top: 2px;
}
.fach-modal-close:hover { background: #fee2e2; color: var(--fach-red); }

.fach-modal-body {
  padding: 22px 22px 20px;
  overflow-y: auto;
  flex: 1;
}

.fach-modal-text {
  font-size: 14.5px;
  color: var(--fach-ink-2);
  line-height: 1.85;
  white-space: pre-line;
}

.fach-modal-ft {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--fach-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: #fafbfc;
  flex-wrap: wrap;
}

.fach-modal-org {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.fach-modal-org-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fach-muted);
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .fach-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .fach { padding: 16px 14px 48px; }
  .fach-grid { grid-template-columns: 1fr; }
  .fach-modal { max-height: 90vh; }
}
