/* ── Org Chart Page ─────────────────────────────────────────────────────── */

.org-section {
  background-color: #f4f5f7;
}

/* Scrollable wrapper so wide trees don't break the layout */
.org-chart-container {
  width: 100%;
  overflow-x: auto;
  padding: 0 24px 48px;
}

.org-chart-wrap {
  display: inline-block;
  min-width: 100%;
  padding: 0 32px 16px;
}

/* ── Tree root ──────────────────────────────────────────────────────────── */

.org-tree {
  text-align: center;
  font-family: var(--font-body);
}

/* ── Level (ul) ─────────────────────────────────────────────────────────── */

.org-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
  /*
   * 48px total vertical space per level:
   *   - top 24px: parent card → junction point  (drawn by ul::before)
   *   - bot 24px: junction point → child card   (drawn by li::before border-right)
   */
  padding-top: 48px;
  position: relative;
  display: flex;
  justify-content: center;
}

/* Vertical line from the parent card down to the junction point */
.org-tree ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 24px; /* only to junction; li::before handles the rest */
  background-color: #c5c9d3;
}

/* No vertical line above the root level */
.org-tree > ul::before {
  display: none;
}

/* ── Node (li) ──────────────────────────────────────────────────────────── */

.org-tree li {
  position: relative;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/*
 * LEFT half of horizontal bar + vertical drop → forms an L-corner (┐)
 *
 *  ____________|   ← border-top  (horizontal, li-left → li-center)
 *              |   ← border-right (vertical drop, junction → card top)
 */
.org-tree li::before {
  content: "";
  position: absolute;
  top: -24px; /* sit at the junction level */
  right: 50%; /* right edge = li center */
  left: 0;
  height: 24px; /* drop from junction to card */
  border-top: 2px solid #c5c9d3;
  border-right: 2px solid #c5c9d3;
}

/* RIGHT half of horizontal bar only (the vertical drop is already in ::before) */
.org-tree li::after {
  content: "";
  position: absolute;
  top: -24px;
  left: 50%; /* left edge = li center */
  right: 0;
  height: 24px;
  border-top: 2px solid #c5c9d3;
}

/* Single child – no horizontal arms, only the straight vertical drop */
.org-tree li:only-child::before,
.org-tree li:only-child::after {
  border-top: none;
}

/* First child – no left arm (nothing to connect to on the left) */
.org-tree li:first-child::before {
  border-top: none;
}

/* Last child – no right arm */
.org-tree li:last-child::after {
  border-top: none;
}

/* ── Card ───────────────────────────────────────────────────────────────── */

.org-card {
  --dept-color: #a0a0a0;
  position: relative;
  background: #ffffff;
  border-top: 4px solid var(--dept-color);
  border-radius: 6px;
  padding: 12px 18px;
  min-width: 160px;
  max-width: 220px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  text-align: center;
  transition:
    box-shadow 0.25s ease,
    transform 0.25s ease;
}

.org-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  transform: translateY(-2px);
}

/* Vertical line from bottom of card down to the junction point */
.org-card::after {
  content: "";
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 24px;
  background-color: #c5c9d3;
}

/* Cards with no children – no downward line */
.org-node--leaf > .org-card::after {
  display: none;
}

.org-role {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dept-color);
  margin-bottom: 5px;
}

.org-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #1a1d24;
  line-height: 1.4;
}

/* Section header cards (nodes with no role, e.g. "PROJECT SECTION") */
.org-card--section {
  background: var(--dept-color);
  border-top-color: rgba(0, 0, 0, 0.15);
}

.org-card--section .org-name {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
}

/* ── Department color legend ───────────────────────────────────────────── */

.org-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 24px;
  margin-bottom: 40px;
}

.org-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #555;
}

.org-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .org-card {
    min-width: 130px;
    max-width: 170px;
    padding: 10px 12px;
  }

  .org-tree li {
    padding: 0 8px;
  }
}
