/**
 * @file
 * Views Board structure: columns, lanes, cells, cards and controls.
 *
 * What makes the board work, whatever the theme: keep it. Colors, borders,
 * radii and type are in views-board.theme.css, which a theme may replace or
 * drop with libraries-override. The rules here use plain class selectors, so
 * a theme's generic element rules (ul margins, list bullets) do not reach
 * the board, and a theme still overrides any of them with a class of its own.
 */

.views-board {
  --vb-gap: var(--views-board-gap, 0.75rem);
  --vb-column-width: var(--views-board-column-width, 16rem);
  --vb-collapsed-width: var(--views-board-collapsed-width, 3rem);
  --vb-toast-offset: var(--views-board-toast-offset, 1rem);

  position: relative;
  overflow-x: auto;
  padding-block-end: var(--vb-gap);
}

/* Whatever the board hides (a collapsed lane's row, the toast, a count of
   none) stays hidden: its own display rules would otherwise win over the
   browser's [hidden], at the same weight and loaded later. */
.views-board [hidden] {
  display: none;
}

/* The bar above the board: the reader's choice of lanes, and the full screen
   button at the far end. Sticky to the left edge, so it stays in view when
   the board scrolls sideways. */
.views-board__bar {
  position: sticky;
  inset-inline-start: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--vb-gap);
  margin-block-end: var(--vb-gap);
  /* Room for the focus rings of the switch and the button: the board scrolls
     sideways, so it clips whatever reaches past its edges, and the button,
     which keeps the focus when full screen ends, sits against one. */
  padding: 0.25rem;
}

/* The lane switch takes the free space, which leaves the button at the end
   whatever margins the theme gives buttons. */
.views-board__lanes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-inline-end: auto;
}

/* Drupal puts a view's contextual links (the pencil, for those who may edit
   the view) in its top right corner. When the board comes first in the view,
   with no header or filters above it, the bar is in that corner too: it
   keeps the pencil's room. In full screen the pencil is hidden. */
:not(:fullscreen) > .contextual + .view-content > .views-board > .views-board__bar {
  padding-inline-end: 2.5rem;
}

/* Three classes: Claro sizes small buttons with two
   (.no-touchevents .button--small), loaded after the module. */
.views-board .views-board__bar .views-board__fullscreen {
  margin: 0;
  cursor: pointer;
}

.views-board__lanes-label {
  margin-inline-end: 0.25rem;
}

.views-board__lanes-choice {
  padding: 0.25rem 0.625rem;
  text-decoration: none;
}

.views-board__head,
.views-board__row {
  display: flex;
  gap: var(--vb-gap);
  min-width: min-content;
}

.views-board__column-head,
.views-board__cell {
  flex: 1 0 var(--vb-column-width);
  box-sizing: border-box;
  min-width: 0;
}

.views-board__column-head.is-collapsed,
.views-board__cell.is-collapsed {
  flex: 0 0 var(--vb-collapsed-width);
}

/* Column heads. The board scrolls sideways, which makes it the scroll
   container on both axes, so a sticky head inside it would stick to the
   board and not to the page. With "Keep the column heads in view" the
   template moves the head out of that box instead: see the sticky head
   rules below. */
.views-board__head {
  margin-block-end: var(--vb-gap);
}

/* The sticky head. The board itself stops scrolling, so its sticky wrapper
   sticks to the page; the lanes scroll sideways in the body, the head in a
   scroller of its own, and views-board.js keeps the two in step. The
   head's scrollbar is the one shown, right under the heads, where it stays
   in reach however long the board is. */
.views-board--sticky-head {
  overflow-x: visible;
}

.views-board__sticky {
  position: sticky;
  z-index: 2;
  top: var(--views-board-sticky-offset, var(--drupal-displace-offset-top, 0));
}

/* Both scrolling boxes are positioned, so the visually hidden text inside them
   (absolute, 1px) is clipped and scrolled with them; otherwise it lays out
   against the board, which no longer scrolls, and widens the page. */
.views-board__head-scroller {
  position: relative;
  overflow-x: auto;
  scrollbar-width: thin;
}

.views-board__body {
  position: relative;
  overflow-x: auto;
  scrollbar-width: none;
}

.views-board__body::-webkit-scrollbar {
  display: none;
}

/* The lane under the head. It always takes one line, also before
   views-board.js names a lane, so the wrapper never changes height and
   the board below never jumps. */
.views-board__current-lane {
  display: flex;
  overflow: hidden;
  gap: 0.5rem;
  min-block-size: 1.5em;
  padding-inline: 0.25rem;
  white-space: nowrap;
  line-height: 1.5;
}

.views-board__current-lane-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* What the keyboard reaches in the body (a card's links and buttons, a lane
   toggle, an Add link) stops below the head, not under it. The margin is
   the focused element's own: it is not inherited. */
.views-board--sticky-head .views-board__body * {
  scroll-margin-block-start: calc(var(--views-board-sticky-height, 0px) + var(--views-board-sticky-offset, var(--drupal-displace-offset-top, 0px)) + var(--vb-gap));
}

/* A head asks for no width of its own: its column's is enough, and the name
   shrinks to an ellipsis. The head row and the lane rows are laid out
   apart, so a head whose name and counts asked for more than its column
   would widen the head row alone (Chromium sizes a row by what its columns
   ask for), and every column after it would start right of its cells. */
.views-board__column-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  contain: inline-size;
}

.views-board__column-dot {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
}

/* Column and lane names are headings, and themes size h3 for articles: the
   board keeps its own sizes, so a head keeps the height of the others. */
.views-board__column-title {
  overflow: hidden;
  flex: 1;
  margin: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.95rem;
}

.views-board__total {
  margin-inline-start: 0.5rem;
}

.views-board__collapse {
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
}

.views-board__collapse::before {
  content: "\2039\203A";
}

.views-board__collapse[aria-pressed="true"]::before {
  content: "\203A\2039";
}

/* A collapsed head keeps the height of the others and shows only its dot
   and button, as Trello and Jira do; the name and count go down the strip
   below, and stay in the head for screen readers and on hover. */
.views-board__column-head.is-collapsed {
  justify-content: center;
  gap: 0.25rem;
  padding-inline: 0.25rem;
}

.views-board__column-head.is-collapsed .views-board__column-title,
.views-board__column-head.is-collapsed .views-board__column-meta {
  position: absolute;
  overflow: hidden;
  clip: rect(0 0 0 0);
  width: 1px;
  height: 1px;
  white-space: nowrap;
}

/* Lanes. */
.views-board__lane + .views-board__lane {
  margin-block-start: calc(var(--vb-gap) * 1.5);
}

.views-board__lane-head {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.views-board__lane-toggle {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: inherit;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  gap: 0.5rem;
}

.views-board__lane-toggle::before {
  width: 0;
  height: 0;
  content: "";
  transition: transform 0.15s;
  transform: rotate(90deg);
  border-inline-start: 0.5em solid currentColor;
  border-block: 0.35em solid transparent;
}

.views-board__lane-toggle[aria-expanded="false"]::before {
  transform: none;
}

/* What the site draws under a lane's head. Each element in it is an item of a
   row that wraps, as chips are; it starts where the label does, after the
   toggle's padding, triangle and gap, and stays when the lane is collapsed. */
.views-board__lane-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin: -0.25rem 0 0.5rem;
  padding-inline: 1.5rem 0.5rem;
}

/* Cells and cards. */
.views-board__cell {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
}

.views-board__cards {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.views-board__cell.is-collapsed .views-board__card,
.views-board__cell.is-collapsed .views-board__add {
  display: none;
}

.views-board__cell.is-collapsed .views-board__cards {
  align-items: center;
}

/* Without lanes, a collapsed column's strip carries its name and count. */
.views-board__cell.is-collapsed .views-board__cards::before {
  content: attr(data-views-board-column-label) " \00B7  " attr(data-views-board-count);
  padding-block: 0.25rem;
  white-space: nowrap;
  writing-mode: vertical-rl;
}

/* With lanes, each collapsed cell shows only its own count, and nothing when
   it has no cards: the name, down every lane, would say the same thing over
   and over. It stays on the head, on hover and for screen readers. */
.views-board--lanes .views-board__cell.is-collapsed .views-board__cards::before {
  content: attr(data-views-board-count);
  writing-mode: horizontal-tb;
}

.views-board--lanes .views-board__cell.is-collapsed .views-board__cards[data-views-board-count="0"]::before {
  content: none;
}

.views-board__card {
  position: relative;
  margin: 0;
  padding: 0.625rem 0.75rem;
}

.views-board__card--movable {
  padding-inline-start: 1.5rem;
  cursor: grab;
}

.views-board__card[aria-busy="true"] {
  opacity: 0.6;
}

.views-board__card--ghost {
  opacity: 0.4;
}

.views-board__handle {
  position: absolute;
  inset-block: 0.625rem;
  inset-inline-start: 0.4rem;
  width: 0.5rem;
  opacity: 0.45;
  background-image: radial-gradient(currentColor 1px, transparent 1.5px);
  background-size: 4px 4px;
}

/* A card never grows wider than its column. Code, URLs and file names have
   no place to break a line, and a theme that lays the card out as a grid or
   a flex row (Olivero's teaser is a grid) lets it grow to its longest word:
   `overflow-wrap: anywhere` lets that word break, and so shrinks the width
   it asks for, where `break-word` only breaks the line. Media shrink to fit,
   and preformatted text scrolls inside the card. */
.views-board__card-content {
  min-width: 0;
  overflow-wrap: anywhere;
}

.views-board__card-content :is(img, video) {
  max-width: 100%;
  height: auto;
}

.views-board__card-content :is(iframe, pre) {
  max-width: 100%;
}

.views-board__card-content pre {
  overflow-x: auto;
}

/* A card is small whatever the view mode's template does with its title. */
.views-board__card-content :is(h1, h2, h3, h4) {
  margin: 0 0 0.375rem;
  font-size: 1rem;
  line-height: 1.3;
}

.views-board__card-content > :first-child {
  margin-block-start: 0;
}

.views-board__card-content > :last-child {
  margin-block-end: 0;
}

/* The "Move…" button. Two classes, so a theme's button margins (it may carry
   the theme's own button classes) do not push the card apart. */
.views-board .views-board__move {
  margin: 0.5rem 0 0;
  cursor: pointer;
}

/* The compact Move button: a ⋯ in the card's corner. Its accessible name is
   still "Move…" and the card's label, from the visually hidden text. */
.views-board__card--move-icon {
  padding-inline-end: 2.25rem;
}

.views-board .views-board__move--icon {
  position: absolute;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  line-height: 1;
  inset-block-start: 0.375rem;
  inset-inline-end: 0.375rem;
}

/* The due badge. A finished column hides it; the card keeps its state, so
   the badge comes back if the card is moved out again. */
.views-board__due {
  display: inline-flex;
  margin-block-start: 0.5rem;
  padding: 0.0625rem 0.5rem;
}

.views-board__cell[data-views-board-finished] .views-board__due {
  display: none;
}

.views-board__overdue {
  margin-inline-start: 0.5rem;
}

/* What blocks a card: one line per item it waits for, under its content.
   The mark hangs in the margin, so a long title wraps under itself and the
   column's name follows it as text. */
.views-board__dependencies {
  margin-block-start: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.35;
}

.views-board__dependencies-title {
  display: block;
  font-size: 0.75rem;
}

.views-board__dependency-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.views-board__dependency {
  position: relative;
  margin-block-start: 0.125rem;
  padding-inline-start: 1.25em;
  overflow-wrap: anywhere;
}

.views-board__dependency-icon {
  position: absolute;
  inset-inline-start: 0;
  width: 1em;
  text-align: center;
}

.views-board__dependency-note {
  white-space: nowrap;
  font-size: 0.75rem;
}

.views-board__add {
  display: block;
  margin-block-start: 0.5rem;
  padding: 0.25rem;
  text-align: center;
}

/* The "Move…" menu, placed against the viewport by views-board.js, under its
   button: the board scrolls sideways and would clip it otherwise. */
.views-board__menu {
  position: fixed;
  z-index: 500;
  overflow-y: auto;
  min-width: 12rem;
  max-height: calc(100vh - 1rem);
  padding: 0.25rem 0;
}

.views-board__menu-heading {
  padding: 0.375rem 0.75rem 0.125rem;
}

.views-board__menu button {
  display: flex;
  width: 100%;
  margin: 0;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  text-align: start;
  color: inherit;
  border: 0;
  background: transparent;
  font: inherit;
}

.views-board__menu button[aria-checked="true"] {
  font-weight: 700;
}

.views-board__menu button[aria-checked="true"]::after {
  margin-inline-start: auto;
  content: "\2713";
}

/* The confirmation, at the bottom of the window and centered, so it shows
   wherever the moved card is: on a tall board the end of the board can be a
   screen or two below it. Margins center it, which holds in right-to-left
   pages too. The maximum width leaves 1rem on each side only when the padding
   counts inside it, whatever box model the theme gives other elements. */
.views-board__toast {
  position: fixed;
  z-index: 500;
  inset-block-end: var(--vb-toast-offset);
  inset-inline: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100% - 2rem);
  margin-inline: auto;
  padding: 0.625rem 1rem;
}

/* The Undo carries no theme button classes, so it takes the board's type
   rather than the browser's default for buttons. */
.views-board .views-board__undo {
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* Full screen. The element in full screen is the view around the board, so
   its filters come along; views-board.js marks it .views-board-fullscreen,
   and marks the elements between it and the board, which pass the height
   down so the board fills the screen. The view scrolls when the board is
   taller than the screen. Two classes (or a class and :fullscreen), because
   themes lay out .view and .view-content themselves (Olivero makes both a
   grid) and load after the module. */
.views-board-fullscreen:fullscreen {
  display: flex;
  overflow: auto;
  flex-direction: column;
  padding: var(--views-board-gap, 0.75rem);
}

/* The view's contextual links lead away from the page, and sat on the
   Exit full screen button. */
.views-board-fullscreen:fullscreen > .contextual {
  display: none;
}

.views-board-fullscreen .views-board-fullscreen__path {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
}

.views-board-fullscreen .views-board {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
}

/* In full screen the view is the scroll container, and nothing sits above
   it. A sticky element stops at the container's padding, so the head is
   pulled up by that padding, or the cards would show above it. */
.views-board-fullscreen .views-board__sticky {
  top: calc(-1 * var(--views-board-gap, 0.75rem));
}

/* The body passes the height down, so a single lane still fills it. */
.views-board-fullscreen .views-board__body {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
}

/* With a single lane, its cells reach the bottom of the screen: all of that
   height is a place to drop a card. */
.views-board-fullscreen .views-board__lane:only-of-type {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
}

.views-board-fullscreen .views-board__lane:only-of-type .views-board__row {
  flex: 1 0 auto;
}

/* The host of a view that refreshes through AJAX: out of full screen, it is
   as if it were not there. */
.views-board-fullscreen-host:not(.views-board-fullscreen) {
  display: contents;
}

@media (prefers-reduced-motion: reduce) {
  .views-board__lane-toggle::before {
    transition: none;
  }
}
