/* Ledger A - travel time: the Travel row in the event form, and the travel strips on the grid
   (the event's dashed "tail", the side strip, the curved links into the block, Busy stripes lined
   up with a Busy whole-day event's). Loaded after events.css: the strips sit behind event blocks
   and size themselves against the day column. Positions and variables are set by
   js/ui/events/travel-strips.js. */

/* ---------- travel time in the event form ---------- */
/* In the form: "[20 min] before  [30 min] after". */
/* A small grid: the two time boxes (each followed by its word) on the top row, and under each
   box its own Busy/Free choice, once a number has been typed in that box. */
.travel-row {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; /* the boxes keep their size, whatever sits under them */
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
  color: var(--colour-text-muted);
}
.travel-row__box {
  min-width: 0;
}
.travel-row__status {
  justify-self: start;
  width: max-content; /* full pill size, same as the Status row; it may run past its box's column */
  margin-top: var(--space-4);
}
.travel-row__status[hidden] {
  display: none;
}
.travel-row__status--before {
  grid-column: 1;
}
.travel-row__status--after {
  grid-column: 3;
}

/* ---------- travel strips on the grid ---------- */
/* On the grid: the event's "tail", a strip in the event's colour stretched over its travel time.
   It spans the whole width of the day column and sits behind the event blocks (which stop short
   of the column's right edge by --event-gutter), so it stays visible when events overlap it.
   Its outline is as thick as a Free event's (2px) but dashed. Busy travel is also striped; Free
   travel is only the outline. The edge that touches the event is left open (no border, square
   corners) so the event and its travel read as one stretched shape: "before" travel touches the
   event with its bottom edge, "after" travel with its top edge. */
.travel-block {
  position: absolute;
  left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0 var(--space-5);
  border: var(--border-medium) dashed var(--event-colour);
  border-radius: var(--radius-block);
  color: var(--event-colour);
  font-size: var(--font-size-2xs);
  line-height: var(--line-height-none);
  text-align: left;
  cursor: pointer;
}
.travel-block[hidden] {
  display: none;
}
/* The strip of edge that can be dragged to change the travel time: along the strip's far edge. */
.travel-block__resize {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--size-6);
  cursor: ns-resize;
}
.travel-block__resize--before {
  top: 0;
}
.travel-block__resize--after {
  bottom: 0;
}
.travel-block--before {
  border-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.travel-block--after {
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
/* A full-width Free strip draws its own edge facing the event wherever it has free space beside
   the block (.travel-block--linked): to the block's right if it isn't in the rightmost lane
   (--link-right), to its left if it isn't in the leftmost lane (--link-left), or both for a block
   in a middle lane. The corner at the column's edge, where that outline turns toward the block, is
   rounded with the same 5px radius as the blocks. A curve (.travel-link) then joins the line to
   the block. The stretch of
   the edge along the block itself, between --link-from and --link-to (set by travel-strips.js), is
   cut away (clip-path), so the strip stays joined to the block there. The cut is 3px deep although
   the border is only 2px: where the strip falls between whole screen pixels, the border is drawn
   up to half a pixel off, and a cut of exactly 2px would leave a hairline of dashes behind. A 2px
   sliver of the strip's side border is kept so that border still runs all the way down. */
.travel-block--linked.travel-block--before {
  border-bottom: var(--border-medium) dashed var(--event-colour);
  clip-path: polygon(
    0 0,
    100% 0,
    100% 100%,
    var(--link-to) 100%,
    var(--link-to) calc(100% - var(--travel-cut)),
    var(--link-from) calc(100% - var(--travel-cut)),
    var(--link-from) 100%,
    0 100%
  );
}
.travel-block--linked.travel-block--before.travel-block--link-left {
  border-bottom-left-radius: var(--radius-block);
}
.travel-block--linked.travel-block--before.travel-block--link-right {
  border-bottom-right-radius: var(--radius-block);
}
.travel-block--linked.travel-block--after {
  border-top: var(--border-medium) dashed var(--event-colour);
  clip-path: polygon(
    0 0,
    var(--link-from) 0,
    var(--link-from) var(--travel-cut),
    var(--link-to) var(--travel-cut),
    var(--link-to) 0,
    100% 0,
    100% 100%,
    0 100%
  );
}
.travel-block--linked.travel-block--after.travel-block--link-left {
  border-top-left-radius: var(--radius-block);
}
.travel-block--linked.travel-block--after.travel-block--link-right {
  border-top-right-radius: var(--radius-block);
}
/* The strip in the free gap on the column's right edge, beside an event that has travel. It
   joins the travel strips above and/or below: its left edge (against the event) has no border,
   and its top / bottom edge has none either where a travel strip joins on (--open-top,
   --open-bottom). */
.travel-block--gutter {
  left: calc(100% - var(--event-gutter));
  width: var(--event-gutter);
  padding: 0;
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.travel-block--open-top {
  border-top: 0;
  border-top-right-radius: 0;
}
.travel-block--open-bottom {
  border-bottom: 0;
  border-bottom-right-radius: 0;
}
/* A dashed line across the free space beside an event block, from the block's right edge to the
   column's right edge. It is the edge of a full-width Free travel strip that faces the event
   (the bottom of travel before, the top of travel after), so the travel runs back to the block
   at the first chance (see addTravelLink in travel-strips.js). Same 2px dashes as the travel
   outline. Where it meets the block it curves into the block's side with the same 5px radius as
   the block's own corners: the left border plus a rounded corner make that curve. It sits behind
   the event blocks and can't be clicked. */
.travel-link {
  position: absolute;
  box-sizing: border-box;
  height: var(--size-7); /* the 2px line plus the 5px curve */
  pointer-events: none;
}
.travel-link[hidden] {
  display: none;
}
.travel-link--before {
  border-top: var(--border-medium) dashed var(--event-colour);
  border-left: var(--border-medium) dashed var(--event-colour);
  border-top-left-radius: var(--radius-block);
}
.travel-link--after {
  border-bottom: var(--border-medium) dashed var(--event-colour);
  border-left: var(--border-medium) dashed var(--event-colour);
  border-bottom-left-radius: var(--radius-block);
}
/* The same curve on the block's LEFT side (--left): the line comes from the left and curves
   down (travel before) or up (travel after) into the block's left edge. */
.travel-link--left.travel-link--before {
  border-left: 0;
  border-right: var(--border-medium) dashed var(--event-colour);
  border-top-left-radius: 0;
  border-top-right-radius: var(--radius-block);
}
.travel-link--left.travel-link--after {
  border-left: 0;
  border-right: var(--border-medium) dashed var(--event-colour);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: var(--radius-block);
}
/* The stripes are the same size and angle as a Busy whole-day event's (.day-column--blocked: 7px
   bands every 14px at 135deg) and LINE UP with them. A stripe pattern starts at the corner of
   whatever it is painted on, so the picture is made as big as the day column and shifted back by
   how far down the column the strip starts (--top-px, set by travel-strips.js). The strip starts at
   the column's left edge, so there is no sideways shift. 100cqw is the column's width. */
.travel-block--busy {
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent var(--stripe-width),
    color-mix(in srgb, var(--event-colour) 35%, transparent) var(--stripe-width),
    color-mix(in srgb, var(--event-colour) 35%, transparent) var(--stripe-period)
  );
  background-origin: border-box;
  background-repeat: no-repeat;
  background-size: 100cqw var(--stripe-reach);
  /* x: back by where the strip starts (--lane-frac of the share the event blocks use; 0 for a
     strip that starts at the column's left edge). y: back by how far down the column it is. */
  background-position: calc((100cqw - var(--event-gutter)) * var(--lane-frac, 0) * -1)
    calc(-1 * var(--top-px, 0px));
}
/* The gap strip starts at the column's right edge, so its picture is shifted back across too. */
.travel-block--gutter.travel-block--busy {
  background-position: calc(var(--event-gutter) - 100cqw) calc(-1 * var(--top-px, 0px));
}
.travel-block--free {
  background: transparent;
}
/* All of an event's travel pieces darken together (js/ui/events/travel-strips.js sets --shaded on
   each); :hover stays for a single piece in case the script hasn't run yet. */
.travel-block:hover,
.travel-block--shaded {
  filter: brightness(0.95);
}
/* A little walking person drawn as a mask, so it takes the strip's colour. Decorative only. */
.travel-block__icon {
  flex: none;
  width: var(--size-14);
  height: var(--size-16);
  margin-left: var(--space-3);
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='13' cy='4' r='2.6'/%3E%3Cpath d='M10.5 8.5l-3 1.4-1.6 5 1.9.6 1.2-3.7 1.4.7-1.6 4.6-3.2 5.2 1.7 1.1 3.3-5.3 1.5-1.8 2.2 2.6.6 5.2 2-.3-.7-5.9-2-2.8.6-3.5c.9 1 2 1.6 3.4 1.6v-2c-1.4 0-2.4-.8-3-1.8l-.9-1.5c-.5-.8-1.4-1.2-2.3-1.2z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='13' cy='4' r='2.6'/%3E%3Cpath d='M10.5 8.5l-3 1.4-1.6 5 1.9.6 1.2-3.7 1.4.7-1.6 4.6-3.2 5.2 1.7 1.1 3.3-5.3 1.5-1.8 2.2 2.6.6 5.2 2-.3-.7-5.9-2-2.8.6-3.5c.9 1 2 1.6 3.4 1.6v-2c-1.4 0-2.4-.8-3-1.8l-.9-1.5c-.5-.8-1.4-1.2-2.3-1.2z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}
.travel-block__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--font-weight-bold);
}
