/*
 * DXP dashboards. Visual language borrowed from the boards we build:
 * blue-slate solder mask for the ground, white silkscreen for text,
 * and ENIG gold as the one accent (most visibly the "Up next" rail,
 * drawn as plated vias joined by a trace).
 *
 * Type is Atkinson Hyperlegible Next, drawn so look-alike characters can't
 * be confused (slashed zero, distinct I/l/1, real parentheses), which is
 * what a wall screen full of keys and version numbers needs.
 */

:root {
    color-scheme: dark;

    /* Board: blue-slate solder mask */
    --mask: #141c24;          /* page ground */
    --mask-raised: #1c2630;   /* cards, panels */
    --mask-high: #27323e;     /* pressed controls, hover */
    --mask-edge: #2f3c49;     /* rules, outlines */
    --silk: #edf1f4;          /* primary text */
    --silk-2: #adb8c3;        /* secondary text */
    --silk-3: #7b8895;        /* tertiary text */
    --gold: #d8b25c;          /* ENIG accent */
    --gold-dim: #86703f;
    --scroll-thumb: #3a4855;

    /* Status hues: solid, ink for text on tint; tints are mixed into the
       mask so they always sit on the board colour */
    --progress: #5b8def;      --progress-ink: #a9c4ff;
    --blocked: #e8833a;       --blocked-ink: #ffbd8a;
    --eco: #4fb477;           --eco-ink: #98e3b4;
    --accepted: #3cb7b0;      --accepted-ink: #8fe3dc;
    --queued: var(--gold);    --queued-ink: #f0d48e;
    --neutral: #5f6c79;       --neutral-ink: var(--silk-2);
    --good: #4fb477;          --good-ink: #98e3b4;
    --warn: #e0b43a;          --warn-ink: #f5d77f;
    --bad: #ec5a6a;           --bad-ink: #ffa3ad;

    --progress-tint: color-mix(in srgb, var(--progress) 24%, var(--mask));
    --blocked-tint:  color-mix(in srgb, var(--blocked) 22%, var(--mask));
    --eco-tint:      color-mix(in srgb, var(--eco) 22%, var(--mask));
    --accepted-tint: color-mix(in srgb, var(--accepted) 22%, var(--mask));
    --queued-tint:   color-mix(in srgb, var(--queued) 20%, var(--mask));
    --neutral-tint:  color-mix(in srgb, var(--neutral) 25%, var(--mask));
    --good-tint:     color-mix(in srgb, var(--good) 22%, var(--mask));
    --warn-tint:     color-mix(in srgb, var(--warn) 20%, var(--mask));
    --bad-tint:      color-mix(in srgb, var(--bad) 22%, var(--mask));

    --red-alert: #ff5d6c;
    --yellow-alert: #f7e04b;

    --font: "Atkinson Hyperlegible Next", system-ui, sans-serif;

    /* Radii follow hierarchy: controls are soft, data marks are crisp */
    --r-control: 8px;
    --r-card: 6px;
    --r-mark: 3px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--mask);
    color: var(--silk);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

/* Thin, theme-coloured scrollbars. Chromium/Safari get the ::-webkit rules
   (which allow hiding the arrow buttons); the standard properties are kept to
   Firefox since in Chrome they'd override the ::-webkit styling */
@supports not selector(::-webkit-scrollbar) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--scroll-thumb) transparent;
    }
    *:hover { scrollbar-color: var(--silk-3) transparent; }
}
::-webkit-scrollbar-button { display: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--silk-3); }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
button { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: var(--r-mark);
}

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 20px;
    background: var(--mask);
    border-bottom: 1px solid var(--mask-edge);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.04em;
}
/* A plated via as the mark */
.brand::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 3px solid var(--gold);
}
.brand:hover { text-decoration: none; }
.tabs { display: flex; gap: 2px; }
.tabs a {
    padding: 6px 12px;
    border-radius: var(--r-control);
    color: var(--silk-2);
}
.tabs a:hover { color: var(--silk); text-decoration: none; }
.tabs a[aria-current="page"] {
    color: var(--silk);
    font-weight: 700;
    box-shadow: inset 0 -2px 0 var(--gold);
    border-radius: 0;
}
.sync {
    margin-left: auto;
    color: var(--silk-3);
    font-size: 12.5px;
    white-space: nowrap;
}
.sync[data-state="error"] { color: var(--bad-ink); }

main { padding: 16px 20px 40px; }

/* ---------- Toolbar & controls ---------- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin-bottom: 10px;
}
.toolbar + .toolbar { margin-bottom: 16px; }
.toolbar-label {
    color: var(--silk-3);
    font-size: 12.5px;
}

.search {
    flex: 0 1 280px;
    min-width: 180px;
    padding: 7px 11px;
    border: 1px solid var(--mask-edge);
    border-radius: var(--r-control);
    background: var(--mask-raised);
    color: var(--silk);
    font: inherit;
}
.search::placeholder { color: var(--silk-3); }
.search:focus { outline: 2px solid var(--gold); outline-offset: -1px; }

.seg {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--mask-edge);
    border-radius: var(--r-control);
    background: var(--mask-raised);
}
.seg button {
    border: 0;
    background: none;
    padding: 5px 11px;
    border-radius: 6px;
    color: var(--silk-2);
    cursor: pointer;
    white-space: nowrap;
}
.seg button:hover { color: var(--silk); }
.seg button[aria-pressed="true"] { background: var(--mask-high); color: var(--silk); font-weight: 700; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--mask-edge);
    border-radius: var(--r-control);
    background: transparent;
    color: var(--silk-2);
    cursor: pointer;
    white-space: nowrap;
}
.chip:hover { color: var(--silk); border-color: var(--silk-3); }
.chip[aria-pressed="true"] { background: var(--mask-high); color: var(--silk); border-color: var(--silk-3); }
.chip[aria-pressed="false"].person { opacity: 0.45; }
.chip .count { color: var(--silk-3); }
.chip .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--neutral)); }
.chip img.avatar, .chip .avatar { width: 18px; height: 18px; font-size: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.linkish {
    border: 0;
    background: none;
    color: var(--gold);
    cursor: pointer;
    padding: 4px;
}
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Avatars ---------- */

.avatar {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--mask-high);
    color: var(--silk-2);
    font-size: 10px;
    font-weight: 700;
    object-fit: cover;
}
.avatar.lg { width: 34px; height: 34px; font-size: 13px; }

/* ---------- Status colours (shared by pills, meters, cards) ---------- */

[data-status="In Progress"] { --c: var(--progress); --tint: var(--progress-tint); --ink: var(--progress-ink); }
[data-status="Blocked"]     { --c: var(--blocked);  --tint: var(--blocked-tint);  --ink: var(--blocked-ink); }
[data-status="ECO'd"]       { --c: var(--eco);      --tint: var(--eco-tint);      --ink: var(--eco-ink); }
[data-status="Queued"]      { --c: var(--queued);   --tint: var(--queued-tint);   --ink: var(--queued-ink); }
[data-status="Accepted"]    { --c: var(--accepted); --tint: var(--accepted-tint); --ink: var(--accepted-ink); }

.pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: var(--r-mark);
    background: var(--tint, var(--neutral-tint));
    color: var(--ink, var(--neutral-ink));
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

/* ---------- Project board ---------- */

/* One row of open columns sharing the width, scrolling sideways only when they can't fit */
.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 1fr);
    align-items: start;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
}
.board > .lane { scroll-snap-align: start; }

.lane {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    min-height: 100%;
    padding: 0 12px 12px;
    border-left: 1px solid var(--mask-edge);
}
.lane:first-child { border-left: 0; padding-left: 0; }
.lane-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 2px 0 8px;
    background: var(--mask);
}
.lane-head {
    display: flex;
    align-items: center;
    gap: 10px;
}
.lane-head .who { min-width: 0; flex: 1; }
.lane-head .name {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lane-head .sub { color: var(--silk-3); font-size: 12px; }
.lane-head .sub .warn { color: var(--blocked-ink); }
/* Every slot blocked or waiting: the header carries an orange bar */
.lane[data-blocked="true"] .lane-top { box-shadow: inset 0 3px 0 var(--blocked); padding-top: 9px; }
.lane[data-blocked="true"] .name { color: var(--blocked-ink); }
.lane-empty {
    padding: 10px;
    color: var(--silk-3);
    font-size: 12.5px;
    text-align: center;
    border: 1px dashed var(--mask-edge);
    border-radius: var(--r-card);
}

/* Capacity meter: one pad per slot, filled with the status of what's in it */
.meter { display: flex; align-items: center; gap: 8px; }
.meter .segs { display: flex; flex: 1; flex-wrap: wrap; gap: 3px; min-width: 0; }
.meter .seg-cell {
    width: 9px;
    height: 12px;
    border-radius: 2px;
    background: var(--c, transparent);
    box-shadow: inset 0 0 0 1px var(--mask-edge);
}
.meter .seg-cell[data-status] { box-shadow: none; }
/* Slots past capacity sit in their own outlined group */
.meter .over-group {
    display: flex;
    gap: 3px;
    margin: -3px 0 -3px 3px;
    padding: 2px;
    border: 1px solid var(--bad);
    border-radius: 4px;
}
.meter .label { flex: none; font-size: 12px; color: var(--silk-3); }
.meter .label.over { color: var(--bad-ink); font-weight: 700; }

.divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0;
    color: var(--bad-ink);
    font-size: 11.5px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--bad) 45%, transparent); }

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 9px 10px 9px 13px;
    border-radius: var(--r-card);
    background: var(--mask-raised);
    border: 1px solid transparent;
    overflow: hidden;
}
/* status stripe down the left edge */
.card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--c, var(--neutral));
}
/* Contributing (not leading): drawn like an unpopulated footprint */
.card[data-role="contrib"] { background: transparent; border: 1px dashed var(--mask-edge); }
.card[data-role="contrib"]::before { opacity: 0.55; }
.card[data-alert="red"] { border: 1px solid var(--red-alert); box-shadow: 0 0 12px -4px var(--red-alert); }
.card[data-alert="yellow"] { border: 1px solid var(--yellow-alert); box-shadow: 0 0 12px -4px var(--yellow-alert); }

.card-top {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--silk-3);
}
.card-top .key { font-weight: 700; color: var(--silk-2); white-space: nowrap; }
.card-top .prio, .card-top .flag { flex: none; }
.card-top .type { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-top .since { margin-left: auto; white-space: nowrap; }
.prio { font-weight: 700; font-size: 10px; letter-spacing: -0.1em; }
.prio[data-p="1"] { color: var(--bad-ink); }
.prio[data-p="2"] { color: var(--blocked-ink); }
.flag { color: var(--yellow-alert); }

.card .title {
    font-weight: 700;
    font-size: 13.5px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.card-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: var(--silk-3);
}
.card-meta .role { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.card-meta .avatar { width: 20px; height: 20px; font-size: 9px; }
.card-meta .spacer { flex: 1; }

.docs summary {
    cursor: pointer;
    list-style: none;
    color: var(--silk-3);
    font-size: 11.5px;
    white-space: nowrap;
}
.docs summary::-webkit-details-marker { display: none; }
.docs summary::before { content: "▸ "; }
.docs[open] summary::before { content: "▾ "; }
.docs summary:hover { color: var(--silk); }
.doc-list { display: flex; flex-direction: column; gap: 4px; margin-top: 5px; }
.doc {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 12px;
}
.doc a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .when { margin-left: auto; color: var(--silk-3); white-space: nowrap; }

.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--silk-3);
}

/* ---------- Up next: plated vias joined by a gold trace ---------- */

.workspace { display: block; }
.workspace.with-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 244px;
    gap: 16px;
    align-items: start;
}
.rail {
    position: sticky;
    top: 68px;
    max-height: calc(100vh - 84px);
    overflow-y: auto;
    padding: 2px 4px 4px 18px;
    border-left: 1px solid var(--mask-edge);
}
.rail-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 14px;
}
.rail-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.rail-head .count { color: var(--gold); font-weight: 700; }
.rail-empty { color: var(--silk-3); font-size: 12.5px; }

.rail-list { margin: 0; padding: 0; list-style: none; }
.rail-item {
    --via: 24px;
    position: relative;
    display: grid;
    grid-template-columns: var(--via) minmax(0, 1fr);
    gap: 11px;
    padding-bottom: 16px;
}
/* The trace to the next via */
.rail-item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: calc(var(--via) / 2 - 1.5px);
    top: var(--via);
    bottom: 0;
    width: 3px;
    background: var(--gold-dim);
}
.rail-item .rank {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: var(--via);
    height: var(--via);
    border-radius: 50%;
    border: 3px solid var(--gold);
    background: var(--mask);
    color: var(--queued-ink);
    font-size: 11px;
    font-weight: 700;
}
/* Next to be picked up: fully plated */
.rail-item:first-child .rank { background: var(--gold); color: var(--mask); }
.rail-item[data-alert="red"] .rank { box-shadow: 0 0 0 2px var(--mask), 0 0 0 4px var(--red-alert); }
.rail-item[data-alert="yellow"] .rank { box-shadow: 0 0 0 2px var(--mask), 0 0 0 4px var(--yellow-alert); }
.rail-body { min-width: 0; padding-top: 3px; }
.rail-item .title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 700;
    font-size: 13px;
    line-height: 1.3;
}
.rail-item .meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    color: var(--silk-3);
    font-size: 11.5px;
}
.rail-item .meta .age { margin-left: auto; }
.rail-item .meta .who { display: flex; }
.rail-item .avatar { width: 18px; height: 18px; font-size: 8px; }

/* ---------- Hosting matrix ---------- */

.summary-line {
    margin: 0 0 14px;
    color: var(--silk-2);
    font-size: 15px;
}
.summary-line b { color: var(--ink, var(--silk)); }

[data-health="good"]    { --c: var(--good); --tint: var(--good-tint); --ink: var(--good-ink); }
[data-health="warning"] { --c: var(--warn); --tint: var(--warn-tint); --ink: var(--warn-ink); }
[data-health="bad"]     { --c: var(--bad);  --tint: var(--bad-tint);  --ink: var(--bad-ink); }

[data-v="Stable"]             { --c: var(--good); --tint: var(--good-tint); --ink: var(--good-ink); }
[data-v="Dev"],
[data-v="Unstable"]           { --c: var(--warn); --tint: var(--warn-tint); --ink: var(--warn-ink); }
[data-v="Lagging"],
[data-v="Unknown Descriptor"] { --c: var(--bad);  --tint: var(--bad-tint);  --ink: var(--bad-ink); }
[data-v="No Record"]          { --c: var(--neutral); --tint: transparent; --ink: var(--silk-3); }

.matrix-wrap {
    overflow-x: auto;
    border-top: 1px solid var(--mask-edge);
    border-bottom: 1px solid var(--mask-edge);
}
table.matrix {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.matrix th, .matrix td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--mask-edge);
    text-align: center;
    white-space: nowrap;
}
.matrix tr:last-child td, .matrix tr:last-child th { border-bottom: 0; }
.matrix thead th {
    position: sticky;
    top: 0;
    background: var(--mask);
    vertical-align: bottom;
    font-size: 12.5px;
    padding-top: 12px;
}
.matrix thead .ver { display: block; font-weight: 400; color: var(--silk-3); font-size: 11.5px; margin-top: 2px; }
.matrix tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--mask);
    text-align: left;
    font-weight: 700;
}
.matrix tbody th .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 9px;
    border-radius: 50%;
    background: var(--c);
}
.matrix td .v {
    display: inline-block;
    min-width: 68px;
    padding: 2px 8px;
    border-radius: var(--r-mark);
    background: var(--tint);
    color: var(--ink);
    font-weight: 700;
    font-size: 13px;
}
.matrix .none { color: var(--silk-3); }
.matrix tbody tr:hover th, .matrix tbody tr:hover td { background: var(--mask-raised); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--silk-2); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); }

.unreachable { margin-top: 16px; color: var(--silk-2); }
.unreachable summary { cursor: pointer; }
.unreachable ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 4px 20px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    font-size: 12.5px;
}
.unreachable li { display: flex; gap: 8px; }
.unreachable li span { color: var(--silk-3); }

/* ---------- Layout modes ---------- */

/* On desktop the projects page is a fixed-height app: the board scrolls inside
   the window, so its horizontal scrollbar sits at the bottom of the screen
   instead of below the fold */
@media (min-width: 901px) {
    body[data-page="summary"] {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
    }
    body[data-page="summary"] main {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        padding-bottom: 12px;
    }
    body[data-page="summary"] .workspace {
        flex: 1;
        min-height: 0;
    }
    body[data-page="summary"] .workspace.with-rail { grid-template-rows: minmax(0, 1fr); align-items: stretch; }
    body[data-page="summary"] .board {
        height: 100%;
        overflow: auto;
        overscroll-behavior: contain;
    }
    /* Keep whose lane it is visible while the board scrolls */
    /* Background runs into the lane's side padding so alert glows on cards
       scrolling underneath can't show past its edges */
    body[data-page="summary"] .lane-top {
        position: sticky;
        top: 0;
        z-index: 2;
        margin: 0 -12px;
        padding-left: 12px;
        padding-right: 12px;
    }
    body[data-page="summary"] .lane:first-child .lane-top { margin-left: 0; padding-left: 0; }
    body[data-page="summary"] .rail {
        position: static;
        max-height: 100%;
    }
}

@media (max-width: 900px) {
    .workspace.with-rail { grid-template-columns: minmax(0, 1fr); }
    .rail {
        position: static;
        max-height: none;
        margin-top: 8px;
        padding: 16px 0 0;
        border-left: 0;
        border-top: 1px solid var(--mask-edge);
    }
}

@media (max-width: 640px) {
    .topbar { padding: 8px 16px; gap: 14px; }
    .sync { display: none; }
    main { padding: 12px 16px 32px; }
    .search { flex: 1 1 100%; }
}

/* ---------- Compact density: key + one-line title only ---------- */

.dense .card { gap: 2px; padding: 6px 9px 6px 12px; }
.dense .card .title { -webkit-line-clamp: 1; font-size: 13px; }
.dense .card .card-meta,
.dense .card .docs,
.dense .card-top .type { display: none; }
.dense .lane { gap: 5px; }
.dense .rail-item { padding-bottom: 12px; }
.dense .rail-item .title { -webkit-line-clamp: 1; }

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
}
