/* ═══════════════════════════════════════════════════════════════════════════
   gene.fortitude.eu — main.css  v3
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:           #F5F2EC;
  --bg-card:      #FEFDFB;
  --bg-nav:       #FEFDFB;

  --text:         #1A1714;
  --text-sub:     #5C5853;
  --text-muted:   #9A9589;

  --accent:       #8B6914;
  --accent-dim:   rgba(139, 105, 20, 0.10);
  --accent-dark:  #6B5010;

  --border:       #DDD8CE;
  --border-light: #EAE7E0;
  --shadow-sm:    0 1px 3px rgba(26, 23, 20, 0.07);
  --shadow-md:    0 4px 16px rgba(26, 23, 20, 0.10);
  --shadow-lg:    0 8px 32px rgba(26, 23, 20, 0.14);

  --cert-confirmed:   #2D7A3A;
  --cert-probable:    #D4860A;
  --cert-speculative: #C94B3A;
  --cert-unknown:     #9E9A8E;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui:      'DM Sans', system-ui, -apple-system, sans-serif;

  --nav-h:    56px;
  --radius:   8px;
  --radius-s: 4px;
  --ease:     cubic-bezier(0.22, 0.68, 0, 1.2);
  --dur:      0.18s;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.site-header__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.site-header__label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.site-header__sep {
  color: var(--border);
  font-weight: 300;
}

.site-header__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-header__copy {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Logo (conservé si utilisé ailleurs) */
.site-header__logo {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.site-header__logo span { color: var(--accent); }

/* Switcher de langue */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--border-light);
  border-radius: var(--radius-s);
  padding: 2px;
  flex-shrink: 0;
}

.lang-switcher__option,
.lang-switcher__current {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 3px;
  text-decoration: none;
  display: inline-block;
  line-height: 1.4;
}

.lang-switcher__option {
  color: var(--text-muted);
  transition: color var(--dur), background var(--dur);
}
.lang-switcher__option:hover {
  color: var(--text);
  background: var(--bg-card);
}

.lang-switcher__current {
  color: var(--accent);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  cursor: default;
}

/* ── Layout général ─────────────────────────────────────────────────────────── */
main {
  padding-top: var(--nav-h);
  min-height: 100vh;
}

/* ── Layout page arbre ──────────────────────────────────────────────────────── */
main.tree-page {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.page-tree {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#tree-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  background:
    radial-gradient(ellipse at 50% 90%, rgba(139,105,20,0.05) 0%, transparent 55%),
    var(--bg);
}

#tree-container:active { cursor: grabbing; }

#tree-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Page Login ─────────────────────────────────────────────────────────────── */
.page-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-h));
  padding: 40px 20px;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(139,105,20,0.06) 0%, transparent 65%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 40px 40px;
  box-shadow: var(--shadow-md);
}

.login-ornament {
  display: block;
  width: 32px;
  height: 2px;
  background: var(--accent);
  margin-bottom: 18px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 32px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.login-field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-sub);
}

.login-field input[type="password"] {
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 10px 13px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  outline: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.login-field input[type="password"]::placeholder { color: var(--text-muted); }
.login-field input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.login-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 11px 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: background var(--dur), transform 80ms;
}
.login-btn:hover  { background: var(--accent-dark); }
.login-btn:active { transform: translateY(1px); }

.login-error {
  font-size: 13px;
  color: var(--cert-speculative);
  background: rgba(201, 75, 58, 0.07);
  border-left: 3px solid var(--cert-speculative);
  padding: 8px 12px;
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  margin-bottom: 16px;
}

/* ── SVG — Cartes ───────────────────────────────────────────────────────────── */
.card-bg {
  fill: var(--bg-card, #FEFDFB);
  stroke: #DDD8CE;
  stroke-width: 1;
}

.card-bg.placeholder {
  fill: #ECEAE3;
  stroke: #C8C4BA;
  stroke-dasharray: 4 3;
}

.card-bg:not(.placeholder) { transition: filter 0.15s ease; }

.node:not(.is-placeholder):hover .card-bg {
  filter: drop-shadow(0 3px 10px rgba(26,23,20,0.13));
}

.card-img-placeholder {
  fill: #E8E4DC;
  stroke: #D4D0C8;
  stroke-width: 0.5;
}

.card-img-placeholder.hidden {
  display: none;
}

.card-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  font-weight: 500;
  fill: #1A1714;
}

.card-name.is-placeholder {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  fill: #C8C4BA;
  font-style: italic;
}

.card-subtitle {
  font-size: 11px;
  font-style: italic;
  fill: #7A756D;   /* ton parchemin atténué */
}

.card-dates {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 300;
  fill: #9A9589;
  pointer-events: none;
}

.edge {
  fill: none;
  stroke: #C8C4BA;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.expand-btn-bg {
  fill: #F0EDE6;
  stroke: #C8C4BA;
  stroke-width: 1;
  transition: fill 0.12s;
}
.expand-btn-bg:hover { fill: #E5E1D7; }

.expand-btn-icon {
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  fill: #9A9589;
  pointer-events: none;
  user-select: none;
}

/* ── Contrôles zoom — décalés du bord ──────────────────────────────────────── */
.tree-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.tree-ctrl-btn {
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text-sub);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.tree-ctrl-btn:hover {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

/* ── Burger menu ────────────────────────────────────────────────────────────── */
.tree-burger {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.burger-panel {
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.burger-panel.open {
  display: flex;
}

#burger-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

/* Légende certitude */
.tree-legend {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(254,253,251,0.90);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.tree-legend-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-sub);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Modale — centrée ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 24px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.22s var(--ease);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal-overlay.open .modal-panel {
  transform: scale(1) translateY(0);
}

.modal-panel-inner {
  padding: 32px 28px 40px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-s);
  transition: color var(--dur), background var(--dur);
}
.modal-close:hover {
  color: var(--text);
  background: var(--border-light);
}

.modal-cert-stripe {
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  border-bottom: none;
}

.modal-header-text {
  flex: 1;
  min-width: 0;  /* permet la troncature si nécessaire */
}

.modal-header-img {
  flex-shrink: 0;
  margin-right: 48px;
  margin-top: 2px;
}

.modal-header-img-el {
  width: 62px;
  height: 62px;
  object-fit: contain;
  border-radius: 4px;
}

.modal-header-img-placeholder {
  width: 62px;  
  height: 62px;
  background: #E8E4DC;
  border-radius: 4px;
}

.modal-person-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 4px;
  padding-right: 28px;
}

.modal-person-epithet {
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  color: var(--text-sub);
}

.modal-dates-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 12px 0;
  border-top: none;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.modal-dates-row .date-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-sub);
}

.modal-dates-row .date-glyph {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--accent);
}

.modal-bio {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 14px;
}

.modal-section-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 20px 0 8px;
}

.modal-parent-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 7px;
}

.modal-parent-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  width: 40px;
  flex-shrink: 0;
}

/* ── Modale — deux colonnes Ascendants / Filiation ──────────────────────────── */
.modal-lineage-row {
  display: flex;
  align-items: flex-start;
  width: 100%;
  border-top: 1px solid var(--border-light);
  margin-top: 20px;
  padding-top: 16px;
}

/* Annule le margin-top du modal-section-title à l'intérieur du bloc */
.modal-lineage-row .modal-section-title {
  margin-top: 0;
}

.modal-lineage-col {
  flex: 1;
  min-width: 0;
}

.modal-lineage-col--right {
  text-align: right;
}

.modal-lineage-col--right .modal-child-row {
  justify-content: flex-end;
}

.modal-lineage-divider {
  display: none;
}

.modal-child-row {
  display: flex;
  align-items: baseline;
  margin-bottom: 7px;
}

.modal-child-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
}

.modal-person-link {
  font-size: 14px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur);
}
.modal-person-link:hover { border-bottom-color: var(--accent); }

.modal-cert-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
}

.modal-cert-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-sub);
}

.modal-cert-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.modal-source-item {
  font-size: 13px;
  color: var(--text-sub);
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  line-height: 1.5;
}
.modal-source-item:last-child { border-bottom: none; }

.modal-source-name { font-weight: 500; color: var(--text); }
.modal-source-loc  { color: var(--text-muted); }

.modal-loading,
.modal-error {
  text-align: center;
  padding: 48px 24px;
  font-size: 14px;
  color: var(--text-muted);
}

.modal-loading::before {
  content: '…';
  font-family: var(--font-display);
  font-size: 32px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.4;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.2; }
  50%       { opacity: 0.6; }
}

/* ── Sources dans la modale ─────────────────────────────────────────────── */

/* Source secondaire (niveau 1) — style existant, inchangé */
.modal-source-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 0;
  font-size: 13px;
  color: #3D3A35;
}

/* Source primaire (niveau 2) — indentée, atténuée */
.modal-source-item.modal-source-primary {
  padding-left: 16px;
  font-size: 12px;
  color: #7A756D;
}

/* Flèche ↳ */
.modal-source-arrow {
  flex-shrink: 0;
  color: #8B6914;        /* accent parchemin */
  font-size: 11px;
  line-height: 1;
  margin-right: 2px;
  opacity: 0.7;
}

/* Nom de la source — lien ou texte */
.modal-source-name {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  color: inherit;
  text-decoration: none;
}

.modal-source-name[href]:hover {
  color: #8B6914;
  text-decoration: underline;
}

/* Localisation dans la source (ex: "— p. 48–49") */
.modal-source-loc {
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  color: #9E9A8E;
  font-size: inherit;
}

/* Notes internes (recherche, toujours en FR) */
.modal-note {
  font-size: 12px;
  color: #7A756D;
  font-style: italic;
  margin: 2px 0 6px;
  line-height: 1.5;
}

/* Bio — version longue (details/summary natif) */
.modal-bio-details {
  margin-top: 6px;
}

.modal-bio-summary {
  display: inline-block;
  font-size: 11px;
  font-family: 'DM Sans', sans-serif;
  color: #8B6914;
  cursor: pointer;
  text-align: right;
  float: right;
  margin-top: -4px;
  letter-spacing: 0.02em;
  user-select: none;
}

.modal-bio-summary:hover {
  text-decoration: underline;
}

/* Bascule expand ↔ collapse via details[open] */
.bio-label-collapse              { display: none; }
details[open] .bio-label-expand  { display: none; }
details[open] .bio-label-collapse { display: inline; }

.modal-bio-long {
  margin-top: 10px;
  padding-top: 8px;
  font-size: 13px;
  color: #3D3A35;
  line-height: 1.6;
  clear: both;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
}

/* ── Utilitaires ────────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}