/* =============================================================================
   OWFR Member Hub — Frontend Styles
   Plugin: owfr-member-hub
   WCAG 2.1 AA compliant (4.5:1 contrast for normal text, 3:1 for large text)
   ============================================================================= */

/* ── Custom Properties ─────────────────────────────────────────────────────── */
/* Defined on :root so the modal overlay (moved to document.body at runtime)
   can still access them after being reparented out of .owfr-hub. */
:root {
  --hub-primary:      #006B3F;
  --hub-primary-dk:   #004d2c;
  --hub-primary-lt:   #e8f5ee;
  --hub-text:         #1a1a1a;
  --hub-text-muted:   #555555;
  --hub-bg:           #f7f8f9;
  --hub-card-bg:      #ffffff;
  --hub-border:       #d4d8dc;
  --hub-radius:       8px;
  --hub-shadow:       0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
  --hub-focus-ring:   0 0 0 3px rgba(0,107,63,.35);
  /* Type badge colours — all meet WCAG AA on white card background */
  --hub-c-article:    #0055aa;
  --hub-c-podcast:    #6b2080;
  --hub-c-event:      #b04500;
  --hub-c-reflection: #006B3F;
  --hub-c-resource:   #006688;
  --hub-c-download:   #404040;
  --hub-c-video:      #bb0000;
}

.owfr-hub {
  font-family: inherit;
  color: var(--hub-text);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 .5rem;
  box-sizing: border-box;
}

/* ── Screen-reader-only utility ─────────────────────────────────────────────── */
.owfr-hub-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Portal Header ──────────────────────────────────────────────────────────── */
.owfr-hub-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.owfr-hub-title {
  font-size: 1.875rem;
  font-weight: 700;
  margin: 0 0 .375rem;
  color: var(--hub-text);
  line-height: 1.2;
}

.owfr-hub-subtitle {
  margin: 0;
  color: var(--hub-text-muted);
  font-size: 1rem;
  max-width: 58ch;
  line-height: 1.6;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.owfr-hub-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .625rem 1.25rem;
  border-radius: 6px;
  border: 2px solid transparent;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  line-height: 1.2;
  white-space: nowrap;
}

.owfr-hub-btn:focus-visible {
  outline: none;
  box-shadow: var(--hub-focus-ring);
}

.owfr-hub-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.owfr-hub-btn-primary {
  background: var(--hub-primary);
  color: #fff;
  border-color: var(--hub-primary);
}
.owfr-hub-btn-primary:hover,
.owfr-hub-btn-primary:focus {
  background: var(--hub-primary-dk);
  border-color: var(--hub-primary-dk);
  color: #fff;
  text-decoration: none;
}

.owfr-hub-btn-outline {
  background: transparent;
  color: var(--hub-primary);
  border-color: var(--hub-primary);
}
.owfr-hub-btn-outline:hover,
.owfr-hub-btn-outline:focus {
  background: var(--hub-primary);
  color: #fff;
  text-decoration: none;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────────── */
.owfr-hub-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.owfr-hub-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.owfr-hub-filter-btn {
  padding: .4rem .9rem;
  border-radius: 20px;
  border: 1.5px solid var(--hub-border);
  background: #fff;
  color: var(--hub-text-muted);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.owfr-hub-filter-btn:hover {
  border-color: var(--hub-primary);
  color: var(--hub-primary);
}
.owfr-hub-filter-btn.active {
  background: var(--hub-primary);
  border-color: var(--hub-primary);
  color: #fff;
}
.owfr-hub-filter-btn:focus-visible {
  outline: none;
  box-shadow: var(--hub-focus-ring);
}

.owfr-hub-search-wrap { margin-left: auto; }

.owfr-hub-search {
  padding: .5rem .875rem;
  border: 1.5px solid var(--hub-border);
  border-radius: 6px;
  font-size: .9375rem;
  min-width: 220px;
  background: #fff;
  color: var(--hub-text);
}
.owfr-hub-search:focus {
  outline: none;
  border-color: var(--hub-primary);
  box-shadow: var(--hub-focus-ring);
}

/* ── Post Count ─────────────────────────────────────────────────────────────── */
.owfr-hub-count {
  font-size: .875rem;
  color: var(--hub-text-muted);
  margin: 0 0 1.25rem;
}

/* ── Grid ────────────────────────────────────────────────────────────────────── */
.owfr-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

/* ── Card ─────────────────────────────────────────────────────────────────────── */
.owfr-hub-card {
  background: var(--hub-card-bg);
  border: 1px solid var(--hub-border);
  border-radius: var(--hub-radius);
  box-shadow: var(--hub-shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .625rem;
  transition: box-shadow .15s ease, transform .15s ease;
  position: relative;
}
.owfr-hub-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.1), 0 8px 24px rgba(0,0,0,.08);
  transform: translateY(-2px);
}

.owfr-hub-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
}

/* Type badge */
.owfr-hub-badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1.4;
}
.owfr-hub-badge[data-type="article"]    { background: var(--hub-c-article);    }
.owfr-hub-badge[data-type="podcast"]    { background: var(--hub-c-podcast);    }
.owfr-hub-badge[data-type="event"]      { background: var(--hub-c-event);      }
.owfr-hub-badge[data-type="reflection"] { background: var(--hub-c-reflection); }
.owfr-hub-badge[data-type="resource"]   { background: var(--hub-c-resource);   }
.owfr-hub-badge[data-type="download"]   { background: var(--hub-c-download);   }
.owfr-hub-badge[data-type="video"]      { background: var(--hub-c-video);      }

.owfr-hub-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  color: var(--hub-text);
  line-height: 1.35;
}

.owfr-hub-card-desc {
  font-size: .9rem;
  color: var(--hub-text-muted);
  margin: 0;
  line-height: 1.55;
  flex: 1;
}

.owfr-hub-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: auto;
  padding-top: .75rem;
  border-top: 1px solid var(--hub-border);
}

.owfr-hub-card-meta {
  font-size: .8125rem;
  color: var(--hub-text-muted);
  line-height: 1.3;
}

.owfr-hub-card-link {
  font-size: .875rem;
  padding: .35rem .875rem;
}

/* ── Admin delete button ────────────────────────────────────────────────────── */
.owfr-hub-admin-delete {
  padding: .2rem .5rem;
  background: transparent;
  color: #bb0000;
  border: 1px solid #bb0000;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.owfr-hub-admin-delete:hover {
  background: #bb0000;
  color: #fff;
}
.owfr-hub-admin-delete:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(187,0,0,.35);
}

/* ── Loading / Empty / Error ─────────────────────────────────────────────────── */
.owfr-hub-loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 4rem 1rem;
  color: var(--hub-text-muted);
  font-size: 1rem;
  list-style: none;
}

.owfr-hub-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--hub-border);
  border-top-color: var(--hub-primary);
  border-radius: 50%;
  animation: owfrHubSpin .7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes owfrHubSpin { to { transform: rotate(360deg); } }

.owfr-hub-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--hub-text-muted);
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.owfr-hub-empty p { margin: 0; }

.owfr-hub-error-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: #bb0000;
  list-style: none;
}

/* ── Load More ──────────────────────────────────────────────────────────────── */
.owfr-hub-load-more-wrap {
  text-align: center;
  margin-bottom: 2.5rem;
}

/* ── Modal Overlay ──────────────────────────────────────────────────────────── */
.owfr-hub-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  /* !important ensures this beats any Divi/theme stacking context */
  z-index: 999999 !important;
  padding: 1rem;
}

.owfr-hub-modal {
  background: #fff;
  border-radius: 10px;
  max-width: 560px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,.25);
}

.owfr-hub-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--hub-border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.owfr-hub-modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--hub-text);
}

.owfr-hub-modal-close {
  background: transparent;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  color: var(--hub-text-muted);
  padding: .2rem .4rem;
  border-radius: 4px;
  transition: color .12s;
}
.owfr-hub-modal-close:hover { color: var(--hub-text); }
.owfr-hub-modal-close:focus-visible {
  outline: none;
  box-shadow: var(--hub-focus-ring);
}

/* ── Form ─────────────────────────────────────────────────────────────────────── */
.owfr-hub-form {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.owfr-hub-field {
  display: flex;
  flex-direction: column;
  gap: .375rem;
}

.owfr-hub-field label {
  font-weight: 600;
  font-size: .9375rem;
  color: var(--hub-text);
}

.owfr-hub-field input,
.owfr-hub-field select,
.owfr-hub-field textarea {
  padding: .5rem .75rem;
  border: 1.5px solid var(--hub-border);
  border-radius: 6px;
  font-size: .9375rem;
  font-family: inherit;
  color: var(--hub-text);
  background: #fff;
  transition: border-color .15s;
}
.owfr-hub-field input:focus,
.owfr-hub-field select:focus,
.owfr-hub-field textarea:focus {
  outline: none;
  border-color: var(--hub-primary);
  box-shadow: var(--hub-focus-ring);
}

.owfr-hub-field textarea { resize: vertical; min-height: 100px; }

.owfr-hub-char-count {
  font-size: .8125rem;
  color: var(--hub-text-muted);
  text-align: right;
}

.owfr-hub-field-hint,
.owfr-hub-optional {
  font-size: .8125rem;
  color: var(--hub-text-muted);
}

.owfr-hub-required {
  color: #bb0000;
  margin-left: .15em;
}

.owfr-hub-form-note {
  font-size: .8125rem;
  color: var(--hub-text-muted);
  margin: 0;
  padding: .75rem;
  background: #f7f8f9;
  border-radius: 6px;
  border-left: 3px solid var(--hub-border);
  line-height: 1.5;
}

.owfr-hub-form-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.owfr-hub-submit-status {
  font-size: .9rem;
  min-height: 1.2em;
  font-weight: 500;
}

/* Honeypot: visually hidden but NOT display:none (bots should fill it) */
.owfr-hub-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  tab-index: -1;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .owfr-hub-header       { flex-direction: column; align-items: flex-start; }
  .owfr-hub-toolbar      { flex-direction: column; align-items: stretch; }
  .owfr-hub-search-wrap  { margin-left: 0; }
  .owfr-hub-search       { min-width: auto; width: 100%; }
  .owfr-hub-grid         { grid-template-columns: 1fr; }
  .owfr-hub-title        { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .owfr-hub-modal-overlay { padding: 0; align-items: flex-end; }
  .owfr-hub-modal         { border-radius: 10px 10px 0 0; max-height: 95vh; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .owfr-hub-spinner   { animation: none; opacity: .4; }
  .owfr-hub-card      { transition: none; }
  .owfr-hub-card:hover { transform: none; }
  .owfr-hub-btn,
  .owfr-hub-filter-btn { transition: none; }
}
