/* ============================================================
   generator-beta2.css — redesigned admin-creator workbench layout
   for rpg.actor/generator?v=beta2.  Revision 4.

   Everything here is scoped under html.gen-beta2 so it never touches
   classic (?v=beta) or live (?v=live / default) rendering. It is a
   PURE LAYOUT/PRESENTATION skin: every element it styles is either a
   real engine-bound node relocated whole by js/generator-beta2.js, or
   new chrome that only wraps those nodes.

   Rev 4 changes (rev 3 feedback: rail labels/icons looked wrong for every
   category except Body/Face, inline colour pickers were "outta whack",
   Recently Updated wasn't height-cropped, Show/Sort wasn't left-aligned,
   the sync-presence notice was in the wrong place):
   - Rail dropped icon masks entirely (removes any icon-rendering ambiguity)
     in favour of plain, generously-sized, always-correct text labels.
   - ALL inline per-subsection colour pickers are gone. Every colour-picker-
     set in the page (Body skin/eye, Hair/Bangs/Beard, every Clothing/
     Accessories/Handheld/Other channel set) is relocated into ONE "Colours"
     panel docked below the catalogue, grouped under clear headers.
   - `.beta-status-controls` explicitly forced to a left-aligned wrapping
     ROW (base CSS defaults it to flex-direction:column, which was silently
     still applying since rev 1-3 never overrode that property).
   - Recently Updated is now height-cropped by the aside's own flex layout
     (flex:1/min-height:0/overflow-y:auto) instead of a fixed pixel cap, so
     it always fits whatever's left of the viewport instead of overflowing
     or leaving dead space.
   - The sync-presence "who's editing what" line now sits inside the
     Recently Updated box, above the list, instead of stranded in the
     filter strip where it used to live as a sibling of Show/Sort.
   ============================================================ */

html.gen-beta2 {
    --b2-ink: var(--ink, #2c2416);
    --b2-ink-light: var(--ink-light, #8a7a5e);
    --b2-parchment: var(--parchment, #f4f1e8);
    --b2-parchment-dark: var(--parchment-dark, #d4c9a8);
    --b2-gold: var(--gold, #c9a227);
    --b2-accent: var(--accent, #b8860b);
}

/* Kill the classic flex layout chain once the beta2 shell has taken over —
   gated behind .b2-ready so a failed build never hides the classic UI. */
html.gen-beta2.b2-ready body { overflow: hidden; height: 100dvh; }
html.gen-beta2.b2-ready .generator-page { max-width: none; margin: 0; padding: 0; height: 100dvh; }
html.gen-beta2.b2-ready #generator-panel { display: none !important; }
html.gen-beta2 .generator-loading { min-height: 60dvh; display: flex; }
html.gen-beta2.b2-ready .generator-loading { display: none; }

html.gen-beta2 .b2-shell { display: none; }
html.gen-beta2.b2-ready .b2-shell {
    display: grid;
    grid-template-columns: 92px minmax(360px, 1.4fr) 380px 300px;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
        "topbar topbar     topbar topbar"
        "rail   filter     editor aside"
        "rail   catalogue  editor aside"
        "rail   colours    editor aside";
    height: 100dvh;
    background: var(--b2-parchment);
    color: var(--b2-ink);
    font-family: inherit;
}

/* ---------------- Topbar ---------------- */
html.gen-beta2 .b2-topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.85rem;
    border-bottom: 2px solid var(--b2-ink);
    background: linear-gradient(180deg, rgba(201,162,39,0.14), transparent);
}
html.gen-beta2 .b2-brand {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
html.gen-beta2 .b2-brand-tag {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #fff;
    background: var(--b2-accent);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
}
html.gen-beta2 .b2-topbar-spacer { flex: 1 1 auto; }
html.gen-beta2 .b2-tools { display: flex; align-items: center; gap: 0.5rem; }
html.gen-beta2 .b2-search {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--b2-parchment-dark);
    border-radius: 0.4rem;
    background: rgba(255,255,255,0.55);
    padding: 0.28rem 0.55rem;
}
html.gen-beta2 .b2-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.85rem;
    width: 190px;
    color: var(--b2-ink);
}
html.gen-beta2 .b2-btn {
    border: 1px solid var(--b2-ink);
    background: var(--b2-parchment);
    color: var(--b2-ink);
    border-radius: 0.4rem;
    padding: 0.32rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
html.gen-beta2 .b2-btn:hover { background: rgba(201,162,39,0.2); }
html.gen-beta2 .b2-btn-link { text-decoration: none; display: inline-flex; align-items: center; }

/* ---------------- Left hot-button rail: plain text, no icons -------------- */
html.gen-beta2 .b2-rail {
    grid-area: rail;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.5rem 0.35rem;
    border-right: 2px solid var(--b2-ink);
    overflow-y: auto;
    background: rgba(244,241,232,0.6);
}
html.gen-beta2 .b2-rail-item {
    border: 1px solid var(--b2-parchment-dark);
    background: rgba(255,255,255,0.4);
    border-radius: 0.35rem;
    padding: 0.4rem 0.2rem;
    cursor: pointer;
    color: var(--b2-ink);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    word-break: break-word;
}
html.gen-beta2 .b2-rail-item:hover { background: rgba(201,162,39,0.18); border-color: var(--b2-accent); }
html.gen-beta2 .b2-rail-item.active {
    background: var(--b2-ink);
    border-color: var(--b2-ink);
    color: var(--b2-parchment);
}

/* ---------------- Filter strip (status filter/sort — left aligned) ------- */
html.gen-beta2 .b2-filter {
    grid-area: filter;
    padding: 0.4rem 0.75rem 0.5rem;
    border-bottom: 1px solid var(--b2-parchment-dark);
    text-align: left;
}
html.gen-beta2 #beta-status-box {
    display: block !important;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
}
html.gen-beta2 .beta-status-head { display: none; }
/* Base CSS defaults .beta-status-controls to flex-direction:column — force
   a left-aligned wrapping row here so Show/Sort read as one clear line. */
html.gen-beta2 .beta-status-controls {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem 1.25rem;
    text-align: left;
}
html.gen-beta2 .beta-status-group {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.3rem;
}
html.gen-beta2 .beta-status-glabel { font-size: 0.68rem; font-weight: 700; color: var(--b2-ink-light); }

/* ---------------- Catalogue column: one continuous scroll, no tabs ------- */
html.gen-beta2 .b2-catalogue {
    grid-area: catalogue;
    min-width: 0;
    overflow-y: auto;
    padding: 0.5rem 0.85rem 1rem;
}
html.gen-beta2 .generator-controls { flex: none; min-width: 0; }

/* Category-level accordion chrome is retired — every .gen-foldable renders
   permanently (js visits each once so deferred thumbnails still populate),
   separated by a heading instead of collapsing. */
html.gen-beta2 .gen-foldable { border: none; margin: 0 0 1.1rem; display: block !important; }
html.gen-beta2 .gen-foldable > summary { display: none; }
html.gen-beta2 .gen-foldable-body { padding: 0; }
html.gen-beta2 .b2-cat-head {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
    margin: 0 0 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid var(--b2-ink);
    scroll-margin-top: 0.5rem;
}
html.gen-beta2 .gen-coming-soon { text-align: left; padding: 0.25rem 0; }

/* Sub-type/channel tabs become plain labeled dividers in the item lists —
   every trait is reachable by scrolling, nothing is gated behind a click.
   (Colour-tabs INSIDE the Colours panel are flattened the same way — see
   below — this rule intentionally applies globally.) */
html.gen-beta2 .colour-tab-bar { display: none !important; }
html.gen-beta2 .colour-tab-panel { display: block !important; }
html.gen-beta2 .b2-subhead {
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--b2-ink-light);
    margin: 0.6rem 0 0.35rem;
}
html.gen-beta2 .b2-subdivider {
    border: none;
    border-top: 1px dashed var(--b2-parchment-dark);
    margin: 0.7rem 0 0.5rem;
}

/* Item lists in the catalogue never carry a colour picker anymore — those
   all live in the Colours panel below. Any leftover empty picker-column
   wrapper in the catalogue collapses to nothing. */
html.gen-beta2 .hair-colour-col:empty,
html.gen-beta2 .clothing-picker-col:empty,
html.gen-beta2 .acc-picker-col:empty,
html.gen-beta2 .body-picker-col:empty { display: none; }

/* ---------------- Glance-awareness badges ----------------
   Driven by dataset flags generator-engine.js emits on every catalogue tile
   in beta mode. Pure additive corner marks — never affects hit-testing or
   existing equipment/note badges. */
html.gen-beta2 .hair-thumb { overflow: visible; }
html.gen-beta2 .b2-badges {
    position: absolute;
    left: 1px;
    bottom: 1px;
    display: flex;
    gap: 1px;
    pointer-events: none;
}
html.gen-beta2 .b2-badge {
    min-width: 11px;
    height: 11px;
    line-height: 11px;
    text-align: center;
    font-size: 0.52rem;
    font-weight: 800;
    font-family: monospace;
    color: #fff;
    border-radius: 2px;
}
html.gen-beta2 .b2-badge-class { background: #8b4513; }
html.gen-beta2 .b2-badge-suppress { background: #aa2e2e; }
html.gen-beta2 .b2-badge-suppress-as { background: #2e6f9e; }
html.gen-beta2 .b2-badge-extra { background: #55606b; }
html.gen-beta2 .b2-status-stripe {
    position: absolute;
    right: 0; bottom: 0; left: 0;
    height: 3px;
    pointer-events: none;
}
html.gen-beta2 .hair-item[data-status="ready"] .b2-status-stripe { background: #7d3fc9; }
html.gen-beta2 .hair-item[data-status="beta"] .b2-status-stripe { background: #2e6f9e; }
html.gen-beta2 .hair-item[data-status="live"] .b2-status-stripe { background: #3a8a3a; }
html.gen-beta2 .hair-item[data-unlock] .b2-status-stripe { background: #4e8a57; }

/* ---------------- Colours panel: docked below the catalogue --------------- */
html.gen-beta2 .b2-colours {
    grid-area: colours;
    border-top: 2px solid var(--b2-ink);
    background: rgba(255,255,255,0.45);
    padding: 0.5rem 0.85rem 0.75rem;
    max-height: 34vh;
    overflow-y: auto;
}
html.gen-beta2 .b2-colours-title {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}
html.gen-beta2 .b2-colour-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.6rem 1rem;
}
html.gen-beta2 .b2-colour-group {
    border: 1px solid var(--b2-parchment-dark);
    border-radius: 0.35rem;
    padding: 0.4rem 0.5rem 0.5rem;
    background: rgba(255,255,255,0.4);
}
html.gen-beta2 .b2-colour-group-head {
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--b2-ink-light);
    margin-bottom: 0.3rem;
}
/* Condense: no swatch grids inside the Colours panel, just the picker. */
html.gen-beta2 .b2-colours .swatch-grid,
html.gen-beta2 .b2-colours .swatch-grid-sm,
html.gen-beta2 .b2-colours .skin-swatches-col { display: none !important; }
html.gen-beta2 .b2-colours .skin-layout { display: block; }
html.gen-beta2 .b2-colours .skin-picker-col { width: 100%; }
html.gen-beta2 .b2-colours .b2-subhead { margin-top: 0.4rem; font-size: 0.68rem; }
html.gen-beta2 .b2-colours .b2-subdivider { margin: 0.4rem 0; }

/* ---------------- Editor column (persistent, no redundant title) --------- */
html.gen-beta2 .b2-editor {
    grid-area: editor;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-left: 1px solid var(--b2-parchment-dark);
    border-right: 2px solid var(--b2-ink);
    overflow-y: auto;
    padding: 0.6rem 0.75rem 1.25rem;
    background: rgba(255,255,255,0.35);
}
html.gen-beta2 .generator-beta-column {
    display: block !important;
    width: auto;
    position: static;
    max-height: none;
    overflow: visible;
}
html.gen-beta2 .beta-item-panel { margin-bottom: 0; }

/* Fold SET/DEFAULT signal on each beta-panel-fold summary (Z-Layer, Submask
   Rules, Define Class, Suppression, Suppress As, Suppress Specific, …). */
html.gen-beta2 .beta-panel-fold > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}
html.gen-beta2 .b2-fold-flag {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    flex-shrink: 0;
}
html.gen-beta2 .b2-fold-flag.b2-fold-set { background: #2e6f9e; color: #fff; }
html.gen-beta2 .b2-fold-flag.b2-fold-default { background: rgba(0,0,0,0.08); color: var(--b2-ink-light); }

/* ---------------- Aside: preview + Recently Updated, cropped to viewport - */
html.gen-beta2 .b2-aside {
    grid-area: aside;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.6rem;
    min-height: 0;
    overflow: hidden;
}
html.gen-beta2 .preview-card { position: static; flex-shrink: 0; }
html.gen-beta2 #btn-live-view { width: 100%; margin-bottom: 0.4rem; flex-shrink: 0; }

/* Recently Updated fills whatever height remains under the preview instead
   of a fixed pixel cap — it can never overflow the page regardless of
   viewport height. */
html.gen-beta2 .b2-recent-box {
    border: 1px solid var(--b2-parchment-dark);
    border-radius: 0.4rem;
    background: rgba(255,255,255,0.4);
    padding: 0.55rem 0.6rem 0.6rem;
    flex: 1 1 auto;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}
html.gen-beta2 .b2-recent-box-title {
    font-weight: 700;
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
    flex-shrink: 0;
}
html.gen-beta2 .beta-sync-notice,
html.gen-beta2 .beta-sync-presence {
    flex-shrink: 0;
    margin-bottom: 0.35rem;
    font-size: 0.7rem;
}
html.gen-beta2 .beta-recent-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}
html.gen-beta2 .beta-recent-head { display: none; }
html.gen-beta2 .beta-recent-list {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
}

/* ---------------- Responsive fallback ----------------
   Below the workbench floor, stack columns instead of clipping content —
   this is an admin tool so the desktop grid is the priority contract. */
@media (max-width: 1180px) {
    html.gen-beta2.b2-ready .b2-shell {
        grid-template-columns: 80px minmax(280px, 1fr) 320px;
        grid-template-areas:
            "topbar topbar     topbar"
            "rail   filter     editor"
            "rail   catalogue  editor"
            "rail   colours    editor";
    }
    html.gen-beta2 .b2-aside { display: none; }
}
@media (max-width: 860px) {
    html.gen-beta2.b2-ready .b2-shell {
        grid-template-columns: 64px 1fr;
        grid-template-rows: auto auto auto 1fr 40dvh;
        grid-template-areas:
            "topbar topbar"
            "rail   filter"
            "rail   catalogue"
            "rail   colours"
            "editor editor";
        height: auto;
        min-height: 100dvh;
    }
    html.gen-beta2 .b2-editor { border-left: none; border-top: 2px solid var(--b2-ink); }
}
