/* Reyes–Palma Family Tree — Bounded Family Collaboration V2 Styles */

.v2-hidden-baseline-lineage {
  display: none !important;
}

.v2-hidden-drawer-actions {
  display: none !important;
}

.v2-collaboration-panel {
  display: grid;
  gap: 1rem;
  margin: 1.25rem 0;
}

.v2-section {
  padding: 1rem;
  border: 1px solid var(--border-archival, #d8c9b6);
  border-radius: 12px;
  background: rgba(255, 252, 246, 0.95);
  box-shadow: 0 4px 14px rgba(70, 50, 28, 0.05);
}

.v2-section-head {
  margin-bottom: 0.65rem;
}

.v2-eyebrow {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-heritage, #8b5f2c);
  font-weight: 700;
}

.v2-section-title {
  margin: 0.2rem 0 0;
  font-family: var(--font-serif, Georgia, serif);
  color: var(--text-primary, #261e16);
  font-size: 1.05rem;
  font-weight: 600;
}

/* Archival Actions Row */
.v2-archival-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.v2-btn-archival {
  min-height: 40px;
  padding: 0.45rem 0.65rem;
  border: 1px solid #ccb99f;
  background: #fffaf1;
  border-radius: 8px;
  color: #5a3d1c;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.v2-btn-archival:hover {
  background: #f6ecd9;
  border-color: #ba9e7d;
}

.v2-btn-archival:active {
  transform: translateY(1px);
}

/* Relationship Blocks */
.v2-rel-block {
  padding: 0.75rem 0;
  border-top: 1px solid rgba(150, 120, 85, 0.18);
}

.v2-rel-block:first-of-type {
  border-top: none;
  padding-top: 0.25rem;
}

.v2-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.v2-block-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #423223;
}

.v2-btn-add {
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  border: 1px solid #ccb99f;
  background: #fffaf1;
  border-radius: 6px;
  color: #6d4d2a;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.15s, border-color 0.15s;
}

.v2-btn-add:hover {
  background: #f6ecd9;
  border-color: #bfa17d;
}

/* Relative Lists */
.v2-rel-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.v2-rel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(150, 120, 85, 0.18);
  border-radius: 8px;
}

.v2-rel-main {
  min-width: 0;
}

.v2-person-link {
  border: 0;
  background: none;
  padding: 0;
  color: #2b2118;
  font: 600 0.88rem var(--font-serif, Georgia, serif);
  text-align: left;
  cursor: pointer;
}

.v2-person-link:hover {
  color: var(--accent-heritage, #8b5f2c);
  text-decoration: underline;
}

.v2-person-link.is-collaborative {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  color: #623f18;
}

.v2-person-link em {
  font-style: italic;
  color: #8b5f2c;
  font-weight: normal;
}

.v2-attached-name {
  display: block;
  font: 600 0.88rem var(--font-serif, Georgia, serif);
  color: #2b2118;
}

.v2-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.v2-role-pill {
  font-size: 0.65rem;
  color: #7b7062;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.v2-badge-amber {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 9999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
}

.v2-level-tag {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 9999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
}

.v2-drawer-only-tag {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
}

.v2-attr-text {
  font-size: 0.7rem;
  color: #786f64;
  font-style: italic;
  display: block;
}

.v2-btn-remove {
  border: 0;
  background: transparent;
  color: #8a483a;
  font-size: 0.72rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.v2-btn-remove:hover {
  background: #fee2e2;
}

.v2-empty-note {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: #877e72;
  font-style: italic;
}

/* Modals */
.v2-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(30, 22, 14, 0.52);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.v2-modal-card {
  width: min(560px, 100%);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  background: #fffaf1;
  border: 1px solid #c9b394;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(30, 18, 8, 0.3);
  padding: 1.25rem;
  box-sizing: border-box;
}

.v2-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.v2-modal-head h3 {
  margin: 0.15rem 0 0;
  font-family: var(--font-serif, Georgia, serif);
  color: var(--text-primary, #261e16);
  font-size: 1.2rem;
}

.v2-modal-subhead {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: #76695b;
  font-style: italic;
}

.v2-x {
  border: 0;
  background: transparent;
  font-size: 1.8rem;
  line-height: 0.8;
  cursor: pointer;
  color: #6f6255;
  padding: 0.2rem;
}

.v2-x:hover {
  color: #261e16;
}

.v2-info-callout {
  background: #fbf4e6;
  border-left: 4px solid var(--accent-heritage, #8b5f2c);
  padding: 0.65rem 0.85rem;
  border-radius: 0 8px 8px 0;
  margin: 0.85rem 0 1rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #554433;
}

.v2-callout-sub {
  display: block;
  margin-top: 0.35rem;
  color: #63503d;
  font-size: 0.74rem;
}

.v2-form {
  display: grid;
  gap: 0.85rem;
}

.v2-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: #4a3c2e;
}

.v2-opt {
  font-weight: normal;
  font-size: 0.7rem;
  color: #837566;
}

.v2-form input,
.v2-form select,
.v2-form textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  border: 1px solid #ccbba7;
  border-radius: 8px;
  background: #ffffff;
  padding: 0.65rem 0.75rem;
  font-size: 0.95rem;
  color: #2a2016;
  font-family: inherit;
}

.v2-form input:focus,
.v2-form select:focus,
.v2-form textarea:focus {
  outline: 2px solid var(--accent-heritage, #8b5f2c);
  outline-offset: 1px;
}

.v2-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.v2-helper {
  font-size: 0.74rem;
  line-height: 1.4;
  color: #73695d;
  margin: -0.3rem 0 0;
}

.v2-error {
  padding: 0.65rem 0.8rem;
  border: 1px solid #e5aba1;
  background: #fff0ec;
  border-radius: 8px;
  color: #8f3422;
  font-size: 0.8rem;
  line-height: 1.4;
}

.v2-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.v2-btn-primary {
  min-height: 44px;
  padding: 0.65rem 1.15rem;
  border: 1px solid #714920;
  background: #714920;
  color: #ffffff;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
}

.v2-btn-primary:hover {
  background: #5d3b19;
}

.v2-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.v2-btn-secondary {
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 1px solid #ccbba7;
  background: #fffaf1;
  color: #554434;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}

.v2-btn-secondary:hover {
  background: #f6ecdc;
}

/* Summary Details */
.v2-summary-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0.5rem;
}

.v2-summary-dl {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
}

.v2-summary-dl div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #ece0d1;
}

.v2-summary-dl dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #796d60;
  font-weight: 700;
}

.v2-summary-dl dd {
  margin: 0;
  color: #31261d;
  font-size: 0.88rem;
}

/* History List */
.v2-history-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.v2-history-entry {
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #e7dcce;
  border-radius: 8px;
}

.v2-history-sentence {
  font-size: 0.84rem;
  line-height: 1.45;
  color: #2b2117;
}

.v2-history-sentence strong {
  color: #1a140f;
}

.v2-history-sentence em {
  font-family: var(--font-serif, Georgia, serif);
  color: #784d20;
}

.v2-history-time {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.7rem;
  color: #82786b;
}

.v2-loading-spinner {
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.84rem;
  color: #766a5d;
  font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .v2-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .v2-modal-card {
    border-radius: 18px 18px 0 0;
    max-height: 90vh;
    padding: 1rem 1rem 1.25rem;
  }

  .v2-grid-2 {
    grid-template-columns: 1fr;
  }

  .v2-actions {
    position: sticky;
    bottom: -1.25rem;
    background: #fffaf1;
    padding: 0.75rem 0 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(150, 120, 85, 0.15);
  }

  .v2-archival-actions {
    grid-template-columns: 1fr;
  }

  .v2-block-head {
    align-items: flex-start;
  }

  .v2-btn-add {
    min-height: 40px;
  }
}

/* ==========================================================================
   Dynamic Direct Ancestor Main Tree Canvas Styles (Collaboration V2)
   ========================================================================== */

.v2-ancestors-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 2;
  width: 100%;
}

.v2-ancestor-level-row {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
}

.v2-ancestor-level-row .level-indicator-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  font-family: var(--font-serif, Georgia, serif);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #726859;
  padding: 0.25rem 0.5rem;
}

.v2-ancestor-level-row .level-indicator-tag::before,
.v2-ancestor-level-row .level-indicator-tag::after {
  content: "";
  flex: 1;
  max-width: 180px;
  height: 1px;
  background: linear-gradient(to right, transparent, #dacdbb, transparent);
}

.v2-ancestor-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.v2-ancestor-cluster.paternal-great-grandparents {
  flex: 1;
  max-width: 530px;
}

.v2-ancestor-cluster.maternal-great-grandparents {
  flex: 1;
  max-width: 530px;
  flex-direction: row;
  justify-content: center;
  gap: 1.25rem;
}

.v2-sub-cluster-palma,
.v2-sub-cluster-marasigan {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 236px;
}

.v2-cluster-spacer {
  visibility: hidden;
  width: 236px;
  min-height: 1px;
  pointer-events: none;
}

.v2-couple-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.v2-couple-cards {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.v2-couple-cards.single-parent {
  justify-content: center;
}

.v2-couple-bridge {
  color: #92775d;
  font-size: 1.35rem;
  line-height: 1;
  user-select: none;
  padding: 0 0.15rem;
}

/* Deep Archival Direct Ancestor Card */
.tree-card.v2-ancestral-card {
  background: linear-gradient(150deg, #f7efe0 0%, #e6d7bc 100%);
  border-color: #beaa91;
  box-shadow: 
    inset 0 0 0 1px rgba(255, 255, 255, 0.75), 
    inset 0 1px 2px rgba(210, 190, 165, 0.2), 
    0 2px 7px rgba(60, 42, 22, 0.05);
}

.tree-card.v2-ancestral-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-repeat: no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none'%3E%3Cpath d='M50 82 C50 65 36 54 26 50 C36 46 45 36 46 22 C48 35 55 45 68 48 C58 52 50 64 50 82 Z' fill='%23876d49' fill-opacity='0.035' stroke='%23876d49' stroke-opacity='0.09' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 8px bottom 8px;
  background-size: 74px 74px;
}

.tree-card.v2-ancestral-card:hover {
  border-color: #a3896b;
  transform: translateY(-2px);
  box-shadow: 
    inset 0 0 0 1px rgba(255, 255, 255, 0.85), 
    0 4px 12px rgba(60, 42, 22, 0.1);
}

.tree-card.v2-ancestral-card.is-selected {
  border-color: var(--accent-heritage, #8b5f2c) !important;
  box-shadow: 0 0 0 2px rgba(139, 95, 44, 0.35), 0 4px 14px rgba(60, 42, 22, 0.12) !important;
  transform: translateY(-2px);
}

body.mode-focus .tree-card.v2-ancestral-card.is-dimmed {
  opacity: 0.3;
  filter: grayscale(40%);
}

body.mode-focus .tree-card.v2-ancestral-card.is-connected {
  opacity: 1;
  border-color: #a87e43;
}

/* V2 SVG Overlay for Ancestor Connectors */
.v2-tree-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

.v2-tree-svg path {
  fill: none;
  transition: opacity var(--transition-fast, 0.2s);
}

body.mode-focus .v2-tree-svg path.is-dimmed {
  opacity: 0.15;
}

body.mode-focus .v2-tree-svg path.is-highlighted {
  opacity: 1;
  stroke: #8b5f2c;
}

