/*
    Settings > Site Preferences > Menu layout (Components/Pages/Admin/MenuLayout.razor, js/menu-layout.js).

    The board is the sidebar unrolled: one column per section, the same chips, hues and section headers the menu
    itself wears (the hues and washes come from css/admin-nav.css, data-hue), on the Settings family's quiet cards
    (css/settings-theme.css, --set-*). Prefix ml-. Drag states: .ml-src is the element being dragged, hidden where it
    sits; .ml-ghost is the copy under the pointer; .ml-drop is the placeholder where it would land.
*/

/* ------------------------------------------------------------------ Page head */
.ml-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; margin-bottom: 1.25rem; }
.ml-back { display: inline-flex; align-items: center; gap: .1rem; margin: 0 0 .35rem -.3rem; color: var(--set-muted); font-size: .8rem; font-weight: 700; text-decoration: none; }
.ml-back:hover { color: var(--set-accent); }
.ml-back i { font-size: 1.05rem; }
.ml-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
.ml-colors { display: inline-flex; align-items: center; gap: .6rem; }
.ml-colors-label { color: var(--set-muted); font-size: .8rem; font-weight: 700; }

/* ------------------------------------------------------------------ Board */
.ml-board { display: grid; gap: 1rem; }

/* Sections run in the menu's order, left to right then down; a column is never narrower than a menu row reads well. */
.ml-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr)); align-items: start; gap: 1rem; }

/* Dashboard: one row above the sections, because it is above them in the menu and does not move. */
.ml-pinned {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .95rem .45rem .7rem;
    border: 1px dashed var(--set-card-border);
    border-radius: 14px;
    color: var(--set-text);
    font-size: .9rem;
    font-weight: 500;
}

/* ADMIN (operators only): the row under the sections, in the accent color it has in the menu. */
.ml-pinned.is-admin { flex-wrap: wrap; row-gap: .4rem; }
.ml-pinned.is-admin .ml-lock,
.ml-admin-label { color: var(--set-accent); }
.ml-admin-label { margin-right: .35rem; font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.ml-admin-links { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: .3rem .4rem; min-width: 0; }
.ml-admin-link { display: inline-flex; align-items: center; gap: .35rem; padding: .16rem .6rem .16rem .5rem; border-radius: 999px; background: var(--set-accent-soft); font-size: .8rem; white-space: nowrap; }
.ml-admin-link i { color: var(--set-accent); font-size: .95rem; }

/* ------------------------------------------------------------------ A section */
.ml-sec {
    min-width: 0;
    padding: .3rem .45rem .5rem;
    border: 1px solid var(--set-section-border);
    border-radius: 18px;
    background: var(--set-section-bg);
}

.ml-sec-head { display: flex; align-items: center; gap: .3rem; min-height: 2.35rem; padding: 0 .5rem 0 .2rem; user-select: none; -webkit-user-select: none; }
.ml-sec[data-ml-drag] > .ml-sec-head { cursor: grab; }

/* The header as the sidebar draws it: the label in the section's hue, then a hairline that fades out. */
.ml-sec-label {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: .6rem;
    min-width: 0;
    color: var(--set-muted);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    white-space: nowrap;
}

.ml-sec-label::after { content: ""; flex: 1 1 auto; height: 1px; background: linear-gradient(90deg, var(--set-card-border), transparent); }
.ml-sec[data-hue] .ml-sec-label { color: color-mix(in srgb, var(--nav-hue) 82%, var(--nav-ink)); }
[data-bs-theme="dark"] .ml-sec[data-hue] .ml-sec-label { color: color-mix(in srgb, var(--nav-hue) 86%, transparent); }
.ml-sec[data-hue] .ml-sec-label::after { background: linear-gradient(90deg, color-mix(in srgb, var(--nav-hue-2, var(--nav-hue)) 32%, transparent), transparent); }

.ml-sec[data-hue="couple"] .ml-sec-label > span {
    background: linear-gradient(90deg, var(--nav-hue), var(--nav-hue-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ml-pin-note { flex: none; margin-left: auto; color: var(--set-light); font-size: .7rem; font-weight: 700; white-space: nowrap; }

/* ------------------------------------------------------------------ Links and pages */
.ml-list { display: flex; flex-direction: column; gap: 2px; min-height: 2.35rem; }
.ml-item { min-width: 0; border-radius: .7rem; }

.ml-row {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-height: 2.35rem;
    padding: .2rem .45rem .2rem .2rem;
    border-radius: .65rem;
    color: var(--set-text);
    font-size: .9rem;
    font-weight: 500;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color .15s ease;
}

[data-ml-drag] > .ml-row { cursor: grab; }
[data-ml-drag] > .ml-row:hover { background: linear-gradient(90deg, color-mix(in srgb, var(--nav-hue, var(--set-muted)) var(--nav-wash-hover), transparent), color-mix(in srgb, var(--nav-hue-2, var(--nav-hue, var(--set-muted))) var(--nav-wash-hover), transparent)); }

.ml-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The handle: the one control that starts a drag by touch, and the one the arrow keys move from. */
.ml-grip {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.35rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: .4rem;
    background: none;
    color: var(--set-light);
    font-size: 1.05rem;
    cursor: grab;
    opacity: .55;
    touch-action: none;
    transition: opacity .15s ease, color .15s ease;
}

[data-ml-row]:hover > .ml-grip { opacity: 1; }
.ml-grip:focus-visible { outline: 2px solid var(--set-accent); outline-offset: 1px; color: var(--set-accent); opacity: 1; }

.ml-lock { display: grid; place-items: center; flex: none; width: 1.35rem; height: 1.75rem; color: var(--set-light); font-size: .9rem; opacity: .7; }

/* The chip a top-level link wears in the menu. */
.ml-chip {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: .55rem;
    background: var(--set-icon-bg);
    color: var(--set-icon);
    font-size: 1.05rem;
}

[data-hue] > .ml-row > .ml-chip,
.ml-pinned[data-hue] > .ml-chip {
    background: linear-gradient(135deg, color-mix(in srgb, var(--nav-hue) var(--nav-wash-chip), transparent), color-mix(in srgb, var(--nav-hue-2, var(--nav-hue)) var(--nav-wash-chip), transparent));
    color: var(--nav-hue);
}

/* Icons > Icon only (the default): the board shows the bare glyph, as the menu does. */
.ml-board[data-icons="plain"] .ml-chip { background: transparent; }

/* A group: how many pages it holds, and the pages under it when it is open. */
.ml-kids-toggle {
    display: inline-flex;
    align-items: center;
    flex: none;
    gap: .1rem;
    padding: .12rem .25rem .12rem .5rem;
    border: 0;
    border-radius: 999px;
    background: var(--set-icon-bg);
    color: var(--set-muted);
    font-size: .7rem;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
}

.ml-kids-toggle:hover { color: var(--set-text); }
.ml-kids-toggle:focus-visible { outline: 2px solid var(--set-accent); outline-offset: 1px; }
.ml-kids-toggle i { font-size: 1rem; transition: transform .2s ease; }
.ml-item.is-open > .ml-row .ml-kids-toggle i { transform: rotate(180deg); }

/* One grid item (.ml-kids-inner) so 0fr -> 1fr folds the whole list, as the sidebar's submenus do. */
.ml-kids { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .24s cubic-bezier(.4, 0, .2, 1); }
.ml-item.is-open > .ml-kids { grid-template-rows: 1fr; }

.ml-kids-inner {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-height: 0;
    margin-left: 2.05rem;
    padding-left: .3rem;
    overflow: hidden;
    border-left: 1px solid color-mix(in srgb, var(--nav-hue, var(--set-light)) var(--nav-rail), transparent);
    /* Folded pages leave the tab order once the fold finishes. */
    visibility: hidden;
    transition: visibility 0s linear .24s;
}

.ml-item.is-open > .ml-kids > .ml-kids-inner { margin-top: .1rem; margin-bottom: .3rem; visibility: visible; transition-delay: 0s; }

.ml-kid > .ml-row { min-height: 2rem; padding-top: .1rem; padding-bottom: .1rem; font-size: .84rem; }
.ml-glyph { flex: none; width: 1.25rem; color: color-mix(in srgb, var(--nav-hue, var(--set-icon)) 82%, transparent); font-size: 1rem; text-align: center; }

.ml-empty { padding: .6rem .7rem; border: 1px dashed var(--set-card-border); border-radius: .65rem; color: var(--set-light); font-size: .8rem; line-height: 1.4; text-align: center; }
.ml-list:has(> .ml-drop) > .ml-empty { display: none; }

/* ------------------------------------------------------------------ Drag */
.ml-src { display: none !important; }

.ml-drop {
    flex: none;
    box-sizing: border-box;
    border: 1.5px dashed color-mix(in srgb, var(--nav-hue, var(--set-accent)) 45%, transparent);
    border-radius: .65rem;
    background: color-mix(in srgb, var(--nav-hue, var(--set-accent)) 7%, transparent);
}

.ml-drop-section { border-radius: 18px; }

.ml-ghost {
    box-sizing: border-box;
    border-radius: .7rem;
    background: var(--set-card);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--nav-hue, var(--set-accent)) 28%, transparent), 0 18px 36px -16px rgba(15, 23, 42, .42), 0 2px 6px rgba(15, 23, 42, .1);
    rotate: 1.2deg;
    scale: 1.02;
    transition: rotate .15s ease, scale .15s ease;
}

.ml-ghost.ml-sec { border-radius: 18px; background: var(--set-card); }
.ml-ghost.ml-ghost-landing { rotate: 0deg; scale: 1; }
[data-bs-theme="dark"] .ml-ghost { box-shadow: 0 0 0 1px color-mix(in srgb, var(--nav-hue, var(--set-accent)) 36%, transparent), 0 18px 36px -14px rgba(0, 0, 0, .75); }

html.ml-dragging,
html.ml-dragging * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }

/* ------------------------------------------------------------------ The row on Site Preferences that leads here */
a.a11y-row-link { color: inherit; text-decoration: none; }
.a11y-go { display: inline-flex; align-items: center; gap: .15rem; color: var(--set-accent); font-size: .85rem; font-weight: 700; white-space: nowrap; }
.a11y-go i { font-size: 1.15rem; }

@media (max-width: 575.98px) {
    .ml-head-actions { width: 100%; justify-content: space-between; }
    .ml-pin-note { font-size: .66rem; }
}

@media (prefers-reduced-motion: reduce) {
    .ml-row, .ml-grip, .ml-kids, .ml-kids-inner, .ml-kids-toggle i, .ml-ghost { transition: none; }
    .ml-ghost { rotate: none; scale: none; }
}
