/* Robertson Family Tree — v1.0.0 */

/* ── CSS variables ────────────────────────────────────────────────────────── */

:root { --card-width: 200px; }

/* ── Reset & base ─────────────────────────────────────────────────────────── */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { background: #212121; font-family: 'Roboto', sans-serif; }

/* ── Tree canvas ──────────────────────────────────────────────────────────── */

/* Dot grid — doubled density (48px apart)
   color: #fff ensures currentColor resolves correctly inside the form panel */
#FamilyChart {
  width: 100%;
  height: 100vh;
  color: #fff;
  background-image: radial-gradient(rgba(255,255,255,0.09) 1.5px, transparent 1.5px);
  background-size: 48px 48px;
}


/* ── Loading / error status ───────────────────────────────────────────────── */

#status {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 1.2rem;
  text-align: center;
  padding: 2rem;
  pointer-events: none;
  z-index: 100;
}
#status.error { color: #ff6b6b; }
#status code {
  display: inline-block;
  margin-top: 0.75rem;
  background: #333;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-size: 0.85rem;
}


/* ── People count badge — bottom right ───────────────────────────────────── */

#people-count {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  color: rgba(255,255,255,0.3);
  font-size: 0.72rem;
  font-family: 'Roboto', sans-serif;
  pointer-events: none;
  z-index: 200;
  letter-spacing: 0.02em;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

/* Card box (SVG foreignObject) + inner div both follow --card-width */
.f3 svg foreignObject {
  width: var(--card-width) !important;
}

/* Left-aligned, stacked name layout */
.f3 div.card-rect,
.f3 div.card-image-rect {
  text-align: left;
  width: var(--card-width) !important;
}
.f3 div.card-rect {
  padding: 5px;
  justify-content: center;
}
.f3 div.card-image-rect div.card-label {
  text-align: left;
}

/* All name/date spans — left-aligned block */
.f3 .card-label span {
  display: block;
  text-align: left;
}

/* Date line — JS adds .date-line to any div containing an en-dash */
#FamilyChart div.date-line {
  opacity: 0.6 !important;
  font-size: 0.5em !important;
  display: block !important;
  margin-top: 2px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Avatar toggle */
body.no-avatar #FamilyChart .person-icon {
  display: none !important;
}
body.no-avatar #FamilyChart .card-inner {
  justify-content: center !important;
  padding: 0 8px !important;
}

/* ── Form panel ───────────────────────────────────────────────────────────── */

.f3-form-cont { background-color: #1c1928; }
.f3-form-cont.opened { width: 320px; }

/* Person name at top */
.f3-form-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0 0.4rem;
}

/* Section dividers inserted via setOnFormCreation */
.f3-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.35);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 1rem;
  margin-top: 0.25rem;
  margin-bottom: 0.6rem;
}

/* Field labels */
.f3-info-field-label,
.f3-form-field label {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 2px;
}

/* Inputs */
.f3-form input[type="text"],
.f3-form textarea,
.f3-form select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 5px;
  color: #fff;
  font-size: 0.88rem;
  font-family: 'Roboto', sans-serif;
  padding: 6px 10px;
  margin: 3px 0 9px;
  transition: border-color 0.15s, background 0.15s;
}
.f3-form input[type="text"]:focus,
.f3-form textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.09);
  box-shadow: none;
}

/* Gender radio group */
.f3-radio-group {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 7px 10px;
  margin-bottom: 10px;
}
.f3-radio-group label {
  font-size: 0.87rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  opacity: 1;
}

/* Submit / Cancel */
.f3-form button[type="submit"] {
  background-color: #5a4fcf;
  border-radius: 5px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  transition: background-color 0.2s;
}
.f3-form button[type="submit"]:hover { background-color: #4a3fbf; }

.f3-cancel-btn {
  background-color: rgba(255,255,255,0.1) !important;
  color: #fff !important;
  border-radius: 5px;
  font-family: 'Roboto', sans-serif;
  transition: background-color 0.2s !important;
}
.f3-cancel-btn:hover { background-color: rgba(255,255,255,0.18) !important; }

/* Delete / Remove */
.f3-form .f3-delete-btn,
.f3-form .f3-remove-relative-btn {
  border-radius: 5px;
  font-family: 'Roboto', sans-serif;
}

/* Info values */
.f3-info-field-value {
  font-size: 0.9rem;
  border-bottom-color: rgba(255,255,255,0.12);
}

/* HR dividers */
.f3-form hr { border-color: rgba(255,255,255,0.07); opacity: 1; }

/* Close / nav buttons */
.f3-close-btn { opacity: 0.55; }
.f3-close-btn:hover { opacity: 1; }

/* ── Kinship badge ───────────────────────────────────────────────────────── */

#FamilyChart div.card_cont {
  position: relative; /* needed for z-index stacking in some browsers */
}
#FamilyChart .card-inner {
  position: relative;
  overflow: hidden;
}

/* HTML badge injected into div.card-inner — bottom-left corner */
#FamilyChart .kinship-html-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  font-family: 'Roboto', sans-serif;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.85);
  background: rgba(90,79,207,0.75);
  padding: 2px 7px 2px 6px;
  border-radius: 0 8px 0 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

/* ── Marriage year labels — SVG text on spouse connector lines ───────────── */

#FamilyChart .marriage-label {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  font-weight: 600;
  fill: rgba(255,255,255,0.85);
  stroke: #1c1928;
  stroke-width: 3px;
  paint-order: stroke fill;
  pointer-events: none;
}

/* ── Deceased members — dimmed cards ─────────────────────────────────────── */

/* Deceased — golden halo */
#FamilyChart div.card_cont.deceased .card-inner {
  outline: 5px solid #FFE87A !important;
  box-shadow: 0 0 10px 2px rgba(255, 232, 122, 0.3) !important;
}

/* ── Selected / main card — gender / death coloured border ───────────────── */

#FamilyChart div.card_cont.main-card-male .card-inner {
  outline: 5px solid #00D4FF !important;
  box-shadow: 0 0 14px rgba(0,212,255,0.55) !important;
}
#FamilyChart div.card_cont.main-card-female .card-inner {
  outline: 5px solid #FF69B4 !important;
  box-shadow: 0 0 14px rgba(255,105,180,0.55) !important;
}
#FamilyChart div.card_cont.main-card-deceased .card-inner {
  outline: 5px solid #FFCC00 !important;
  box-shadow: 0 0 14px rgba(255,204,0,0.55) !important;
}

/* ── Gear / settings button — bottom left ─────────────────────────────── */

#btn-gear {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  background: none;
  color: rgba(255,255,255,0.5);
  border: none;
  padding: 0;
  font-size: 3rem;
  cursor: pointer;
  z-index: 200;
  line-height: 1;
  animation: gear-idle 8s linear infinite;
  transform-origin: center;
}
#btn-gear:hover { color: rgba(255,255,255,0.85); }

/* Spin for 3s, pause for 5s, repeat. Glow peaks at 180° (midway through spin). */
@keyframes gear-idle {
  0%     { transform: rotate(0deg);   filter: drop-shadow(0 0 3px rgba(255,255,255,0.15)); }
  18.75% { transform: rotate(180deg); filter: drop-shadow(0 0 10px rgba(255,255,255,0.65)); }
  37.5%  { transform: rotate(360deg); filter: drop-shadow(0 0 3px rgba(255,255,255,0.15)); }
  100%   { transform: rotate(360deg); filter: drop-shadow(0 0 3px rgba(255,255,255,0.15)); }
}

/* ── Settings drawer ──────────────────────────────────────────────────── */

#settings-drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 260px;
  height: 100vh;
  background: #1c1928;
  border-right: 1px solid rgba(255,255,255,0.08);
  overflow-y: auto;
  z-index: 300;
  transition: left 0.25s ease;
  padding: 1rem;
  color: #fff;
  font-family: 'Roboto', sans-serif;
}
#settings-drawer.open { left: 0; }

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
#btn-settings-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  line-height: 1;
}
#btn-settings-close:hover { color: #fff; }

.settings-section {
  margin-bottom: 1.5rem;
}
.settings-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.35);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 0.9rem;
  margin-bottom: 0.75rem;
}
/* No border above the first section — header already provides the divider */
#settings-drawer .settings-section:nth-child(2) .settings-section-label {
  border-top: none;
  padding-top: 0;
}
/* hr inside settings drawer matches section-label divider style */
#settings-drawer hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 0.9rem 0 0.75rem;
  opacity: 1;
}
.settings-hint {
  font-size: 0.68rem;
  opacity: 0.4;
  margin-bottom: 0.6rem;
  margin-top: -0.4rem;
}
.settings-toggle-row + .settings-hint {
  margin-top: 0.5rem;
  margin-bottom: 0;
}
.settings-row {
  margin-bottom: 0.85rem;
}
.settings-row label {
  display: block;
  font-size: 0.78rem;
  opacity: 0.75;
  margin-bottom: 0.3rem;
}
.settings-val {
  font-weight: 600;
  opacity: 1;
  color: #fff;
}

/* Stepper rows (Card Width / Horizontal / Vertical) */
.settings-stepper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.settings-stepper-label {
  font-size: 0.78rem;
  opacity: 0.75;
}
.settings-stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.stepper-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  min-width: 1.6rem;
  text-align: center;
}
.stepper-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  width: 1.6rem;
  height: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Roboto', sans-serif;
  transition: background 0.15s;
}
.stepper-btn:hover { background: rgba(255,255,255,0.22); }

/* Lineage select */
.settings-select {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 5px;
  color: #fff;
  font-size: 0.82rem;
  font-family: 'Roboto', sans-serif;
  padding: 5px 8px;
  margin-top: 3px;
  cursor: pointer;
}
.settings-select option { background: #1c1928; color: #fff; }

/* Show siblings toggle row */
.settings-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  opacity: 0.85;
  cursor: pointer;
  padding: 0.3rem 0;
}
.settings-toggle-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: #5a4fcf;
  cursor: pointer;
  flex-shrink: 0;
}
.au-mode-active #row-toggle-siblings,
.au-mode-active #row-toggle-sibling-kids {
  opacity: 0.25;
  pointer-events: none;
}

/* ── Profile link button on cards ──────────────────────────────────────── */
#FamilyChart .profile-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  padding: 1px 3px;
  text-decoration: none;
  line-height: 1;
  z-index: 10;
  transition: background 0.15s, color 0.15s;
}
#FamilyChart .profile-btn:hover {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

