/* family-chart-app — dark theme */

:root {
  --bg: #1a1a2e;
  --panel: #16213e;
  --accent: #e94560;          /* lines, underlines, accents (non-text) */
  --accent-strong: #cf2c4b;   /* fills behind white text (5.1:1) */
  --accent-text: #f26b82;     /* coral used as text or focus ring on navy (5.1:1+) */
  --secondary: #0f3460;       /* Harbor Blue */
  --text: #e0e0e0;
  --text-muted: #a0a0b4;      /* 6.2:1 on panel navy */
  --well: #101022;            /* sunken group background inside panels */
  --control-off: #4a4a66;     /* toggle track, off */
  --hairline: rgba(255, 255, 255, 0.06);
  --status-ok: #2ecc71;
  --status-error: #ff8888;
  --nav-height: 52px;
  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Nav bar ── */
#nav-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--nav-height);
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}

#app-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-right: 8px;
}

/* ── Tab buttons ── */
#tab-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

#tab-buttons button,
#logout-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 12px;
  min-height: 44px;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: var(--nav-height);
  height: var(--nav-height);
}

#tab-buttons button:hover,
#logout-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

#tab-buttons button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ── Logout button ── */
#logout-btn {
  margin-left: auto;
  color: var(--text-muted);
}

/* ── Error banner ── */
#error-banner {
  background: rgba(233, 69, 96, 0.15);
  border-bottom: 1px solid rgba(233, 69, 96, 0.4);
  color: var(--status-error);
  padding: 10px 16px;
  font-size: 0.875rem;
}

#error-banner[hidden] {
  display: none;
}

/* ── Access denied ── */
#access-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: calc(100vh - var(--nav-height));
  height: calc(100dvh - var(--nav-height));
  gap: 16px;
  color: var(--text-muted);
  font-size: 1.1rem;
}

#access-denied[hidden] {
  display: none;
}

#access-denied p {
  margin: 0;
}

#access-denied-logout-btn {
  background: var(--accent-strong);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px 20px;
  min-height: 44px;
  transition: opacity 0.15s;
}

#access-denied-logout-btn:hover {
  opacity: 0.85;
}

/* ── App content + chart ── */
#app-content {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-height));
  height: calc(100dvh - var(--nav-height));
  overflow: hidden;
}

#chart-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* f3 chart fills the container */
#chart-container .f3 {
  width: 100%;
  height: 100%;
}

/* ── Focus ── */
:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

#tab-buttons button:focus-visible,
#logout-btn:focus-visible {
  outline-offset: -2px;
}

/* ── Themed browser surfaces ── */
::selection {
  background: rgba(233, 69, 96, 0.35);
  color: var(--text);
}

input, textarea {
  caret-color: var(--accent-text);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Viewer search ── */
#viewer-search {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 200px;
  z-index: 1000;
}

#viewer-search input {
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  font: inherit;
  font-size: 0.9rem;
}

#viewer-search input::placeholder {
  color: var(--text-muted);
}

#viewer-dropdown {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 4px;
  background: var(--panel);
  color: var(--text);
  border-radius: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--control-off) transparent;
}

#viewer-dropdown:empty {
  display: none;
}

#viewer-dropdown [role="option"] {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--hairline);
}

#viewer-dropdown [role="option"]:hover {
  background: rgba(255, 255, 255, 0.05);
}

#viewer-dropdown [role="option"].active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-text);
}

/* ── Small screens ── */
@media (max-width: 720px) {
  #nav-bar {
    gap: 4px;
    padding: 0 8px;
    overflow-x: hidden;
  }

  #app-title {
    margin-right: 4px;
    letter-spacing: 0.02em;
  }

  #tab-buttons {
    gap: 0;
  }

  #tab-buttons button,
  #logout-btn {
    padding: 0 10px;
  }

  #viewer-search {
    width: 200px;
    max-width: calc(100% - 20px);
  }

  #error-banner {
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }
}

/* ── Reduced motion: keep state changes, drop the duration ── */
@media (prefers-reduced-motion: reduce) {
  #tab-buttons button,
  #logout-btn,
  #access-denied-logout-btn {
    transition-duration: 0.01ms;
  }
}
