/* ════════════════════════════════════════════════════════════════
   xtabs-theme.css — workspace tab strip (BlazorXTabs 3.0.1)
   Single source of truth for tab styling; replaces the former
   overrides in gs-pages.css. Must stay the LAST stylesheet in
   index.html: several rules below out-cascade the library's scoped
   CSS ([b-…]) and Bootstrap utility !important (.text-primary,
   .font-weight-bold) by combining specificity + load order.

   DOM contract (verified against BlazorXTabs 3.0.1 source):
   div.xtabs.card
   └─ div.xtabs-header.card-header
      ├─ button.xtabs-close-all.close        (optional, DOM-first)
      └─ ul.xtabs-header-tabs.nav.nav-tabs.card-header-tabs
         └─ li.xtabs-item.nav-item
            ├─ button.xtabs-close.close      (PRECEDES the link)
            └─ a.xtabs-link.nav-link(.active)
               └─ h6.m-0.font-weight-bold.text-primary  (title)

   Flex `order` puts the close button visually AFTER the label, so
   it lands on the inline-end side (left in RTL, right in LTR)
   without touching the library's markup.
   ════════════════════════════════════════════════════════════════ */

:root {
    --xt-ink: var(--gs-text, #1b4332);
    --xt-ink-muted: #64766c;
    --xt-ink-faint: #64766c;   /* 4.83:1 on white — WCAG AA for the ✕ glyphs */
    --xt-hover-wash: rgba(216, 243, 220, .55);   /* --gs-p5 */
    --xt-active-wash: rgba(183, 228, 199, .28);  /* --gs-p4 */
    --xt-hairline: #e2ebe5;
    --xt-underline: linear-gradient(90deg, var(--gs-p1, #52b788), var(--gs-accent, #40916c));
    --xt-fade: 16px;                             /* overflow fade width */
    --xt-ease: cubic-bezier(.4, 0, .2, 1);
}

/* ── Strip ──────────────────────────────────────────────────────── */

.xtabs.card > .xtabs-header.card-header {
    display: flex;
    align-items: stretch;
    background: #fff !important;      /* never inherit .gs-card-header gradient */
    box-shadow: none !important;
    border-bottom: 1px solid var(--xt-hairline) !important;
    padding: .25rem .4rem 0 !important;
    min-height: 48px;                 /* stretched links ≈ 44px touch targets */
}

/* (0,3,0): must tie the library's scoped `.xtabs .xtabs-header-tabs[b-…]`
   so this file's load-last position decides — at (0,2,0) the library's
   flex-wrap:wrap / negative margins / padding-left:0 silently win. */
.xtabs .xtabs-header .xtabs-header-tabs {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;                     /* required for overflow inside flex */
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    border-bottom: 0 !important;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    /* Edge fade: padding matches --xt-fade, so at either scroll extreme
       only empty padding sits under the fade — it reads as "more tabs
       this way" exactly when tabs are actually hidden. */
    padding: 0 var(--xt-fade);
    -webkit-mask-image: linear-gradient(to right,
        transparent 0, #000 var(--xt-fade),
        #000 calc(100% - var(--xt-fade)), transparent 100%);
    mask-image: linear-gradient(to right,
        transparent 0, #000 var(--xt-fade),
        #000 calc(100% - var(--xt-fade)), transparent 100%);
}

.xtabs .xtabs-header .xtabs-header-tabs::-webkit-scrollbar { display: none; }

/* ── Tab item ───────────────────────────────────────────────────── */

.xtabs-header .xtabs-item {
    display: flex;
    align-items: stretch;             /* full-height links = real touch targets */
    flex: 0 0 auto;
    margin: 0 !important;
    animation: xt-tab-in .18s var(--xt-ease);
}

@keyframes xt-tab-in {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: none; }
}

.xtabs-header .xtabs-item .xtabs-link {
    order: 1;
    display: flex;
    align-items: center;
    position: relative;
    border: 0 !important;
    border-radius: 9px 9px 0 0;
    background: transparent;
    padding: .5rem .95rem .6rem;
    margin: 0;                        /* cancel BS5 .nav-tabs .nav-link margin-bottom:-1px */
    cursor: pointer;
    transition: background-color .15s var(--xt-ease);
}

.xtabs-header .xtabs-item .xtabs-link:hover  { background-color: var(--xt-hover-wash); }
.xtabs-header .xtabs-item .xtabs-link.active { background-color: var(--xt-active-wash); }

.xtabs-header .xtabs-item .xtabs-link:focus-visible {
    outline: 2px solid var(--gs-p1, #52b788);
    outline-offset: -2px;
}

/* ── Title (beats .text-primary / .font-weight-bold !important) ─── */

.xtabs-header .xtabs-item .xtabs-link h6 {
    margin: 0;
    font-size: .875rem;
    font-weight: 500 !important;
    line-height: 1.2;
    color: var(--xt-ink-muted) !important;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .15s var(--xt-ease);
}

.xtabs-header .xtabs-item .xtabs-link:hover h6 { color: var(--xt-ink) !important; }

.xtabs-header .xtabs-item .xtabs-link.active h6 {
    color: var(--xt-ink) !important;
    font-weight: 700 !important;
}

/* ── Active underline ───────────────────────────────────────────── */

.xtabs-header .xtabs-item .xtabs-link::after {
    content: "";
    position: absolute;
    inset-inline: 12px;
    bottom: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--xt-underline);
    opacity: 0;
    transform: scaleX(.6);
    transition: opacity .18s var(--xt-ease), transform .18s var(--xt-ease);
}

.xtabs-header .xtabs-item .xtabs-link.active::after {
    opacity: 1;
    transform: scaleX(1);
}

/* Mirror the underline gradient in RTL (linear-gradient angles are physical). */
[dir="rtl"] .xtabs-header .xtabs-item .xtabs-link::after {
    background: linear-gradient(-90deg, var(--gs-p1, #52b788), var(--gs-accent, #40916c));
}

/* ── Per-tab close (✕) — revealed on hover/focus/active ─────────── */

.xtabs-header .xtabs-item .xtabs-close {
    order: 2;                          /* inline-end of the label */
    position: relative;
    z-index: 1;                        /* wins hit-testing over the link's 6px overlap */
    align-self: center;                /* li stretches; keep ✕ centered */
    float: none !important;            /* library scoped CSS floats it right */
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    padding: 0;
    margin-inline: -6px 6px;           /* tuck against the label */
    border: 0;
    background: transparent;
    border-radius: 7px;
    color: var(--xt-ink-faint);
    font-size: 15px;
    font-weight: 400;
    text-shadow: none;
    line-height: 1;
    opacity: 0;
    cursor: pointer;
    transition: opacity .15s var(--xt-ease),
                background-color .15s var(--xt-ease),
                color .15s var(--xt-ease);
}

.xtabs-header .xtabs-item:hover .xtabs-close,
.xtabs-header .xtabs-item:focus-within .xtabs-close {
    opacity: 1;
}

/* Kept separate: a :has() failure must not void the hover rule above. */
.xtabs-header .xtabs-item:has(.xtabs-link.active) .xtabs-close {
    opacity: 1;    /* de-emphasis carried by color, not opacity (contrast) */
}

.xtabs-header .xtabs-item .xtabs-close:hover {
    opacity: 1;
    background-color: rgba(27, 67, 50, .09);
    color: var(--xt-ink);
}

.xtabs-header .xtabs-item .xtabs-close:focus-visible {
    opacity: 1;
    outline: 2px solid var(--gs-p1, #52b788);
    outline-offset: 1px;
}

/* ── Close-all (strip-level, destructive → warm hover) ──────────── */

/* (0,4,0): ties the library's `.xtabs .xtabs-header .xtabs-close-all[b-…]`
   (which paints it RED/BOLD — a leftover debug rule) so load order decides. */
.xtabs .xtabs-header > .xtabs-close-all.xtabs-close-all {
    order: 2;
    align-self: center;
    float: none !important;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    padding: 0;
    margin-inline-start: .4rem;
    margin-bottom: .3rem;
    border: 1px solid var(--xt-hairline);
    background: #fff;
    border-radius: 8px;
    color: var(--xt-ink-faint);
    font-size: 15px;
    font-weight: 400;
    text-shadow: none;
    line-height: 1;
    opacity: 1;
    cursor: pointer;
    transition: background-color .15s var(--xt-ease),
                color .15s var(--xt-ease),
                border-color .15s var(--xt-ease);
}

.xtabs .xtabs-header > .xtabs-close-all.xtabs-close-all:hover {
    background: #fdf0ef;
    border-color: #ecd9d6;
    color: #b3564a;
    opacity: 1;
}

/* ── Touch devices: no hover exists, keep ✕ always visible ──────── */

@media (hover: none) {
    .xtabs-header .xtabs-item .xtabs-close { opacity: 1; }
}

/* ── Motion opt-out ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .xtabs-header .xtabs-item { animation: none; }
    .xtabs-header .xtabs-item .xtabs-link,
    .xtabs-header .xtabs-item .xtabs-link h6,
    .xtabs-header .xtabs-item .xtabs-link::after,
    .xtabs-header .xtabs-item .xtabs-close,
    .xtabs .xtabs-header > .xtabs-close-all.xtabs-close-all { transition: none; }
}
