﻿/* ============================================================================================
   Bortable demo - the styles of the live samples.

   The site's chrome, tokens and shared surfaces live in app.css (the site kit every Utilities demo
   shares); this file only draws what is Bortable's own - the lists, their items and the drag
   states - and it is written against the kit's --bb-* names, so it follows the light/dark theme
   with no rules of its own for either.
   ============================================================================================ */

/* The library's drag states, tinted with the site's brand color. html:root rather than :root:
   bit-bortable.css declares the same property on :root and is linked after this file, so a plain
   :root here would lose. Every list inherits it from there, and each state color is worked out
   from it on the item that wears the state. */
html:root {
    --bit-bortable-accent-rgb: 18, 118, 198;
}

html:root[bit-theme="dark"] {
    --bit-bortable-accent-rgb: 79, 163, 244;
}

/* Side-by-side lists. They wrap under each other once the column is too narrow for two. */
.demo-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.demo-columns > .demo-col {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Fluent's Overline over each list. */
.demo-col-title {
    margin-bottom: .5rem;
    font-size: var(--fl-font-size-100);
    font-weight: var(--fl-weight-semibold);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--bb-text-soft);
}

.demo-col-title--spaced {
    margin-top: 1.75rem;
}

/* The live readout of a bound list. The span holds just the items, joined with ", ". */
.demo-order {
    margin: .875rem 0 0;
    font-size: var(--fl-font-size-200);
    color: var(--bb-text-muted);
    overflow-wrap: anywhere;
}

.demo-order + .demo-order {
    margin-top: .25rem;
}

.demo-order strong {
    margin-inline-end: .25rem;
    color: var(--bb-text);
}

.demo-order span {
    color: var(--bb-text);
    font-family: var(--bb-mono);
    font-size: .8125rem;
}

/* A list: a recessed tray of cards. Padding and a minimum height leave an area to drop into even
   when it is empty. */
.demo-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 520px;
    min-height: 3.5rem;
    padding: .5rem;
    background: var(--bb-bg);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-lg);
}

/* In a column the tray fills it, so the shorter of two lists is as easy to drop into as the longer. */
.demo-col > .demo-list {
    flex: 1;
    max-width: none;
}

/* An item: a Fluent card at rest, raised a step on hover. */
.demo-item {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: .625rem .875rem;
    background: var(--bb-surface);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius);
    box-shadow: var(--bb-shadow-card);
    color: var(--bb-text);
    font-size: var(--fl-font-size-200);
    font-weight: var(--fl-weight-medium);
    cursor: grab;
    transition: border-color var(--bb-motion-duration-short) var(--bb-motion-easing),
                box-shadow var(--bb-motion-duration-short) var(--bb-motion-easing);
}

.demo-item:hover {
    border-color: color-mix(in srgb, var(--bb-primary) 45%, transparent);
    box-shadow: var(--fl-shadow-4);
}

.demo-item.tinted {
    border-color: color-mix(in srgb, var(--bb-primary) 30%, transparent);
    background: var(--bb-primary-soft);
}

/* Locked by a Filter predicate: the library gives such an item bit-bortable-filtered on its own. */
.demo-item.bit-bortable-filtered {
    border-color: color-mix(in srgb, var(--bb-danger) 40%, transparent);
    background: var(--bb-danger-soft);
    color: var(--bb-danger-text);
    cursor: not-allowed;
}

/* A Disabled list: the library gives its container bit-bortable-disabled, and nothing in it can be picked up. */
.demo-list.bit-bortable-disabled {
    border-style: dashed;
}

.bit-bortable-disabled > .demo-item {
    color: var(--bb-text-soft);
    box-shadow: none;
    cursor: not-allowed;
}

/* The empty state a list renders through ChildContent. It sits inside the list, after the items, so it is hidden
   while the list previews an item dropped into it. */
.demo-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: .5rem;
    border: 1px dashed var(--bb-border);
    border-radius: var(--bb-radius);
    color: var(--bb-text-soft);
    font-size: var(--fl-font-size-200);
}

.demo-list:has(> [data-bortable-placeholder]) > .demo-empty {
    display: none;
}

/* A row of controls over a sample: sliders with their value, checkboxes and choices. */
.demo-controls {
    display: flex;
    flex-direction: column;
    gap: .625rem;
    margin-bottom: 1.25rem;
    padding: .875rem 1rem;
    background: var(--bb-surface-sunken);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-lg);
}

.demo-controls label,
.demo-controls .demo-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .625rem;
    font-size: var(--fl-font-size-200);
    color: var(--bb-text);
}

.demo-controls strong {
    min-width: 2.6rem;
    font-family: var(--bb-mono);
    font-variant-numeric: tabular-nums;
}

.demo-controls input[type="range"] {
    flex: 1 1 160px;
    max-width: 260px;
}

.demo-controls .demo-check {
    gap: .5rem;
}

/* A readout over a sample's log: what the last drag did, or what was last announced. */
.demo-log-title {
    margin: 1rem 0 0;
    font-size: var(--fl-font-size-100);
    font-weight: var(--fl-weight-semibold);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--bb-text-soft);
}

.demo-log-title + .bb-log {
    margin-top: .5rem;
}

/* The bar over the Events page's log: what a line says, and the button that clears it. */
.demo-log-bar {
    margin: 1rem 0 0;
}

.demo-log-bar + .bb-log {
    margin-top: .5rem;
}

.demo-log-legend {
    font-size: var(--fl-font-size-100);
    color: var(--bb-text-soft);
}

/* The ghost: the dragged item in its list, and the placeholder that previews where it lands in another. */
.demo-ghost {
    opacity: 1 !important;
    border-style: dashed !important;
    border-color: var(--bb-primary) !important;
    background: var(--bb-primary-soft) !important;
    box-shadow: none !important;
}

/* The library's swap and selection states, restated for the cards: .demo-item paints its own
   background, border and shadow, and these have to win over it, over .tinted and over :hover.
   bit-bortable.css declares no --bit-bortable-swap-* or -selected-* property, only uses them with
   its defaults as fallbacks, so the same fallbacks are repeated here: a var() of an undeclared
   property with none would void the whole declaration, leaving the card bare. */
.demo-item.bit-bortable-swap-highlight,
.nested-item.bit-bortable-swap-highlight {
    --demo-swap-bg: var(--bit-bortable-swap-bg, rgba(var(--bit-bortable-accent-rgb), 0.18));
    background: linear-gradient(var(--demo-swap-bg), var(--demo-swap-bg)), var(--bb-surface);
    outline: var(--bit-bortable-swap-outline, 2px dashed rgba(var(--bit-bortable-accent-rgb), 0.6));
    outline-offset: -2px;
}

.demo-item.bit-bortable-selected {
    --demo-selected-bg: var(--bit-bortable-selected-bg, rgba(var(--bit-bortable-accent-rgb), 0.25));
    border-color: transparent;
    background: linear-gradient(var(--demo-selected-bg), var(--demo-selected-bg)), var(--bb-surface);
    box-shadow: var(--bit-bortable-selected-ring, inset 0 0 0 2px rgba(var(--bit-bortable-accent-rgb), 0.8));
}

/* The drag handle of the Handle page: the only part of a row that starts a drag. */
.handle {
    margin-inline-end: .625rem;
    padding: 0 .125rem;
    color: var(--bb-text-soft);
    font-size: 1.0625rem;
    line-height: 1;
    cursor: grab;
    user-select: none;
}

.handle:hover {
    color: var(--bb-primary);
}

.handle:active {
    cursor: grabbing;
}

/* With a handle only the handle drags: the rest of a row keeps the default cursor. */
.bit-bortable-has-handle > .demo-item {
    cursor: default;
}

/* The Rules page: the board outlines the columns that take the dragged card, and a column that refuses it. */
.rules-board {
    --bit-bortable-accepts-outline: 2px dashed color-mix(in srgb, var(--bb-primary) 45%, transparent);
    --bit-bortable-over-outline: 2px solid var(--bb-primary);
    --bit-bortable-refused-outline: 2px solid #dc2626;
}

/* The Keyboard and screen readers page: the buttons that move an item without dragging it. */
.a11y-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.a11y-actions {
    display: inline-flex;
    gap: .25rem;
}

.a11y-actions button {
    min-width: 1.75rem;
    min-height: 1.75rem;
    border: 1px solid var(--bb-border);
    border-radius: .375rem;
    background: var(--bb-surface);
    color: inherit;
    cursor: pointer;
}

.a11y-actions button:focus-visible {
    outline: 2px solid var(--bb-primary);
    outline-offset: 1px;
}

/* The Large list page: a scrolling panel of rows. */
.large-panel {
    max-height: 520px;
    overflow: auto;
    border: 1px solid var(--bb-border);
    border-radius: .5rem;
    padding: .5rem;
}

.large-panel .demo-item {
    display: flex;
    justify-content: space-between;
}

.large-note {
    color: var(--bb-text-soft);
    font-size: .8125rem;
}

/* The Touch page's handle drags at once on a touch screen: the browser must not scroll from it. */
.touch-handle {
    touch-action: none;
}

/* Grid example: the list is a CSS grid; each item wraps a square. */
.demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: .625rem;
    max-width: 520px;
}

.grid-square {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 90px;
    border-radius: var(--bb-radius-lg);
    background: linear-gradient(135deg, var(--bb-primary) 0%, var(--bb-primary-active) 100%);
    box-shadow: var(--bb-shadow-card);
    color: var(--bb-primary-text);
    font-size: var(--fl-font-size-400);
    font-weight: var(--fl-weight-semibold);
    cursor: grab;
}

.demo-grid > .bit-bortable-item:hover .grid-square {
    box-shadow: var(--bb-shadow-raised);
}

/* The square covers its wrapper, so the ghost state is drawn on the square, and the wrapper -
   square where the square is rounded - stays clear. */
.demo-grid > .demo-ghost {
    background: transparent !important;
}

.demo-ghost .grid-square {
    outline: 2px dashed var(--bb-primary);
    outline-offset: -2px;
    background: var(--bb-primary-soft);
    box-shadow: none;
    color: var(--bb-primary);
}

/* The Grid and layouts page: a row of chips that wraps - a horizontal list, as Direction="Auto" reads it from the
   layout - laid out left to right, or right to left under dir="rtl". */
.demo-strip {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 3.5rem;
    padding: .5rem;
    background: var(--bb-bg);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-lg);
}

.demo-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    padding: .375rem .875rem;
    background: var(--bb-surface);
    border: 1px solid var(--bb-border);
    border-radius: 999px;
    box-shadow: var(--bb-shadow-card);
    color: var(--bb-text);
    font-size: var(--fl-font-size-200);
    font-weight: var(--fl-weight-medium);
    cursor: grab;
}

.demo-chip:hover {
    border-color: color-mix(in srgb, var(--bb-primary) 45%, transparent);
}

/* The Handle and Filter pages: rows that carry controls of their own next to their text. */
.demo-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.demo-row > input[type="text"] {
    flex: 1;
    min-width: 0;
}

.demo-row > .demo-row__text {
    flex: 1;
    min-width: 0;
}

.demo-icon-btn {
    min-width: 1.75rem;
    min-height: 1.75rem;
    border: 1px solid var(--bb-border);
    border-radius: .375rem;
    background: var(--bb-surface);
    color: inherit;
    cursor: pointer;
}

.demo-icon-btn:focus-visible {
    outline: 2px solid var(--bb-primary);
    outline-offset: 1px;
}

/* The Styling page. Its cards paint only a background colour, so the library's own drag states - drawn with
   background-color and opacity, tinted with the accent the page picks - show as the stylesheet draws them. */
.styling-item {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: .625rem .875rem;
    background-color: var(--bb-surface);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius);
    color: var(--bb-text);
    font-size: var(--fl-font-size-200);
    font-weight: var(--fl-weight-medium);
}

/* The classes of its own the second list of the Styling page passes through GhostClass, ChosenClass and DragClass. */
.my-ghost {
    opacity: .55;
    outline: 2px dashed var(--bb-warning);
    outline-offset: -2px;
}

.my-chosen {
    background-color: var(--bb-warning-soft);
}

.my-drag {
    rotate: -3deg;
    opacity: .95;
    outline: 2px solid var(--bb-warning);
    box-shadow: 0 18px 36px rgba(0, 0, 0, .25);
}

/* Nested example. Every item holds a list of its own; the padding and minimum height keep an empty
   branch big enough to drop into. */
.nested-list {
    display: flex;
    flex-direction: column;
    gap: .375rem;
    min-height: 2.5rem;
    padding: .4375rem;
    background: color-mix(in srgb, var(--bb-primary) 4%, transparent);
    border: 1px dashed color-mix(in srgb, var(--bb-primary) 35%, transparent);
    border-radius: var(--bb-radius);
}

#nested-root {
    max-width: 640px;
}

.nested-item {
    padding: .5rem .5rem .5625rem;
    background: var(--bb-surface);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius);
    box-shadow: var(--bb-shadow-card);
    cursor: grab;
}

/* Only the innermost item under the pointer lights up, not every item around it. */
.nested-item:hover:not(:has(.nested-item:hover)) {
    border-color: color-mix(in srgb, var(--bb-primary) 45%, transparent);
}

.nested-item__name {
    margin: 0 0 .375rem .1875rem;
    color: var(--bb-text);
    font-size: var(--fl-font-size-200);
    font-weight: var(--fl-weight-medium);
}

/* Events example: the log itself is the kit's .bb-log. */
.event-log {
    margin: 1rem 0 0;
    max-height: 220px;
}

/* Thresholds example. */
.threshold-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 300px;
}

/* The swap-zone visualizer. Each item draws its active zones, sized by the --zone and
   --inverted-zone the page sets on the list: one band of --zone across the middle, or with
   InvertSwap two bands of --inverted-zone / 2 at the edges - the geometry bit-bortable.js
   hit-tests against. The list is measured top to bottom, the grid left to right
   (Direction="Horizontal"). */
.show-zones > .bit-bortable-item {
    position: relative;
}

.show-zones > .bit-bortable-item::before,
.show-zones > .bit-bortable-item::after {
    content: "";
    position: absolute;
    border: 1px dashed color-mix(in srgb, var(--bb-primary) 60%, transparent);
    border-radius: var(--bb-radius-sm);
    background: color-mix(in srgb, var(--bb-primary) 14%, transparent);
    pointer-events: none;
}

.show-zones > .bit-bortable-item::after {
    display: none;
}

.threshold-list.show-zones > .bit-bortable-item::before {
    left: 3px;
    right: 3px;
    top: calc((1 - var(--zone)) * 50%);
    bottom: calc((1 - var(--zone)) * 50%);
}

.threshold-list.show-zones.zones-inverted > .bit-bortable-item::before,
.threshold-list.show-zones.zones-inverted > .bit-bortable-item::after {
    display: block;
    left: 3px;
    right: 3px;
    height: calc(var(--inverted-zone) * 50%);
}

.threshold-list.show-zones.zones-inverted > .bit-bortable-item::before {
    top: 0;
    bottom: auto;
}

.threshold-list.show-zones.zones-inverted > .bit-bortable-item::after {
    bottom: 0;
}

.threshold-grid.show-zones > .bit-bortable-item::before,
.threshold-grid.show-zones > .bit-bortable-item::after {
    border-color: rgba(255, 255, 255, .85);
    background: rgba(255, 255, 255, .26);
}

.threshold-grid.show-zones > .bit-bortable-item::before {
    top: 3px;
    bottom: 3px;
    left: calc((1 - var(--zone)) * 50%);
    right: calc((1 - var(--zone)) * 50%);
}

.threshold-grid.show-zones.zones-inverted > .bit-bortable-item::before,
.threshold-grid.show-zones.zones-inverted > .bit-bortable-item::after {
    display: block;
    top: 3px;
    bottom: 3px;
    width: calc(var(--inverted-zone) * 50%);
}

.threshold-grid.show-zones.zones-inverted > .bit-bortable-item::before {
    left: 0;
    right: auto;
}

.threshold-grid.show-zones.zones-inverted > .bit-bortable-item::after {
    right: 0;
}

/* The "View code" toggle: the kit's secondary button, with the caret and the code glyph in it. */
.demo-code__caret {
    font-size: .8em;
    color: var(--bb-text-soft);
}

.demo-code__glyph {
    font-family: var(--bb-mono);
    color: var(--bb-primary);
}

/* The panel follows the sample it shows the code of, as close under it as the sample's frame sits to
   what follows it. A panel that ends a section of the page, rather than a card, keeps the gap the
   sections have between them. */
.demo-code {
    margin: 1.25rem 0;
}

.bb-docs-content > .demo-code {
    margin-bottom: 2.5rem;
}

/* ---------- Code: SyntaxHighlighter's tokens on the kit's code surface ----------

   The highlighter tells more kinds apart than the kit's four (keyword, string, comment, parameter),
   so the extra ones get colours of their own here, light and dark, picked to hold their contrast on
   --bb-code-bg in both themes. */
:root {
    --demo-code-type: #8250DF;
    --demo-code-fn: #795E26;
    --demo-code-number: #CF222E;
    --demo-code-razor: #A21CAF;
}

:root[bit-theme="dark"] {
    --demo-code-type: #D2A8FF;
    --demo-code-fn: #DCDCAA;
    --demo-code-number: #FF7B72;
    --demo-code-razor: #F0ABFC;
}

.bb-code .tok-com { color: var(--bb-code-comment); font-style: italic; }
.bb-code .tok-pun { color: var(--bb-code-comment); }
.bb-code .tok-tag,
.bb-code .tok-key { color: var(--bb-code-keyword); }
.bb-code .tok-str { color: var(--bb-code-string); }
.bb-code .tok-attr { color: var(--bb-code-param); }
.bb-code .tok-type { color: var(--demo-code-type); }
.bb-code .tok-fn { color: var(--demo-code-fn); }
.bb-code .tok-num { color: var(--demo-code-number); }
.bb-code .tok-raz { color: var(--demo-code-razor); }

/* The landing page's hero: the live list under the sample's markup, inside the window frame. */
.home-hero-live {
    padding: 1rem;
    background: var(--bb-surface);
    border-top: 1px solid var(--bb-border);
}

.home-hero-live .demo-list {
    max-width: none;
}
