/* ════════════════════════════════════════════════
   Family Graph App — Kids Edition
   Warm picture-book light theme, RTL, ages 3+
   ════════════════════════════════════════════════ */

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

/* ── Design Tokens ── */
:root {
  /* Warm cream/sky canvas */
  --bg:            #fdf6e9;
  --bg-sky:        #eaf6ff;
  --surface:       #fffdf7;
  --surface2:      #fdf3e0;
  --surface3:      #f7e8cf;

  /* Role accents (match RING_COLORS in ego.js) */
  --sun:           #ffb703;   /* ego */
  --coral:         #ef476f;   /* parents / partners */
  --leaf:          #06d6a0;   /* siblings / children */
  --sky:           #219ebc;   /* grandparents */
  --tangerine:     #f4845f;   /* aunts / uncles */
  --grape:         #9b5de5;   /* cousins */
  --cloud:         #8ecae6;   /* other relatives */

  --accent:        var(--sky);
  --accent-hover:  #2fb3d4;
  --accent2:       var(--leaf);

  --text:          #4a3f35;
  --text-muted:    #8a7a68;
  --text-subtle:   #bcab96;
  --border:        #f0e2c8;
  --shadow:        rgba(122, 92, 47, 0.16);

  /* Legacy graph views (classic / ancestors / …) on the light canvas */
  --node-fill:     #ffffff;
  --node-stroke:   #7cc3dd;
  --node-text:     #4a3f35;
  --ego-fill:      #fff3d6;
  --ego-stroke:    var(--sun);
  --edge-color:    #d9c9ae;
  --partner-edge:  #06d6a0;

  --radius:        18px;
  --sidebar-w:     300px;
  --topbar-h:      64px;

  --font-round:    "Varela Round", "Rubik", "Arial Rounded MT Bold",
                   -apple-system, "Segoe UI", system-ui, sans-serif;
}

/* ── Base ── */
html, body {
  height: 100%;
  font-family: var(--font-round);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
}

/* ════════════════════════════════════════════════
   TOP BAR — kid-facing title + tucked-away admin
   ════════════════════════════════════════════════ */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  min-height: var(--topbar-h);
  background: linear-gradient(180deg, #fffdf7 0%, #fdf6e9 100%);
  border-bottom: 3px solid #f6e7c9;
  box-shadow: 0 4px 18px rgba(122, 92, 47, 0.08);
  position: relative;
  z-index: 100;
  flex-wrap: wrap;
}

/* ── App title (המשפחה של …) ── */
#app-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#title-text {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8);
}

/* ── Home button ── */
#btn-home {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px var(--shadow), inset 0 0 0 3px var(--sun);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
#btn-home:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 14px var(--shadow), inset 0 0 0 3px var(--sun);
}
#btn-home:active {
  transform: scale(0.92);
}

/* ── Admin gear toggle ── */
#btn-admin-toggle {
  margin-inline-start: auto;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-subtle);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.2s, background 0.2s, transform 0.35s ease, color 0.2s;
}
#btn-admin-toggle:hover {
  opacity: 1;
  background: var(--surface3);
  color: var(--text-muted);
}
#btn-admin-toggle.open {
  opacity: 1;
  color: var(--accent);
  transform: rotate(90deg);
}

/* ── Admin tools strip (hidden until ⚙) ── */
#admin-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-basis: 100%;
  padding: 8px 2px 12px;
  border-top: 1px dashed var(--border);
}
#admin-tools.collapsed {
  display: none;
}

/* ── View Switcher ── */
#view-switcher {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.view-btn {
  padding: 6px 14px;
  background: transparent;
  border: none;
  border-radius: 20px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.view-btn:hover {
  color: var(--text);
  background: var(--surface3);
}
.view-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Search ── */
#search-box {
  position: relative;
  flex: 1;
  max-width: 220px;
}

#search-input {
  width: 100%;
  padding: 6px 14px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
#search-input::placeholder {
  color: var(--text-subtle);
}
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(33, 158, 188, 0.15);
}

#search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 10px 28px var(--shadow);
}
#search-results li {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
}
#search-results li:hover {
  background: var(--surface2);
}

/* ── Label Toggle ── */
#label-toggle {
  display: flex;
}

#btn-label-mode {
  padding: 6px 14px;
  background: var(--accent2);
  border: 2px solid transparent;
  border-radius: 20px;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#btn-label-mode.absolute {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
#btn-label-mode.absolute:hover {
  border-color: var(--accent2);
  color: var(--accent2);
}

/* ── Topbar Action Buttons ── */
#topbar-actions {
  display: flex;
  gap: 6px;
  margin-inline-start: auto;
}
#topbar-actions button {
  padding: 6px 14px;
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: 20px;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
#topbar-actions button:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Depth Control ── */
#depth-control-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
#depth-control {
  accent-color: var(--accent);
  width: 80px;
  cursor: pointer;
}

/* ════════════════════════════════════════════════
   MAIN LAYOUT
   ════════════════════════════════════════════════ */
#main-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
}

#canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 214, 140, 0.25), transparent 42%),
    radial-gradient(circle at 82% 80%, rgba(142, 202, 230, 0.22), transparent 45%),
    linear-gradient(180deg, var(--bg-sky) 0%, var(--bg) 70%);
}

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

/* ════════════════════════════════════════════════
   SIDEBAR — admin person panel (soft card look)
   ════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-inline-start: 3px solid #f6e7c9;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}
#sidebar[hidden] {
  display: none;
}

/* Person name heading */
#person-panel h2 {
  font-size: 19px;
  font-weight: 700;
  border-inline-start: 4px solid var(--sun);
  padding-inline-start: 10px;
  border-radius: 2px;
  margin-bottom: 12px;
  color: var(--text);
  line-height: 1.3;
}

/* Detail rows */
#person-panel .detail-row {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
  padding-inline-start: 2px;
}
#person-panel .detail-row span {
  color: var(--text);
  font-weight: 500;
}

/* Section titles */
#person-panel .section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 16px 0 6px;
  padding-top: 12px;
  border-top: 2px dashed var(--border);
  font-weight: 700;
}

/* Relationship list */
#person-panel .rel-list {
  list-style: none;
  font-size: 13px;
}
#person-panel .rel-list li {
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 10px;
  transition: color 0.12s, background 0.12s, padding 0.12s;
}
#person-panel .rel-list li:hover {
  color: var(--accent);
  background: rgba(33, 158, 188, 0.08);
  padding-inline-start: 10px;
}

/* Button row inside sidebar */
#person-panel .btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
#person-panel .btn-row button {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: 2px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
#person-panel .btn-row button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(33, 158, 188, 0.08);
}

/* History entries */
.history-entry {
  font-size: 11px;
  color: var(--text-subtle);
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

/* ════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════ */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(90, 70, 40, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
#modal-overlay[hidden] {
  display: none;
}

#modal-box {
  background: var(--surface);
  border: 3px solid #f6e7c9;
  border-radius: 24px;
  padding: 28px 28px 24px;
  min-width: 380px;
  max-width: 560px;
  width: 90%;
  position: relative;
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(90, 70, 40, 0.35);
  animation: modal-in 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

#modal-box h2, #modal-box h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}

#modal-close {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.12s, color 0.12s;
}
#modal-close:hover {
  background: var(--surface3);
  color: var(--text);
}

/* ════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
  font-family: ui-monospace, "SF Mono", "Fira Code", monospace;
  font-size: 13px;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(33, 158, 188, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-subtle);
}

/* Form feedback */
.form-error {
  color: #e5484d;
  font-size: 12px;
  margin-top: 5px;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px dashed var(--border);
}

.btn-primary {
  padding: 9px 24px;
  background: var(--accent);
  border: none;
  border-radius: 20px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(33, 158, 188, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 9px 24px;
  background: transparent;
  border: 2px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ════════════════════════════════════════════════
   SVG — NODES (pill / card style, legacy views)
   ════════════════════════════════════════════════ */
.node-group {
  cursor: pointer;
}

/* Pill card */
.node-card {
  fill: var(--node-fill);
  stroke: var(--node-stroke);
  stroke-width: 2px;
  transition: filter 0.2s, stroke-width 0.15s;
  filter: drop-shadow(0 3px 6px rgba(122, 92, 47, 0.18));
}
.node-card:hover,
.node-group:hover .node-card {
  filter: drop-shadow(0 5px 12px rgba(33, 158, 188, 0.3));
  stroke-width: 3px;
}
.node-card.ego {
  fill: var(--ego-fill);
  stroke: var(--ego-stroke);
  stroke-width: 3px;
  filter: drop-shadow(0 4px 12px rgba(255, 183, 3, 0.45));
}
.node-card.selected {
  stroke: var(--coral);
  stroke-width: 3px;
  filter: drop-shadow(0 4px 14px rgba(239, 71, 111, 0.35));
}
.node-card.placeholder {
  fill: none;
  stroke: var(--text-subtle);
  stroke-dasharray: 5 4;
  stroke-width: 2px;
  stroke-linecap: round;
  filter: none;
}

/* Card text layers */
.node-name {
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-round);
  fill: var(--node-text);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.node-name.ego-name {
  font-size: 13px;
  font-weight: 700;
  fill: #c98d00;
}

.node-year {
  font-size: 10px;
  font-family: var(--font-round);
  fill: var(--text-muted);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.node-relation {
  font-size: 10px;
  font-style: italic;
  font-family: var(--font-round);
  fill: var(--accent);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

/* ════════════════════════════════════════════════
   SVG — NODES (legacy circle style)
   ════════════════════════════════════════════════ */
.node-circle {
  fill: var(--node-fill);
  stroke: var(--node-stroke);
  stroke-width: 2px;
  transition: stroke-width 0.15s, filter 0.2s;
}
.node-circle.ego {
  fill: var(--ego-fill);
  stroke: var(--ego-stroke);
  stroke-width: 3px;
}
.node-circle.selected {
  stroke: var(--coral);
  stroke-width: 3px;
}
.node-circle.placeholder {
  fill: none;
  stroke: var(--text-subtle);
  stroke-dasharray: 5 4;
  stroke-width: 2;
}
.node-group:hover .node-circle {
  filter: drop-shadow(0 3px 8px rgba(33, 158, 188, 0.3));
  stroke-width: 2.5px;
}

.node-label {
  font-size: 11px;
  font-family: var(--font-round);
  fill: var(--node-text);
  text-anchor: middle;
  pointer-events: none;
  dominant-baseline: middle;
}
.node-label.relational {
  fill: var(--accent);
}
.node-label.ego-label {
  font-weight: bold;
  font-size: 12px;
}

/* ════════════════════════════════════════════════
   SVG — EDGES
   ════════════════════════════════════════════════ */
.edge {
  fill: none;
  stroke: var(--edge-color);
  stroke-width: 2px;
  stroke-linecap: round;
}
.edge.partner {
  stroke: var(--partner-edge);
  stroke-width: 2.5px;
}

.partnership-bar {
  fill: none;
  stroke: var(--partner-edge);
  stroke-width: 3px;
  stroke-linecap: round;
}

.couple-box {
  fill: rgba(6, 214, 160, 0.06);
  stroke: var(--partner-edge);
  stroke-width: 2px;
  opacity: 0.8;
}

/* ════════════════════════════════════════════════
   SVG — EXPAND / COLLAPSE BADGE
   ════════════════════════════════════════════════ */
.more-badge  { cursor: pointer; }
.badge-rect  { fill: #fff; stroke: var(--accent); stroke-width: 1.5px; }
.badge-text  { fill: var(--accent); font-size: 10px; font-family: var(--font-round); text-anchor: middle; dominant-baseline: middle; }

/* Legacy badge class compatibility */
.badge-group { cursor: pointer; }

/* ════════════════════════════════════════════════
   SVG — CLASSIC VIEW
   ════════════════════════════════════════════════ */
.couple-line {
  stroke: var(--partner-edge);
  stroke-width: 2.5px;
  stroke-linecap: round;
}

.gen-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  dominant-baseline: middle;
  opacity: 0.7;
}

/* ════════════════════════════════════════════════
   SVG — META-GRAPH (Tribe view)
   ════════════════════════════════════════════════ */
.meta-node-rect {
  fill: var(--node-fill);
  stroke: var(--accent2);
  stroke-width: 2px;
  rx: 12;
}
.meta-node-text {
  fill: var(--text);
  font-size: 11px;
  font-family: var(--font-round);
  text-anchor: middle;
  dominant-baseline: middle;
}
.meta-edge {
  stroke: var(--edge-color);
  stroke-width: 2px;
}
.meta-edge-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-round);
  text-anchor: middle;
}

/* ════════════════════════════════════════════════
   TOOLTIP
   ════════════════════════════════════════════════ */
#tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(255, 253, 247, 0.96);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text);
  z-index: 400;
  display: none;
  white-space: nowrap;
  box-shadow: 0 6px 18px var(--shadow);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ════════════════════════════════════════════════
   KID EGO VIEW — warm, circular, photo-first
   ════════════════════════════════════════════════ */
#canvas-container.kid-view {
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 205, 112, 0.35), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(142, 202, 230, 0.30), transparent 38%),
    radial-gradient(circle at 78% 88%, rgba(255, 175, 204, 0.22), transparent 42%),
    radial-gradient(circle at 50% 40%, #fffdf5 0%, #fdf4de 58%, #f8e9cc 100%);
}

/* Person nodes: outer group carries position, inner group carries scale
   (both set inline by ego.js — CSS provides the easing only) */
.kid-node {
  cursor: pointer;
  transition: transform 0.7s cubic-bezier(0.25, 1, 0.35, 1), opacity 0.5s ease;
  will-change: transform, opacity;
}
.kid-node-inner {
  transition: transform 0.7s cubic-bezier(0.34, 1.2, 0.4, 1);
  will-change: transform;
}

/* Tap / hover delight: the portrait pieces are all centered at (0,0),
   so scaling each around its own fill-box center is safe and never
   fights the inline translate/scale transforms set by the JS. */
.kid-node .portrait-plate,
.kid-node image {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.kid-node .portrait-ring {
  transform-box: fill-box;
  transform-origin: center;
}
.kid-node:hover .portrait-plate,
.kid-node:hover .portrait-ring,
.kid-node:hover image {
  transform: scale(1.07);
}
.kid-node:active .portrait-plate,
.kid-node:active .portrait-ring,
.kid-node:active image {
  transform: scale(0.92);
  transition-duration: 0.12s;
}

/* Decor (family blob, cluster bubbles, connectors) cross-fades on re-center */
.kid-decor {
  transition: opacity 0.5s ease;
  pointer-events: none;
}

/* Portrait circle pieces */
.portrait-plate {
  fill: #ffffff;
  filter: drop-shadow(0 6px 14px rgba(122, 82, 30, 0.20));
}
.portrait-ring {
  stroke-width: 7px;
  transition: stroke 0.4s ease, stroke-width 0.2s ease,
              transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.kid-node:hover .portrait-ring {
  stroke-width: 9px;
}
.kid-ego .portrait-ring,
.kid-ego:hover .portrait-ring {
  stroke-width: 10px;
}

/* The ego gets a soft sunny glow */
.kid-ego .portrait-plate {
  filter: drop-shadow(0 8px 20px rgba(214, 148, 15, 0.35));
}

/* Big friendly Hebrew relationship label + name (outlined sticker text) */
.kid-rel {
  font-size: 27px;
  font-weight: 700;
  font-family: var(--font-round);
  paint-order: stroke;
  stroke: #fffdf5;
  stroke-width: 7px;
  stroke-linejoin: round;
  pointer-events: none;
}
.kid-ego .kid-rel {
  font-size: 34px;
}
.kid-name {
  font-size: 17px;
  font-weight: 500;
  font-family: var(--font-round);
  fill: #857664;
  paint-order: stroke;
  stroke: #fffdf5;
  stroke-width: 5px;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Soft family circle behind the core ring */
.kid-family-blob {
  fill: rgba(255, 183, 3, 0.10);
  stroke: rgba(255, 183, 3, 0.50);
  stroke-width: 5px;
  stroke-dasharray: 1 18;
  stroke-linecap: round;
}

/* Extended-family cluster bubbles (fill/stroke tint set inline per cluster) */
.kid-cluster-bubble {
  stroke-width: 4px;
  stroke-dasharray: 1 15;
  stroke-linecap: round;
}

/* Soft curved connectors from the family circle to each cluster */
.kid-connector {
  fill: none;
  stroke: rgba(190, 160, 110, 0.38);
  stroke-width: 14px;
  stroke-linecap: round;
  stroke-dasharray: 0.5 24;
}

/* ── Reduced motion: keep everything calm ── */
@media (prefers-reduced-motion: reduce) {
  .kid-node,
  .kid-node-inner,
  .kid-decor,
  .kid-node .portrait-plate,
  .kid-node .portrait-ring,
  .kid-node image {
    transition: none;
  }
  #modal-box {
    animation: none;
  }
}

/* ════════════════════════════════════════════════
   ADMIN FORMS (af-*) — Hebrew RTL person/partnership
   Warm picture-book look, slightly grown-up
   ════════════════════════════════════════════════ */

.af-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  padding-inline-end: 28px; /* keep clear of the ✕ button */
}

/* Numbered sections */
.af-section {
  background: #fffefb;
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px 12px;
  margin-bottom: 14px;
}
.af-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.af-step {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sun);
  color: #6b4d00;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(214, 148, 15, 0.35);
}

.af-req { color: var(--coral); }

.af-help {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.45;
}

/* Inputs — 16px+ so iOS never zooms */
.af-input,
input.af-input,
textarea.af-input {
  font-size: 16px;
  border-radius: 14px;
}
.af-field-err {
  color: #e5484d;
  font-size: 12.5px;
  min-height: 0;
  margin-top: 4px;
}
.af-field-err:empty { display: none; }

.af-more {
  margin-top: 4px;
}
.af-more summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 2px;
  border-radius: 10px;
  user-select: none;
}
.af-more summary:hover { color: var(--accent); }
.af-more[open] summary { margin-bottom: 10px; }

/* ── Gender / kind toggle: two big friendly buttons ── */
.af-gender {
  display: flex;
  gap: 10px;
}
.af-gender-btn {
  flex: 1;
  padding: 12px 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  background: #fff;
  border: 2.5px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s,
              transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s;
}
.af-gender-btn:hover {
  border-color: var(--sky);
  color: var(--text);
}
.af-gender-btn:active { transform: scale(0.96); }
.af-gender-btn.active {
  background: rgba(33, 158, 188, 0.10);
  border-color: var(--sky);
  color: #14708c;
  box-shadow: 0 3px 10px rgba(33, 158, 188, 0.2);
}

/* ── Avatars in pickers / chips / lists ── */
.af-avatar {
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(122, 92, 47, 0.25);
}

/* ── Searchable person picker ── */
.af-picker { position: relative; }

.af-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.af-chips[hidden] { display: none; }
.af-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px 5px 10px;
  background: rgba(6, 214, 160, 0.12);
  border: 2px solid rgba(6, 214, 160, 0.45);
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  color: #067a5d;
}
.af-chip-x {
  border: none;
  background: rgba(6, 122, 93, 0.12);
  color: #067a5d;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.af-chip-x:hover { background: var(--coral); color: #fff; }

.af-search-wrap { position: relative; }
.af-search-wrap[hidden] { display: none; }
.af-search {
  width: 100%;
  padding: 10px 14px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.af-search::placeholder { color: var(--text-subtle); }
.af-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(33, 158, 188, 0.15);
}

.af-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 30;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 16px;
  max-height: 216px;
  overflow-y: auto;
  box-shadow: 0 12px 30px var(--shadow);
  padding: 5px;
}
.af-list[hidden] { display: none; }
.af-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  background: transparent;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  text-align: start;
  transition: background 0.1s;
}
.af-list-item:hover,
.af-list-item:focus-visible {
  background: var(--surface2);
  outline: none;
}
.af-list-name { font-weight: 600; }
.af-list-sub {
  margin-inline-start: auto;
  font-size: 11.5px;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}
.af-list-empty {
  padding: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}
.af-full-hint {
  font-size: 12.5px;
  color: #067a5d;
  background: rgba(6, 214, 160, 0.10);
  border-radius: 12px;
  padding: 7px 12px;
}
.af-full-hint[hidden] { display: none; }

/* ── Couple suggestions (one tap = both parents) ── */
.af-couples { margin-bottom: 10px; }
.af-couples[hidden] { display: none; }
.af-couples-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.af-couple-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 8px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.12s;
}
.af-couple-chip .af-avatar + .af-avatar { margin-inline-start: -12px; }
.af-couple-chip:hover {
  border-color: var(--sun);
  color: var(--text);
}
.af-couple-chip:active { transform: scale(0.96); }
.af-couple-chip.active {
  background: rgba(255, 183, 3, 0.14);
  border-color: var(--sun);
  color: #9a6b00;
}

/* ── Photo step ── */
.af-photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.af-photo-preview {
  flex: none;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 4px solid #fff;
  box-shadow: 0 4px 12px rgba(122, 92, 47, 0.28);
}
.af-photo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}
.af-photo-btn {
  display: inline-block;
  padding: 8px 16px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.af-photo-btn:hover { background: var(--accent); color: #fff; }
.af-photo-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.af-photo-clear:hover { color: var(--coral); }
.af-photo-actions .af-help { margin-bottom: 0; }

/* ── Partnership: two slots + heart ── */
.af-pair {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 10px;
}
.af-slot {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 10px;
  background: #fff;
  border: 2.5px dashed var(--border);
  border-radius: 18px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
  position: relative;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.af-slot:hover { border-color: var(--sky); }
.af-slot.active {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(33, 158, 188, 0.14);
}
.af-slot.filled {
  border-style: solid;
  border-color: rgba(239, 71, 111, 0.5);
  background: rgba(239, 71, 111, 0.05);
}
.af-slot-plus {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-subtle);
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.af-slot-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.af-slot:not(.filled) .af-slot-name {
  color: var(--text-muted);
  font-weight: 500;
}
.af-slot-x {
  position: absolute;
  top: 7px;
  inset-inline-end: 7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(239, 71, 111, 0.12);
  color: var(--coral);
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.af-slot-x:hover { background: var(--coral); color: #fff; }
.af-heart {
  flex: none;
  align-self: center;
  font-size: 26px;
  color: var(--coral);
  animation: af-heartbeat 1.6s ease-in-out infinite;
}
@keyframes af-heartbeat {
  0%, 100% { transform: scale(1); }
  12%      { transform: scale(1.18); }
  24%      { transform: scale(1); }
}

.af-pair-info { font-size: 13px; line-height: 1.5; }
.af-pair-info:empty { display: none; }
.af-pair-warn {
  color: #b3261e;
  background: rgba(229, 72, 77, 0.09);
  border: 2px solid rgba(229, 72, 77, 0.3);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.af-pair-note {
  color: #8a6d1d;
  background: rgba(255, 183, 3, 0.12);
  border: 2px solid rgba(255, 183, 3, 0.35);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

/* Two date fields side by side */
.af-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Feedback / action buttons ── */
.af-form-err {
  font-size: 13.5px;
  margin: 0 0 4px;
}
.af-form-err:empty { display: none; }

.btn-primary:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
  box-shadow: none;
}
.af-btn-success,
.af-btn-success:disabled {
  background: var(--leaf) !important;
  opacity: 1;
  color: #fff;
}
.af-btn-danger {
  border-color: rgba(229, 72, 77, 0.5);
  color: #d13438;
}
.af-btn-danger:hover {
  border-color: #d13438;
  color: #d13438;
  background: rgba(229, 72, 77, 0.07);
}

/* ── Mobile: modal fills the screen nicely, no iOS zoom ── */
@media (max-width: 560px) {
  #modal-overlay {
    align-items: flex-end;
  }
  #modal-box {
    min-width: 0;
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    padding: 22px 16px 18px;
  }
  .form-group input,
  .form-group textarea {
    font-size: 16px;
  }
  .af-dates { grid-template-columns: 1fr; }
  .af-photo-row { gap: 12px; }
  .form-actions {
    flex-wrap: wrap;
  }
  .form-actions .btn-primary {
    flex: 1 1 100%;
    order: -1;
    padding: 12px 24px;
    font-size: 16px;
  }
  .form-actions .btn-secondary { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .af-heart { animation: none; }
}

/* ════════════════════════════════════════════════
   TOAST — brief Hebrew confirmations (admin flows)
   ════════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 14px);
  background: var(--surface, #fff);
  color: var(--text, #3d3428);
  border: 3px solid #f6e7c9;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 10px 32px rgba(90, 70, 40, 0.28);
  opacity: 0;
  pointer-events: none;
  z-index: 700;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: min(90vw, 480px);
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ════════════════════════════════════════════════
   SCROLLBAR (webkit)
   ════════════════════════════════════════════════ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #e8d6b4;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}
