/* MV_FamilyList (#509) — the whole family as a keyboard-navigable list.
   A reading overlay, sibling to the chronicle: same warm field, same header
   band, same one-exit back button. The rows follow THE HOUSE LOOK's one-row-
   grammar rule — every person wears the same elevated card, differentiated
   only by their avatar and, for the remembered, the brass memorial edge. */

.family-list-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--color-bg);
  z-index: var(--z-reading-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.family-list-overlay--open {
  opacity: 1;
  pointer-events: auto;
}

.family-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at top, var(--color-bg-tint) 0%, var(--color-bg) 60%);
}

/* ---------------- header ---------------- */

.family-list__header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(to bottom,
    var(--color-surface) 0%,
    var(--color-surface-elevated) 100%);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

/* Treatment lives in css/back-button.css (MV_BackButton, #482) — only the
   grid placement is this surface's business. */
.family-list__back {
  justify-self: start;
}

.family-list__title {
  text-align: center;
}

.family-list__title-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-xl);
  color: var(--color-text);
  line-height: var(--line-height-tight);
}

.family-list__title-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* ---------------- body ---------------- */

.family-list__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
  padding: var(--space-lg) var(--space-lg) var(--space-xxl);
}

.family-list__body::-webkit-scrollbar {
  width: 10px;
}

.family-list__body::-webkit-scrollbar-thumb {
  background-color: var(--color-border-strong);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: padding-box;
}

.family-list__empty {
  max-width: 46ch;
  margin: var(--space-xxl) auto;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
  line-height: var(--line-height-loose);
}

.family-list__tree,
.family-list__people {
  list-style: none;
  margin: 0;
  padding: 0;
}

.family-list__tree {
  max-width: 720px;
  margin: 0 auto;
}

/* ---------------- generations ---------------- */

.family-list__gen + .family-list__gen {
  margin-top: var(--space-lg);
}

.family-list__gen:focus {
  outline: none;
}

.family-list__gen-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-xxs);
  cursor: pointer;
  /* A short warm accent under-rule, not a full hairline (design-language). */
  border-bottom: 2px solid var(--color-accent-soft);
}

.family-list__gen:focus-visible .family-list__gen-row {
  outline: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-glow);
}

.family-list__gen-marker {
  display: inline-flex;
  color: var(--color-accent);
  transition: transform var(--transition-fast);
}

.family-list__gen-marker svg {
  width: 18px;
  height: 18px;
}

/* The chevron points down when a generation is folded and turns to point up
   when it's open — the same disclosure convention as the panel's Stories
   list (#292). */
.family-list__gen[aria-expanded="true"] .family-list__gen-marker {
  transform: rotate(180deg);
}

.family-list__gen-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-serif);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.family-list__gen-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.family-list__gen[aria-expanded="false"] .family-list__people {
  display: none;
}

.family-list__people {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-top: var(--space-sm);
}

/* ---------------- people ---------------- */

.family-list__person {
  border-radius: var(--radius-md);
}

.family-list__person:focus {
  outline: none;
}

.family-list__person-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  min-height: 40px;
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.family-list__person:hover .family-list__person-row {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.family-list__person:focus-visible .family-list__person-row {
  box-shadow: var(--shadow-glow);
}

.family-list__person--selected .family-list__person-row {
  border-color: var(--color-accent);
  background-color: var(--color-accent-soft);
}

/* A remembered relative's row wears the memorial itself — parchment fill plus
   an inset brass edge, the same treatment as their tree card and the panel's
   In-memory section (KIND DIALOG rule 6). Never a black border, never greyed
   out; the row's aria-label says "in memory" in words. */
.family-list__person--memorial .family-list__person-row {
  background-color: var(--color-node-deceased);
  border-left: 4px solid var(--color-remembrance);
}

.family-list__person--memorial .family-list__person-dates {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-remembrance-deep);
}

/* Initials in cream serif on a deep tint of the person's own colour — the
   same recipe as the panel header's hero and their tree node (HOUSE LOOK 7). */
.family-list__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: color-mix(in srgb,
    var(--family-list-person-color, var(--color-node-fill-personal)) 40%,
    var(--color-accent-deep));
  background-size: cover;
  background-position: center;
  font-family: var(--font-serif);
  font-size: var(--font-size-sm);
  color: var(--color-surface-elevated);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.family-list__person--memorial .family-list__avatar {
  background-color: color-mix(in srgb, var(--color-node-deceased) 30%, var(--color-remembrance-deep));
}

.family-list__person-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.family-list__person-name-line {
  display: flex;
  align-items: center;
  gap: var(--space-xxs);
  min-width: 0;
}

.family-list__person-name {
  font-size: var(--font-size-base);
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.family-list__person-dates {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.family-list__person-relation {
  font-size: var(--font-size-xs);
  font-style: italic;
  color: var(--color-accent);
}

/* The paw is quiet in-card ink, not another corner sticker — the same
   treatment (and the same russet dial) the tree node's pet marker wears. It is
   drawn solid rather than as an outline: the shared line-icon paw dissolves
   into a smudge at row scale, where the node's own paw is a filled shape. */
.family-list__person-pets {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  color: var(--color-pet-deep);
  opacity: 0.8;
}

.family-list__person-pets svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  stroke: none;
}

.family-list__person-pets-count {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

/* ---------------- phone ---------------- */

@media (max-width: 640px) {
  .family-list__header {
    grid-template-columns: auto 1fr auto;
    padding: var(--space-sm) var(--space-md);
  }

  .family-list__title {
    text-align: left;
  }

  .family-list__title-name {
    font-size: var(--font-size-lg);
  }

  .family-list__title-subtitle {
    font-size: var(--font-size-xs);
  }

  .family-list__body {
    padding: var(--space-md) var(--space-md) var(--space-xxl);
  }
}

@media (prefers-reduced-motion: reduce) {
  .family-list-overlay,
  .family-list__gen-marker,
  .family-list__person-row {
    transition: none;
  }

  .family-list__person:hover .family-list__person-row {
    transform: none;
  }
}

/* Touch-device-only sizing. See css/layout.css for the strategy note. */
@media (hover: none) and (pointer: coarse) {
  .family-list__gen-row,
  .family-list__person-row {
    min-height: var(--touch-target-min);
    touch-action: manipulation;
  }
}
