/**
 * <sis-project-feed> — v1
 *
 * Feed projets communautaires + détail + matching habilitations.
 * Direction éditoriale technique française reconduite.
 *
 * Light DOM — préfixe `.spf-` (sis-project-feed).
 */

sis-project-feed {
  --spf-serif: "Iowan Old Style", "Palatino", "Hoefler Text", "Times New Roman", Georgia, serif;
  --spf-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --spf-body: var(--font-family-base);

  display: block;
  min-height: 100vh;
  background: var(--color-bg-soft);
  font-family: var(--spf-body);
  color: var(--color-text);
  padding-bottom: var(--space-2xl);
  position: relative;
}

/* Top bar */
.spf-top {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: max(env(safe-area-inset-top, 0), var(--space-sm)) var(--space-md) var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.spf-back {
  background: 0; border: 1px solid var(--color-border);
  width: var(--touch-target-min); height: var(--touch-target-min);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text);
}
.spf-back:hover { background: var(--color-bg-soft); }
.spf-back svg { width: 18px; height: 18px; }
.spf-top__titles { flex: 1; min-width: 0; }
.spf-top__eyebrow {
  font-family: var(--spf-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--uttop-compl-1);
  font-weight: var(--font-weight-semibold);
}
.spf-top__title {
  font-family: var(--spf-body);
  font-size: 0.95rem;
  font-weight: var(--font-weight-semibold);
}
.spf-propose {
  background: var(--uttop-principale);
  color: #fff;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-family: var(--spf-body);
  font-size: 0.82rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.spf-propose:hover { background: #003958; }

/* Filtres */
.spf-filters {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 57px;
  z-index: calc(var(--z-sticky) - 1);
}
.spf-filters::-webkit-scrollbar { display: none; }
.spf-filter {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-family: var(--spf-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-soft);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.spf-filter:hover { background: var(--color-bg-soft); }
.spf-filter.is-active {
  background: var(--uttop-principale);
  color: #fff;
  border-color: var(--uttop-principale);
  font-weight: var(--font-weight-bold);
}

/* Feed liste */
.spf-feed {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Card projet */
.spf-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.spf-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.spf-card.is-looking {
  border-color: rgba(245,216,54,0.5);
  box-shadow: 0 0 0 1px rgba(245,216,54,0.3);
}

/* Bandeau "cherche du monde" voyant */
.spf-card__looking-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--uttop-compl-3);
  color: #4a3700;
  font-family: var(--spf-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: var(--font-weight-bold);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-sm);
}
.spf-card__looking-banner::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4a3700;
  animation: spf-blink 1.4s ease-in-out infinite;
}

.spf-card__tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}
.spf-tag {
  font-family: var(--spf-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--tag-bg, rgba(0,80,120,0.08));
  color: var(--tag-color, var(--uttop-principale));
  font-weight: var(--font-weight-semibold);
}

.spf-card__title {
  font-family: var(--spf-serif);
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.15;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}
.spf-card__desc {
  font-family: var(--spf-body);
  font-size: 0.88rem;
  color: var(--color-text-soft);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--space-md);
}

/* Matching habilitations */
.spf-match {
  background: var(--color-bg-soft);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
}
.spf-match__title {
  font-family: var(--spf-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-soft);
  margin-bottom: 6px;
}
.spf-match__habs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.spf-match__hab {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--spf-body);
  font-size: 0.8rem;
}
.spf-match__hab-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  font-weight: var(--font-weight-bold);
  color: #fff;
  flex-shrink: 0;
}
.spf-match__hab.is-covered .spf-match__hab-dot { background: var(--uttop-compl-1); }
.spf-match__hab.is-missing .spf-match__hab-dot { background: var(--uttop-compl-3); color: #4a3700; }
.spf-match__hab-label { flex: 1; color: var(--color-text); }
.spf-match__hab-count {
  font-family: var(--spf-mono);
  font-size: 10px;
  color: var(--color-text-soft);
}
.spf-match__hab.is-missing .spf-match__hab-count { color: #856704; font-weight: var(--font-weight-semibold); }
/* "Tu peux aider" highlight */
.spf-match__hab.is-can-help {
  background: rgba(18,154,126,0.08);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  margin: 0 -6px;
}

/* Footer card */
.spf-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}
.spf-contribs {
  display: flex;
  align-items: center;
}
.spf-contrib {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--c, var(--uttop-compl-2));
  border: 2px solid var(--color-bg);
  margin-left: -8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--spf-mono);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  color: #fff;
}
.spf-contrib:first-child { margin-left: 0; }
.spf-contrib--more { background: var(--color-text-soft); }

.spf-vote {
  display: flex;
  align-items: center;
  gap: 4px;
  background: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  cursor: pointer;
  font-family: var(--spf-mono);
  font-size: 12px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-soft);
  transition: all var(--transition-fast);
}
.spf-vote:hover { border-color: var(--uttop-compl-3); }
.spf-vote.is-voted {
  background: rgba(245,216,54,0.12);
  border-color: var(--uttop-compl-3);
  color: #856704;
}
.spf-vote__star { font-size: 13px; }

/* Badge équipe constituée */
.spf-card__badge-team {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  font-family: var(--spf-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(18,154,126,0.12);
  color: #0a5040;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-bold);
}

/* État vide */
.spf-empty {
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
}
.spf-empty__icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}
.spf-empty__title {
  font-family: var(--spf-serif);
  font-size: 1.4rem;
  margin-bottom: var(--space-sm);
}
.spf-empty__text {
  font-family: var(--spf-body);
  font-size: 0.9rem;
  color: var(--color-text-soft);
  margin-bottom: var(--space-lg);
}

/* ============================================================================
   VUE DÉTAIL
   ============================================================================ */
.spf-detail {
  min-height: 100vh;
  background: var(--color-bg);
}
.spf-detail__hero {
  background: var(--zone-color, var(--uttop-principale));
  color: #fff;
  padding: max(env(safe-area-inset-top, 0), var(--space-md)) var(--space-md) var(--space-lg);
  position: relative;
  overflow: hidden;
}
.spf-detail__hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}
.spf-detail__hero > * { position: relative; }
.spf-detail__topnav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.spf-detail__back {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  width: var(--touch-target-min); height: var(--touch-target-min);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.spf-detail__back svg { width: 18px; height: 18px; }
.spf-detail__status-tag {
  font-family: var(--spf-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: var(--font-weight-semibold);
  opacity: 0.9;
}
.spf-detail__title {
  font-family: var(--spf-serif);
  font-size: clamp(1.75rem, 7vw, 2.25rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-sm);
}
.spf-detail__meta {
  font-family: var(--spf-body);
  font-size: 0.85rem;
  opacity: 0.9;
}
.spf-detail__body {
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.spf-detail__section-title {
  font-family: var(--spf-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--uttop-compl-1);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.spf-detail__section-title::before {
  content: "";
  width: 20px; height: 1px;
  background: currentColor;
}
.spf-detail__desc {
  font-family: var(--spf-body);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--color-text);
}

/* Habilitations détail */
.spf-detail__habs {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.spf-detail__hab {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.spf-detail__hab.is-missing {
  border-color: rgba(245,216,54,0.5);
  background: rgba(245,216,54,0.06);
}
.spf-detail__hab-icon {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  color: #fff;
}
.spf-detail__hab.is-covered .spf-detail__hab-icon { background: var(--uttop-compl-1); }
.spf-detail__hab.is-missing .spf-detail__hab-icon { background: var(--uttop-compl-3); color: #4a3700; }
.spf-detail__hab-body { flex: 1; }
.spf-detail__hab-name {
  font-family: var(--spf-body);
  font-size: 0.9rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}
.spf-detail__hab-count {
  font-family: var(--spf-mono);
  font-size: 10px;
  color: var(--color-text-soft);
}

/* Contributeurs détail */
.spf-detail__contribs {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.spf-detail__contrib {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.spf-detail__contrib-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--c, var(--uttop-compl-2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--spf-serif);
  font-size: 0.95rem;
  font-weight: var(--font-weight-bold);
  color: #fff;
}
.spf-detail__contrib-info { flex: 1; }
.spf-detail__contrib-name {
  font-family: var(--spf-body);
  font-size: 0.9rem;
  font-weight: var(--font-weight-semibold);
}
.spf-detail__contrib-role {
  font-family: var(--spf-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--color-text-soft);
}
.spf-detail__contrib-role.is-porteur { color: var(--uttop-principale); }

/* Discussion mock */
.spf-detail__discussion {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.spf-comment {
  display: flex;
  gap: var(--space-sm);
}
.spf-comment__avatar {
  flex: 0 0 30px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--c, var(--uttop-compl-2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--spf-mono);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  color: #fff;
}
.spf-comment__bubble {
  flex: 1;
  background: var(--color-bg-soft);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}
.spf-comment__author {
  font-family: var(--spf-body);
  font-size: 0.8rem;
  font-weight: var(--font-weight-semibold);
  margin-bottom: 2px;
}
.spf-comment__text {
  font-family: var(--spf-body);
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.4;
}
.spf-comment__time {
  font-family: var(--spf-mono);
  font-size: 9px;
  color: var(--color-text-soft);
  margin-top: 2px;
}

/* Barre actions détail sticky */
.spf-detail__actions {
  position: sticky;
  bottom: 0;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: var(--space-sm) var(--space-md) max(env(safe-area-inset-bottom, 0), var(--space-sm));
  display: flex;
  gap: var(--space-sm);
}
.spf-action-btn {
  flex: 1;
  font-family: var(--spf-body);
  font-size: 0.9rem;
  font-weight: var(--font-weight-semibold);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 0;
  cursor: pointer;
  min-height: var(--touch-target-comfortable);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: filter var(--transition-fast);
}
.spf-action-btn:hover { filter: brightness(0.95); }
.spf-action-btn--join { background: var(--uttop-principale); color: #fff; }
.spf-action-btn--help { background: var(--uttop-compl-1); color: #fff; }
.spf-action-btn--learn { background: var(--color-bg-soft); color: var(--uttop-principale); border: 1px solid var(--color-border); }
.spf-action-btn--leave { background: 0; color: var(--color-danger); border: 1px solid rgba(220,38,38,0.3); flex: 0 0 auto; }
.spf-action-btn.is-member { background: rgba(18,154,126,0.12); color: #0a5040; pointer-events: none; }

/* ============================================================================
   Modal proposer projet
   ============================================================================ */
.spf-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: var(--color-overlay);
  backdrop-filter: blur(2px);
}
.demo-frame .spf-modal { position: absolute; }
.spf-modal.is-open { display: flex; }
@media (min-width: 480px) { .spf-modal { align-items: center; } }
.spf-modal__sheet {
  background: var(--color-bg);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0));
}
@media (min-width: 480px) { .spf-modal__sheet { border-radius: var(--radius-xl); } }
.spf-modal__handle {
  width: 40px; height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  margin: 0 auto var(--space-md);
}
.spf-modal__title {
  font-family: var(--spf-serif);
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: var(--space-md);
}
.spf-modal__field { margin-bottom: var(--space-md); }
.spf-modal__label {
  display: block;
  font-family: var(--spf-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-soft);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-xs);
}
.spf-modal__input, .spf-modal__textarea {
  width: 100%;
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--spf-body);
  font-size: 0.95rem;
  color: var(--color-text);
  outline: 0;
}
.spf-modal__input:focus, .spf-modal__textarea:focus {
  border-color: var(--uttop-principale);
  box-shadow: var(--shadow-focus);
}
.spf-modal__textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
.spf-modal__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.spf-modal__tag {
  font-family: var(--spf-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-soft);
  cursor: pointer;
}
.spf-modal__tag.is-selected {
  background: var(--tag-color, var(--uttop-principale));
  color: #fff;
  border-color: var(--tag-color, var(--uttop-principale));
}
.spf-modal__actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.spf-modal__cancel {
  flex: 0 0 auto;
  background: 0;
  color: var(--color-text-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--spf-body);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  min-height: var(--touch-target-comfortable);
}
.spf-modal__submit {
  flex: 1;
  background: var(--uttop-principale);
  color: #fff;
  border: 0;
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  font-family: var(--spf-body);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  min-height: var(--touch-target-comfortable);
}
.spf-modal__submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* Toast interne (vote, rejoindre) */
.spf-toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  z-index: var(--z-toast);
  background: #1A1410;
  color: #FBF7F2;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-family: var(--spf-mono);
  font-size: 12px;
  border: 1px solid var(--uttop-compl-1);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-base);
  white-space: nowrap;
}
.demo-frame .spf-toast { position: absolute; }
.spf-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes spf-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@media (prefers-reduced-motion: reduce) {
  .spf-card__looking-banner::before { animation: none; }
}
