/* Sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  transition: opacity var(--dur-base) ease;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.sidebar--folded {
  align-items: center;
}

.sidebar--dimmed {
  opacity: 0.25;
  pointer-events: none;
}

.column--sidebar:has(.sidebar--folded) {
  overflow: visible;
}

/* Tree wrap */

.sidebar__tree-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

/* folded: this wrap also clips (at the slot width) — release it too so the
   hover flyout escapes the whole sidebar, not just the tree */
.sidebar--folded .sidebar__tree-wrap {
  overflow: visible;
}

/* Tree */

.sidebar__tree {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 30px 10px 40px;
  gap: 8px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  box-sizing: border-box;
}

.sidebar__tree::-webkit-scrollbar {
  display: none;
}

.sidebar__tree--folded {
  align-items: center;
  padding: 0;
  /* folded rows are few and short: drop the scroll clip so the hover
     flyout can escape the narrow slot to the right */
  overflow: visible;
}

/* Shadow (sticky inside tree) */

.sidebar__shadow {
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  pointer-events: none;
  background: url('/img/scrolled_border.svg') center / 100% 10px no-repeat;
  opacity: 0;
  transition: opacity var(--dur-quick) ease;
  z-index: 2;
  overflow-x: clip;
  overflow-y: visible;
}

.sidebar__shadow--top {
  top: 0;
  transform: scaleY(-1);
}

.sidebar__shadow--bottom {
  bottom: 0;
}

.sidebar__shadow--visible {
  opacity: 1;
}

/* Group */

.sidebar__group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  transition: gap var(--dur-quick) ease, padding-bottom var(--dur-quick) ease;
}

.sidebar__group--expanded {
  gap: 8px;
  padding-bottom: 14px;
}

/* Pointers wrap */

.place-rows-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-quick) ease;
  width: 100%;
}

.sidebar__group--expanded .place-rows-wrap {
  grid-template-rows: 1fr;
}

/* Header */

.sidebar__header {
  display: flex;
  align-items: center;
  padding: 1px 3px 0;
  cursor: pointer;
  border-radius: 0;
  transition: background var(--dur-quick) ease;
}

.sidebar__header:hover {
  background: #fff;
  border-radius: 5px;
}

.sidebar__header--active {
  font-weight: 500;
}

.sidebar__header-label {
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  line-height: 15px;
  font-weight: inherit;
  color: #000;
}

/* Pointer */

.place-rows {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-left: 10px;
  gap: 6px;
  width: 100%;
  overflow: hidden;
  min-height: 0;
}

.place-row {
  display: flex;
  align-items: flex-start;
  padding: 1px 3px 0;
  cursor: pointer;
  border-radius: 0;
  transition: background var(--dur-quick) ease;
}

.place-row {
  display: flex;
  align-items: center;
}

.place-row:hover {
  background: #fff;
  border-radius: 5px;
}

.place-row--active .place-row-label {
  font-weight: 500;
}

.place-row--dark {
  color: #fff;
}

.place-row--dark:hover {
  background: rgba(255, 255, 255, 0.1);
}

.place-row-label {
  font-family: 'Fira Code', monospace;
  font-size: 10px;
  line-height: 12px;
  font-weight: 400;
  color: inherit;
}

/* Avatar */

.sidebar__avatar-wrap {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.sidebar__avatar {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__face {
  width: 20px;
  height: 20px;
  background: #000;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width var(--dur-quick) ease, height var(--dur-quick) ease;
}

.sidebar__avatar--hovered .sidebar__face {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.sidebar__avatar--active .sidebar__face {
  width: 24px;
  height: 24px;
}

.sidebar__acronym {
  font-family: 'Fira Code', monospace;
  font-size: 9px;
  line-height: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #fff;
  text-align: center;
  transition: font-size var(--dur-quick) ease;
}

.sidebar__avatar--hovered .sidebar__acronym {
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
}

.sidebar__avatar--active .sidebar__acronym {
  font-size: 14px;
  line-height: 17px;
  font-weight: 600;
}

/* Flyout */

.sidebar__flyout {
  position: absolute;
  left: 100%;
  top: 0;
  background: #000;
  border-radius: 8px 16px 16px 8px;
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 6px;
  white-space: nowrap;
}

.sidebar__notch {
  position: absolute;
  width: 15px;
  height: 17px;
  left: -15px;
  top: 11px;
  background: #000;
}

.sidebar__flyout-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Actions */

.sidebar__actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 15px;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  background: #F3F3F3;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: opacity var(--dur-base) ease;
}

.sidebar__actions--folded {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px 0;
  gap: 10px;
}

.sidebar--dimmed .sidebar__actions {
  opacity: 0;
}

.sidebar__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  cursor: pointer;
}

.sidebar__action-icon {
  width: 18px;
  height: 18px;
  opacity: 0.1;
}

.sidebar__chat-icon {
  width: 20px;
  height: 20px;
  background: #DBDBDB;
  border-radius: 5px;
}

/* selected place: 2px outer white stroke, uniform with the Person widget.
   The stroke width is constant and transparent when idle, so selection
   fades in by animating only the color. Softness everywhere: this is not
   an office CRM. */
.sidebar__header-label,
.place-row-label,
.sidebar__person-label {
  -webkit-text-stroke-width: 4px;
  -webkit-text-stroke-color: transparent;
  paint-order: stroke fill;
  transition: -webkit-text-stroke-color var(--dur-move) ease;
}

.sidebar__header--active .sidebar__header-label,
.place-row--active .place-row-label,
.sidebar__person--active .sidebar__person-label {
  -webkit-text-stroke-color: #fff;
}

.sidebar__header,
.place-row {
  transition: background var(--dur-base) ease;
}

/* a new business arrives on a stage: the place opens up empty,
   the business fades in at its center, the place settles to its height */
@keyframes sidebar-place {
  /* the place opens up softly to 150% of the row's real height
     (--arrive-h is measured on mount, multiline-aware), then the
     spring lives in the settle back to 100% */
  0%   { max-height: 0;
         animation-timing-function: var(--ease-out-quint); }
  55%  { max-height: calc(var(--arrive-h, 42px) * 1.5);
         animation-timing-function: var(--ease-out-back); }
  100% { max-height: var(--arrive-h, 42px); }
}

@keyframes sidebar-reveal {
  0%, 25% { opacity: 0;
            animation-timing-function: var(--ease-out-quint); }
  65%     { opacity: 1; }
  100%    { opacity: 1; }
}

.sidebar__group--arriving,
.place-row--arriving {
  overflow: hidden;
  animation: sidebar-place var(--dur-reveal);
}

/* a group stacks vertically (header + rows); a pointer keeps its base
   row (diamond + label) — column here would float the diamond above */
.sidebar__group--arriving {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sidebar__group--arriving > *,
.place-row--arriving > * {
  animation: sidebar-reveal var(--dur-reveal);
}


/* tiers: my affairs / the coop / wards */
.sidebar__tier-divider {
  height: 1px;
  background: rgba(26, 24, 20, 0.12);
  margin: 10px 12px;
}

/* outside the current place only the text breathes quieter:
   hovering brings back full black on a full white pad */
.sidebar__header-label,
.place-row-label {
  transition: opacity var(--dur-move) ease, -webkit-text-stroke-color var(--dur-move) ease;
}

.sidebar__group--dimmed .sidebar__header-label,
.sidebar__group--dimmed .place-row-label {
  opacity: 0.4;
}

.sidebar__group--dimmed .sidebar__header:hover .sidebar__header-label,
.sidebar__group--dimmed .place-row:hover .place-row-label {
  opacity: 1;
}

/* the shape language: a diamond is a project (the square at 45deg);
   the selection ring lives inside the SVG, stroke under fill */
.sidebar__diamond {
  flex: none;
  width: 6px;
  height: 6px;
  color: #111;
  margin-right: 7px;
  opacity: 0.4;
  transition: opacity var(--dur-base) ease,
              transform var(--dur-cross) var(--ease-out-back);
}

.sidebar__diamond polygon {
  stroke: transparent;
  stroke-width: 55;
  stroke-linejoin: miter;
  paint-order: stroke fill;
  transition: stroke var(--dur-move) ease;
}

.sidebar__diamond--grown {
  transform: scale(1.5);
}

.sidebar__diamond--unread {
  opacity: 1;
}

.place-row--active .sidebar__diamond {
  opacity: 1;
}

.place-row--active .sidebar__diamond polygon {
  stroke: #fff;
}

/* the people tier: a dot for the avatar, the name or the email */
.sidebar__person {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 3px 0;
  width: 100%;
  cursor: pointer;
}

.sidebar__person-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #111;
  opacity: 0.4;
  /* the growth is springy, the house style of arrivals */
  transition: opacity var(--dur-base) ease,
              transform var(--dur-cross) var(--ease-out-back);
}

.sidebar__person-label {
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  line-height: 15px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.4;
  transition: opacity var(--dur-quick) ease;
}

.sidebar__person:hover .sidebar__person-dot,
.sidebar__person--active .sidebar__person-dot,
.sidebar__person:hover .sidebar__person-label,
.sidebar__person--active .sidebar__person-label {
  opacity: 1;
}

/* size is the collective debt, color is the personal unread:
   read but awaiting an answer stays grown, only dimmed */
.sidebar__person--grown .sidebar__person-dot {
  transform: scale(1.5);
}

.sidebar__person--unread .sidebar__person-dot {
  opacity: 1;
}

.sidebar__person--active .sidebar__person-label {
  font-weight: 500;
}

.sidebar__person--active .sidebar__person-dot {
  box-shadow: 0 0 0 3px #fff;
}

/* the shape language: a square is a business (the future avatar) */
.sidebar__square {
  flex: none;
  width: 6px;
  height: 6px;
  background: #111;
  margin-right: 6px;
  opacity: 0.4;
  transition: opacity var(--dur-base) ease,
              transform var(--dur-cross) var(--ease-out-back);
}

.sidebar__square--grown {
  transform: scale(1.5);
}

.sidebar__square--unread {
  opacity: 1;
}

.sidebar__header--active .sidebar__square {
  box-shadow: 0 0 0 3px #fff;
}

