/* Palette + type from the Oakside Ventures brand guide */
:root {
  --sage: #D7E6C1;
  --olive: #78854D;
  --oak: #333921;
  --tan: #F0EFE2;
  --pale-blue: #E1EAF0;
  --navy: #2C4354;
  --font-serif: 'Averia Serif Libre', Georgia, serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--tan);
  color: var(--oak);
}

body {
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  height: 64px;
  padding: 0 16px;
  background: var(--oak);
  border-bottom: 1px solid #23271a;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 0;
  color: var(--tan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-switcher {
  display: flex;
  gap: 4px;
  background: rgba(240, 239, 226, 0.12);
  border-radius: 8px;
  padding: 3px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--tan);
  opacity: 0.75;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  border-radius: 6px;
  cursor: pointer;
}

.tab.active {
  background: var(--olive);
  color: var(--tan);
  opacity: 1;
}

.request-update-btn {
  padding: 8px 16px;
  background: var(--sage);
  color: var(--oak);
  border: none;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.request-update-btn:hover {
  background: #c5d4ab;
}

.demo-banner {
  background: var(--sage);
  color: var(--oak);
  font-size: 0.85rem;
  text-align: center;
  padding: 6px 10px;
}

.demo-banner code {
  background: rgba(51, 57, 33, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
}

#app {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.state-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 20px;
}

.state-screen[hidden] {
  display: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--pale-blue);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-message { font-size: 1.1rem; font-weight: 700; }
.error-detail { color: #5c5f4f; font-size: 0.9rem; max-width: 400px; }

#retry-button {
  padding: 8px 20px;
  border-radius: 6px;
  border: none;
  background: var(--olive);
  color: var(--tan);
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
}

.view {
  position: absolute;
  inset: 0;
}

.view[hidden] {
  display: none;
}

/* --- Tree view cards --- */

.f3 .card {
  /* family-chart's card container is pointer-events:none; re-enable it on
     the card itself so real mouse hover/clicks register (the default card
     does this inline, but our custom card markup has to set it here). */
  pointer-events: auto;
  cursor: pointer;
  width: 130px;
  height: 150px;
  padding: 6px;
  border-radius: 8px;
  text-align: center;
  color: var(--tan);
  transform: translate(-50%, -50%);
  transition: transform 0.15s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.f3 .card:hover { transform: translate(-50%, -50%) scale(1.05); }

.f3 .card.divorced {
  background: #999999 !important;
}

.f3 .card-divorced-label {
  font-size: 0.75rem;
  font-style: italic;
  opacity: 0.9;
  flex-shrink: 0;
}

.f3 .card-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 6px;
  display: block;
  border: 2px solid rgba(240, 239, 226, 0.5);
}

.f3 .card-photo-placeholder {
  background: rgba(240, 239, 226, 0.3);
}

.f3 .card-name {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
  flex-shrink: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.f3 .card-years {
  font-size: 0.72rem;
  opacity: 0.85;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.f3 path.link { stroke: #b7b39c; stroke-width: 3; }
.f3 path.link.divorced { stroke-dasharray: 8, 4; opacity: 0.6; }

.f3 .card-male { background: var(--navy); }
.f3 .card-female { background: var(--olive); }
.f3 .card-genderless { background: #6b6b5a; }
.f3 .card-main { box-shadow: 0 0 0 3px var(--oak); }

/* --- Tree zoom controls (scroll/pinch also work, but aren't discoverable) --- */

.zoom-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.zoom-controls[hidden] { display: none; }

.zoom-controls button {
  width: 34px;
  height: 34px;
  border: none;
  border-bottom: 1px solid rgba(240, 239, 226, 0.25);
  background: var(--oak);
  color: var(--tan);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font-sans);
}

.zoom-controls button:last-child {
  border-bottom: none;
  font-size: 1.4rem;
}
.zoom-controls button:hover { background: var(--olive); }

/* --- Map view --- */

#map-view { background: var(--pale-blue); }

.map-popup { min-width: 160px; font-family: var(--font-sans); }

.map-popup-location {
  font-weight: 700;
  font-family: var(--font-serif);
  margin-bottom: 8px;
  color: var(--oak);
}

.map-popup-person {
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid #e5e4d8;
}

.map-popup-person:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.map-popup-name { font-weight: 700; margin-bottom: 2px; color: var(--oak); }
.map-popup-meta { font-size: 0.85rem; color: #5c5f4f; margin-bottom: 8px; }

.view-in-tree-btn {
  border: none;
  background: var(--olive);
  color: var(--tan);
  padding: 5px 10px;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
}

/* --- Person detail card --- */

.person-detail-card {
  position: absolute;
  right: 0;
  top: 0;
  width: 320px;
  height: 100%;
  background: var(--tan);
  border-left: 1px solid #d4d3c8;
  overflow-y: auto;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.person-detail-card[hidden] {
  display: none;
}

.person-detail-card-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--oak);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 12px 16px;
  line-height: 1;
}

.person-detail-card-close:hover {
  color: var(--navy);
}

.person-detail-content {
  padding: 16px;
  flex: 1;
}

.person-detail-name {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--oak);
  line-height: 1.3;
}

.person-detail-section {
  margin-bottom: 16px;
}

.person-detail-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--olive);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.person-detail-value {
  color: var(--oak);
  font-size: 0.95rem;
  line-height: 1.5;
}

.person-detail-value a {
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid var(--navy);
}

.person-detail-value a:hover {
  color: var(--olive);
  border-bottom-color: var(--olive);
}

.person-detail-about {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #5c5f4f;
  font-style: italic;
}

@media (max-width: 480px) {
  .topbar h1 { font-size: 1.1rem; }
  .tab { padding: 7px 12px; font-size: 0.85rem; }
  .person-detail-card {
    width: 100%;
    position: fixed;
  }
}
