@import url("/procore-tokens.css");

/*
 * Gantt styling, entirely in Procore's captured tokens so the component sits
 * inside their UI without a seam.
 *
 * Layout: a fixed left pane and a horizontally scrolling right pane, sharing
 * one vertical scroll container so the two can never drift out of alignment.
 */

.gantt {
  position: relative;
  font-family: var(--pc-font);
  font-size: var(--pc-font-size);
  color: var(--pc-text);
  border: 1px solid var(--pc-border);
  border-radius: 0;
  overflow: hidden;
  background: var(--pc-surface);
}

.gantt-splitter {
  position: absolute;
  inset: 0 auto 0 calc(var(--gantt-left-width, 620px) - 4px);
  width: 8px;
  z-index: 5;
  cursor: col-resize;
  touch-action: none;
}
.gantt-splitter:hover, .gantt-splitter:focus-visible {
  background: var(--pc-focus);
  outline: 1px solid var(--pc-orange);
}
.gantt-weekend {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgb(35 39 41 / 6%);
}

/* Header ------------------------------------------------------------- */

.gantt-head {
  display: flex;
  height: var(--pc-header-height);
  background: var(--pc-surface-header);
  border-bottom: 1px solid var(--pc-border);
  color: #000;
}

.gantt-head-left {
  flex: 0 0 var(--gantt-left-width, 620px);
  display: flex;
  align-items: center;
  padding: var(--pc-cell-padding);
  border-right: 1px solid var(--pc-border);
  box-sizing: border-box;
}

.gantt-head-right {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Column headings, aligned to the row layout below them. */
.gantt-head-left > span {
  font-size: var(--pc-font-size-small);
  font-weight: 700;
  white-space: nowrap;
}

.gantt-head-left .h-name {
  flex: 1;
}

.gantt-head-left .h-pct {
  flex: none;
  width: var(--pc-dial-size);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-head-left .h-start {
  flex: none;
  width: 82px;
  margin-left: 6px;
}

.gantt-head-left .h-status {
  flex: none;
  width: 76px;
}

.gantt-head-left .h-num {
  flex: none;
  width: 64px;
  text-align: right;
}

.gantt-ticks {
  position: absolute;
  inset: 0;
  will-change: transform;
}

/* Two tiers, as Procore has: year above, period below. */
.gantt-tier {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--pc-header-tier);
}

.gantt-tier.top {
  top: 0;
  border-bottom: 1px solid var(--pc-rule);
}

.gantt-tier.bottom {
  top: var(--pc-header-tier);
}

.gantt-tick-year {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--pc-rule);
  font-size: var(--pc-font-size-small);
  font-weight: 700;
  color: #000;
}

.gantt-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid transparent;
  padding-left: 6px;
  font-size: var(--pc-font-size-small);
  font-weight: 600;
  color: var(--pc-text-grid);
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.gantt-tick.major {
  border-left-color: var(--pc-rule);
}

/* Grid lines and today marker, behind the bars ----------------------- */

.gantt-chrome {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.gantt-gridline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--pc-surface-alt);
}

.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--pc-today);
  z-index: 2;
}

/* Body --------------------------------------------------------------- */

.gantt-body {
  display: flex;
  /* Fill the Procore frame below the top bar and toolbar, as their tools do. */
  height: var(--gantt-height, max(320px, calc(100vh - 370px)));
  overflow-y: auto;
  overflow-x: hidden;
  /* Not stretch: a stretched pane is only as tall as the visible box, so the
     column divider (the left pane's border) and the today line and grid lines
     (sized to the right pane) stopped at the first screenful while the rows
     scrolled on past them. Panes take their content's height instead, and
     min-height keeps them full height when there are only a few rows. */
  align-items: flex-start;
}

.gantt-body > .gantt-pane-left,
.gantt-body > .gantt-pane-right {
  min-height: 100%;
}

.gantt-body:focus-visible {
  outline: 2px solid var(--pc-focus);
  outline-offset: -2px;
}

.gantt-pane-left {
  flex: 0 0 var(--gantt-left-width, 620px);
  border-right: 1px solid var(--pc-border);
  /* min-width:0 stops the rows pushing the pane past its flex-basis, which
     is what knocks the body divider out of line with the header divider.
     NOT overflow:hidden — clipping here also clips vertically, and then the
     pane never reports its true height so .gantt-body has nothing to
     scroll. Rows clip their own content instead. */
  min-width: 0;
  box-sizing: border-box;
}

.gantt-pane-right {
  flex: 1;
  min-width: 0;
  position: relative;
  /* No overflow of its own. The axis always spans the visible width, so
     there is nothing to scroll horizontally, and asking for overflow-x here
     would force vertical clipping too (CSS refuses one visible axis when the
     other is not). */
}

.gantt-bars {
  position: relative;
  min-width: 100%;
  z-index: 1;
}

/* Dependency lines sit between the grid chrome and the bars, so a line can
   pass under a bar rather than over it, exactly as Procore's do. */
.gantt-deps {
  position: absolute;
  left: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.gantt-dep {
  fill: none;
  stroke: var(--pc-dep-stroke);
  stroke-width: var(--pc-dep-width);
}

/* Rows --------------------------------------------------------------- */

.gantt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--pc-cell-padding);
  border-bottom: 1px solid var(--pc-rule);
  cursor: pointer;
  box-sizing: border-box;
  /* Each row clips its own overflow, so the PANE never has to — which keeps
     the pane's height honest and the body scrollable. */
  overflow: hidden;
}

.gantt-row:hover {
  background: var(--pc-orange-wash);
}

/* Parent rows read as a band, as PTF's programme summary rows do. */
.gantt-row.summary {
  background: var(--pc-surface-summary);
}

/* Translucent on the timeline, so grid lines and today show through. */
.gantt-barrow.summary {
  background: rgb(35 39 41 / 5%);
}

.gantt-row.summary:hover {
  background: var(--pc-orange-wash);
}

.gantt-indent {
  flex: none;
}

.gantt-twisty {
  flex: none;
  width: 24px;
  min-height: 0;
  height: 24px;
  padding: 0;
  line-height: 1;
  font-size: 16px;
  font-weight: 400;
  color: var(--pc-text-muted);
  background: transparent;
  border: none;
  border-radius: var(--pc-radius);
  cursor: pointer;
}

.gantt-twisty:hover {
  color: var(--pc-text);
  background: var(--pc-surface-header);
}

.gantt-twisty-spacer {
  flex: none;
  width: 24px;
}

.gantt-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A project reads as the heading of its group; activities are plain. */
.gantt-label.kind-project {
  font-weight: 700;
}

.gantt-row.summary .gantt-label {
  font-weight: 600;
}

.gantt-label.kind-milestone {
  color: var(--pc-text);
}

.gantt-label.kind-activity {
  color: var(--pc-text-grid);
}

.gantt-status {
  flex: none;
  width: 76px;
}

/* The component styles its own pill rather than relying on the host page,
   so it renders correctly wherever it is embedded. Status is never colour
   alone: the pill always states it in words. Overdue is the only solid one,
   because it is the one that means a date has actually passed. */
.gantt .badge {
  display: inline-block;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: var(--pc-font-size-small);
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.gantt .badge.overdue {
  color: #fff;
  background: var(--pc-red-dark);
}

.gantt .badge.late {
  color: var(--pc-red-dark);
  background: var(--pc-red-wash);
  border-color: #f2c4c4;
}

.gantt .badge.at-risk {
  color: var(--pc-amber);
  background: var(--pc-amber-wash);
  border-color: #f1d9a6;
}

.gantt .badge.on-time {
  color: var(--pc-green);
  background: var(--pc-green-wash);
  border-color: #b7dfc6;
}

/* Percent-complete dial ---------------------------------------------- */

/*
 * Exactly Procore's .b-percentdone-circle: a conic-gradient disc on a track
 * colour, with a smaller white disc punched out by ::after carrying the
 * number. Ring thickness is the difference between the two, (34-28)/2 = 3px.
 */
.gantt-dial {
  flex: none;
  position: relative;
  width: var(--pc-dial-size);
  height: var(--pc-dial-size);
  border-radius: 50%;
  background-color: var(--pc-dial-track);
  background-image: conic-gradient(
    var(--pc-dial-fill) 0deg,
    var(--pc-dial-fill) var(--dial-angle, 0turn),
    rgba(0, 0, 0, 0) var(--dial-angle, 0turn),
    rgba(0, 0, 0, 0) 1turn
  );
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* At 100% theirs drops the gradient for a solid fill. */
.gantt-dial.full {
  background-image: none;
  background-color: var(--pc-dial-fill);
}

.gantt-dial.empty {
  background-image: none;
}

.gantt-dial::after {
  content: attr(data-value);
  width: var(--pc-dial-hole);
  height: var(--pc-dial-hole);
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--pc-dial-text-size);
  color: var(--pc-dial-text);
  font-variant-numeric: tabular-nums;
}

.gantt-dates {
  flex: none;
  width: 82px;
  font-size: var(--pc-font-size-small);
  color: var(--pc-text-grid);
  font-variant-numeric: tabular-nums;
}

.gantt-overdue,
.gantt-variance {
  flex: none;
  width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: var(--pc-font-size-small);
}

.gantt-overdue {
  color: var(--pc-red-dark);
  font-weight: 700;
}

.gantt-variance {
  color: var(--pc-text-muted);
}

/* Bars --------------------------------------------------------------- */

.gantt-barrow {
  position: relative;
  border-bottom: 1px solid var(--pc-rule);
  box-sizing: border-box;
}

.gantt-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: var(--pc-bar-height);
  min-width: 4px;
  border-radius: var(--pc-bar-radius);
  /* Procore's own task colour. Status is conveyed by the badge and the
     overdue count, not by repainting every bar — a wall of red reads as
     broken software rather than as information. */
  background: var(--pc-bar-blue);
  overflow: hidden;
  z-index: 1;
}

/* Only genuine trouble recolours the bar. */
.gantt-bar.overdue {
  background: var(--pc-status-overdue);
}

.gantt-bar.late {
  background: var(--pc-status-late);
}

.gantt-bar.at-risk {
  background: var(--pc-status-at-risk);
}

/* Parent rows: Procore's thin dark summary span, whatever the status. */
.gantt-bar.summary,
.gantt-bar.summary.overdue,
.gantt-bar.summary.late,
.gantt-bar.summary.at-risk {
  height: var(--pc-bar-summary-height);
  border-radius: 2px;
  background: var(--pc-bar-summary);
}

.gantt-bar.summary .gantt-bar-progress {
  display: none;
}

/* Every bar is the same thickness, as Procore's are. Varying it by level
   made the hierarchy louder than the schedule and is not what their tool
   does. Depth is already carried by the indent and the label. */

/* Zero-duration milestone: a square rotated to a diamond, 17.67px as theirs
   is, with square corners. Without this it is invisible and unclickable. */
.gantt-bar.marker {
  width: var(--pc-milestone-size);
  height: var(--pc-milestone-size);
  min-width: 0;
  margin-left: calc(var(--pc-milestone-size) / -2);
  border-radius: 0;
  overflow: visible;
  transform: translateY(-50%) rotate(45deg);
}

/* Progress is a darkening overlay rather than a second colour, which is how
   Procore does it — one hue per bar, and progress reads at any bar colour. */
.gantt-bar-progress {
  height: 100%;
  background: var(--pc-bar-progress);
  border-radius: var(--pc-bar-radius) 0 0 var(--pc-bar-radius);
}

/* Procore puts the name to the LEFT of its bar. Near the left edge there is
   no room, so the label flips to the right of the bar instead of being
   clipped into nonsense ("3 Melaleuca Way" rendering as "ay"). */
.gantt-bar-label {
  position: absolute;
  top: 50%;
  transform: translate(-100%, -50%);
  margin-left: -8px;
  font-size: var(--pc-bar-label-size);
  color: var(--pc-bar-label-color);
  white-space: nowrap;
  pointer-events: none;
}

.gantt-bar-label.flip {
  transform: translate(0, -50%);
  margin-left: 8px;
}

/* Side-panel width: the left pane gives up its numbers before its names. */
@media (max-width: 700px) {
  .gantt-splitter { display: none; }
  .gantt-head-left .h-start, .gantt-head-left .h-num { display: none; }
  .gantt-head-left,
  .gantt-pane-left {
    flex-basis: 200px;
  }

  .gantt-dates,
  .gantt-overdue,
  .gantt-variance {
    display: none;
  }
}
