/*
 * Cadmus: only what Pico CSS lacks. Pico's defaults win; rules here use
 * Pico's variables so they follow light and dark mode on their own.
 */

/*
 * Tables scroll inside their wrapper, never the page. Relative, so a
 * visually hidden header label inside stays in the wrapper too.
 */
.table-wrap {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ------------------------------------------------------------------ */
/* Frame                                                              */
/* ------------------------------------------------------------------ */

.wordmark {
  color: var(--pico-primary);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}

/* Signed-in header: wordmark, navigation, sign-out; wraps at 360 px. */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: calc(var(--pico-spacing) * 2);
  padding-top: var(--pico-spacing);
  border-bottom: var(--pico-border-width) solid var(--pico-muted-border-color);
}

.site-header nav ul {
  flex-wrap: wrap;
}

.site-header form {
  margin-left: auto;
}

/* Public pages: one centered card that starts with the wordmark. */
.public-card {
  max-width: 32rem;
  margin: calc(var(--pico-spacing) * 2) auto;
}

.public-card > .wordmark {
  display: inline-block;
  margin-bottom: var(--pico-spacing);
}

/* Every page: the running build, small and muted, below the content. */
.site-footer {
  color: var(--pico-muted-color);
  text-align: center;
  border-top: var(--pico-border-width) solid var(--pico-muted-border-color);
}

/* ------------------------------------------------------------------ */
/* Status badges                                                      */
/* ------------------------------------------------------------------ */

/*
 * Badge colors are Pico palette values, copied in because the palette
 * variables live only in pico.colors.css, which isn't served. White text on
 * each fill meets WCAG AA (at least 4.5:1) in light and dark alike.
 */
:root {
  --cadmus-badge-amber: #876400; /* Pico amber-550 */
  --cadmus-badge-cyan: #047878; /* Pico cyan-550 */
  --cadmus-badge-indigo: #524ed2; /* Pico indigo-600 */
  --cadmus-badge-violet: #7540bf; /* Pico violet-600 */
  --cadmus-badge-red: #af291d; /* Pico red-600 */
  --cadmus-badge-green: #33790f; /* Pico green-550 */
  --cadmus-badge-grey: #6a6a6a; /* Pico grey-550 */
  --cadmus-badge-text: #ffffff;
}

.badge {
  --cadmus-badge-border: transparent;
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border: var(--pico-border-width) solid var(--cadmus-badge-border);
  border-radius: var(--pico-border-radius);
  color: var(--cadmus-badge-text);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

/* Pico gives tooltip targets a dotted underline; keep the badge's own border. */
.badge[data-tooltip] {
  border-bottom: var(--pico-border-width) solid var(--cadmus-badge-border);
}

/*
 * Pico's tooltip never wraps: let the badge's meaning wrap at a readable
 * width. Wider screens keep Pico's tooltip centred on the badge; phones get
 * the full-width box below.
 */
.badge[data-tooltip]::before {
  width: max-content;
  max-width: min(16rem, 80vw);
  white-space: normal;
}

/* A hidden tooltip takes no space, so it never widens the page. */
.badge[data-tooltip]:not(:hover, :focus)::before,
.badge[data-tooltip]:not(:hover, :focus)::after {
  display: none;
}

/*
 * On a phone a tooltip centred on its badge can run off either edge, so the
 * shown meaning spans the screen inside the page gutters, just above the
 * badge: fixed, it keeps its static vertical place and never widens the page.
 * The arrow would no longer point at the badge, so it is hidden.
 */
@media (max-width: 767.98px) {
  .badge[data-tooltip]:is(:hover, :focus)::before {
    position: fixed;
    inset-inline: var(--pico-spacing);
    top: auto;
    bottom: auto;
    width: auto;
    max-width: none;
    white-space: normal;
    text-align: start;
    transform: none;
    translate: 0 calc(-100% - 0.5rem);
    animation: none;
    opacity: 1;
  }

  .badge[data-tooltip]:is(:hover, :focus)::after {
    display: none;
  }
}

/* Draft, and a status Cadmus can't read: outline, in the normal text color. */
.badge--draft,
.badge--unclear {
  --cadmus-badge-border: var(--pico-muted-border-color);
  background: transparent;
  color: var(--pico-color);
}

.badge--needs-engineer {
  background: var(--cadmus-badge-amber);
}

.badge--backlog {
  background: var(--cadmus-badge-cyan);
}

.badge--active {
  background: var(--cadmus-badge-indigo);
}

.badge--review {
  background: var(--cadmus-badge-violet);
}

.badge--stuck {
  background: var(--cadmus-badge-red);
}

.badge--done {
  background: var(--cadmus-badge-green);
}

.badge--cancelled {
  background: var(--cadmus-badge-grey);
}

/* A row of badges that wraps, with no bullets. */
.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--pico-spacing) / 2);
  padding: 0;
  list-style: none;
}

.badge-list li {
  margin: 0;
  list-style: none;
}

/* ------------------------------------------------------------------ */
/* Pipeline board                                                     */
/* ------------------------------------------------------------------ */

/*
 * Status groups stack on phones and sit side by side as columns on wide
 * screens. Pico has no grid that wraps by content width.
 */
.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--pico-spacing);
  align-items: start;
}

@media (min-width: 1024px) {
  .board {
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  }
}

.board-group {
  min-width: 0;
  margin-bottom: 0;
}

.board-group h2 {
  margin-bottom: calc(var(--pico-spacing) / 4);
  font-size: 1.25rem;
}

.board-meaning,
.board-empty {
  color: var(--pico-muted-color);
}

/* Task lists: cards in board order, no numbers or bullets. */
.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-list > li {
  margin: 0;
  list-style: none;
}

.task-card {
  margin-bottom: var(--pico-spacing);
  padding: var(--pico-spacing);
  overflow-wrap: anywhere;
}

.task-card-title {
  margin-bottom: calc(var(--pico-spacing) / 2);
  font-weight: 600;
}

/* Badge, then who asked (or the meaning), wrapping at 360 px. */
.task-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--pico-spacing) / 2);
}

.task-reason {
  font-style: italic;
}

/*
 * Owner action buttons: each is its own form, so Pico's role="group" can't
 * hold them; they wrap instead of squeezing at 360 px.
 */
.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--pico-spacing) / 2);
}

.task-actions form {
  margin: 0;
}

.task-actions button {
  margin-bottom: 0;
}

/* A dragged task while SortableJS moves it. */
.task-list .sortable-ghost {
  opacity: 0.4;
}

.task-list[data-sortable] > li {
  cursor: grab;
}

/* Home: each project link is a comfortable tap target on a phone. */
.project-list a {
  display: inline-block;
  padding-block: calc(var(--pico-spacing) / 2);
}

/* ------------------------------------------------------------------ */
/* Guide (add-guide-pages)                                            */
/* ------------------------------------------------------------------ */

/* Read by screen readers, never shown: the switch's status line. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/*
 * 1. The line map: one vertical track with a station per step. From 768 px a
 * side path sits in a second column beside the step it leaves.
 */
.guide-journey {
  position: relative;
  margin: 0 0 var(--pico-spacing);
  padding: 0;
  list-style: none;
}

.guide-journey::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0.6875rem;
  border-inline-start: 3px solid var(--pico-muted-border-color);
}

.guide-journey > .guide-station {
  position: relative;
  margin: 0;
  padding-inline-start: 2.25rem;
  list-style: none;
}

.guide-stop > .guide-node,
.guide-side,
details.guide-place {
  margin: 0;
  border: var(--pico-border-width) solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color);
  box-shadow: var(--pico-card-box-shadow);
}

.guide-who,
.guide-return {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
}

.guide-return {
  flex-wrap: nowrap;
}

@media (min-width: 768px) {
  .guide-journey > .guide-station {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 2.5rem;
    align-items: start;
  }

  .guide-station > .guide-stop,
  .guide-station > .guide-arrow {
    grid-column: 1;
  }

  .guide-station > .guide-arrow--side {
    grid-column: 2;
    grid-row: 1;
  }
}

/* 2. Station markers: a dot on the track in the step's badge color. */
.guide-station::before {
  content: "";
  position: absolute;
  top: 0.875rem;
  inset-inline-start: 0.25rem;
  width: 1rem;
  height: 1rem;
  border: 3px solid var(--guide-dot, var(--pico-muted-border-color));
  border-radius: 50%;
  background: var(--pico-background-color);
}

.guide-station[data-status="backlog"] {
  --guide-dot: var(--cadmus-badge-cyan);
}

.guide-station[data-status="active"] {
  --guide-dot: var(--cadmus-badge-indigo);
}

.guide-station[data-status="review"] {
  --guide-dot: var(--cadmus-badge-violet);
}

.guide-station[data-status="done"] {
  --guide-dot: var(--cadmus-badge-green);
}

.guide-station[data-status]:not([data-status="draft"])::before {
  background: var(--guide-dot);
}

/*
 * 3. Connectors: the arrow to the next step runs along the track; a side path
 * hangs off its step with a dashed line.
 */
.guide-arrow {
  margin: 0.25rem 0 0.75rem;
  color: var(--pico-muted-color);
  font-size: 0.875rem;
}

.guide-arrow > summary {
  color: inherit;
}

.guide-arrow--side {
  position: relative;
  margin: 0.75rem 0 0;
  padding-inline-start: 1rem;
  border-inline-start: 2px dashed var(--pico-muted-border-color);
}

@media (min-width: 768px) {
  .guide-arrow--side {
    margin: 0;
    padding-inline-start: 0;
    border-inline-start: 0;
  }

  .guide-arrow--side::before {
    content: "";
    position: absolute;
    top: 1.375rem;
    inset-inline-start: -2.5rem;
    width: 2.5rem;
    border-top: 2px dashed var(--pico-muted-border-color);
  }
}

/* 4. Every node's summary: a tap target at least 44 px tall. */
.guide-node > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  line-height: var(--pico-line-height);
}

/* Pico mutes an open accordion's summary; a node's label stays readable. */
details.guide-node[open] > summary:not([role]) {
  color: var(--pico-color);
}

.guide-node > summary::after {
  margin-inline-start: auto;
}

/* The label takes the room left, so it wraps before the chevron does. */
.guide-node > summary > span:last-of-type {
  flex: 1 1 8rem;
  min-width: 0;
}

.guide-node > summary > h3 {
  margin: 0;
  font-size: 1.125rem;
}

.guide-node > .guide-note {
  padding: 0 0.75rem 0.75rem;
}

.guide-note > p:last-of-type {
  margin-bottom: 0;
}

/* 5. With guide.js, from 768 px a note floats under its summary as a card. */
@media (min-width: 768px) {
  [data-guide-enhanced] .guide-node {
    position: relative;
  }

  [data-guide-enhanced] .guide-node > .guide-note {
    position: absolute;
    z-index: 10;
    top: 100%;
    inset-inline-start: 0;
    width: 22rem;
    max-width: min(22rem, 100%);
    padding: var(--pico-spacing);
    border-radius: var(--pico-border-radius);
    background: var(--pico-card-background-color);
    box-shadow: var(--pico-card-box-shadow);
    color: var(--pico-color);
    font-size: 1rem;
  }
}

/* 6. Follow a task: the current step is outlined and tinted. */
.guide-node.is-current {
  outline: 3px solid var(--pico-primary);
  outline-offset: 2px;
  background: color-mix(in srgb, var(--pico-primary) 10%, var(--pico-card-background-color));
  transition:
    outline-color 0.3s,
    background-color 0.3s;
}

@media (prefers-reduced-motion: reduce) {
  .guide-node.is-current {
    transition: none;
  }
}

/* 7. Engineers' notes read as an aside. */
.guide-tech {
  margin-block: 0.5rem;
  padding-inline-start: 0.75rem;
  border-inline-start: 3px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color);
}

.guide-tech > p {
  margin: 0;
  font-size: 0.875rem;
}

/* 8. Role cards: one column on phones, two from 768 px, three from 1024 px. */
.guide-roles {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--pico-spacing);
  margin-bottom: var(--pico-spacing);
}

.guide-roles > .guide-role {
  margin: 0;
}

@media (min-width: 768px) {
  .guide-roles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .guide-roles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* 9. Places: a row of neutral chips (badges are for statuses only). */
.guide-places {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.guide-places > li {
  margin: 0;
  list-style: none;
}

.guide-places--nodes > li {
  flex: 1 1 14rem;
}

li.guide-place {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.75rem;
  border: var(--pico-border-width) solid var(--pico-muted-border-color);
  border-radius: 999px;
  font-size: 0.875rem;
}

/* 10. Icons: drawn in the text color. */
.guide-icon {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  stroke-width: 1.75;
}

li.guide-place > .guide-icon,
.guide-who > .guide-icon,
.guide-return > .guide-icon {
  width: 1.125rem;
  height: 1.125rem;
}
