/*
  Projects module (/projects): the Table | Board switch, the board and its
  cards, and the Projects drawer (issues, projects, members, statuses).
  Uses the shared theme tokens only, so light and dark mode follow the app.
  Kept in its own file because it is a self-contained module; the table,
  toolbar and drawer chrome come from application.css.
*/

/* ---- Drawer: medium width (style guide: drawers) ---------------------- */

.projects-drawer {
  z-index: 120;
  --tickets-compact-control-height: 24px;
}

.projects-drawer .canned-response-drawer__panel {
  width: var(--drawer-width-medium);
  max-width: var(--drawer-width-medium);
}

/* The stacked project drawer sits over the issue drawer (120) and under
   History, multi-edit and merge (130). */
.projects-stack-drawer {
  z-index: 125;
}

/* Drawers opened over the Projects page (issue history on top of the issue
   drawer; multi-edit and merge from the table) sit above the projects drawer. */
.projects-index .ticket-history-drawer,
.projects-index .bulk-edit-tickets-drawer,
.projects-index .merge-tickets-drawer {
  z-index: 130;
}

.projects-drawer .button {
  min-height: var(--tickets-compact-control-height);
}

/* ---- Toolbar ---------------------------------------------------------- */

/* Table | Board: two module-size icon buttons joined into one control. The
   current layout uses the "on" tint the guide gives icon buttons. */
.projects-layout-toggle {
  display: inline-flex;
}

.projects-layout-toggle__option:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.projects-layout-toggle__option + .projects-layout-toggle__option {
  margin-left: -1px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Columns dropdown in the board's row: room for its longest choice
   ("Assignee"). */
.projects-board-columns-switcher {
  --index-control-width: 7.5rem;
}

.projects-layout-toggle__option--on {
  color: var(--badge-solution-text);
  background: color-mix(in srgb, var(--badge-solution-text) 12%, var(--surface));
  position: relative;
  z-index: 1;
}

/* ---- Small pieces shared by table, board and drawer -------------------- */

.issue-type {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.issue-type-icon {
  flex: none;
  color: var(--muted);
}

/* Each type's colour comes from its Manage types setting (inline style). */

/* Drawer form fields fill their column. The select enhancer pins each
   dropdown's min-width to the width it had when enhanced; in a drawer that
   width can be wider than the final column (a scrollbar appears once the
   content loads, or the window is resized), leaving Assignee, Parent and the
   like sticking out past the other inputs. */
.projects-drawer .ticket-details-field .custom-select {
  min-width: 0 !important;
  width: 100%;
}

.projects-drawer .ticket-details-field .priority-color-picker {
  width: 100%;
}

/* Icon in place of the colour block in the Type dropdown (priority-color-picker). */
.priority-color-picker__icon {
  display: inline-flex;
  align-items: center;
  flex: none;
  min-width: 14px;
}

.issue-labels {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.issue-label {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1.4;
}

button.issue-label--suggestion {
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
}

button.issue-label--suggestion:hover {
  border-color: var(--primary);
}

.issues-table__key {
  white-space: nowrap;
}

/* ---- Board ------------------------------------------------------------ */

/* The board's row of tools above the board, which fills the rest. */
.projects-index--board #projects-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* The Projects control row (issues/_control_row) on the table and board:
   Project, Columns (board) and Labels. Shared look: .control-row. */
/* No top padding: the captions sit the page head's 16px below its line,
   the same distance as a table's column headers on Tickets. */
.projects-control-row {
  padding: 0 0 0.5rem;
}

/* The hierarchy's Levels and Completed fields share one controller
   (hierarchy-tools); the wrapper stays out of the row's layout. */
.projects-hierarchy-tools {
  display: contents;
}

/* Labels: room for a few chips and the placeholder, not the rest of the row
   (halved by request; it was about twice as wide as needed). */
.projects-labels-filter {
  flex: 0 1 16rem;
  width: 16rem;
  min-width: 12rem;
}

.projects-board {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  overflow-x: auto;
  padding: 0.25rem 0 0.75rem;
  flex: 1;
  min-height: 0;
}

/* Board column fill. Light mode: "frosted" — see-through white over the page
   background, so a column is always a lighter shade of whichever background
   colour the person picked (cream on the default Dune). The shared
   --bg-subtle grey clashed with the warm Dune default. Frosting only works
   on the page background, not on white surfaces, so it stays a board token
   rather than replacing --bg-subtle. Dark mode keeps --bg-subtle as before. */
:root {
  --board-column-bg: rgba(255, 255, 255, 0.42);
  --board-column-border: rgba(255, 255, 255, 0.75);
  --board-column-divider: rgba(0, 0, 0, 0.06);
}

/* Porcelain is already white, so frosting would hide the columns. */
html[data-user-theme-color="porcelain"] {
  --board-column-bg: color-mix(in srgb, var(--bg), black 4%);
  --board-column-border: var(--border);
  --board-column-divider: var(--border);
}

/* Dark mode (OS setting or chosen): unchanged. These come after the
   Porcelain rule so they win over it in dark mode. */
@media (prefers-color-scheme: dark) {
  html:not([data-user-theme="light"]) {
    --board-column-bg: var(--bg-subtle);
    --board-column-border: var(--border);
    --board-column-divider: var(--border);
  }
}

html[data-user-theme="dark"] {
  --board-column-bg: var(--bg-subtle);
  --board-column-border: var(--border);
  --board-column-divider: var(--border);
}

.projects-board__column {
  flex: 0 0 17rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--board-column-bg);
  border: 1px solid var(--board-column-border);
  border-radius: 8px;
}

.projects-board__column-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--board-column-divider);
}

/* Column headers are the handle for dragging a column sideways. */
.projects-board__column-head[draggable="true"] {
  cursor: grab;
}

.projects-board__column-head[draggable="true"]:active {
  cursor: grabbing;
}

.projects-board__column--dragging {
  opacity: 0.5;
}

.projects-board__swatch {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--ticket-status-badge-color, var(--muted));
  flex: none;
}

.projects-board__type-icon {
  display: inline-flex;
  align-items: center;
  flex: none;
}

.projects-board__column-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.projects-board__count {
  font-size: 0.8rem;
  color: var(--muted);
}

.projects-board__add.button--icon-only {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
}

.projects-board__cards {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 4rem;
  border-radius: 0 0 8px 8px;
}

.projects-board__cards--over {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.projects-board__empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.75rem 0;
}

.projects-board__more {
  margin: 0;
  padding: 0 0.6rem 0.5rem;
  font-size: 0.8rem;
}

.projects-board__card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.projects-board__card--draggable {
  cursor: grab;
}

/* Finished issues step back so open work stands out; hovering, focusing or
   ticking one brings it back to full strength. Same as hierarchy tiles. */
.projects-board__card--finished {
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.projects-board__card--finished:hover,
.projects-board__card--finished:focus-within,
.projects-board__card--finished:has(> .projects-board__card-check:checked) {
  opacity: 1;
}

.projects-board__card--dragging {
  opacity: 0.5;
}

/* Selected cards (by checkbox, or the card a right-click menu acts on). */
.projects-board__card:has(> .projects-board__card-check:checked) {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

/* Selection checkbox, upper-right corner. Out of sight until the card is
   hovered or focused; once anything on the board is selected every card
   shows it, so adding to a selection needs no hunting. Touch screens (no
   hover) always show it. */
.projects-board__card-check {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.projects-board__card:hover > .projects-board__card-check,
.projects-board__card:focus-within > .projects-board__card-check,
.projects-board__card-check:checked,
.projects-board:has(.projects-board__card-check:checked) .projects-board__card-check {
  opacity: 1;
}

.projects-board__card-link {
  color: var(--text);
  text-decoration: none;
  /* Room for the checkbox in the corner. */
  padding-right: 1.25rem;
}

.projects-board__card-link:hover .projects-board__card-title {
  text-decoration: underline;
}

.projects-board__card-title {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* Description peek: hidden until the card's peek button opens it, then at
   most four lines. */
.projects-board__card-description {
  display: none;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.projects-board__card--expanded .projects-board__card-description {
  display: -webkit-box;
}

.projects-board__card-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}

/* Bottom row: key bottom-left, assignee bottom-right. */
.projects-board__card-foot {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.projects-board__card-key {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
  white-space: nowrap;
}

/* The peek button: a small ghost glyph (no border, unlike toolbar icon
   buttons) so it doesn't crowd the card. Out of sight until the card is
   hovered or focused; stays visible, tinted "on", while open. */
.projects-board__card-peek {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.projects-board__card-peek:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.projects-board__card:hover .projects-board__card-peek,
.projects-board__card-peek:focus-visible,
.projects-board__card--expanded .projects-board__card-peek {
  opacity: 1;
}

.projects-board__card--expanded .projects-board__card-peek {
  color: var(--badge-solution-text);
  background: color-mix(in srgb, var(--badge-solution-text) 12%, var(--surface));
}

/* Touch screens can't hover, so they always show both. (Pointer check too:
   headless test browsers report no hover but have no touch.) */
@media (hover: none) and (pointer: coarse) {
  .projects-board__card-check,
  .projects-board__card-peek {
    opacity: 1;
  }
}

.projects-board__card-estimate {
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--muted);
}

.projects-board__card-assignee {
  margin-left: auto;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Hierarchy -------------------------------------------------------- */
/* Issues as trees through their Parent field (issues/_hierarchy.html.erb):
   one frosted lane per top-level issue, sub-issues branching to the right.
   The connector lines are borders on each branch: every tile's "anchor" sits
   --tree-anchor below its top (the middle of its key row), so a parent's
   stub and its children's elbows meet at the same height without any
   measuring in JavaScript. */

/* The progress bar's three colours, shared by the hierarchy and the issue
   drawer's "Issues in this epic" bar (.issue-children-progress). */
.projects-tree,
/* Attachment lists in comments and the read-only issue view. */
.issue-attachments {
  list-style: none;
  margin: 0 0 0.4rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.issue-attachments__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* The issue drawer's Attachments row: the ticket reply drop zone
   (shared/_attachments_dropzone) with Choose... beside it, like tickets. */
.issue-form__attachments .form__field--attachments-controls {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.issue-form__attachments .message-form__file-browse {
  white-space: nowrap;
}

/* A saved file's pill downloads it: text colour, underline on hover. */
.issue-form__attachments a.message-form__attachments-name {
  color: inherit;
  text-decoration: none;
}

.issue-form__attachments a.message-form__attachments-name:hover,
.issue-form__attachments a.message-form__attachments-name:focus-visible {
  color: var(--primary);
  text-decoration: underline;
}

.issue-children-progress {
  --tree-done: var(--badge-solution-text);
  /* Mixed with the tile colour (not see-through) so the three parts stay
     distinct in light and dark: dark green, a lighter brand tint, grey. */
  --tree-active: color-mix(in srgb, var(--primary) 50%, var(--surface));
  --tree-todo: color-mix(in srgb, var(--muted) 30%, var(--surface));
}

.projects-tree {
  --tree-anchor: 1.2rem;
  --tree-gap: 1.25rem;
  --tree-line: color-mix(in srgb, var(--muted) 55%, transparent);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0.25rem 0 0.75rem;
  scroll-padding-bottom: var(--tree-sticky-bottom, 0px);
}

.projects-tree__project {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.projects-tree__lane {
  background: var(--board-column-bg);
  border: 1px solid var(--board-column-border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow-x: auto;
}

/* ---- Nodes and connector lines ---- */

.projects-tree__node {
  display: flex;
  align-items: flex-start;
}

.projects-tree__children {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--tree-gap);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* The stub from the parent tile to its children's trunk. */
.projects-tree__children::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--tree-anchor);
  width: var(--tree-gap);
  border-top: 2px solid var(--tree-line);
}

.projects-tree__branch {
  position: relative;
  padding: 0 0 0.6rem var(--tree-gap);
}

.projects-tree__branch--last {
  padding-bottom: 0;
}

/* Horizontal line into this child's tile. */
.projects-tree__branch::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--tree-anchor);
  width: var(--tree-gap);
  border-top: 2px solid var(--tree-line);
}

/* The trunk: runs down the whole branch, from the first child's anchor... */
.projects-tree__branch::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-left: 2px solid var(--tree-line);
}

.projects-tree__branch--first::after {
  top: var(--tree-anchor);
}

/* ...to a rounded elbow into the last child. --first / --last are set by
   the server and moved by Hide completed (project_hierarchy_controller.js)
   onto the first and last tiles still showing. Classes, not
   :nth-child(… of :not([hidden])), which some browsers drew as if every
   branch were an only child (no trunks). */
.projects-tree__branch--last::before {
  display: none;
}

.projects-tree__branch--last::after {
  top: 0;
  bottom: auto;
  width: var(--tree-gap);
  height: calc(var(--tree-anchor) + 2px);
  border-bottom: 2px solid var(--tree-line);
  border-bottom-left-radius: 8px;
}

/* A single child: one straight line. */
.projects-tree__branch--first.projects-tree__branch--last::before {
  display: block;
}

.projects-tree__branch--first.projects-tree__branch--last::after {
  display: none;
}

.projects-tree__node--collapsed > .projects-tree__children {
  display: none;
}

/* Hide completed (project_hierarchy_controller.js) sets `hidden` on lanes,
   branches, loose tiles, emptied columns and fold buttons; several of those
   set their own display, so make hidden win. */
.projects-tree [hidden] {
  display: none !important;
}

.projects-tree__none {
  margin: 0;
  padding: 0.6rem 0 0 var(--tree-gap);
  font-size: 0.85rem;
  max-width: 22rem;
}

/* ---- Tiles ---- */

.projects-tree__tile {
  position: relative;
  flex: none;
  width: 15rem;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tile-accent, var(--border));
  border-radius: 8px;
  padding: 0.55rem 0.6rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 6%, transparent);
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
}

.projects-tree__tile:hover {
  box-shadow: 0 3px 10px color-mix(in srgb, var(--text) 12%, transparent);
}

.projects-tree__tile--root {
  width: 18rem;
}

.projects-tree__tile--draggable {
  cursor: grab;
}

.projects-tree__tile--dragging {
  opacity: 0.5;
}

/* Finished issues step back so open work stands out (full strength on
   hover or focus), like finished board cards. Comes before --faded so a
   tile that is both stays at the fainter level. */
.projects-tree__tile--finished {
  opacity: 0.55;
}

.projects-tree__tile--finished:hover,
.projects-tree__tile--finished:focus-within {
  opacity: 1;
}

/* In the family of a match, but not a match itself. */
.projects-tree__tile--faded {
  opacity: 0.45;
}

.projects-tree__tile--faded:hover,
.projects-tree__tile--faded:focus-within {
  opacity: 0.85;
}

/* While dragging: where the tile may land, and where it is now. */
.projects-tree__tile--droppable {
  outline: 2px dashed color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 2px;
}

.projects-tree__tile--over {
  outline: 2px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

/* The drag magnet (project_hierarchy_controller.js): a dashed --primary
   curve from the tile it would land under to the pointer, dots at both
   ends, and a small tag naming the new parent. Fixed to the viewport and
   click-through, so it never gets in the way of the drop. */
.projects-tree__magnet {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.projects-tree__magnet[hidden] {
  display: none;
}

.projects-tree__magnet-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.projects-tree__magnet-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 6 5;
  animation: projects-tree-magnet 0.6s linear infinite;
}

/* Landing preview: where the dragged tile will appear. A ghost tile (its
   first sub-issue spot, or below the column when it sorts last): a faint
   copy with the dragged issue's key and title, dashed --primary border on a
   10% --primary tint, tile radius. A bar (it sorts in between): a 4px
   --primary pill in the gap above the sibling it goes before. Either is
   joined to the parent's lines by a still, dashed connector. */
.projects-tree__magnet-ghost {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.6rem;
  overflow: hidden;
  border: 2px dashed var(--primary);
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}

.projects-tree__magnet-ghost-key {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.projects-tree__magnet-ghost-title {
  overflow: hidden;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.projects-tree__magnet-bar {
  position: absolute;
  border-radius: 999px;
  background: var(--primary);
}

.projects-tree__magnet-ghost[hidden],
.projects-tree__magnet-bar[hidden] {
  display: none;
}

.projects-tree__magnet-link {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-dasharray: 4 4;
}

.projects-tree__magnet-dot {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 2;
}

.projects-tree__magnet-label {
  position: absolute;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--text) 18%, transparent);
}

@keyframes projects-tree-magnet {
  to { stroke-dashoffset: -11; }
}

@media (prefers-reduced-motion: reduce) {
  .projects-tree__magnet-line {
    animation: none;
  }
}

/* Just dropped: two quick --primary rings, then gone, so the eye finds
   where the tile landed (project_hierarchy_controller.js adds the class for
   a moment after a drop). Reduced motion gets a steady outline instead. */
.projects-tree__tile--landed {
  animation: projects-tree-landed 2.2s ease-out;
}

@keyframes projects-tree-landed {
  0% { box-shadow: 0 0 0 3px var(--primary); }
  22% { box-shadow: 0 0 0 3px transparent; }
  45% { box-shadow: 0 0 0 3px var(--primary); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .projects-tree__tile--landed {
    animation: none;
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }
}

/* While the right-click menu is open, outline the tile it acts on. */
.projects-index:has(.ticket-context-menu.is-open) .projects-tree__tile:has(> input:checked) {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.projects-tree__tile-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.projects-tree__tile-key {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
}

.projects-tree__check {
  display: inline-flex;
  color: var(--tree-done);
}

.projects-tree__points {
  margin-left: auto;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The whole tile opens the drawer: the title link stretches over it. */
.projects-tree__tile-link {
  color: var(--text);
  text-decoration: none;
}

.projects-tree__tile-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

/* Tile description: hidden until the control row's Descriptions is All
   (hierarchy_descriptions_controller.js), then at most three lines, like the
   board's card peek. */
.projects-tree__tile-description {
  display: none;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.projects-tree--descriptions .projects-tree__tile-description {
  display: -webkit-box;
}

.projects-tree__tile-link:hover .projects-tree__tile-title {
  text-decoration: underline;
}

.projects-tree__tile-link:focus-visible {
  outline: none;
}

.projects-tree__tile-link:focus-visible::after {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.projects-tree__tile-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.projects-tree__tile--root .projects-tree__tile-title {
  font-size: 1rem;
  font-weight: 600;
}

.projects-tree__tile--finished .projects-tree__tile-title {
  color: var(--muted);
}

.projects-tree__tile-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.projects-tree__assignee {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fold and + sit above the stretched link. */
.projects-tree__tile-tools {
  position: relative;
  z-index: 1;
  display: inline-flex;
  gap: 0.25rem;
  flex: none;
}

.projects-tree__tile-tools .button--icon-only {
  height: 24px;
  min-height: 24px;
  min-width: 24px;
  padding: 0 0.25rem;
  gap: 0.1rem;
}

.projects-tree__fold svg {
  transition: transform 0.15s ease;
  transform: rotate(90deg);
}

.projects-tree__node--collapsed > .projects-tree__tile .projects-tree__fold svg {
  transform: none;
}

.projects-tree__fold-count {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* ---- Progress ---- */

.projects-tree__tile-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.projects-tree__progress {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.projects-tree__bar {
  flex: 1;
  display: flex;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.projects-tree__bar-seg {
  display: block;
  height: 100%;
}

.projects-tree__bar-seg--done {
  background: var(--tree-done);
}

.projects-tree__bar-seg--active {
  background: var(--tree-active);
}

.projects-tree__bar-seg--todo {
  background: var(--tree-todo);
}

.projects-tree__percent {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.projects-tree__progress--large .projects-tree__bar {
  height: 0.6rem;
}

.projects-tree__progress--large .projects-tree__percent {
  font-size: 1.1rem;
}

.projects-tree__share {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ---- "Not in an epic" ---- */

/* "Not in an epic" sticks to the bottom of the tree's scroll box (within
   its project), so there is always somewhere to drop an issue to take it
   out of its epic. Solid background (the lane colour over --bg) and a soft
   upward shadow, since lanes scroll under it; capped in height, with its
   tiles scrolling inside it under a fixed title. The script sets
   --tree-sticky-bottom to its height so scrolling to a tile stops above it. */
.projects-tree__lane--loose {
  position: sticky;
  /* Past the tree's own bottom padding, so nothing shows beneath it. */
  bottom: -0.75rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  max-height: min(40vh, 17rem);
  overflow: hidden;
  background: linear-gradient(var(--board-column-bg), var(--board-column-bg)), var(--bg);
  box-shadow: 0 -6px 16px -10px color-mix(in srgb, var(--text) 35%, transparent);
}

.projects-tree__lane--loose .projects-tree__loose-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px;
  margin: -2px;
}

.projects-tree__loose-title {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.projects-tree__loose-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.5rem;
}

/* Each tile fills its grid cell and wraps its title, rather than sizing to
   the title on one line (which overlapped the next tile). */
.projects-tree__loose-grid .projects-tree__node {
  display: block;
  min-width: 0;
}

.projects-tree__loose-grid .projects-tree__tile {
  width: 100%;
  height: 100%;
}

.projects-tree__loose-empty {
  margin: 0;
  font-size: 0.85rem;
}

.projects-tree__lane--droppable {
  outline: 2px dashed color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 2px;
}

.projects-tree__lane--over {
  background: color-mix(in srgb, var(--primary) 8%, var(--board-column-bg));
}

/* ---- Issue drawer ------------------------------------------------------ */

.issue-drawer__key {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.issue-drawer__section {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* A section right after form rows: the last row's bottom border is the
   divider, so the section's own top line would double it. */
.issue-drawer__section--flush {
  border-top: 0;
}

.project-form__workspace {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.issue-drawer__section-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

/* Points (issues/_points_field): a narrow box; its suggestion list may be
   a little wider so numbers never wrap. */
.issue-points-input {
  max-width: 7rem;
}

.issue-points-input .suggest-input__list {
  min-width: 7rem;
}

/* Description row: label in the left column, the editor (full width of the
   right column) with the attachment list and file picker under it. */
.issue-form__description .form__field--message-editor {
  width: 100%;
}

.issue-form__description .ticket-details-field__label {
  padding-top: 0.35rem;
}

.issue-rich-text {
  overflow-wrap: anywhere;
}

.issue-rich-text img {
  max-width: 100%;
  height: auto;
}

/* Labels field (issues/_labels_field, label_chips_controller): the Watchers
   chip box, tinted like the drawer's other inputs, with light chips on it. */
.label-chips {
  background: var(--bg);
}

.label-chips .recipient-chips__chip {
  background: var(--surface);
  cursor: default;
}

.label-chips .requester-picker__suggestions {
  max-height: 14rem;
  overflow-y: auto;
}

/* "Issues in this epic" (issues/_children): the hierarchy's progress bar
   (shared colours above) with the "4/10 pts" note, then a Simple table.
   Key, Assignee, Points and Status fit their content and never wrap; Title
   takes the rest. */
.issue-children-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.issue-children-progress__points {
  flex: none;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.issue-children-table {
  margin-top: 0.25rem;
}

.issue-children-table th.issue-children-table__fit,
.issue-children-table td.issue-children-table__fit {
  white-space: nowrap;
}

.issue-children-table th,
.issue-children-table td {
  vertical-align: middle;
}

.issue-children-table .sortable-table__sort,
.issue-children-table__key {
  white-space: nowrap;
}

.issue-children-table__title {
  width: 100%;
  overflow-wrap: anywhere;
}

.issue-children-table th.issue-children-table__num,
.issue-children-table td.issue-children-table__num {
  text-align: right;
  white-space: nowrap;
}

.issue-comments,
.issue-history {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.issue-comments__item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
}

.issue-comments__meta,
.issue-history__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.issue-comments__meta form {
  margin-left: auto;
}

/* Comments row: same two columns as the issue form rows. The heading takes
   the label's look; the thread, the Add comment button and (once revealed)
   the editor fill the value column. */
.issue-comments-row {
  border-bottom: 0;
}

.issue-comments-row__label {
  margin: 0;
  padding-top: 0.35rem;
  font-size: inherit;
  font-weight: inherit;
}

.issue-comments-row__value {
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.issue-comments-row__value > *,
.issue-comment-composer > [data-comment-reveal-target="slot"] {
  width: 100%;
  margin: 0;
}

.issue-comment-composer > .button {
  align-self: flex-start;
}

/* .button sets display, which would otherwise beat the hidden attribute. */
.issue-comment-composer > .button[hidden] {
  display: none;
}

.issue-comment-composer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.issue-comment-form__buttons {
  display: inline-flex;
  gap: 0.5rem;
}

.issue-comment-form__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* The compact drop zone (no Choose...) takes the row's free space; Cancel
   and Comment keep their place on the right. */
.issue-comment-form__actions .form__field--attachments-controls {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}

.issue-comment-form__buttons {
  flex: none;
}

.issue-history__changes {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.issue-history__field {
  color: var(--muted);
}

/* ---- Project drawer: members and statuses ----------------------------- */

.projects-key-input {
  max-width: 8rem;
  text-transform: uppercase;
}

.projects-archive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.projects-manage-table {
  width: 100%;
  margin-top: 0.5rem;
}

/* Sortable headers use the shared .sortable-table__sort look (application.css). */
.projects-manage-table .sortable-table__sort {
  text-decoration: none;
  white-space: nowrap;
}

.projects-manage-table th.projects-manage-table__num,
.projects-manage-table td.projects-manage-table__num {
  text-align: right;
}

/* Members: a Simple table (docs/typography.md). "Add member" sits on the
   heading row and opens a row at the bottom (projects/_members,
   project_members_controller). */
.project-members {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Heading left, Add member right. Keeps the button's height while it is
   hidden so the table below doesn't jump. */
.project-members__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--tickets-compact-control-height);
}

.project-members__head .issue-drawer__section-title {
  margin: 0;
}

/* .button sets its own display, which would beat the hidden attribute. */
.project-members__head .button[hidden] {
  display: none;
}

/* Fixed columns: opening the add row (Add + Cancel, the person picker) must
   not reflow the table. Member takes what Role and the buttons leave. */
.project-members-table {
  table-layout: fixed;
}

.project-members-table th,
.project-members-table td {
  vertical-align: middle;
}

/* Fits the longest role ("Contributor") with the dropdown caret. */
.project-members-table th.project-members-table__role {
  width: 10rem;
}

/* Room for Add + Cancel, so Remove rows and the add row line up. */
.project-members-table th.project-members-table__actions {
  width: 10rem;
}

.project-members-table td.project-members-table__actions {
  white-space: nowrap;
  text-align: right;
}

.project-members-table__name {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.project-members-table__role-form {
  margin: 0;
}

/* Pickers fill their column and never push it wider (the custom dropdown
   copies the select's first width onto itself as an inline min-width). */
.project-members-table .ticket-details-field__input {
  width: 100%;
  min-width: 0;
}

.project-members-table .custom-select {
  min-width: 0 !important;
}

.project-members-table__add-actions {
  display: inline-flex;
  gap: 0.35rem;
}

/* The member rows' last line is dropped (.table), so the add row draws its
   own, and a faint tint marks it as the row being filled in. */
.project-members-table__add-body td {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--primary) 4%, transparent);
}

.project-members__add-form {
  display: none;
}

.project-status-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.project-status-list__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  cursor: grab;
}

.project-status-list__grip {
  color: var(--muted);
  letter-spacing: -0.2em;
}

.project-status-list__count {
  font-size: 0.8rem;
  white-space: nowrap;
}

.project-status-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

.project-status-row .ticket-details-field__input {
  min-width: 0;
}

/* Priorities drawer: the Default badge and Make default button share one
   fixed-width slot so the name fields line up. */
.project-priority-default-slot {
  flex: 0 0 7.5rem;
  display: flex;
  justify-content: center;
}

/* Manage types: icon button with a grid of icons under it, and the Epic tick. */
.issue-type-icon-picker {
  position: relative;
  display: inline-flex;
}

.issue-type-icon-picker__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(6, 2rem);
  gap: 0.25rem;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.issue-type-icon-picker__panel[hidden] {
  display: none;
}

.issue-type-icon-picker__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.issue-type-icon-picker__option:hover,
.issue-type-icon-picker__option:focus-visible {
  background: var(--bg);
  outline: none;
}

.issue-type-icon-picker__option[aria-checked="true"] {
  border-color: var(--primary);
}

.issue-type-epic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  font-size: 0.9rem;
}

.project-status-row__color {
  width: 2rem;
  height: var(--tickets-compact-control-height);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  flex: none;
}

/* Field + hint stacked in one drawer row (the hint sits under the control). */
.issue-form__stack {
  gap: 0.25rem;
  padding: 0.25rem 0;
}

.issue-form__stack > .ticket-details-field__input,
.issue-form__stack > .custom-select,
.issue-form__stack > .ticket-details-field__hint {
  width: 100%;
  margin: 0;
}

/* Row whose control has extra content under it (hint, label chips): line the
   label's text up with the text inside the first control, as the plain
   centred rows do, instead of with the middle or top of the whole stack. */
.ticket-details-field.issue-form__stack-row {
  align-items: baseline;
}

/* Keep the page-head title group from being squeezed by the centre controls. */
.projects-index .page-head__left {
  flex-shrink: 0;
}

.projects-index .page-head__left .button {
  white-space: nowrap;
}

.projects-project-switcher .ticket-view-switcher__select {
  max-width: 14rem;
}

/* The centre carries Project, View, search and the layout switch, so the side
   groups size to their content and the centre takes the rest (the shared
   1fr / auto / 1fr split lets a wide left group run into it). */
.projects-index .page-head:has(.filter-form--tickets-index) {
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 1rem;
}

/* When the centre group is wider than its column (Project + View + search +
   Table/Board at medium widths or larger text), wrap it onto a second line
   inside its column rather than letting it spill over New issue on the left
   and the icon tools on the right. */
.projects-index .page-head:has(.filter-form--tickets-index) .page-head__center {
  justify-self: stretch;
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 0.5rem;
}

/* Starting widths so short headers are not clipped; a width someone saves by
   dragging a column edge is written inline and wins. */
.projects-index th[data-column-key="key"] { min-width: 6.5rem; }
.projects-index th[data-column-key="title"] { min-width: 16rem; }
.projects-index th[data-column-key="issue_type"] { min-width: 6.5rem; }
.projects-index th[data-column-key="status"] { min-width: 8rem; }
.projects-index th[data-column-key="priority"] { min-width: 7rem; }
.projects-index th[data-column-key="requester"] { min-width: 9rem; }
.projects-index th[data-column-key="labels"] { min-width: 7rem; }
.projects-index th[data-column-key="estimate"] { min-width: 6.5rem; }
.projects-index th[data-column-key="parent"] { min-width: 6.5rem; }
.projects-index th[data-column-key="updated_at"] { min-width: 8rem; }
