/* ============================================================
   APC Revision — Extensions for mandatory-competency restructure
   Adds: competency grid, article-card covers, paywall card,
   filter select, article cover figure, locked body fade.
   ============================================================ */

/* --- Competency coverage grid (homepage) --------------------- */
.comp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-8);
}

.comp-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--color-surface-1);
  border: 1px solid var(--color-divider);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.comp-card:hover {
  border-color: var(--color-gold);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -14px rgba(15, 43, 70, 0.25);
}

.comp-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.comp-card__count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}
.comp-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1.25;
  margin-bottom: var(--space-3);
  letter-spacing: -0.01em;
}
.comp-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.55;
  margin-bottom: var(--space-5);
  flex: 1;
}
.comp-card__link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-gold-active);
  margin-top: auto;
}

/* --- Article card cover image -------------------------------- */
.article-card__cover {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--color-surface-2);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}
.article-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}
.article-card:hover .article-card__cover img { transform: scale(1.03); }

/* --- Article hero cover figure ------------------------------- */
.article-cover {
  margin: var(--space-6) 0 var(--space-8);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--color-surface-2);
}
.article-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* --- Filter select ------------------------------------------- */
.filter-select {
  font-family: inherit;
  font-size: var(--text-sm);
  padding: 0.65rem 2.25rem 0.65rem 0.9rem;
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  appearance: none;
  /* Tell the browser to render native UI (including the open option list) in the correct theme */
  color-scheme: light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}
.filter-select:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 1px;
}
/* Dark-mode: switch native option list to a dark surface with readable text,
   and swap the chevron icon so it remains visible on the dark control. */
[data-theme='dark'] .filter-select {
  color-scheme: dark;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23C9A34E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
[data-theme='dark'] .filter-select option {
  background-color: var(--color-surface);
  color: var(--color-text);
}

/* --- Paywall card on locked article pages -------------------- */
.paywall {
  position: relative;
  margin: var(--space-8) 0 var(--space-10);
}
.paywall__card {
  position: relative;
  padding: clamp(var(--space-7), 4vw, var(--space-10));
  border-radius: var(--radius-lg);
  background: var(--gradient-cta);
  color: var(--color-text-inverse);
  text-align: center;
  box-shadow: 0 12px 36px -16px rgba(15,43,70,0.4);
}
.paywall__card h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin-bottom: var(--space-4);
  color: var(--color-text-inverse);
}
.paywall__card p {
  color: rgba(255,255,255,0.85);
  max-width: 52ch;
  margin: 0 auto var(--space-6);
  line-height: 1.55;
}
.paywall__card .btn { display: inline-block; }
.paywall__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-5);
  border-radius: var(--radius-full);
  background: rgba(201, 163, 78, 0.2);
  color: #F3D58D;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --- Locked article body preview — ~12 lines with fade ------- */
.article-body--locked {
  position: relative;
  max-height: 22em;        /* roughly 12 lines of body copy */
  overflow: hidden;
}
.article-body--locked::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 8em;
  background: linear-gradient(to bottom, transparent, var(--color-bg));
  pointer-events: none;
}

/* Unlocked state (auth-gate.js swaps the class when user is a member) */
.article-body--unlocked {
  max-height: none;
  overflow: visible;
}
.article-body--unlocked::after { display: none; }

/* --- Filter bar small improvements --------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  padding: var(--space-5);
  background: var(--color-surface-1);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
}
.filter-group { display: flex; flex-direction: column; gap: var(--space-2); }
.filter-group__label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
