/* The crafting index: a tree of groups, each holding device rows.
   Nesting is unbounded, so depth is carried by an indented rail rather than by a per-level rule. */

/* Everything lives in one measured column. Left to fill a wide monitor, a device row puts its
   name at the far left and its controls at the far right, and the eye cannot hold the two
   together — which is what made this hard to use. */
.craft-head,
.craft-tree,
.craft-bin,
.craft-empty {
    max-width: 940px;
}

.craft-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.craft-head h2 {
    margin: 0 0 2px;
}

.craft-sub {
    margin: 0;
    color: #8a8a8a;
    font-size: 13px;
}

.craft-empty {
    color: #777;
    font-size: 13px;
    margin: 6px 0;
}

.craft-tree {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.craft-group {
    background: #1b1b1b;
    border: 1px solid #303030;
    border-radius: 6px;
    padding: 12px 14px;
    scroll-margin-top: 70px;
}

.craft-group-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.craft-group-name {
    margin: 0;
    font-size: 15px;
    color: #e8e2d4;
}

.craft-group-meta {
    font-size: 12px;
    color: #7d7d7d;
    font-variant-numeric: tabular-nums;
}

/* Children sit inside their parent behind a rail, so a group four deep still reads as belonging
   to the one above it without needing four different background colours. */
.craft-children {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0 2px 10px;
    padding-left: 12px;
    border-left: 2px solid #2e2e2e;
}

.craft-children .craft-group {
    background: #202020;
    padding: 10px 12px;
}

.craft-children .craft-group-name {
    font-size: 13.5px;
}

.craft-devices {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.craft-device {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 68px auto;
    align-items: baseline;
    gap: 10px;
    padding: 4px 6px;
    border-radius: 4px;
    border-top: 2px solid transparent;
    border-bottom: 2px solid transparent;
}

.craft-device:hover {
    background: #262626;
}

.craft-device-name {
    color: #cfd8dc;
    text-decoration: none;
    font-size: 13.5px;
}

.craft-device-name:hover {
    color: #ffd98a;
    text-decoration: underline;
}

.craft-device-where {
    font-size: 12px;
    color: #6f7f74;
}

.craft-device-count {
    font-size: 12px;
    color: #7d7d7d;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.craft-device-missing .craft-device-name {
    color: #8a8a8a;
    text-decoration: line-through;
}

.craft-missing-tag {
    color: #c98b6a;
    font-size: 11px;
}

/* ---- DEBUG bins ------------------------------------------------------- */

.craft-bin {
    margin-top: 22px;
    background: #191919;
    border: 1px dashed #3a3a3a;
    border-radius: 6px;
    padding: 12px 14px;
}

.craft-bin h3 {
    margin: 0 0 2px;
    font-size: 14px;
    color: #d8d2c4;
}

.craft-bin-sub {
    margin: 0 0 8px;
    font-size: 12px;
    color: #7d7d7d;
}

.craft-count {
    color: #7d7d7d;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.craft-devices-hidden .craft-device-name {
    color: #8f8f8f;
}

/* ---- DEBUG editing ---------------------------------------------------- */

.craft-admin {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.craft-btn {
    background: #262626;
    border: 1px solid #3d3d3d;
    color: #ddd;
    border-radius: 4px;
    padding: 5px 11px;
    font-size: 12.5px;
    cursor: pointer;
}

.craft-btn:hover {
    border-color: #5a5a5a;
    background: #2e2e2e;
}

.craft-btn-primary {
    background: #2f5d52;
    border-color: #2f5d52;
    color: #eafff8;
}

.craft-btn-primary:hover {
    background: #386e61;
}

.craft-status {
    font-size: 12px;
    color: #7d7d7d;
}

.craft-status[data-s="saving"] { color: #d0a85f; }
.craft-status[data-s="saved"] { color: #6fbf95; }
.craft-status[data-s="error"] { color: #d98b7f; }

/* Only while editing. Kept off the read-only page entirely so the index stays a list of links. */
.craft-editing .craft-device {
    cursor: grab;
    border: 1px solid transparent;
}

.craft-editing .craft-device:hover {
    border-color: #3d3d3d;
}

.craft-editing .craft-device.craft-dragging {
    opacity: .4;
}

.craft-editing .craft-group.craft-drop,
.craft-editing .craft-bin.craft-drop {
    border-color: #6fbf95;
}

.craft-editing .craft-device.craft-drop-before {
    border-top-color: #6fbf95;
}

.craft-editing .craft-device.craft-drop-after {
    border-bottom-color: #6fbf95;
}

.craft-editing .craft-group-name {
    outline: 1px dashed #3d3d3d;
    outline-offset: 3px;
    border-radius: 3px;
}

.craft-editing .craft-group-name:focus {
    outline: 2px solid #6fbf95;
}

.craft-tools {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
}

/* The group header still pushes its tools right — there is nothing between them to associate. */
.craft-group-head .craft-tools {
    margin-left: auto;
}

.craft-tool {
    background: #262626;
    border: 1px solid #3d3d3d;
    color: #9d9d9d;
    border-radius: 3px;
    font-size: 11px;
    line-height: 1;
    padding: 3px 6px;
    cursor: pointer;
}

.craft-tool:hover {
    border-color: #6fbf95;
    color: #6fbf95;
}

.craft-tool-bad:hover {
    border-color: #d98b7f;
    color: #d98b7f;
}

.craft-editing .craft-device-name {
    outline: 1px dashed #3d3d3d;
    outline-offset: 2px;
    border-radius: 3px;
    cursor: text;
}

.craft-editing .craft-device-name:focus {
    outline: 2px solid #6fbf95;
}

