/* ═══ Anchor HQ — CRM Section (Villager Journal) ═══ */
/* Stardew Valley friendship journal: tracking hearts, gifts, and villager bonds */


/* ─── Keyframes ─── */

@keyframes vj-card-appear {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes vj-heart-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

@keyframes vj-alert-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

@keyframes gold-shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes vj-slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}


/* ═══════════════════════════════════════════════════════════════════════════
   CHURN ALERT BANNER — Red pulsing warning strip
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-churn-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: linear-gradient(90deg, rgba(224,64,64,0.15), rgba(224,128,48,0.12));
  border: 2px solid rgba(224,64,64,0.3);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  animation: vj-alert-pulse 2s ease infinite;
}

.vj-churn-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.vj-churn-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.4;
}

.vj-churn-dismiss {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
  transition: color 150ms ease;
}

.vj-churn-dismiss:hover {
  color: var(--text);
}


/* ═══════════════════════════════════════════════════════════════════════════
   KPI STATS BAR — Six metric tiles with wood trim
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.vj-kpi {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  position: relative;
}

/* Wood trim top bar */
.vj-kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--wood-dark) 0%,
    var(--wood) 30%,
    var(--wood-light) 50%,
    var(--wood) 70%,
    var(--wood-dark) 100%
  );
  border-radius: var(--radius) var(--radius) 0 0;
}

.vj-kpi-icon {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.vj-kpi-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.vj-kpi-value {
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  color: var(--gold);
}

.vj-kpi-danger {
  color: var(--red);
}

/* Warmth distribution bar */
.vj-warmth-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
  margin-top: 8px;
}

.vj-warmth-segment {
  height: 100%;
  transition: width 300ms ease;
}

.vj-warmth-segment.cold      { background: var(--blue); }
.vj-warmth-segment.warm      { background: #e88d3a; }
.vj-warmth-segment.hot       { background: var(--red); }
.vj-warmth-segment.champion  { background: var(--gold); }


/* ═══════════════════════════════════════════════════════════════════════════
   CONTROLS BAR — View toggle, search, and filters
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

/* Segmented view toggle (Kanban / Table) */
.vj-view-toggle {
  display: flex;
  gap: 0;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.vj-view-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 200ms ease;
}

.vj-view-btn.active {
  background: var(--gold);
  color: var(--wood-dark);
  font-weight: 700;
}

.vj-view-btn:hover:not(.active) {
  background: rgba(218,165,32,0.1);
}

/* Filters row */
.vj-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.vj-search {
  max-width: 200px;
}

.vj-filter-select {
  max-width: 150px;
  font-size: 0.8rem;
}


/* ═══════════════════════════════════════════════════════════════════════════
   KANBAN BOARD — The Villager Board Frame
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
  padding: 4px;
  position: relative;
}

/* Decorative wood grain behind the board */
.vj-kanban::before {
  content: "";
  position: absolute;
  inset: -4px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 60px,
      rgba(107, 68, 35, 0.06) 60px,
      rgba(107, 68, 35, 0.06) 62px
    );
  border-radius: var(--radius);
  pointer-events: none;
  z-index: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   KANBAN COLUMN — Wooden Villager Board Post
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-kanban-col {
  background: var(--panel-soft);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px 14px;
  min-height: 200px;
  position: relative;
  z-index: 1;
  transition: border-color 250ms ease, box-shadow 250ms ease;

  /* Wood grain texture overlay */
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 40px,
      rgba(107, 68, 35, 0.04) 40px,
      rgba(107, 68, 35, 0.04) 42px
    );
  background-color: var(--panel-soft);
}

/* Top wood trim bar */
.vj-kanban-col::before {
  content: "";
  display: block;
  margin: 0 -14px 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--wood-dark) 0%,
    var(--wood) 15%,
    var(--wood-light) 50%,
    var(--wood) 85%,
    var(--wood-dark) 100%
  );
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 1px solid rgba(139, 90, 43, 0.4);
}

/* Bottom wood trim */
.vj-kanban-col::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--wood-dark),
    var(--wood) 50%,
    var(--wood-dark)
  );
  border-radius: 0 0 var(--radius) var(--radius);
  opacity: 0.6;
}

/* Drag-over glow */
.vj-kanban-col.drag-over {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(218,165,32,0.15);
}


/* ─── Column Header ─── */

.vj-kanban-col-header {
  padding: 14px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
}

.vj-kanban-col-title {
  font-family: var(--font-pixel);
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-heading);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Column count badge — reuses .kanban-col-count from tasks.css */


/* ═══════════════════════════════════════════════════════════════════════════
   MEMBER CARD — Pinned Villager Note
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-card {
  /* Parchment texture */
  background:
    radial-gradient(ellipse at 20% 80%, rgba(139,111,71,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 15%, rgba(139,111,71,0.04) 0%, transparent 50%),
    linear-gradient(
      180deg,
      var(--panel) 0%,
      rgba(30, 25, 20, 0.95) 100%
    );
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 200ms ease;
  animation: vj-card-appear 300ms ease backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
  position: relative;
}

/* Pin tack emoji at top-right */
.vj-card::before {
  content: "\1F4CC"; /* pushpin */
  position: absolute;
  top: -6px;
  right: 8px;
  font-size: 0.7rem;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
  transition: transform 200ms ease;
}

.vj-card:hover::before {
  transform: rotate(10deg);
  animation: quest-pin-wobble 300ms ease;
}

.vj-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.35),
    0 0 8px rgba(218,165,32,0.08);
}

.vj-card:last-child {
  margin-bottom: 0;
}

/* ─── Dragging State ─── */

.vj-card.dragging {
  opacity: 0.5;
  transform: rotate(-2deg);
}

/* ─── Card Inner Elements ─── */

.vj-card-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-heading);
  margin-bottom: 6px;
  padding-right: 16px; /* space for pin */
}

.vj-card-hearts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.vj-card-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.vj-topic-tag {
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 0;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.vj-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--muted);
}

.vj-card-gifts {
  font-size: 0.72rem;
}

.vj-card-seen {
  font-size: 0.68rem;
  color: var(--muted);
}

/* Churn risk card highlight */
.vj-card-churn {
  border-color: rgba(224,64,64,0.4);
  box-shadow: 0 0 8px rgba(224,64,64,0.1);
}

.vj-churn-dot {
  animation: vj-alert-pulse 2s ease infinite;
}


/* ═══════════════════════════════════════════════════════════════════════════
   HEARTS SYSTEM — Friendship rating display
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-hearts {
  display: inline-flex;
  gap: 2px;
  font-size: 0.8rem;
}

.vj-heart {
  color: var(--muted);
  opacity: 0.25;
  transition: all 200ms ease;
}

.vj-heart.filled {
  opacity: 1;
}

.vj-heart.cold {
  color: var(--blue);
}

.vj-heart.warm {
  color: #e88d3a;
}

.vj-heart.hot {
  color: var(--red);
}

.vj-heart.champion {
  color: var(--gold);
  animation: vj-heart-pulse 600ms ease infinite;
}


/* ═══════════════════════════════════════════════════════════════════════════
   TIER BADGE — Membership level indicator
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-tier-badge {
  font-size: 0.52rem;
  font-family: var(--font-pixel);
  padding: 2px 6px;
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid;
  display: inline-block;
}

.vj-tier-vip {
  color: var(--gold);
  border-color: rgba(218,165,32,0.4);
  background: rgba(218,165,32,0.1);
}

.vj-tier-premium {
  color: var(--purple);
  border-color: rgba(144,96,192,0.4);
  background: rgba(144,96,192,0.1);
}

.vj-tier-free {
  color: var(--green);
  border-color: rgba(108,191,74,0.4);
  background: rgba(108,191,74,0.1);
}

.vj-tier-unknown {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}


/* ═══════════════════════════════════════════════════════════════════════════
   TABLE VIEW — Sortable villager roster
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-table-wrap {
  overflow-x: auto;
}

.vj-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.vj-table th {
  font-family: var(--font-pixel);
  font-size: 0.48rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  color: var(--gold);
  background: var(--panel-soft);
  cursor: pointer;
  user-select: none;
  transition: color 150ms ease;
  white-space: nowrap;
}

.vj-table th:hover {
  color: var(--gold-bright);
}

.vj-th-sorted-asc::after {
  content: " \25B2"; /* ▲ */
}

.vj-th-sorted-desc::after {
  content: " \25BC"; /* ▼ */
}

.vj-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text);
}

.vj-table tr:hover {
  background: rgba(218,165,32,0.04);
}

.vj-td-name {
  font-weight: 600;
}

.vj-row-churn td {
  background: rgba(224,64,64,0.04);
}


/* ═══════════════════════════════════════════════════════════════════════════
   DETAIL PANEL — Villager Scroll Side Panel
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  justify-content: flex-end;
  align-items: stretch;
}

.vj-detail-overlay.open {
  display: flex;
}

.vj-detail-panel {
  width: 420px;
  max-width: 90vw;
  background:
    /* Parchment texture */
    radial-gradient(ellipse at 15% 85%, rgba(139,111,71,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 10%, rgba(139,111,71,0.03) 0%, transparent 50%),
    var(--panel);
  border-left: 3px solid var(--border);
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  animation: vj-slideIn 250ms ease;
  position: relative;
  /* Wood grain left edge */
  box-shadow:
    inset 3px 0 8px rgba(107, 68, 35, 0.2),
    -4px 0 20px rgba(0, 0, 0, 0.3);
}

/* Decorative scroll top ornament */
.vj-detail-panel::before {
  content: "";
  display: block;
  width: 60%;
  height: 2px;
  margin: 0 auto 16px;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      var(--wood-light) 20%,
      var(--gold) 50%,
      var(--wood-light) 80%,
      transparent 100%
    );
  border-radius: 1px;
}

/* Scroll ornament below top bar */
.vj-detail-panel::after {
  content: "\2756"; /* diamond dingbat */
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--wood-light);
  opacity: 0.5;
}

.vj-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.vj-detail-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-heading);
  margin: 0;
}

.vj-detail-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 150ms ease;
}

.vj-detail-close:hover {
  color: var(--text);
}

/* Member name in detail panel */
.vj-detail-name {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 16px;
  letter-spacing: 0.06em;
}

/* Warmth selector buttons */
.vj-warmth-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.vj-warmth-btn {
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text);
  transition: all 200ms ease;
}

.vj-warmth-btn.active {
  border-color: var(--gold);
  background: rgba(218,165,32,0.15);
}

.vj-warmth-btn:hover {
  border-color: var(--border-accent);
}

/* Tags in detail panel */
.vj-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.vj-detail-tag {
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 0;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.vj-detail-tag .vj-tag-remove {
  cursor: pointer;
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
  transition: color 150ms ease;
}

.vj-detail-tag .vj-tag-remove:hover {
  color: var(--red);
}

.vj-tag-input {
  width: 100%;
  margin-top: 6px;
}

/* Read-only fields */
.vj-detail-readonly {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.vj-detail-readonly .vj-ro-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

.vj-detail-readonly .vj-ro-value {
  color: var(--text);
  font-size: 0.82rem;
}

/* Action buttons at panel bottom */
.vj-detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
}

/* Reuses .btn, .btn-primary, .btn-ghost from components.css */


/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATE — No villagers found
   ═══════════════════════════════════════════════════════════════════════════ */

.vj-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.vj-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.vj-empty-title {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--text-heading);
  margin-bottom: 8px;
}

.vj-empty-desc {
  font-size: 0.82rem;
  line-height: 1.4;
}


/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════ */

[data-theme="light"] .vj-card {
  background: var(--panel);
}

[data-theme="light"] .vj-table th {
  background: var(--panel-soft);
}


/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .vj-card,
  .vj-heart.champion {
    animation: none;
  }

  .vj-churn-banner {
    animation: none;
  }

  .vj-churn-dot {
    animation: none;
  }

  .vj-detail-panel {
    animation: none;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Large Tablets / Small Desktops
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
  .vj-kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .vj-kanban {
    grid-template-columns: repeat(2, 1fr);
  }

  .vj-kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .vj-kanban {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 0;
  }

  .vj-kanban::before {
    display: none;
  }

  .vj-kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .vj-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .vj-filters {
    flex-direction: column;
  }

  .vj-search,
  .vj-filter-select {
    max-width: none;
  }

  .vj-detail-panel {
    width: 100vw;
    max-width: 100vw;
    padding: 16px;
  }

  .vj-kanban-col {
    min-height: 100px;
    padding: 0 10px 10px;
  }

  .vj-kanban-col::before {
    margin: 0 -10px 0;
  }

  .vj-kanban-col-header {
    padding: 10px 0 8px;
    margin-bottom: 8px;
  }

  .vj-kanban-col-title {
    font-size: 0.48rem;
  }

  .vj-card {
    padding: 10px;
    margin-bottom: 8px;
  }

  .vj-card:hover {
    transform: none;
  }

  .vj-kpi {
    padding: 10px 8px;
  }

  .vj-kpi-value {
    font-size: 0.7rem;
  }

  .vj-detail-close {
    font-size: 1.4rem;
    padding: 8px;
  }
}
