/* ============================================================
   Iowa's Little Ireland. Map pages (Family Tree + Family Network)
   Shared on-brand skin for the two chart pages. Light parchment,
   hunter green, old gold, serif type. Pulls every value from
   melrose-tokens.css. No em or en dashes anywhere.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--ff-body);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--green-mid); text-decoration: none; transition: color var(--transition); }
a:hover, a:focus-visible { color: var(--gold); }

/* ---- NAV (matches the site) ---- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(26, 58, 42, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(201, 164, 74, 0.2);
  padding: var(--space-3) var(--space-6);
  flex-shrink: 0;
}
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}
.nav-logo {
  font-family: var(--ff-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.nav-logo:hover, .nav-logo:focus-visible { color: var(--white); }
.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.nav-links a {
  font-family: var(--ff-body);
  font-size: var(--fs-sm);
  color: rgba(247,243,234,0.8);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-links a:hover, .nav-links a:focus-visible { color: var(--gold-light); }
.nav-links a.current { color: var(--gold-light); border-bottom: 1px solid var(--gold); padding-bottom: 2px; }

/* ---- PAGE HEAD (slim title bar) ---- */
.map-head {
  background: var(--parchment);
  border-bottom: 1px solid rgba(45,90,61,0.18);
  padding: var(--space-3) var(--space-6);
  flex-shrink: 0;
}
.map-head-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}
.map-title {
  font-family: var(--ff-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: var(--lh-tight);
  color: var(--green-deep);
  margin: 0;
}
.map-tagline {
  font-family: var(--ff-body);
  font-size: var(--fs-sm);
  font-weight: 300;
  font-style: italic;
  color: var(--ink-light);
  margin: 0;
}

/* ---- CHART TOOLBAR (search, slider, buttons) ---- */
.map-toolbar {
  background: var(--cream);
  border-bottom: 1px solid rgba(45,90,61,0.18);
  padding: var(--space-3) var(--space-6);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.map-toolbar .tb-group { display: flex; align-items: center; gap: var(--space-3); }
.tb-sep { width: 1px; height: 28px; background: rgba(45,90,61,0.2); flex-shrink: 0; }

.search-wrap { position: relative; }
#search {
  width: 250px; max-width: 60vw;
  background: var(--white);
  border: var(--border-green);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
  font-family: var(--ff-body);
  outline: none;
}
#search:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,164,74,0.18); }
#search::placeholder { color: var(--ink-light); }
#search-results {
  position: absolute; top: 40px; left: 0; width: 340px; max-width: 80vw;
  max-height: 340px; overflow-y: auto;
  background: var(--white);
  border: var(--border-gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 300; display: none;
}
#search-results.open, #search-results.show { display: block; }
.sr-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid rgba(45,90,61,0.12);
  font-size: var(--fs-sm);
  display: flex; align-items: center; gap: var(--space-2);
  color: var(--ink-mid);
}
.sr-item:hover, .sr-item.sel { background: var(--parchment); }
.sr-name { flex: 1; display: flex; align-items: center; gap: var(--space-2); color: var(--ink); }
.sr-dates, .sr-item .yr { color: var(--ink-light); font-size: var(--fs-xs); white-space: nowrap; }
.sr-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.15); }

.year-row { display: flex; align-items: center; gap: var(--space-3); min-width: 240px; flex: 1; }
.yl {
  font-family: var(--ff-body);
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--ink-light); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
#year-slider {
  flex: 1; min-width: 90px;
  -webkit-appearance: none; appearance: none; height: 3px;
  background: rgba(45,90,61,0.25); border-radius: 2px; cursor: pointer; outline: none;
}
#year-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--white); cursor: pointer;
  box-shadow: var(--shadow-sm);
}
#year-slider::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--white); cursor: pointer;
}
#year-display {
  font-family: var(--ff-display);
  font-size: var(--fs-lg); font-weight: 700; color: var(--green-deep);
  min-width: 4ch; text-align: right;
}

.btn {
  background: var(--white);
  border: var(--border-green);
  border-radius: var(--radius-sm);
  color: var(--green-mid);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  font-family: var(--ff-body);
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  white-space: nowrap;
}
.btn:hover { color: var(--green-deep); border-color: var(--gold); background: var(--parchment); }
.btn.active { color: var(--white); background: var(--green-mid); border-color: var(--green-mid); }

.stat-pill {
  background: var(--parchment);
  border: var(--border-green);
  border-radius: 20px;
  padding: var(--space-1) var(--space-3);
  font-family: var(--ff-body);
  font-size: var(--fs-xs);
  color: var(--ink-light); white-space: nowrap;
}
.stat-pill strong { color: var(--green-deep); font-weight: 700; }

/* ---- CHART STAGE ---- */
#stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--cream);
  min-height: 420px;
}

/* legend (shared) */
#legend {
  position: absolute; top: var(--space-4); right: var(--space-4);
  background: rgba(247,243,234,0.94);
  border: var(--border-gold);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  z-index: 20; max-width: 210px;
  box-shadow: var(--shadow-sm);
}
#legend h4, #legend .lg-title {
  font-family: var(--ff-display);
  font-size: var(--fs-xs); font-weight: 700;
  color: var(--green-deep);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
  text-transform: none;
}
.leg, .lg-item {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-xs); color: var(--ink-mid);
  margin-bottom: var(--space-1);
}
.lg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1) var(--space-4); }
.leg-sw, .lg-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}

#hint {
  position: absolute; bottom: var(--space-3); left: 50%; transform: translateX(-50%);
  font-family: var(--ff-body);
  font-size: var(--fs-xs); color: var(--ink-light);
  letter-spacing: 0.04em; pointer-events: none; z-index: 10; white-space: nowrap;
  background: rgba(247,243,234,0.8); padding: var(--space-1) var(--space-3); border-radius: 20px;
}

/* focus banner (network) */
#focusbar {
  position: absolute; bottom: var(--space-5); left: 50%; transform: translateX(-50%);
  font-family: var(--ff-body);
  font-size: var(--fs-sm); color: var(--ink-mid);
  background: rgba(247,243,234,0.92); border: var(--border-gold);
  padding: var(--space-2) var(--space-5); border-radius: 20px;
  display: none; text-align: center; z-index: 15; box-shadow: var(--shadow-sm);
}
#focusbar.show { display: block; }
#focusbar b { color: var(--green-deep); font-weight: 700; }
#reset { margin-left: var(--space-3); cursor: pointer; color: var(--green-mid); text-decoration: underline; }
#reset:hover { color: var(--gold); }

/* ---- INFO PANEL (shared) ----
   Pinned bottom-LEFT so it can never collide with the legend (top-right).
   Capped height leaves room above the bottom hint, and a comfortable right
   margin keeps a gap from the legend column. */
#info-panel, #info {
  position: absolute; bottom: var(--space-4); left: var(--space-4);
  width: 300px; max-width: calc(100vw - 2 * var(--space-4)); max-height: calc(100% - var(--space-16));
  overflow-y: auto;
  background: var(--white);
  border: var(--border-gold);
  border-radius: var(--radius);
  padding: var(--space-5);
  padding-right: var(--space-8);
  display: none; z-index: 200;
  box-shadow: var(--shadow-md);
}
#info-panel.open, #info.show { display: block; }
.i-close {
  position: absolute; top: var(--space-2); right: var(--space-2);
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--green-mid);
  background: var(--parchment); border: var(--border-gold); border-radius: 50%;
  font-size: 1.05rem; line-height: 1; padding: 0;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.i-close:hover, .i-close:focus-visible {
  color: var(--green-deep); background: var(--gold-pale); border-color: var(--gold);
}
.i-name, #info .nm {
  font-family: var(--ff-display);
  font-size: var(--fs-lg); font-weight: 700;
  color: var(--green-deep); clear: both; line-height: var(--lh-snug); margin-bottom: var(--space-1);
}
.i-dates { font-size: var(--fs-sm); color: var(--ink-light); margin-bottom: var(--space-3); }
#info .fam {
  font-family: var(--ff-body); font-size: var(--fs-sm); font-weight: 600;
  color: var(--gold); letter-spacing: 0.02em; margin-bottom: var(--space-3);
}
.i-row, #info .row { font-size: var(--fs-sm); color: var(--ink-mid); margin-bottom: var(--space-1); line-height: 1.5; }
.i-row strong { color: var(--green-deep); font-weight: 600; }
#info .row b { color: var(--ink-light); font-weight: 600; display: inline-block; width: 70px; }
.i-btn {
  display: inline-block; margin-top: var(--space-3); margin-right: var(--space-2);
  background: var(--parchment); border: var(--border-green); border-radius: var(--radius-sm);
  color: var(--green-mid); padding: var(--space-2) var(--space-3);
  font-family: var(--ff-body); font-size: var(--fs-xs); font-weight: 600;
  cursor: pointer; letter-spacing: 0.05em; text-transform: uppercase;
}
.i-btn:hover { border-color: var(--gold); color: var(--green-deep); }
.i-link, #info a {
  display: inline-block; margin-top: var(--space-3);
  font-size: var(--fs-sm); color: var(--green-mid); font-weight: 600;
}
.i-link:hover, #info a:hover { color: var(--gold); text-decoration: underline; }
.i-obit {
  margin-top: var(--space-3); font-family: var(--ff-display);
  font-size: var(--fs-sm); font-style: italic; color: var(--ink-mid);
  border-top: 1px solid rgba(45,90,61,0.18); padding-top: var(--space-3); line-height: 1.6;
}
#info .hint { font-size: var(--fs-xs); color: var(--ink-light); margin-top: var(--space-3); line-height: 1.5; }

/* ---- LOADING ---- */
#loading {
  position: absolute; inset: 0;
  background: var(--cream);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-4); z-index: 500; transition: opacity 0.4s ease;
}
.load-spinner {
  width: 24px; height: 24px;
  border: 2px solid rgba(45,90,61,0.2); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.load-title { font-family: var(--ff-display); font-size: var(--fs-lg); color: var(--green-deep); font-weight: 700; }
.load-sub { font-size: var(--fs-sm); color: var(--ink-light); }

/* ---- FOOTER (compact, matches site) ---- */
.site-footer {
  background: var(--ink);
  padding: var(--space-10) var(--space-6) var(--space-8);
  border-top: 3px solid var(--green-deep);
  flex-shrink: 0;
}
.footer-inner { max-width: var(--max-w); margin: 0 auto; text-align: center; }
.footer-logo {
  font-family: var(--ff-display); font-size: var(--fs-xl); font-weight: 700;
  color: var(--gold-light); margin-bottom: var(--space-2);
}
.footer-tagline {
  font-family: var(--ff-body); font-size: var(--fs-sm); font-style: italic;
  color: rgba(247,243,234,0.55); line-height: 1.7; margin-bottom: var(--space-4);
}
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-5); justify-content: center; margin-bottom: var(--space-4); }
.footer-links a {
  font-size: var(--fs-xs); color: rgba(247,243,234,0.5);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.footer-links a:hover { color: var(--gold-light); }
.footer-copy { font-size: var(--fs-xs); color: rgba(247,243,234,0.4); line-height: 1.7; max-width: 600px; margin: 0 auto; }
.footer-note { margin-top: var(--space-2); color: rgba(247,243,234,0.5); font-style: italic; }

/* ============================================================
   FAMILY TREE (f3 / family-chart) light-parchment skin
   ============================================================ */
#FamilyChart { width: 100%; height: 100%; position: absolute; inset: 0; }
#FamilyChart.f3 {
  --background-color: #f7f3ea;
  --text-color: #1c1a14;
}
#FamilyChart svg.main_svg { width: 100%; height: 100%; background: var(--cream); }
/* node card: cream fill, gold hairline border, surname tint applied per-card via JS */
#FamilyChart .card rect.card-body-rect {
  stroke: rgba(201,164,74,0.55);
  stroke-width: 1.4;
  rx: 6; ry: 6;
}
#FamilyChart .card text { fill: #1c1a14 !important; }
/* the focused (main) card gets a hunter-green outline */
#FamilyChart .card-main-outline { stroke: #1a3a2a; stroke-width: 3px; }
/* relationship links: thin ink-green on parchment */
#FamilyChart .link, #FamilyChart path.link {
  stroke: rgba(45,90,61,0.45); stroke-width: 1.4; fill: none;
}

/* year-filter visual states on light bg */
#FamilyChart g.card_cont.f3-unborn { display: none; }
#FamilyChart g.card_cont.f3-deceased { opacity: 0.42; }
#FamilyChart g.card_cont.f3-alive rect.card-body-rect { stroke: #1a3a2a; stroke-width: 2; }

/* ============================================================
   FAMILY NETWORK (d3 force) light-parchment skin
   ============================================================ */
#graph { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; background: var(--cream); }
#graph:active { cursor: grabbing; }
/* node labels: dark ink, parchment halo so they stay legible over links */
.lbl {
  font-family: var(--ff-body);
  font-size: 11px; fill: #1c1a14;
  paint-order: stroke; stroke: #f7f3ea; stroke-width: 3.5px; stroke-linejoin: round;
  pointer-events: none;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .map-toolbar { gap: var(--space-2); }
  #search { width: 160px; }
}
