/**
 * GeneLink – Lineage page styles
 * Adopts generational sections, person tiles, and sidebar from mockup (04-lineage).
 */

/* ── Living / Deceased badge ────────────────────────────────────────── */
.gl-lin-badge {
  display: inline-flex; align-items: center;
  font-size: .68rem; font-weight: 600; letter-spacing: .03em;
  padding: .2rem .6rem; border-radius: 99px;
  text-transform: uppercase;
}
.gl-lin-badge--living  { background: #D1FAE5; color: #065F46; }
.gl-lin-badge--deceased { background: #F3F4F6; color: #4B5563; }

/* ── Subject header ─────────────────────────────────────────────────── */
.gl-subject-header {
  background: var(--gl-surface, #fff);
  border: 1px solid var(--gl-border, #E2E0DB);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  padding: 1.75rem 2rem;
  margin-bottom: 1.75rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.5rem;
  align-items: center;
}
.gl-subject-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--gl-accent, #2D6A4F);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--gl-font-heading, 'DM Serif Display', serif);
  font-size: 1.75rem;
  flex-shrink: 0;
  overflow: hidden;
}
.gl-subject-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.gl-subject-name { font-size: 1.75rem; margin-bottom: .2rem; }
.gl-subject-meta { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; margin-bottom: .5rem; }
.gl-subject-meta span { font-size: .82rem; color: var(--gl-muted, #7A786F); display: flex; align-items: center; gap: .3rem; }
.gl-subject-bio { font-size: .875rem; color: var(--gl-muted, #7A786F); max-width: 520px; line-height: 1.55; }
.gl-subject-actions { display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; min-width: 150px; }
.gl-subject-stat { text-align: right; }
.gl-subject-stat strong { display: block; font-family: var(--gl-font-heading, 'DM Serif Display', serif); font-size: 1.4rem; }
.gl-subject-stat span { font-size: .72rem; color: var(--gl-muted, #7A786F); text-transform: uppercase; letter-spacing: .04em; }

/* Action buttons row inside subject header */
.gl-subject-action-btns { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; margin-bottom: .75rem; }
.gl-subject-action-btn { font-size: .82rem; }
.gl-btn-disabled { opacity: .55; cursor: default; pointer-events: none; }

/* Mobile action row — hidden on desktop, shown at ≤ 860px */
.gl-subject-mobile-actions {
  display: none;
  gap: .6rem; flex-wrap: wrap; align-items: center;
  margin-bottom: 1.25rem;
}
.gl-mobile-gen-count { font-size: .75rem; color: var(--gl-muted, #7A786F); margin-left: auto; }

/* ── Main layout ────────────────────────────────────────────────────── */
.gl-lineage-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; }

/* ── Generation sections ────────────────────────────────────────────── */
.gl-gen-section { margin-bottom: 1.5rem; }
.gl-gen-label {
  font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gl-muted, #7A786F); margin-bottom: .65rem;
  display: flex; align-items: center; gap: .5rem;
}
.gl-gen-label::after { content: ''; flex: 1; height: 1px; background: var(--gl-border, #E2E0DB); }

.gl-person-row { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ── Person tile ────────────────────────────────────────────────────── */
.gl-person-tile {
  background: var(--gl-surface, #fff);
  border: 1px solid var(--gl-border, #E2E0DB);
  border-radius: 10px;
  padding: .9rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  cursor: pointer;
  transition: all .18s;
  flex: 1; min-width: 180px; max-width: 260px;
  text-decoration: none;
  color: var(--gl-text, #1A1916);
  display: block;
}
.gl-person-tile:hover { border-color: var(--gl-accent, #2D6A4F); box-shadow: 0 4px 18px rgba(45,106,79,.1); transform: translateY(-1px); }
.gl-person-tile.gl-subject { border-color: var(--gl-accent, #2D6A4F); border-width: 2px; background: var(--gl-alight, #E8F1ED); }

.gl-pt-top { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; }
.gl-pt-av { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--gl-font-heading, 'DM Serif Display', serif); font-size: .85rem; flex-shrink: 0; overflow: hidden; }
.gl-pt-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.gl-pt-name { font-family: var(--gl-font-heading, 'DM Serif Display', serif); font-size: .92rem; line-height: 1.2; }
.gl-pt-years { font-size: .72rem; color: var(--gl-muted, #7A786F); }
.gl-pt-detail { font-size: .75rem; color: var(--gl-muted, #7A786F); line-height: 1.4; margin-top: .15rem; }
.gl-pt-detail strong { color: var(--gl-text, #1A1916); font-weight: 500; }

/* Partner tile — dashed border */
.gl-person-tile.gl-partner { border-style: dashed; }

/* ── Connector ──────────────────────────────────────────────────────── */
.gl-connector { display: flex; justify-content: center; align-items: center; height: 28px; position: relative; }
.gl-connector::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--gl-border, #E2E0DB); }
.gl-connector-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gl-accent, #2D6A4F); position: relative; z-index: 1; }

/* ── Sidebar ────────────────────────────────────────────────────────── */
.gl-sidebar-section { background: var(--gl-surface, #fff); border: 1px solid var(--gl-border, #E2E0DB); border-radius: 12px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06); margin-bottom: 1rem; }
.gl-ss-title { font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--gl-muted, #7A786F); margin-bottom: .85rem; }
.gl-fact-row { display: flex; justify-content: space-between; align-items: flex-start; padding: .45rem 0; border-bottom: 1px solid var(--gl-border, #E2E0DB); gap: .5rem; }
.gl-fact-row:last-child { border-bottom: none; }
.gl-fact-label { font-size: .78rem; color: var(--gl-muted, #7A786F); white-space: nowrap; }
.gl-fact-val { font-size: .82rem; color: var(--gl-text, #1A1916); text-align: right; }
.gl-fact-place { color: var(--gl-muted, #7A786F); }

/* ── Ancestry breadcrumbs (US-LIN-009) ─────────────────────────────── */
.gl-ancestry-label {
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gl-muted, #7A786F);
  margin-bottom: .3rem;
  font-weight: 600;
}

.gl-ancestry-bc {
  margin: 0 0 .7rem 0;
  font-family: var(--gl-serif, var(--gl-font-heading, 'DM Serif Display', serif));
  font-size: .82rem;
  color: var(--gl-text, #1A1916);
  line-height: 1.7;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 .1rem;
}

.gl-ancestry-bc:last-child {
  margin-bottom: 0;
}

.gl-ancestry-bc a {
  color: var(--gl-accent, #2D6A4F);
  text-decoration: none;
}

.gl-ancestry-bc a:hover {
  text-decoration: underline;
}

.gl-bc-year {
  color: var(--gl-muted, #7A786F);
  font-size: .72rem;
}

.gl-bc-sep {
  color: var(--gl-muted, #7A786F);
  margin: 0 .3rem;
}

/* ── Timeline ───────────────────────────────────────────────────────── */
.gl-timeline { display: flex; flex-direction: column; gap: 0; }
.gl-tl-item { display: flex; gap: .75rem; align-items: flex-start; padding: .55rem 0; position: relative; }
.gl-tl-item:not(:last-child)::after { content: ''; position: absolute; left: 8px; top: 28px; bottom: 0; width: 1px; background: var(--gl-border, #E2E0DB); }
.gl-tl-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gl-border, #E2E0DB); background: var(--gl-surface, #fff); flex-shrink: 0; margin-top: 3px; z-index: 1; }
.gl-tl-dot.accent { border-color: var(--gl-accent, #2D6A4F); background: var(--gl-accent, #2D6A4F); }
.gl-tl-dot--manual { border-color: #6B7280; border-style: dashed; }
.gl-tl-year { font-size: .7rem; font-weight: 600; color: var(--gl-muted, #7A786F); margin-bottom: .05rem; }
.gl-tl-event { font-size: .82rem; color: var(--gl-text, #1A1916); }

/* ── Siblings list ──────────────────────────────────────────────────── */
.gl-sibling-list { display: flex; flex-direction: column; gap: .5rem; }
.gl-sib-item { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--gl-text, #1A1916); padding: .4rem .5rem; border-radius: var(--gl-r, 8px); transition: background .15s; }
.gl-sib-item:hover { background: var(--gl-s2, #F0EFEB); }
.gl-sib-av { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: .65rem; font-family: var(--gl-font-heading, 'DM Serif Display', serif); flex-shrink: 0; }
.gl-sib-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.gl-sib-name { font-size: .82rem; font-weight: 500; }
.gl-sib-dates { font-size: .72rem; color: var(--gl-muted, #7A786F); }

/* ── Mobile sidebar toggle ──────────────────────────────────────────── */
.gl-sidebar-toggle { display: none; width: 100%; margin-bottom: 1rem; justify-content: space-between; align-items: center; padding: .75rem 1rem; background: var(--gl-surface, #fff); border: 1px solid var(--gl-border, #E2E0DB); border-radius: var(--gl-r, 8px); cursor: pointer; font-size: .85rem; font-weight: 500; color: var(--gl-text, #1A1916); font-family: var(--gl-font-body, 'DM Sans', sans-serif); }
.gl-sidebar-toggle .arrow { transition: transform .2s; font-size: .7rem; color: var(--gl-muted, #7A786F); }
.gl-sidebar-toggle.open .arrow { transform: rotate(180deg); }
.gl-sidebar-mobile { display: none; }
.gl-sidebar-mobile.open { display: block; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .gl-subject-header { grid-template-columns: auto 1fr; gap: 1rem; }
  .gl-subject-actions { display: none; }
  .gl-lineage-layout { grid-template-columns: 1fr; }
  .gl-sidebar-toggle { display: flex; }
  .gl-lineage-desktop-sidebar { display: none; }
}
@media (max-width: 640px) {
  .gl-subject-header { grid-template-columns: 1fr; gap: .85rem; padding: 1.25rem; }
  .gl-subject-avatar { width: 56px; height: 56px; font-size: 1.4rem; }
  .gl-subject-name { font-size: 1.35rem; }
  /* Bio: clamp to 3 lines on mobile rather than hiding content entirely */
  .gl-subject-bio {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: .85rem;
  }
  .gl-person-tile { min-width: 140px; }
}

/* Template compatibility: current Twig class names */
.gl-subject-av-wrap { width: 72px; height: 72px; }
.gl-subject-av {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--gl-font-heading, 'DM Serif Display', serif);
  font-size: 1.75rem;
}

.gl-subject-info h1 { font-size: 1.75rem; margin-bottom: .2rem; }

.gl-subject-parents {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .82rem;
  color: var(--gl-muted, #7A786F);
}

.gl-subject-parents a {
  color: var(--gl-accent, #2D6A4F);
  text-decoration: none;
}

.gl-gen-row { display: flex; gap: .75rem; flex-wrap: wrap; }

.gl-person-tile-av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .6rem;
  font-family: var(--gl-font-heading, 'DM Serif Display', serif);
  font-size: .85rem;
  overflow: hidden;
}

.gl-person-tile-av img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.gl-person-tile-name {
  font-family: var(--gl-font-heading, 'DM Serif Display', serif);
  font-size: .92rem;
  line-height: 1.2;
}

.gl-person-tile-dates {
  font-size: .72rem;
  color: var(--gl-muted, #7A786F);
}

.gl-vitals {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: .55rem .75rem;
}

.gl-vitals dt {
  font-size: .78rem;
  color: var(--gl-muted, #7A786F);
}

.gl-vitals dd {
  margin: 0;
  font-size: .82rem;
  color: var(--gl-text, #1A1916);
  text-align: right;
}

/* ── Sidebar action buttons ──────────────────────────────────────── */
.gl-sidebar-cta { width: 100%; margin-top: .85rem; text-align: center; display: block; }
.gl-sidebar-actions { display: flex; flex-direction: column; gap: .5rem; }
.gl-sidebar-actions .gl-btn { width: 100%; justify-content: center; }

/* ── Mobile action row (≤ 860px) ───────────────────────────── */
@media (max-width: 860px) {
  .gl-subject-mobile-actions { display: flex; }
}

/* ── Print styles ──────────────────────────────────────────── */
@media print {
  .genelink-nav,
  nav,
  .gl-subject-actions,
  .gl-subject-mobile-actions,
  .gl-sidebar-toggle,
  .gl-sidebar-mobile {
    display: none !important;
  }

  /* Use full width, no sidebar grid */
  .gl-lineage-layout { display: block !important; }
  .gl-lineage-desktop-sidebar {
    display: block !important;
    margin-top: 2rem;
    border-top: 1px solid #ccc;
    padding-top: 1rem;
  }

  /* Print header: site name, member name, date */
  .genelink-page::before {
    content: attr(data-print-header);
    display: block;
    font-family: var(--gl-font-heading, 'DM Serif Display', serif);
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #333;
  }

  /* Keep tiles readable on paper */
  .gl-person-tile { page-break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  .gl-subject-header { box-shadow: none; border: 1px solid #ccc; }
  .gl-sidebar-section { box-shadow: none; }
}

/* ── Relationship label + alternate names (US-LIN-008 / US-EXT-001) ── */
.gl-rel-label {
  display: block;
  color: var(--gl-accent, #2D6A4F);
  font-size: .82rem;
  font-weight: 500;
  margin-top: .2rem;
  margin-bottom: .15rem;
}
.gl-also-known-as {
  display: block;
  color: var(--gl-muted, #7A786F);
  font-size: .78rem;
  margin-bottom: .25rem;
}

/* ── Member messaging modal (US-MSG-001) ─────────────────────────────── */
body.gl-modal-open {
  overflow: hidden;
}

.gl-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 9, .55);
  z-index: 600;
  border: 0;
  margin: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}

.gl-modal-overlay.open {
  display: flex;
}

.gl-modal {
  background: var(--gl-surface, #fff);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .22);
}

.gl-contact-modal {
  max-width: 480px;
}

.gl-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gl-border, #E2E0DB);
  flex-shrink: 0;
}

.gl-modal-title {
  font-family: var(--gl-font-heading, 'DM Serif Display', serif);
  font-size: 1.15rem;
  margin: 0;
}

.gl-modal-close {
  background: var(--gl-s2, #F0EFEB);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gl-muted, #7A786F);
  transition: background .15s;
  flex-shrink: 0;
}

.gl-modal-close:hover {
  background: var(--gl-border, #E2E0DB);
  color: var(--gl-text, #1A1916);
}

.gl-modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

.gl-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .65rem;
  padding-top: .75rem;
}

.gl-contact-form {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.gl-contact-form textarea {
  min-height: 140px;
  resize: vertical;
}

.gl-contact-note {
  font-size: .72rem;
  color: var(--gl-muted, #7A786F);
  margin: 0;
}

.gl-contact-error {
  margin: 0;
  font-size: .8rem;
  color: #b91c1c;
}

.gl-contact-success {
  padding: 1.4rem 1rem;
  text-align: center;
}

.gl-contact-success-icon {
  color: #15803d;
  font-size: 2rem;
  margin-bottom: .55rem;
}

.gl-contact-success p {
  margin: 0;
  font-size: .92rem;
}

@media (max-width: 640px) {
  .gl-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .gl-modal {
    border-radius: 16px 16px 0 0;
    max-height: 100vh;
    max-width: none;
  }
}
