/* WebDragDrop lists and boards (DragDropList, DragDropBoard). Colors match the WebEditor (DdtTheme tokens).
   --wdd-column-width sets the width of the columns (Columns) and the smallest width of the boxes (Wrap). */
/* The component is the containing block of its own absolutely placed parts (the hidden help, the file field): in a
   layout whose inner box scrolls (not positioned), they would otherwise count in the height of the whole page and
   give it a second scrollbar. */
.wdd-root {
    position: relative;
}

.wdd-board {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
    font-family: var(--ddt-font);
    color: var(--ddt-text);
}

.wdd-column {
    display: flex;
    flex: 0 0 var(--wdd-column-width, 280px);
    flex-direction: column;
    max-height: 75vh;
    border: 1px solid var(--ddt-border);
    border-radius: var(--ddt-radius-lg);
    background: var(--ddt-surface-muted);
}

/* Groups: one under another, full width; a group grows with its items. */
.wdd-groups {
    flex-direction: column;
    align-items: stretch;
    overflow-x: visible;
}

.wdd-groups .wdd-column {
    flex: 0 0 auto;
    max-height: none;
}

.wdd-groups .wdd-column .wdd-items {
    overflow-y: visible;
}

/* Wrap: boxes side by side, as many as fit in a row (each at least the column width, sharing the rest), the others
   in the next rows; one under another on a narrow screen. */
.wdd-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(var(--wdd-column-width, 280px), 100%), 1fr));
    overflow-x: visible;
}

.wdd-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px 6px;
    font-weight: 700;
}

.wdd-column-count {
    min-width: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--ddt-surface);
    color: var(--ddt-text-muted);
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.wdd-column .wdd-items {
    overflow-y: auto;
    padding: 6px 8px 10px;
}

.wdd-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 44px;
}

.wdd-list {
    font-family: var(--ddt-font);
    color: var(--ddt-text);
}

.wdd-item {
    padding: 10px 12px;
    border: 1px solid var(--ddt-border);
    border-radius: var(--ddt-radius);
    background: var(--ddt-surface);
    color: var(--ddt-text);
}

.wdd-item[data-wdd-drag="true"] {
    cursor: grab;
    -webkit-touch-callout: none;
    user-select: none;
}

.wdd-item[data-wdd-drag="true"]:has([data-wdd-handle]) {
    cursor: auto;
    user-select: auto;
}

.wdd-item [data-wdd-handle] {
    cursor: grab;
    touch-action: none;
}

/* Editing in place: the content and the edit button side by side; the button shows on hover and focus (always on
   touch screens, which have no hover). */
.wdd-item.wdd-editable {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.wdd-item-content {
    flex: 1;
    min-width: 0;
}

.wdd-edit {
    display: flex;
    flex: 1;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
}

.wdd-edit-input {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
    border: 1px solid var(--ddt-accent);
    border-radius: var(--ddt-radius-sm);
    background: var(--ddt-surface);
    color: var(--ddt-text);
    font: inherit;
    resize: vertical;
}

.wdd-edit-open,
.wdd-edit-button {
    flex: 0 0 auto;
    padding: 1px 7px;
    border: 1px solid var(--ddt-border);
    border-radius: var(--ddt-radius-sm);
    background: var(--ddt-surface);
    color: var(--ddt-text-muted);
    font: inherit;
    line-height: 1.4;
    cursor: pointer;
}

.wdd-edit-open:hover,
.wdd-edit-open:focus-visible,
.wdd-edit-button:hover,
.wdd-edit-button:focus-visible {
    border-color: var(--ddt-accent);
    color: var(--ddt-text);
}

.wdd-edit-open {
    opacity: 0;
}

/* Only the item's own button: a tree item holds its children, whose hover must not show the parent's button. */
.wdd-item:hover > .wdd-edit-open,
.wdd-item:focus-within > .wdd-edit-open,
.wdd-node-head:hover > .wdd-edit-open,
.wdd-node-head:focus-within > .wdd-edit-open,
.wdd-item:focus > .wdd-node-head > .wdd-edit-open {
    opacity: 1;
}

@media (hover: none) {
    .wdd-edit-open {
        opacity: 1;
    }
}

/* Selected items (AllowMultiSelect); dragging one of them takes all along, the copy shows how many. */
.wdd-item.wdd-selected,
.wdd-tree .wdd-item.wdd-selected > .wdd-node-head {
    border-color: var(--ddt-accent);
    background: var(--ddt-accent-subtle);
}

.wdd-ghost[data-wdd-count]::after {
    content: attr(data-wdd-count);
    position: absolute;
    top: -10px;
    right: -10px;
    min-width: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--ddt-accent);
    color: var(--ddt-on-accent);
    font-size: 12px;
    font-weight: 700;
    line-height: 24px;
    text-align: center;
}

/* A full column (its WIP limit reached). */
.wdd-full > .wdd-column-header .wdd-column-count,
.wdd-column-header.wdd-full .wdd-column-count {
    background: var(--ddt-danger-bg);
    color: var(--ddt-danger-strong);
}

/* Tiles in rows (ItemsLayout = Grid): --wdd-tile-width sets the smallest tile width. */
.wdd-grid .wdd-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(var(--wdd-tile-width, 160px), 100%), 1fr));
    align-items: start;
}

/* Swimlanes: a header row of columns, then every lane as a title and a row of cells; the columns line up. */
.wdd-swimlanes {
    display: grid;
    gap: 10px;
    overflow-x: auto;
}

.wdd-swim-row {
    display: grid;
    grid-template-columns: repeat(var(--wdd-swim-columns, 3), minmax(var(--wdd-column-width, 240px), 1fr));
    gap: 8px;
    min-width: min-content;
}

.wdd-swim-head .wdd-column-header {
    border-radius: var(--ddt-radius);
    background: var(--ddt-surface-muted);
}

.wdd-swim-lane {
    min-width: min-content;
    padding: 0 8px 8px;
    border: 1px solid var(--ddt-border);
    border-radius: var(--ddt-radius-lg);
    background: var(--ddt-surface-muted);
}

.wdd-swim-lane-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    font-weight: 700;
}

.wdd-swim-cell {
    position: relative;
    min-height: 56px;
    padding: 6px;
    border-radius: var(--ddt-radius);
    background: var(--ddt-surface-subtle, var(--ddt-surface));
}

/* A cell's own limit (CellLimit): its count on the top right, red when full. */
.wdd-cell-limit {
    align-self: flex-end;
    margin: -2px -2px 0 0;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--ddt-surface-muted);
    color: var(--ddt-text-muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
}

.wdd-cell-limit.wdd-full {
    background: var(--ddt-danger-bg);
    color: var(--ddt-danger-strong);
}

/* A tree: every item is its own row (the head) with its children indented under it. The application sets the look
   with these variables (on the tree or any of its ancestors); the component keeps the mechanics. --wdd-tree-indent is
   also read by the script (the level lines and the drop line follow it). */
.wdd-tree {
    --wdd-tree-indent: 24px;
    --wdd-tree-row-gap: 8px;
    --wdd-tree-children-gap: 6px;
    --wdd-tree-padding-y: 8px;
    --wdd-tree-padding-x: 10px;
    --wdd-tree-border: 1px solid var(--ddt-border);
    --wdd-tree-radius: var(--ddt-radius);
    --wdd-tree-background: var(--ddt-surface);
    --wdd-tree-hover: var(--ddt-surface);
    --wdd-tree-line: var(--ddt-border);
}

/* Compact (Compact = true): rows without cards, as in a file explorer; a row lights up under the pointer. */
.wdd-tree.wdd-compact {
    --wdd-tree-row-gap: 0px;
    --wdd-tree-children-gap: 0px;
    --wdd-tree-padding-y: 3px;
    --wdd-tree-padding-x: 8px;
    --wdd-tree-border: 1px solid transparent;
    --wdd-tree-background: transparent;
    --wdd-tree-hover: var(--ddt-hover, var(--ddt-surface-muted));
}

.wdd-tree .wdd-items {
    gap: var(--wdd-tree-row-gap);
}

.wdd-tree .wdd-item,
.wdd-tree .wdd-item.wdd-editable {
    display: block;
    padding: 0;
    border: none;
    background: none;
}

.wdd-node-head {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: var(--wdd-tree-padding-y) var(--wdd-tree-padding-x);
    border: var(--wdd-tree-border);
    border-radius: var(--wdd-tree-radius);
    background: var(--wdd-tree-background);
}

.wdd-node-head:hover {
    background: var(--wdd-tree-hover);
}

.wdd-tree-children {
    margin: var(--wdd-tree-children-gap) 0 0 var(--wdd-tree-indent);
}

/* In a tree the edit button stands right after the text (where the eye is), not at the far end of the row. */
.wdd-node-head > .wdd-item-content {
    flex: 0 1 auto;
}

/* The number of items in a collapsed branch. */
.wdd-tree-count {
    flex: 0 0 auto;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--ddt-surface-muted);
    color: var(--ddt-text-muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* Level lines (ShowLevels): every children list has a line at its left edge, under its parent's expand button; a
   click on the line collapses the branch. While dragging the lines are stronger. */
.wdd-levels .wdd-node-head {
    padding-left: 2px;
}

.wdd-levels .wdd-tree-children {
    margin: var(--wdd-tree-children-gap) 0 0 calc(var(--wdd-tree-indent) / 2);
    padding-left: calc(var(--wdd-tree-indent) / 2 - 1px);
    border-left: 1px solid var(--wdd-tree-line);
}

html.wdd-dragging .wdd-levels .wdd-tree-children {
    border-left-color: var(--ddt-border-strong);
}

/* A dragged branch shows only its own row and how many items it takes along. */
.wdd-ghost-more {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--ddt-accent);
    color: var(--ddt-on-accent);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
}

/* The group an item goes into (a tree): boxed, named above and its level as a tab on the left. */
.wdd-zone.wdd-zone-branch {
    border: 2px solid var(--ddt-accent);
    border-radius: var(--ddt-radius);
    background: rgba(var(--ddt-accent-rgb), 0.07);
}

.wdd-label {
    position: fixed;
    z-index: 10003;
    display: none;
    max-width: 360px;
    overflow: hidden;
    padding: 1px 10px;
    border-radius: 999px;
    background: var(--ddt-accent);
    color: var(--ddt-on-accent);
    font-family: var(--ddt-font);
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(var(--ddt-shadow-rgb), 0.2);
    pointer-events: none;
}

.wdd-level-tab {
    position: fixed;
    z-index: 10002;
    display: none;
    box-sizing: border-box;
    width: 18px;
    padding: 6px 0;
    border-radius: var(--ddt-radius-sm) 0 0 var(--ddt-radius-sm);
    background: var(--ddt-accent);
    color: var(--ddt-on-accent);
    font-family: var(--ddt-font);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    pointer-events: none;
}

/* The same height with or without a button inside (a leaf's is hidden), so all rows are equally high. */
.wdd-tree-toggle {
    flex: 0 0 auto;
    width: 20px;
    height: 1.5em;
    padding: 0;
    border: none;
    background: none;
    color: var(--ddt-text-muted);
    font: inherit;
    line-height: 1.5;
    cursor: pointer;
}

.wdd-tree-toggle.wdd-tree-leaf {
    visibility: hidden;
}

.wdd-tree .wdd-item.wdd-flash,
.wdd-tree .wdd-item.wdd-changed {
    animation: none;
}

.wdd-tree .wdd-item.wdd-flash > .wdd-node-head {
    animation: wdd-flash 3s ease-out;
}

.wdd-tree .wdd-item.wdd-changed > .wdd-node-head {
    animation: wdd-changed 3.5s ease-out;
}

.wdd-tree .wdd-item:focus-visible > .wdd-node-head {
    border-color: var(--ddt-accent);
    box-shadow: 0 0 0 3px rgba(var(--ddt-focus-rgb), 0.18);
}

/* Files dropped from the computer: while files are dragged over the component, its file field covers it. */
.wdd-file-drop {
    display: none;
}

.wdd-file-over .wdd-file-drop {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: copy;
}

/* Read only: no grab cursor, no handles. */
.wdd-readonly [data-wdd-handle] {
    display: none;
}

.wdd-item:focus-visible {
    outline: none;
    border-color: var(--ddt-accent);
    box-shadow: 0 0 0 3px rgba(var(--ddt-focus-rgb), 0.18);
}

/* An item just moved to another column. */
.wdd-item.wdd-flash {
    animation: wdd-flash 3s ease-out;
}

@keyframes wdd-flash {
    0%, 50% {
        border-color: var(--ddt-accent);
        background: var(--ddt-accent-subtle);
        box-shadow: 0 0 0 3px rgba(var(--ddt-accent-rgb), 0.35);
    }
}

/* An item changed elsewhere (another user, another window): another color, longer. */
.wdd-item.wdd-changed {
    animation: wdd-changed 3.5s ease-out;
}

@keyframes wdd-changed {
    0%, 55% {
        border-color: var(--ddt-warning-border);
        background: var(--ddt-warning-bg);
    }
}

.wdd-item.wdd-source {
    opacity: 0.35;
}

.wdd-empty {
    padding: 12px;
    border: 1px dashed var(--ddt-border);
    border-radius: var(--ddt-radius);
    color: var(--ddt-text-muted);
    font-size: 13px;
    text-align: center;
}

/* The dragged copy, the drop line and the column highlight live on <body>, above everything; the line above the
   copy, so the place stays visible under the pointer. */
.wdd-ghost {
    position: fixed;
    z-index: 10000;
    margin: 0;
    box-sizing: border-box;
    pointer-events: none;
    opacity: 0.9;
    box-shadow: 0 10px 24px rgba(var(--ddt-shadow-rgb), 0.22);
    cursor: grabbing;
}

.wdd-line {
    position: fixed;
    z-index: 10001;
    display: none;
    height: 3px;
    border-radius: 2px;
    background: var(--ddt-accent);
    pointer-events: none;
}

.wdd-zone {
    position: fixed;
    z-index: 9998;
    display: none;
    box-sizing: border-box;
    border: 2px dashed var(--ddt-accent);
    border-radius: var(--ddt-radius-lg);
    background: rgba(var(--ddt-accent-rgb), 0.08);
    pointer-events: none;
}

/* While dragging, the lists (columns, cells) that do not take the dragged item fade out. */
.wdd-list-blocked {
    opacity: 0.4;
    filter: grayscale(0.6);
    transition: opacity 0.15s;
}

/* Soft limits (LimitMode Warn): while dragging, the lists where the item would go over a limit have an amber
   outline, and hovering one shows an amber box with "Over the limit: 3 / 2"; a column, cell or lane over its limit
   stays marked. */
.wdd-list-over {
    outline: 2px dashed var(--ddt-warning-border);
    outline-offset: -2px;
}

.wdd-zone.wdd-zone-over {
    border-color: var(--ddt-warning-border);
    background: rgba(212, 167, 44, 0.12);
}

.wdd-label.wdd-label-over {
    border: 1px solid var(--ddt-warning-border);
    background: var(--ddt-warning-bg);
    color: var(--ddt-warning-text, var(--ddt-text));
}

.wdd-column.wdd-over,
.wdd-swim-cell.wdd-over,
.wdd-swim-lane.wdd-over {
    box-shadow: inset 0 0 0 2px var(--ddt-warning-border);
}

.wdd-swim-cell.wdd-over,
.wdd-column.wdd-over > .wdd-column-header,
.wdd-column-header.wdd-over {
    background: var(--ddt-warning-bg);
}

.wdd-over > .wdd-column-header .wdd-column-count,
.wdd-column-header.wdd-over .wdd-column-count,
.wdd-swim-cell.wdd-over > .wdd-cell-limit {
    background: var(--ddt-danger-bg);
    color: var(--ddt-danger-strong);
}

/* A list that does not take the dragged item (a rule, a hard limit). */
.wdd-zone.wdd-zone-blocked {
    border-color: var(--ddt-danger-border);
    background: var(--ddt-danger-bg-subtle, var(--ddt-danger-bg));
    cursor: not-allowed;
}

/* Onto an item: the dragged item goes under it. */
.wdd-zone.wdd-zone-into {
    border-style: solid;
    border-radius: var(--ddt-radius);
    background: rgba(var(--ddt-accent-rgb), 0.14);
}

.wdd-zone.wdd-zone-files {
    border-style: dotted;
}

html.wdd-dragging,
html.wdd-dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}

.wdd-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
