/*
 * The roadmap - the half of its styling that is only ever a roadmap.
 *
 * Everything this builds on lives in `/shared/base.css`, loaded first by
 * index.html: the two palettes, the top bar, the buttons, `.card`, the credit
 * at the foot, and `--tone` / `--tone-tint` / `--tone-edge` / `--tone-text` -
 * the colour an element owns, worked out from the `--hue` the markup sets on
 * it. A category owns a hue here exactly as an event does on the calendar.
 * Nothing below redefines any of that; a colour that should change on both
 * pages is in that file and not this one.
 *
 * ## This sheet is loaded in two places
 *
 * By the page, and by the panel's visual editor, which puts it inside a shadow
 * root next to `base.css` so its preview is the real thing rather than an
 * impression of it (see dashboard/public/js/roadmap-editor.js). Two
 * consequences worth knowing before editing:
 *
 *   - **No rule here may reach outside the timeline.** No styling of `body`,
 *     no bare element selectors like `h2 { … }`, nothing that assumes it owns
 *     the document - inside the panel it does not, and a stray rule would
 *     repaint the control panel around it. Everything is prefixed `rm-`.
 *   - Rules for the page's own furniture - the filter bar, the dialog, the
 *     hover card - are kept below the timeline and marked, because the editor
 *     draws none of them.
 *
 * ## The one layout idea
 *
 * An axis of columns that scrolls sideways, past on the left and future on the
 * right, and turns into a vertical list on a phone. The rail is not one line
 * drawn across the top: each column draws its own segment and its own node, so
 * it stays continuous however many columns there are, whatever width they end
 * up, and whichever of them are folded - none of which can be known without
 * measuring, and measuring would have to happen again on every resize and
 * every fold.
 */

/* ===================================================================== */
/* The timeline. Everything in this block is drawn by the editor too.     */
/* ===================================================================== */

.rm-timeline {
  overflow-x: auto;
  overflow-y: hidden;
  /* The axis is dragged as well as scrolled - see the pointer handling in
     js/app.js. `grab` is the cursor that says so before anybody tries. */
  cursor: grab;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-3) transparent;
  overscroll-behavior-x: contain;
  /*
   * Deliberately no `scroll-behavior: smooth`.
   *
   * It only ever applies to programmatic scrolls, and a programmatic smooth
   * scroll on this element was measured not to land at all - the "Now" button
   * became a button that did nothing. The jumps in js/app.js are instant on
   * purpose; see `bringIntoView` there.
   */
}
.rm-timeline::-webkit-scrollbar { height: 10px; }
.rm-timeline::-webkit-scrollbar-track { background: transparent; }
.rm-timeline::-webkit-scrollbar-thumb {
  background: var(--panel-3); border-radius: 999px;
  border: 3px solid transparent; background-clip: content-box;
}
.rm-timeline::-webkit-scrollbar-thumb:hover { background: var(--line); background-clip: content-box; }

/* While a drag is in progress. `user-select` is the important half: without it
   the drag selects the text it passes over and the page fills with highlight. */
.rm-timeline[data-dragging] { cursor: grabbing; user-select: none; }
.rm-timeline[data-dragging] .rm-item { pointer-events: none; }

.rm-track {
  display: flex;
  align-items: flex-start;
  gap: 0;
  min-width: min-content;
}

.rm-update {
  position: relative;
  flex: 0 0 auto;
  width: 268px;
  padding: 0 14px 10px 0;
  transition: opacity .16s, width .18s;
}
/* Folded: enough to say which release it was and that it happened. */
.rm-update:not([data-open]) { width: 176px; }
/* No match under the current filter. Dimmed rather than removed - a track that
   changes length on every keystroke is a track you lose your place in. */
.rm-update[data-dimmed] { opacity: .38; }

/* ------------------------------------------------------------- the rail */
.rm-rail { position: relative; height: 26px; margin-bottom: 12px; }
.rm-rail::before {
  content: ''; position: absolute; left: 0; right: 0; top: 11px;
  height: 2px; background: var(--line);
}
/* The line starts *at* the first node rather than running off the left edge,
   where it would suggest a history that is not on the page. */
.rm-update:first-child .rm-rail::before { left: 9px; }
/*
 * And fades out after the last one rather than stopping dead at the column's
 * edge. There *is* more roadmap than is written down, so the line should not
 * end in a hard stop that reads as "this is all there will ever be" - nor run
 * on at full strength to a cut that looks like a rendering fault.
 */
.rm-update:last-child .rm-rail::before {
  background: linear-gradient(to right, var(--line) 40%, transparent);
}

.rm-dot {
  position: absolute; left: 0; top: 3px; z-index: 1;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
  transition: background .16s, border-color .16s, box-shadow .16s;
}
/*
 * Three states, three weights: shipped is solid, current is ringed so the eye
 * lands on it first, planned is a dashed outline.
 *
 * The planned node's edge is `--faint` rather than `--line`, which is what it
 * started as. `--line` is the colour of a divider - something the eye is meant
 * to slide over - and on the light palette a 2px dashed #d6dae5 on #f4f5f9 read
 * as no node at all. This is a marker carrying a meaning, so it gets a colour
 * that is meant to be seen in both palettes.
 *
 * The ring on the current node is mixed from the accent rather than taken from
 * `--accent-dim`, for the same reason: that token is 16% alpha on dark and 10%
 * on light, and at 10% the ring that says "you are here" had all but vanished.
 */
.rm-update[data-status="released"] .rm-dot { background: var(--accent-soft); border-color: var(--accent-soft); }
.rm-update[data-status="wip"] .rm-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 20%, transparent);
}
.rm-update[data-status="planned"] .rm-dot { border-style: dashed; border-color: var(--faint); }

/* ------------------------------------------------------------- the head */
.rm-head {
  display: grid; gap: 2px;
  width: 100%; text-align: left;
  background: none; border: 0; padding: 0 6px 0 0;
  color: inherit; font: inherit; cursor: pointer;
  border-radius: 10px;
}
.rm-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.rm-when {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--faint);
}
.rm-update[data-status="wip"] .rm-when { color: var(--accent); }
.rm-name { font-size: 16.5px; font-weight: 650; letter-spacing: -.2px; }
.rm-subtitle { font-size: 13px; color: var(--muted); line-height: 1.35; }

.rm-state {
  justify-self: start;
  margin-top: 3px; padding: 2px 9px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 10.5px; font-weight: 650; letter-spacing: .3px;
  color: var(--muted);
}
.rm-update[data-status="wip"] .rm-state { border-color: var(--accent); color: var(--accent); }

.rm-count { margin-top: 6px; font-size: 11.5px; color: var(--faint); }
/* Only worth saying while the items are out of sight. Open, they are countable. */
.rm-update[data-open] .rm-count { display: none; }

/* ------------------------------------------------------------ the items */
.rm-items {
  list-style: none; margin: 12px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.rm-items[hidden] { display: none; }

.rm-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  background: var(--tone-tint);
  border: 1px solid var(--line-soft); border-radius: 11px;
  color: inherit; font: inherit; font-size: 13.5px; text-align: left;
  cursor: pointer;
  transition: border-color .13s, transform .1s, box-shadow .13s;
}
.rm-item:hover { border-color: var(--tone-edge); transform: translateY(-1px); box-shadow: var(--shadow); }
.rm-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rm-mark { flex: none; width: 13px; text-align: center; color: var(--tone); font-weight: 700; }
.rm-item[data-status="planned"] .rm-mark { color: var(--faint); }
.rm-emoji { flex: none; font-size: 15px; line-height: 1; }
.rm-item-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
/* A finished item is quieter than a current one. It is still there, and still
   the proof that things get delivered - it just stops competing for attention. */
.rm-item[data-status="done"] .rm-item-title { color: var(--muted); }

/*
 * How far along, as a bar and not a number.
 *
 * Only drawn while something is in progress (see `showsProgress` in
 * js/roadmap.js): a bar on a planned item is a 0% that reads as a stalled 0%,
 * and one on a finished item is a 100% nobody needed telling.
 */
.rm-progress {
  flex: none; width: 34px; height: 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--tone) 22%, transparent);
  overflow: hidden;
}
.rm-progress i { display: block; height: 100%; background: var(--tone); border-radius: 999px; }

.rm-blank { padding: 7px 2px; font-size: 12.5px; }

/* ------------------------------------------------------------ nothing yet */
/*
 * The first state this page is ever in, and therefore the one worth getting
 * right: the roadmap goes live before its content is written.
 */
.rm-empty { text-align: center; padding: clamp(26px, 7vw, 56px) 16px; }
.rm-empty-mark { display: block; font-size: 38px; line-height: 1; margin-bottom: 12px; }
.rm-empty h2 { margin: 0 0 6px; font-size: 17px; }
.rm-empty p { margin: 0; font-size: 13.5px; }

/* ===================================================================== */
/* The page's own furniture. The editor draws none of this.              */
/* ===================================================================== */

/* A heading with one control pushed to the far end of its line. */
.row-between { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.row-between > h2 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; }

/* ------------------------------------------------------------ the intro */
.rm-intro { font-size: 14px; color: var(--muted); margin: 0; max-width: 62ch; }

/* ----------------------------------------------------------- the filters */
/*
 * The filter bar is also the legend.
 *
 * Two separate things - "here is what the colours mean" and "show me only
 * this" - drawn as one, because a chip that explains a colour and a chip that
 * filters by it are the same chip and nobody wants to read two rows of the
 * same seven words.
 */
.rm-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/*
 * The bar sits under the intro paragraph, not against it.
 *
 * A direct child, because the chip row inside it carries the same class (it is
 * the same flex arrangement) - a descendant selector would indent the chips by
 * fourteen pixels as well, for no reason anybody could later explain.
 */
#lead > .rm-filters { margin-top: 14px; }

.rm-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--tone-tint); border: 1px solid var(--tone-edge);
  border-radius: 999px; padding: 5px 13px 5px 10px;
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  transition: transform .1s, box-shadow .13s, opacity .13s;
}
.rm-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.rm-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rm-chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--tone-edge); }
/* Something else is selected. Faded, not hidden: the legend still has to read
   as a complete list of what exists. */
.rm-filters[data-narrowed] .rm-chip[aria-pressed="false"] { opacity: .5; }
.rm-chip img { width: 18px; height: 18px; object-fit: contain; aspect-ratio: 1; display: block; }

.rm-search {
  flex: 1; min-width: 150px; max-width: 260px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 11px; padding: 8px 12px; font: inherit; font-size: 13.5px;
}
.rm-search::placeholder { color: var(--faint); }
.rm-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/*
 * "3 of 41 items", and a way out.
 *
 * Shown only while something is actually narrowed, and always with the Clear
 * next to it. Without both, somebody lands on a filtered page - from a
 * refresh, a back button, a half-typed word - and reads it as the whole
 * roadmap.
 */
.rm-result { font-size: 12.5px; color: var(--muted); }
.rm-clear {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer;
}
.rm-clear:hover { border-color: var(--accent); color: var(--text); }
.rm-clear[hidden], .rm-result[hidden] { display: none; }

/* ------------------------------------------------------------- the peek */
/*
 * What hovering an item says, before anything is clicked.
 *
 * One node, moved around and refilled, rather than one per item: forty of
 * these in the document would be forty things to keep positioned. Positioned
 * in page coordinates and pinned inside the viewport by js/app.js, which is
 * why there is no `transform` here to fight with.
 */
.rm-peek {
  position: absolute; z-index: 60;
  max-width: 280px; padding: 9px 12px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--tone-edge); border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 12.5px; line-height: 1.45;
  pointer-events: none; opacity: 0;
  transition: opacity .12s;
}
.rm-peek[data-shown] { opacity: 1; }
.rm-peek[hidden] { display: none; }
.rm-peek b { display: block; font-size: 13px; margin-bottom: 2px; }
.rm-peek .rm-peek-cat { color: var(--tone-text); font-weight: 650; }
.rm-peek .rm-peek-body { color: var(--muted); margin-top: 3px; }
.rm-peek .rm-peek-more { color: var(--faint); margin-top: 5px; font-size: 11.5px; }

/* ----------------------------------------------------------- the detail */
/*
 * One item, in full.
 *
 * A real `<dialog>`, so Escape, the focus trap and the backdrop are the
 * browser's job rather than three things to reimplement and get subtly wrong.
 */
.rm-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(84vh, 760px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.rm-dialog::backdrop { background: rgba(6, 8, 14, .58); backdrop-filter: blur(3px); }
.rm-dialog[open] { display: flex; flex-direction: column; animation: rm-in .15s cubic-bezier(.2, .8, .3, 1); }
@keyframes rm-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }

.rm-dialog-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--tone-tint), transparent);
}
.rm-dialog-emoji { flex: none; font-size: 26px; line-height: 1.1; }
.rm-dialog-titles { flex: 1; min-width: 0; }
.rm-dialog-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--tone-text);
}
.rm-dialog-titles h2 { margin: 3px 0 0; font-size: 19px; }
.rm-dialog-meta { margin: 7px 0 0; display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.rm-tag {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-size: 11.5px; color: var(--muted);
}
.rm-tag.is-tone { border-color: var(--tone-edge); color: var(--tone-text); }
.rm-dialog-close {
  flex: none; width: 32px; height: 32px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  font: inherit; font-size: 15px; line-height: 1; cursor: pointer;
}
.rm-dialog-close:hover { border-color: var(--accent); color: var(--text); }

.rm-dialog-body { padding: 16px 18px 20px; overflow-y: auto; overscroll-behavior: contain; }
.rm-dialog-body p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; }
.rm-dialog-body p:last-child { margin-bottom: 0; }
.rm-dialog-body ul { margin: 0 0 10px; padding-left: 20px; font-size: 14px; }
.rm-dialog-body li { margin-bottom: 4px; }
.rm-dialog-body code {
  background: var(--panel-3); border-radius: 5px; padding: 1px 5px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px;
}
.rm-shot {
  display: block; width: 100%; height: auto; margin: 0 0 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel-3);
}
.rm-dialog-progress { margin: 0 0 14px; }
.rm-dialog-progress .rm-bar {
  height: 7px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--tone) 20%, transparent);
}
.rm-dialog-progress .rm-bar i { display: block; height: 100%; background: var(--tone); border-radius: 999px; }
.rm-dialog-progress span { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); }

/* -------------------------------------------------------- small screens */
@media (max-width: 760px) {
  /*
   * The axis stands up.
   *
   * A sideways scroller on a phone competes with the page's own vertical
   * scroll and loses - a swipe that was meant to move the axis moves the page
   * instead, or worse, does both. As a column it is just a list, which is what
   * a thumb is already good at.
   */
  .rm-timeline { overflow-x: visible; cursor: auto; }
  .rm-track { flex-direction: column; gap: 4px; min-width: 0; }
  .rm-update, .rm-update:not([data-open]) { width: auto; padding: 0 0 14px 30px; }

  .rm-rail {
    position: absolute; left: 0; top: 2px; bottom: 0;
    width: 30px; height: auto; margin: 0;
  }
  .rm-rail::before { left: 8px; right: auto; top: 0; bottom: 0; width: 2px; height: auto; }
  .rm-update:first-child .rm-rail::before { left: 8px; top: 8px; }
  /* The last node has nothing below it, so the line stops at it instead of
     trailing off into the credit at the foot. */
  .rm-update:last-child .rm-rail::before { bottom: auto; height: 12px; }
  .rm-dot { top: 1px; left: 0; }

  .rm-search { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rm-item:hover, .rm-chip:hover { transform: none; }
  .rm-dialog[open] { animation: none; }
}
