/* === Graph Editor App Styles === */
/* Extends theme.css tokens — bg, fg, accent, white, light, muted, etc. */

body { overflow: hidden; }

/* Full-screen canvas */
#graph-container {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, #B7D9A2 0%, #8FB872 55%, #6A994E 100%),
    var(--bg);
  background-blend-mode: multiply;
  overflow: hidden;
}

/* Subtle vignette + wood-grain overlay so the canvas reads as a hanging-on-the-wall
   LittleBigPlanet scene rather than a flat plane. */
#graph-container::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(86deg,
      rgba(60,40,20,0.04) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(94deg,
      rgba(60,40,20,0.03) 0 1px, transparent 1px 9px);
  pointer-events: none;
}

#graph-canvas {
  width: 100%;
  height: 100%;
}

/* Floating Add button */
.add-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(231, 111, 81, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.add-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(231, 111, 81, 0.45); }

/* Node tooltip on hover */
.node-info {
  position: fixed;
  background: var(--white);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(27, 67, 50, 0.15);
  font-size: 14px;
  pointer-events: none;
  z-index: 20;
  min-width: 140px;
  opacity: 0;
  transition: opacity 0.15s;
}
.node-info.visible { opacity: 1; }
.node-info .ni-name { font-family: 'Bitter', serif; font-size: 16px; font-weight: 700; color: var(--fg); margin-bottom: 4px; }
.node-info .ni-type { font-size: 12px; color: var(--muted); text-transform: capitalize; margin-bottom: 2px; }
.node-info .ni-dob, .node-info .ni-anniv { font-size: 12px; color: var(--accent); margin-top: 2px; }
.node-info .ni-rels { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Relationship label on edge */
.rel-label { font-size: 11px; fill: var(--muted); font-family: 'Source Sans 3', sans-serif; pointer-events: none; }

/* Panels */
.panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 24px rgba(27, 67, 50, 0.1);
  padding: 24px 24px 40px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 30;
  max-height: 80vh;
  overflow-y: auto;
}
.panel.open { transform: translateY(0); }

.panel-handle {
  width: 40px;
  height: 4px;
  background: var(--light);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.panel h2 {
  font-size: 18px;
  color: var(--fg);
  margin-bottom: 20px;
}

/* Form elements */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
}
.field input,
.field select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--light);
  border-radius: 10px;
  font-size: 15px;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus { border-color: var(--accent); }

/* Buttons */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.btn {
  flex: 1;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--light); color: var(--fg); }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--light); }

/* Person type selector */
.type-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.type-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid var(--light);
  background: var(--bg);
  font-size: 14px;
  font-family: 'Source Sans 3', sans-serif;
  cursor: pointer;
  color: var(--fg);
  transition: border-color 0.15s, background 0.15s;
}
.type-btn.selected { border-color: var(--accent); background: rgba(231,111,81,0.08); color: var(--accent); font-weight: 600; }

/* Person list in panel */
.person-list { list-style: none; margin: 0; padding: 0; }
.person-list li {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--light);
  gap: 12px;
}
.person-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Bitter', serif;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.person-avatar.pet { background: var(--accent-sage); }
.person-list li .pname { font-weight: 600; font-size: 15px; color: var(--fg); flex: 1; }
.person-list li .ptype { font-size: 12px; color: var(--muted); }
.person-list li .pdate { font-size: 12px; color: var(--accent); margin-top: 2px; display: block; }
.person-list li .pdel { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 18px; padding: 4px; }
.person-list li .pdel:hover { color: #e74c3c; }

/* Link mode: select two people */
.link-hint {
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state h3 {
  font-size: 20px;
  color: var(--fg);
  margin-bottom: 8px;
}
.empty-state p { font-size: 15px; line-height: 1.6; }

/* Relationship list in link panel */
.rel-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--light);
  font-size: 14px;
}
.rel-item .rel-text { color: var(--fg); }
.rel-item .rel-text span { color: var(--muted); }
.rel-item button { background: none; border: none; cursor: pointer; color: var(--muted); }
.rel-item button:hover { color: #e74c3c; }

/* Confirm delete bar */
.confirm-bar {
  background: #fff3f3;
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.confirm-bar p { flex: 1; font-size: 14px; color: var(--fg); }

/* Overlay for panels */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 67, 50, 0.3);
  z-index: 25;
  display: none;
}
#overlay.visible { display: block; }

/* Person name label above node */
.person-label {
  font-family: 'Cabin Sketch', 'Patrick Hand', cursive;
  font-size: 13px;
  font-weight: 700;
  fill: var(--fg);
  text-anchor: middle;
  pointer-events: none;
  letter-spacing: 0.01em;
}
.person-label-bg {
  fill: var(--bg);
  pointer-events: none;
}

/* Back nav */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 20px;
}
.back-link:hover { color: var(--fg); }

/* Relationship tags on nodes */
.rel-tags {
  font-size: 10px;
  fill: var(--muted);
  text-anchor: middle;
  font-family: 'Source Sans 3', sans-serif;
}

/* Plaque-name typography overrides — placed after `.rel-tags`/`.person-label`
   base rules so the hand-drawn font wins for plaque text elements. */
.node-initials {
  text-shadow: 0 1px 0 rgba(0,0,0,0.28);
  font-family: 'Cabin Sketch', 'Patrick Hand', cursive;
}
.node-name {
  font-family: 'Cabin Sketch', 'Patrick Hand', cursive;
  font-weight: 700;
}
.node-tag {
  font-family: 'Cabin Sketch', 'Patrick Hand', cursive;
}

/* ─── Touch: tap-to-link selected ring + hint banner ──────────────────────── */
g[data-person-id] { touch-action: manipulation; }
g[data-person-id].selected-for-link .plaque-body {
  stroke: var(--accent);
  stroke-width: 4;
  filter: drop-shadow(0 0 6px rgba(231, 111, 81, 0.6));
}

.link-tap-hint {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--accent);
  color: #fff;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  min-height: 44px;
  border-radius: 22px;
  box-shadow: 0 4px 16px rgba(231, 111, 81, 0.35);
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.link-tap-hint.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  .add-btn { bottom: 20px; right: 20px; width: 56px; height: 56px; font-size: 26px; }
  .panel { padding: 20px 20px 36px; }
  #export-btn { bottom: 140px; }
  .circle-chip { min-height: 44px; padding: 10px 14px; }
}

/* ─── Print ─────────────────────────────────────────────────────────────────── */
@media print {
  @page {
    size: landscape;
    margin: 0.5in;
  }

  body {
    overflow: visible;
    background: #fff;
  }

  #graph-container {
    position: static;
    width: 100%;
    height: auto;
    overflow: visible;
    background: #fff;
  }

  #graph-canvas {
    width: 100% !important;
    height: auto !important;
    max-height: none;
    display: block;
  }

  #graph-container.print-mode #graph-canvas {
    height: auto !important;
    overflow: visible;
  }

  /* Hide all UI chrome */
  .add-btn,
  #node-info,
  #overlay,
  .panel,
  #manage-panel,
  #graph-container::before,
  #graph-container::after {
    display: none !important;
  }

  /* White bg for SVG container */
  #graph-canvas {
    background: #fff;
  }

  /* Ensure edges and labels are visible */
  svg text { fill: #1B4332; }
  svg path { stroke: #8B6F47; }
  svg line { stroke: #D4A373; }
  svg circle { stroke: #fff; }

  /* Flatten plaque drop shadows and gradients so print output stays flat wood-tone solid */
  [id^="node-shadow"], .plaque-body { filter: none !important; }
  .plaque-bevel, .photo-vignette { display: none !important; }
}

/* ─── Photo Upload ─────────────────────────────────────────────────────────── */
.photo-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
#photo-preview-container {
  display: none;
  align-items: center;
  gap: 8px;
}
#photo-preview-img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--light);
}
#remove-photo-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  padding: 4px;
  line-height: 1;
}
#remove-photo-btn:hover { color: #e74c3c; }
.photo-upload-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1.5px dashed var(--light);
  border-radius: 10px;
  font-size: 13px;
  font-family: 'Source Sans 3', sans-serif;
  color: var(--muted);
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s, color 0.15s;
}
.photo-upload-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Reminder Badge ──────────────────────────────────────────────────────── */
.reminder-badge {
  display: inline-block;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 20px;
  vertical-align: middle;
  font-family: 'Source Sans 3', sans-serif;
}

.reminder-today {
  background: rgba(231, 111, 81, 0.15);
  border: 1.5px solid var(--accent);
}

.reminder-item .ri-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.reminder-item .ri-emoji {
  font-size: 22px;
  line-height: 1;
  width: 32px;
  text-align: center;
}
.reminder-item .ri-name {
  font-weight: 600;
  color: var(--fg);
  font-size: 14px;
}
.reminder-item .ri-when {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}
.reminder-item .ri-sub {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

/* ─── Circle Chips ─────────────────────────────────────────────────────────── */
.circle-chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 4px;
  scrollbar-width: none;
}
.circle-chips-row::-webkit-scrollbar { display: none; }

.circle-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--light);
  font-size: 13px;
  font-family: 'Source Sans 3', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  border: 1.5px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.circle-chip:hover { border-color: var(--accent); }
.circle-chip.active { background: var(--accent); color: #fff; }
.circle-chip .lock-icon { font-size: 11px; }
.circle-chip .settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}
.circle-chip .settings-btn:hover { opacity: 1; }

/* ─── Circle Settings Panel ────────────────────────────────────────────────── */
#circle-settings-panel .settings-section {
  border-bottom: 1px solid var(--light);
  padding: 12px 0;
  font-size: 14px;
}
#circle-settings-panel .settings-section:last-child { border-bottom: none; }
#circle-settings-panel .settings-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
#circle-settings-panel .settings-section input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
#circle-settings-panel .circle-name-input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--light);
  border-radius: 8px;
  font-size: 15px;
  font-family: 'Source Sans 3', sans-serif;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  margin-bottom: 12px;
}

/* ─── Upgrade Modal ──────────────────────────────────────────────────────── */
#upgrade-modal {
  max-width: 360px;
  margin: 0 auto;
  left: 0; right: 0;
  bottom: auto;
  top: 50%;
  transform: translateY(100%);
  border-radius: 20px;
}
#upgrade-modal.open {
  transform: translateY(-50%);
}

/* ─── Export Paywall Modal ─────────────────────────────────────────────────── */
#export-paywall-modal {
  max-width: 360px;
  margin: 0 auto;
  left: 0; right: 0;
  bottom: auto;
  top: 50%;
  transform: translateY(100%);
  border-radius: 20px;
}
#export-paywall-modal.open {
  transform: translateY(-50%);
}

/* ─── Cap-upsell banner ────────────────────────────────────────────────── */
#cap-banner { animation: capBannerFadeIn 0.25s ease-out; }
@keyframes capBannerFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Near-cap upgrade banner ───────────────────────────────────────────── */
#upgrade-banner { animation: capBannerFadeIn 0.25s ease-out; }
#upgrade-banner-cta:hover { transform: translateY(-1px); }