/* ==========================================================================
   TABS — one underline tab, one pill group, one count badge.

   The tree held FIVE spellings of the same underline tab, in four
   stylesheets, none of them in the design system:

     .patitur-tab-bar   device-detail.css        9 templates
     .policy-tab        policies.css             3
     .landing-tab       compliance/framework…    2
     .fw-tab            compliance/framework…    2
     .l2-tab            positioning/cluster…     1

   Between them: four different active-text colours, three font sizes and
   four paddings for what is visually one control. The compliance bars also
   underlined in --status-active-fg (#10b981, Tailwind's emerald) rather than
   the brand green (#25af88) — near enough to look intentional, and wrong.

   Defined once here. The legacy names are kept as selector aliases rather
   than renamed across fifteen templates: the goal is one definition, not
   one spelling, and a rename would churn every call site for no gain.

   See docs/design-system/tabs.html.
   ========================================================================== */

/* --- the bar ------------------------------------------------------------- */
.tab-bar,
.patitur-tab-bar,
.policy-tabs,
.fw-tabs,
.landing-tabs,
.l2-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-base);
    border-radius: 0;
    margin-bottom: 1rem;
    /* The "mystery vertical symbol next to the Positioning tab" was a macOS
       scrollbar. A blocked third-party stylesheet (Flowbite CDN) applies
       ``overflow: auto`` here; with the active tab's -1px margin over the
       bar's 1px rule that is 1px of reported overflow — enough for the OS to
       claim a scrollbar gutter. !important because the third-party rule has
       higher specificity and we could not introspect it across CORS. A tab
       bar never legitimately scrolls. */
    overflow: visible !important;
}

/* Equal-width tabs: every tab as wide as the widest. The device-detail bars
   are laid out this way; the rest size to their content. */
.tab-bar--equal,
.patitur-tab-bar {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    width: fit-content;
}

/* --- the tab ------------------------------------------------------------- */
.tab,
.patitur-tab-bar button,
.patitur-tab-bar a,
.policy-tab,
.fw-tab,
.landing-tab,
.l2-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--fg-4);
    background: transparent;
    border: none;
    /* reserve the underline slot so activating a tab does not reflow the bar */
    border-bottom: 2px solid transparent;
    border-radius: 0;
    /* sit the underline over the bar's own base rule */
    margin-bottom: -1px;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition:
        color 0.12s,
        border-color 0.12s;
}

.tab:hover,
.patitur-tab-bar button:hover,
.patitur-tab-bar a:hover,
.policy-tab:hover,
.fw-tab:hover,
.landing-tab:hover,
.l2-tab:hover {
    background: transparent;
    color: var(--fg-2);
}

/* --- the selected tab ----------------------------------------------------
   aria-selected is listed alongside the .active class on purpose. Keying the
   look to the class alone let the two drift: components/navigation/tabs.html
   flipped aria-selected correctly while rewriting className with a string
   that no longer matched what it rendered, so the outgoing tab kept its
   underline and two tabs looked selected at once. Style the state and the
   bug cannot recur. */
.tab.active,
.tab[aria-selected="true"],
.patitur-tab-bar button.active,
.patitur-tab-bar a.active,
.patitur-tab-bar button[aria-selected="true"],
.patitur-tab-bar a[aria-selected="true"],
.policy-tab--active,
.policy-tab--active:hover,
.fw-tab-active,
.landing-tab-active,
.l2-tab.active,
[role="tab"][aria-selected="true"].tab,
[role="tab"][aria-selected="true"].fw-tab,
[role="tab"][aria-selected="true"].landing-tab,
[role="tab"][aria-selected="true"].l2-tab {
    background: transparent;
    color: var(--fg-1);
    border-bottom-color: var(--color-brand-green);
}

/* The Policy/Configurations surfaces carry brand-green tab text. This is the
   same documented deviation as their near-black page titles, not drift —
   see the title section in .claude/skills/patitur-design/README.md. */
.tab--brand.active,
.tab--brand[aria-selected="true"],
.policy-tab--active,
.policy-tab--active:hover,
.policy-tab--active i {
    color: var(--color-brand-green);
}

.tab:focus-visible,
.patitur-tab-bar button:focus-visible,
.patitur-tab-bar a:focus-visible,
.policy-tab:focus-visible,
.fw-tab:focus-visible,
.landing-tab:focus-visible,
.l2-tab:focus-visible {
    outline: 2px solid var(--color-brand-green);
    outline-offset: -2px;
    border-radius: 4px;
}

/* A tab's leading glyph. Sized here so a call site never picks its own. */
.tab > svg,
.patitur-tab-bar button svg,
.patitur-tab-bar a svg,
.fw-tab > svg,
.landing-tab > svg,
.l2-tab > svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* --- the subordinate bar ------------------------------------------------
   A second level of tabs beneath a first: smaller, lighter, on a tinted
   strip, with a 1.5px inset underline so the strip's own bottom border stays
   continuous behind it. Genuinely a different rank, not a different tab. */
.tab-bar--l2,
.patitur-tab-bar--l2 {
    border-bottom: none; /* the strip below owns the baseline */
}

.tab-bar--l2 .tab,
.patitur-tab-bar--l2 button,
.patitur-tab-bar--l2 a {
    padding: 0.5rem 1.125rem;
    font-size: var(--fs-sm);
    color: var(--fg-5);
    border-bottom-width: 0;
}

.tab-bar--l2 .tab:hover,
.patitur-tab-bar--l2 button:hover,
.patitur-tab-bar--l2 a:hover {
    color: var(--fg-3);
}

.tab-bar--l2 .tab.active,
.tab-bar--l2 .tab[aria-selected="true"],
.patitur-tab-bar--l2 button.active,
.patitur-tab-bar--l2 a.active {
    color: var(--color-brand-green);
    box-shadow: inset 0 -1.5px 0 var(--color-brand-green);
    border-bottom-color: transparent;
}

.tab-strip,
.l2-tab-strip {
    padding: 0 12px;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-base);
}

/* A tab's panel, when it is not the selected one. */
.tab-panel-hidden,
.fw-tab-panel-hidden,
.landing-panel-hidden {
    display: none;
}

/* --- the count badge -----------------------------------------------------
   Five families each carried their own: .dd-tab-count, .policy-tab-count,
   .landing-tab-count, .fw-tab-count and a bare .count inside .l2-tab. */
.tab-count,
.dd-tab-count,
.policy-tab-count,
.landing-tab-count,
.fw-tab-count,
.l2-tab .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    padding: 0 0.375rem;
    border-radius: var(--radius-pill);
    background: var(--status-neutral-bg);
    color: var(--fg-4);
    font-size: var(--fs-sm);
    font-weight: 500;
}

.tab.active .tab-count,
.tab[aria-selected="true"] .tab-count,
.patitur-tab-bar .active .dd-tab-count,
.patitur-tab-bar [aria-selected="true"] .tab-count,
.policy-tab-count--active,
.fw-tab-active .fw-tab-count,
.landing-tab-active .landing-tab-count,
.l2-tab.active .count {
    background: var(--color-brand-green-light);
    color: var(--color-brand-green-deep);
}

/* A count that is itself a warning — a framework under attack. */
.tab-count--danger,
.fw-tab-count-attack,
.landing-tab-attack .landing-tab-count {
    background: var(--sev-high-bg);
    color: var(--danger-deep-fg);
}

.fw-tab-active .fw-tab-count-attack,
.landing-tab-active.landing-tab-attack .landing-tab-count,
.tab.active .tab-count--danger,
.tab[aria-selected="true"] .tab-count--danger {
    background: var(--sev-high-border);
    color: var(--danger-darkest-fg);
}

/* --- the pill group ------------------------------------------------------
   A genuinely different control: a segmented group on a tinted track, not an
   underlined strip. Kept as its own thing rather than folded in. */
.tab-pills,
.patitur-tab-pills {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-page);
    border: 1px solid var(--border-base);
    border-radius: var(--radius-md);
}

.tab-pills button,
.tab-pills a,
.patitur-tab-pills button,
.patitur-tab-pills a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.375rem 0.75rem;
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--fg-3);
    background: transparent;
    border: none;
    border-radius: 6px;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
}

.tab-pills button:hover:not(.active),
.tab-pills a:hover:not(.active),
.patitur-tab-pills button:hover:not(.active),
.patitur-tab-pills a:hover:not(.active) {
    background: var(--bg-card);
    color: var(--fg-1);
}

.tab-pills button.active,
.tab-pills a.active,
.tab-pills button[aria-selected="true"],
.tab-pills a[aria-selected="true"],
.patitur-tab-pills button.active,
.patitur-tab-pills a.active {
    background: var(--color-brand-green);
    color: var(--fg-on-dark);
}

/* --- the bordered pill ---------------------------------------------------
   .dd-field-tab is a pill that carries a border. Its selected state was
   var(--fg-1) — a near-black fill, the same thing the segmented control was
   pulled off: the product's controls are green, and a black block reads as a
   different system. It now selects in brand green like every other pill. */
.tab-pill-bordered,
.dd-field-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--fg-3);
    background: var(--bg-page);
    border: 1px solid var(--border-base);
    border-radius: 0.5rem;
    cursor: pointer;
    transition:
        background-color 0.12s,
        color 0.12s;
}

.tab-pill-bordered:hover,
.dd-field-tab:hover {
    background: var(--bg-card);
    color: var(--fg-1);
}

.tab-pill-bordered.active,
.tab-pill-bordered[aria-selected="true"],
.dd-field-tab.active {
    background: var(--color-brand-green);
    border-color: var(--color-brand-green);
    color: var(--fg-on-dark);
}

.tab-pill-bordered.active .info-help-icon svg,
.dd-field-tab.active .info-help-icon svg {
    color: var(--fg-on-dark);
    opacity: 0.75;
}
