/* ── Person detail page ──────────────────────────────── */
body.person-page {
  background: #f5f2ee;
  overflow: auto;
  display: block;   /* override tree.css flex — fixes position:fixed in Firefox */
  height: auto;
  min-height: 100vh;
}

/* ── Header adjustments for person page ─────────────── */
.person-page .site-header { position: sticky; top: 0; z-index: 100; }
.header-logo, .header-logo:visited { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.header-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.875rem; color: #bbb; }
.header-breadcrumb a, .header-breadcrumb a:visited { color: #7eb3d8; text-decoration: none; }
.header-breadcrumb a:hover { color: #fff; }
.breadcrumb-sep { color: #666; }
.header-back-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.22);
  color: #c8d8e8;
  border-radius: 4px;
  padding: 3px 12px;
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.header-back-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ── Hero / profile header ───────────────────────────── */
.person-hero { background: #1a2a3a; color: #fff; padding: 28px 24px; }
.person-hero-inner { max-width: 960px; margin: 0 auto; display: flex; gap: 24px; align-items: flex-start; }
.person-photo-wrap {
  flex-shrink: 0;
  width: 120px; height: 120px;
  border-radius: 6px;
  overflow: hidden;
  background: #2d4a63;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.2);
}
.person-photo { width: 120px; height: 120px; object-fit: cover; display: block; }
.person-photo-icon { font-size: 3.5rem; color: rgba(255,255,255,0.5); }
.icon-male { color: #7eb3d8; }
.icon-female { color: #d87e9b; }

.person-photo-col { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.photo-change-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #cce;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
}
.photo-change-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }

.write-story-btn,
.write-story-btn:link,
.write-story-btn:visited {
  display: inline-block;
  background: #e0b872;
  border: 1px solid rgba(255,255,255,0.3);
  color: #1a2a3a;
  text-decoration: none;
  border-radius: 4px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.write-story-btn:hover { background: #ecc98c; }

/* ── Photo picker modal ──────────────────────────────────── */
.photo-modal-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.photo-modal-overlay.hidden { display: none; }

.photo-modal {
  background: #fff;
  border-radius: 8px;
  width: min(700px, 92vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  overflow: hidden;
}
.photo-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.photo-modal-header h3 { margin: 0; font-size: 1rem; color: #1a2a3a; }
.photo-modal-close {
  background: none; border: none; font-size: 1.1rem;
  cursor: pointer; color: #888; line-height: 1;
}
.photo-modal-close:hover { color: #333; }
.photo-modal.drag-over { outline: 2px dashed #6b93b8; outline-offset: -2px; background: #eef4fa; }

.photo-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  overflow-y: auto;
}
.photo-grid-empty { color: #888; font-size: 0.875rem; padding: 8px; margin: 0; }

.photo-thumb {
  position: relative;
  background: #f5f5f5;
  border: 2px solid #ddd;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.photo-thumb:hover { border-color: #7eb3d8; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.photo-thumb.selected { border-color: #2a6db5; box-shadow: 0 0 0 3px rgba(42,109,181,0.25); }

.photo-thumb-delete {
  position: absolute;
  top: 4px; right: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.photo-thumb:hover .photo-thumb-delete { opacity: 1; }
.photo-thumb-delete:hover { background: #a94442; }

.photo-thumb img {
  width: 100%; height: 110px;
  object-fit: cover; display: block;
}
.photo-thumb-name {
  font-size: 0.65rem; color: #555;
  padding: 4px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: left;
}

/* ── Photo lightbox ──────────────────────────────────────── */
.photo-lightbox {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,0.92);
  z-index: 300;
  display: flex; flex-direction: column;
}
.photo-lightbox.hidden { display: none; }

.lightbox-toolbar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.lb-tool-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #eee; border-radius: 4px;
  width: 32px; height: 32px;
  font-size: 1.2rem; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.lb-tool-btn:hover { background: rgba(255,255,255,0.25); color: #fff; }
.lb-fit-btn { width: auto; padding: 0 12px; font-size: 0.8rem; font-weight: 600; }
.lb-zoom-label { color: #999; font-size: 0.78rem; min-width: 40px; text-align: center; }
.lightbox-close-x {
  margin-left: auto;
  background: none; border: none;
  color: rgba(255,255,255,0.55); font-size: 1.4rem;
  cursor: pointer; line-height: 1; padding: 4px 8px;
}
.lightbox-close-x:hover { color: #fff; }

.lightbox-img-wrap {
  flex: 1; min-height: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  user-select: none; -webkit-user-select: none;
}
.lightbox-img-wrap.lb-dragging { cursor: grabbing; }

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 4px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.6);
  transform-origin: center center;
  pointer-events: none;
  user-select: none; -webkit-user-select: none;
}

.lightbox-footer {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  background: rgba(0,0,0,0.5);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.lightbox-filename {
  flex: 1; color: #aaa; font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lightbox-select-btn {
  background: #2a6db5; color: #fff;
  border: none; border-radius: 5px;
  padding: 8px 20px; font-size: 0.875rem; cursor: pointer;
  white-space: nowrap;
}
.lightbox-select-btn:hover { background: #1f56a0; }
.lightbox-cancel-btn {
  background: rgba(255,255,255,0.1); color: #ccc;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 5px;
  padding: 8px 14px; font-size: 0.875rem; cursor: pointer;
  white-space: nowrap;
}
.lightbox-cancel-btn:hover { color: #fff; background: rgba(255,255,255,0.18); }

.person-hero-content { flex: 1; min-width: 0; }
.person-hero-name { font-size: 1.8rem; font-weight: 700; line-height: 1.2; margin-bottom: 12px; }
.person-hero-events p { margin: 0 0 6px; font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
.event-label { font-weight: 600; color: #a8c8e0; min-width: 40px; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; }
.event-date { color: #e0e8f0; }
.event-sep { color: #668; margin: 0 2px; }
.event-place { color: #b0c8d8; }

/* ── Main body layout ────────────────────────────────── */
.person-body {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto;
  grid-template-areas: "stories family";
  gap: 20px;
  align-items: start;
}
.stories-section { grid-area: stories; }
.family-section  { grid-area: family; }

@media (max-width: 767px) {
  .person-body {
    grid-template-columns: 1fr;
    grid-template-areas: "stories" "family";
    padding: 12px;
  }
}

/* ── Section containers ──────────────────────────────── */
.person-section {
  background: #fff;
  border-radius: 6px;
  border: 1px solid #ddd;
  overflow: hidden;
}
.section-header {
  padding: 14px 20px 12px;
  border-bottom: 1px solid #eee;
  display: flex; align-items: center; justify-content: space-between;
}
.section-title { font-size: 1.1rem; font-weight: 700; color: #1a2a3a; margin: 0; }
.section-body { padding: 0; }

/* ── Relationship section ────────────────────────────── */
.relationship-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #668;
  padding: 12px 20px 6px;
  margin: 0;
}

.siblings-details summary { list-style: none; cursor: pointer; }
.siblings-details summary::-webkit-details-marker { display: none; }
.siblings-toggle { display: flex; align-items: center; gap: 8px; }
.siblings-toggle::after { content: '›'; font-size: 1rem; color: #888; transition: transform 0.15s; margin-left: auto; padding-right: 20px; }
.siblings-details[open] .siblings-toggle::after { transform: rotate(90deg); }

.count-badge {
  background: #e8ecf0;
  color: #445;
  border-radius: 10px;
  font-size: 0.72rem;
  padding: 1px 7px;
  font-weight: 600;
}

.person-list { list-style: none; padding: 0 16px 8px; margin: 0; }
.children-list { padding-top: 0; }

.person-list-item { margin-bottom: 6px; }
.person-list-item.indented { padding-left: 20px; }

.person-card-link { text-decoration: none; display: block; }
.person-card-link:hover .mini-card { border-color: #7eb3d8; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }

.mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #dde;
  border-radius: 5px;
  background: #fafafa;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mini-male   { border-left: 3px solid #5b8db8; }
.mini-female { border-left: 3px solid #b87878; }

.mini-avatar {
  font-size: 1.4rem;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}
.mini-male .mini-avatar   { background: #eaf2fb; color: #5b8db8; }
.mini-female .mini-avatar { background: #fbeaea; color: #b87878; }

.mini-info { min-width: 0; }
.mini-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a2a3a;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-dates {
  font-size: 0.78rem;
  color: #778;
  margin: 1px 0 0;
}
.marriage-note {
  font-style: italic;
  color: #999;
  margin-left: 4px;
}

/* ── Stories panel ───────────────────────────────────── */
.stories-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 1380px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Subtle scrollbar */
.stories-list::-webkit-scrollbar { width: 5px; }
.stories-list::-webkit-scrollbar-track { background: transparent; }
.stories-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.story-item { border-bottom: 1px solid #f0ede8; }
.story-item:last-child { border-bottom: none; }

.story-link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 20px;
  text-decoration: none;
  transition: background 0.12s;
}
.story-link:hover { background: #f5f2ee; }

.story-date-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: #5a7a9a;
  white-space: nowrap;
  min-width: 60px;
  flex-shrink: 0;
}

.story-item-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.story-item-title {
  font-size: 0.9rem;
  color: #222;
  line-height: 1.4;
}
.story-link:hover .story-item-title { color: #1a2a3a; }

.story-synopsis {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 0.78rem;
  color: #777;
  line-height: 1.35;
  margin-top: 2px;
}

.no-stories {
  padding: 16px 20px;
  font-size: 0.875rem;
  color: #888;
  margin: 0;
}

/* Pending proposals — only ever rendered for the author or a reviewing
   admin (see CanApprovePending/ditaStory.Pending); everyone else's Stories
   list simply never contains these entries at all. */
.story-pending-summary {
  cursor: default; /* not a link — .story-link's layout is reused, but there's nothing to click through to yet */
}
.story-pending-summary:hover { background: none; }

.pending-badge {
  display: inline-block;
  background: #fdf1d6;
  color: #8a6516;
  border: 1px solid #f0d999;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: 1px;
}

.story-pending-actions {
  display: flex;
  gap: 8px;
  padding: 0 20px 10px 90px; /* aligns under story-item-body, past the date-tag column */
}

.pending-action-btn {
  display: inline-block;
  background: #fff;
  border: 1px solid #ccc;
  color: #445;
  text-decoration: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.pending-action-btn:hover { background: #f5f2ee; }
.pending-approve-btn:disabled { opacity: 0.6; cursor: default; }

/* ── Responsive tweaks ───────────────────────────────── */
@media (max-width: 767px) {
  .person-hero-inner { flex-direction: column; }
  .person-hero-name { font-size: 1.4rem; }
}
