/* assets/css/timeline.css
   Stream, Audit and Handover views of the Timeline route.
   The timer/timesheet view keeps its own styles in time-tracking.css.

   Tokens only — app.css owns every static :root variable. Two of them are not
   what their names suggest, and the first version of this file used both wrong:
     --line     is a BORDER SHORTHAND ("1px solid rgba(...)"). Use `border: var(--line)`.
                `border: 1px solid var(--line)` expands to garbage and the whole
                declaration is dropped, which is why nothing had an edge.
     --surface  is a noise IMAGE (url(...)), never a colour. It cannot be a
                background on its own and cannot go through color-mix().
*/

/* ---- toolbar -------------------------------------------------------------- */
.tl-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2);
  margin-bottom: var(--space-3);
  border: var(--line);
  border-radius: var(--ui-card-radius);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--ui-surface-soft), transparent);
}

/* A segmented control, not a <select> — two options never deserved a dropdown. */
.tl-seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: var(--line);
  border-radius: 999px;
  background: var(--ui-surface-soft);
}

.tl-seg__btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--ui-motion-fast) ease, background var(--ui-motion-fast) ease;
}

.tl-seg__btn:hover { color: var(--text); }

.tl-seg__btn[aria-pressed='true'] {
  color: var(--text);
  background: var(--ui-surface-raised);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}

.tl-ctl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tl-ctl__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.tl-ctl select {
  appearance: none;
  border: 1px solid var(--ui-border-subtle);
  border-radius: var(--ui-control-radius);
  background: var(--ui-surface-soft);
  color: inherit;
  font: inherit;
  font-size: 13px;
  padding: 0 28px 0 12px;
  min-height: 34px;
  outline: none;
  cursor: pointer;
  /* Inline caret — a data: URI keeps the control dependency-free and themes
     with currentColor via the mask, unlike a background-image. */
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 14px center, right 9px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  transition: border-color var(--ui-motion-fast) ease, box-shadow var(--ui-motion-fast) ease;
}

.tl-search {
  position: relative;
  flex: 1 1 200px;
  min-width: 160px;
  margin-left: auto;
  display: flex;
  align-items: center;
}

.tl-search__icon {
  position: absolute;
  left: 11px;
  display: inline-flex;
  pointer-events: none;
  color: var(--text-muted);
}

.tl-search__icon svg { width: 15px; height: 15px; display: block; }

.tl-search input {
  width: 100%;
  border: 1px solid var(--ui-border-subtle);
  border-radius: var(--ui-control-radius);
  background: var(--ui-surface-soft);
  color: inherit;
  font: inherit;
  font-size: 13px;
  padding: 0 12px 0 32px;
  min-height: 34px;
  outline: none;
  transition: border-color var(--ui-motion-fast) ease, box-shadow var(--ui-motion-fast) ease;
}

.tl-search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }

.tl-ctl select:hover,
.tl-search input:hover { border-color: var(--ui-border-strong); }

.tl-ctl select:focus-visible,
.tl-search input:focus {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--ui-border-strong));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}

/* ---- list shell ----------------------------------------------------------- */
.tl-list {
  min-height: 160px;
  border: var(--line);
  border-radius: var(--ui-card-radius);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--ui-surface-soft), transparent);
  padding: 2px var(--space-4) var(--space-3);
  transition: opacity var(--ui-motion-med) ease;
}

.tl-list[aria-busy='true'] { opacity: .45; }

/* ---- day grouping --------------------------------------------------------- */
.tl-day + .tl-day { margin-top: var(--space-2); }

.tl-day__heading {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  /* Opaque: rows scroll underneath this. */
  background-color: var(--bg);
}

/* The hairline that runs out from the date to the right edge. */
.tl-day__heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ui-border-subtle);
}

.tl-day__count {
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-muted);
  opacity: .75;
}

.tl-day__rows { list-style: none; margin: 0; padding: 0; }

/* ---- one event ------------------------------------------------------------ */
.tl-row {
  display: grid;
  grid-template-columns: 58px 22px minmax(0, 1fr) auto;
  align-items: start;
  column-gap: var(--space-3);
  padding: 7px 8px 7px 0;
  position: relative;
  border-radius: var(--ui-control-radius);
  transition: background var(--ui-motion-fast) ease;
}

.tl-row:hover { background: var(--ui-surface-soft); }

/* The rail: one continuous line behind the markers, trimmed at the group ends
   so a day doesn't look like it continues past its first/last event. */
.tl-row::before {
  content: '';
  position: absolute;
  left: calc(58px + var(--space-3) + 10px);
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--ui-border-subtle);
}
.tl-row:first-child::before { top: 18px; }
.tl-row:last-child::before  { bottom: calc(100% - 18px); }
.tl-row:only-child::before  { display: none; }

.tl-row__time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  padding-top: 6px;
  text-align: right;
  white-space: nowrap;
}

/* Marker: a ringed disc carrying the module glyph. It is the row's only colour,
   which keeps a run of warnings from shouting the whole list down. */
.tl-row__marker {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  margin-top: 3px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg);
  box-shadow: inset 0 0 0 1.5px var(--tl-accent, var(--primary));
  color: var(--tl-accent, var(--primary));
}

.tl-row__marker svg {
  width: 12px;
  height: 12px;
  display: block;
}

/* Icons in the registry paint their own duotone fills; inside the marker the
   whole glyph should read as the severity colour instead. */
.tl-row__marker svg path,
.tl-row__marker svg circle,
.tl-row__marker svg rect { fill: currentColor !important; }

.tl-row__body { min-width: 0; padding-top: 2px; }

.tl-row__summary {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text);
  overflow-wrap: anywhere;
}

.tl-row__target { color: var(--text-muted); }
.tl-row__target::before { content: ' — '; }

.tl-row__meta {
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.tl-row__who { font-weight: 600; color: var(--text); }

.tl-row__dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
}

.tl-chip {
  border: var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 11px;
  line-height: 1.6;
  background: var(--ui-surface-soft);
  white-space: nowrap;
}

.tl-chip--audit {
  border-style: dashed;
  color: var(--text);
}

/* Severity drives one custom property; every accented part reads from it. */
.tl-sev-info    { --tl-accent: var(--primary); }
.tl-sev-warn    { --tl-accent: var(--warning); }
.tl-sev-error   { --tl-accent: var(--danger); }
.tl-sev-success { --tl-accent: var(--success); }

.tl-row__sev {
  align-self: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--tl-accent);
  background: color-mix(in srgb, var(--tl-accent) 14%, transparent);
  white-space: nowrap;
}

/* Only things that went WRONG get a badge. `info` is the default, and a green
   "DONE" next to a row that already says "Task completed" is noise — the green
   marker ring carries success on its own. */
.tl-sev-info .tl-row__sev,
.tl-sev-success .tl-row__sev { display: none; }

/* ---- empty, error + paging ------------------------------------------------- */
.tl-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: var(--space-8) var(--space-4);
  text-align: center;
}

.tl-empty__icon {
  display: inline-flex;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-2);
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ui-surface-soft);
  color: var(--text-muted);
}

.tl-empty__icon svg { width: 20px; height: 20px; display: block; }

.tl-empty p { margin: 0; font-size: 13.5px; }
.tl-empty p + p { font-size: 12.5px; color: var(--text-muted); }

.tl-empty--error .tl-empty__icon { color: var(--danger); }

.tl-more {
  display: block;
  margin: var(--space-3) auto 0;
}

/* ---- skeleton -------------------------------------------------------------- */
/* Shown on the FIRST load only; a reload keeps the existing rows visible and
   just dims them, which is far less jarring than a flash of placeholder. */
.tl-skel { padding: var(--space-3) 0; display: grid; gap: var(--space-3); }

.tl-skel__row {
  display: grid;
  grid-template-columns: 58px 22px minmax(0, 1fr);
  column-gap: var(--space-3);
  align-items: center;
}

.tl-skel__bar {
  height: 10px;
  border-radius: 999px;
  background: var(--ui-surface-raised);
  animation: tl-pulse 1.4s ease-in-out infinite;
}

.tl-skel__bar--dot { height: 22px; width: 22px; border-radius: 50%; }
.tl-skel__row:nth-child(even) .tl-skel__bar { animation-delay: .18s; }

@keyframes tl-pulse { 0%, 100% { opacity: .45; } 50% { opacity: .9; } }

@media (prefers-reduced-motion: reduce) {
  .tl-skel__bar { animation: none; }
}

/* ---- handover -------------------------------------------------------------- */
/* A shift report, not a feed: a fixed window, counted sections, and a body you
   can copy straight into a message. */
.tl-handover { display: grid; gap: var(--space-3); }

.tl-ho__doc {
  border: var(--line);
  border-radius: var(--ui-card-radius);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--ui-surface-soft), transparent);
  padding: var(--space-6) var(--space-6) var(--space-4);
}

.tl-ho__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: var(--line);
}

.tl-ho__title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.tl-ho__sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-muted); }

.tl-ho__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

.tl-ho__stat {
  border: var(--line);
  border-radius: var(--ui-control-radius);
  background: var(--ui-surface-soft);
  padding: 10px 12px;
}

.tl-ho__stat .k {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tl-ho__stat .v {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.tl-ho__stat--warn .v  { color: var(--warning); }
.tl-ho__stat--error .v { color: var(--danger); }

.tl-ho__section + .tl-ho__section { margin-top: var(--space-4); }

.tl-ho__h {
  margin: 0 0 var(--space-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tl-ho__lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.tl-ho__line {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: var(--space-3);
  padding: 5px 0;
  font-size: 13px;
  line-height: 1.45;
  border-bottom: var(--line);
}

.tl-ho__line:last-child { border-bottom: 0; }

.tl-ho__line time {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tl-ho__line b { font-weight: 600; }
.tl-ho__by { color: var(--text-muted); }

.tl-ho__line--warn  { color: var(--warning); }
.tl-ho__line--error { color: var(--danger); }

.tl-ho__people {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tl-ho__person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: var(--line);
  border-radius: 999px;
  background: var(--ui-surface-soft);
  padding: 3px 11px 3px 4px;
  font-size: 12.5px;
}

.tl-ho__person .n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
}

/* Areas are not people — no avatar disc, so the padding closes back up. */
.tl-ho__person--area { padding-left: 11px; }

.tl-ho__person .c {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tl-ho__none { margin: 0; font-size: 13px; color: var(--text-muted); }

.tl-ho__foot {
  margin-top: var(--space-6);
  padding-top: var(--space-3);
  border-top: var(--line);
  font-size: 11.5px;
  color: var(--text-muted);
}
