/* =====================================================================
 * NGS Product Tabs — [ngs_product_tabs]
 *
 * Three style variants, switched via `data-style` on the root element:
 *   showcase  — info-rich stat-card tabs (default). Two-line content
 *               with an icon chip, title, and auto-counted item subtitle.
 *               Animated sliding indicator on the bottom.
 *   pills     — single-line pill buttons in a unified container, with
 *               a small count badge to the right of each label.
 *   compact   — slim flat pill buttons, single line, no counts, no
 *               container — for tight layouts.
 *
 * Each tab carries `--ngs-pt-accent-local` (set inline by JS from the
 * section's `data-icon` key) so the active state can color itself per-
 * section without us hard-coding a giant lookup table here.
 * ===================================================================== */

.ngs-pt {
    /* Brand + neutral palette */
    --ngs-pt-bg:           #ffffff;
    --ngs-pt-bg-sticky:    rgba(255, 255, 255, 0.96);
    --ngs-pt-surface:      #fafaf8;
    --ngs-pt-surface-2:    #f4f1ec;
    --ngs-pt-border:       #e6e1da;
    --ngs-pt-on-bg:        #1c1b1b;
    --ngs-pt-on-bg-mut:    #5f5e5b;
    --ngs-pt-on-bg-soft:   #8a8a85;
    --ngs-pt-accent:       #00b5bd;

    /* Per-tab accent — overridden inline by JS */
    --ngs-pt-accent-local: var(--ngs-pt-accent);

    /* Geometry */
    --ngs-pt-radius:       14px;
    --ngs-pt-tab-radius:   10px;
    --ngs-pt-gap:          4px;
    --ngs-pt-shadow:       0 2px 12px rgba(0, 0, 0, 0.05);
    --ngs-pt-shadow-pin:   0 4px 18px rgba(0, 0, 0, 0.08);

    position: relative;
    z-index: 50;
    width: 100%;
    margin: 16px 0 24px;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
}
.ngs-pt[hidden] { display: none !important; }
.ngs-pt *, .ngs-pt *::before, .ngs-pt *::after { box-sizing: inherit; }

/* ============== Sticky / pinned behavior ============== */
.ngs-pt.is-sticky {
    position: sticky;
    top: 0;
}
.ngs-pt.is-sticky.is-pinned {
    margin: 0;
    padding-top: 6px;
    padding-bottom: 6px;
    background: var(--ngs-pt-bg-sticky);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--ngs-pt-border);
    box-shadow: var(--ngs-pt-shadow-pin);
}
.ngs-pt.is-sticky.is-pinned .ngs-pt__inner {
    background: transparent;
    box-shadow: none;
    border-color: transparent;
}

/* ============== Container (one card wrapping all tabs) ============== */
.ngs-pt__inner {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    background: var(--ngs-pt-surface);
    border: 1px solid var(--ngs-pt-border);
    border-radius: var(--ngs-pt-radius);
    box-shadow: var(--ngs-pt-shadow);
    padding: 6px;
}
.ngs-pt[data-style="compact"] .ngs-pt__inner {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0 4px;
}

/* ============== Scrollable track ============== */
.ngs-pt__track {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: var(--ngs-pt-gap);
    flex: 1 1 auto;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
}
.ngs-pt__track::-webkit-scrollbar { display: none; }
.ngs-pt--align-center .ngs-pt__track { justify-content: center; }
.ngs-pt--align-right  .ngs-pt__track { justify-content: flex-end; }
.ngs-pt--align-center.is-overflow .ngs-pt__track { justify-content: flex-start; }
.ngs-pt--align-right.is-overflow  .ngs-pt__track { justify-content: flex-start; }

/* ============== TABS — base ============== */
.ngs-pt__tab {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 0;
    color: var(--ngs-pt-on-bg-mut);
    cursor: pointer;
    white-space: nowrap;
    scroll-snap-align: start;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--ngs-pt-tab-radius);
    transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
}
.ngs-pt__tab:focus-visible {
    outline: 2px solid var(--ngs-pt-accent);
    outline-offset: 2px;
}
.ngs-pt__tab:active { transform: scale(0.985); }

/* =====================================================================
 * SHOWCASE STYLE (default) — stat-card tabs
 * ===================================================================== */
.ngs-pt[data-style="showcase"] .ngs-pt__tab {
    gap: 12px;
    min-height: 64px;
    padding: 10px 16px 10px 12px;
    font: 500 13px/1.2 "Inter", sans-serif;
}
.ngs-pt[data-style="showcase"] .ngs-pt__tab:hover {
    background: rgba(255, 255, 255, 0.7);
    color: var(--ngs-pt-on-bg);
}
.ngs-pt[data-style="showcase"] .ngs-pt__tab.is-active {
    background: #ffffff;
    color: var(--ngs-pt-on-bg);
    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.04),
        0 4px 14px rgba(0, 0, 0, 0.08);
}

/* Icon chip — a colored square that uses the section's accent */
.ngs-pt__tab-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--ngs-pt-accent-local) 14%, #ffffff);
    color: var(--ngs-pt-accent-local);
    flex: 0 0 36px;
    transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.ngs-pt__tab-chip svg { width: 18px; height: 18px; display: block; }
.ngs-pt__tab.is-active .ngs-pt__tab-chip {
    background: var(--ngs-pt-accent-local);
    color: #ffffff;
    transform: scale(1.04);
}
.ngs-pt__tab:hover .ngs-pt__tab-chip {
    background: color-mix(in srgb, var(--ngs-pt-accent-local) 22%, #ffffff);
}

/* Body — title + meta */
.ngs-pt__tab-body {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    text-align: left;
    line-height: 1.1;
}
.ngs-pt__tab-label {
    font: 700 12px/1 "Inter", sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: inherit;
}
.ngs-pt__tab-meta {
    font: 500 12px/1 "Inter", sans-serif;
    color: var(--ngs-pt-on-bg-soft);
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
}
.ngs-pt__tab.is-active .ngs-pt__tab-meta {
    color: var(--ngs-pt-accent-local);
    font-weight: 600;
}

/* Animated sliding indicator — a bottom accent bar that glides between
   the active tab's bounds. The JS sets `transform: translateX(...)` and
   `width` inline on focus changes. */
.ngs-pt__indicator {
    position: absolute;
    left: 0;
    bottom: -2px;
    height: 3px;
    width: 0;
    border-radius: 999px;
    background: var(--ngs-pt-indicator-color, var(--ngs-pt-accent));
    transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1),
                width     0.32s cubic-bezier(0.2, 0.8, 0.2, 1),
                background 0.25s ease,
                opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}
.ngs-pt[data-style="compact"] .ngs-pt__indicator { display: none; }

/* =====================================================================
 * PILLS STYLE — single-line tabs with a small count badge
 * ===================================================================== */
.ngs-pt[data-style="pills"] .ngs-pt__tab {
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    font: 600 13px/1 "Inter", sans-serif;
    letter-spacing: 0.01em;
}
.ngs-pt[data-style="pills"] .ngs-pt__tab:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--ngs-pt-on-bg);
}
.ngs-pt[data-style="pills"] .ngs-pt__tab.is-active {
    background: var(--ngs-pt-on-bg);
    color: #fff;
}
.ngs-pt[data-style="pills"] .ngs-pt__tab.is-active .ngs-pt__tab-icon {
    color: #fff;
}
.ngs-pt[data-style="pills"] .ngs-pt__tab-badge {
    margin-left: 4px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    color: var(--ngs-pt-on-bg-mut);
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}
.ngs-pt[data-style="pills"] .ngs-pt__tab.is-active .ngs-pt__tab-badge {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

/* =====================================================================
 * COMPACT STYLE — slim pill buttons, single line
 * ===================================================================== */
.ngs-pt[data-style="compact"] .ngs-pt__tab {
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    font: 600 12.5px/1 "Inter", sans-serif;
    border-radius: 999px;
    color: var(--ngs-pt-on-bg-mut);
}
.ngs-pt[data-style="compact"] .ngs-pt__tab:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--ngs-pt-on-bg);
}
.ngs-pt[data-style="compact"] .ngs-pt__tab.is-active {
    background: var(--ngs-pt-on-bg);
    color: #fff;
}

/* Shared icon styling for pills / compact */
.ngs-pt__tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    color: var(--ngs-pt-accent-local);
    transition: color 0.2s ease;
}
.ngs-pt__tab-icon svg { width: 100%; height: 100%; display: block; }
.ngs-pt[data-show-icons="0"] .ngs-pt__tab-icon,
.ngs-pt[data-show-icons="0"] .ngs-pt__tab-chip { display: none; }

/* =====================================================================
 * Scroll arrows + edge fades (shared across styles)
 * ===================================================================== */
.ngs-pt__scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: #fff;
    border: 1px solid var(--ngs-pt-border);
    border-radius: 9999px;
    color: var(--ngs-pt-on-bg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 3;
    transition: opacity 0.2s, transform 0.1s;
    opacity: 0.95;
}
.ngs-pt__scroll-arrow[hidden] { display: none; }
.ngs-pt__scroll-arrow:hover { opacity: 1; }
.ngs-pt__scroll-arrow:active { transform: translateY(-50%) scale(0.92); }
.ngs-pt__scroll-arrow--prev { left: -8px; }
.ngs-pt__scroll-arrow--next { right: -8px; }

.ngs-pt.is-overflow .ngs-pt__inner::before,
.ngs-pt.is-overflow .ngs-pt__inner::after {
    content: "";
    position: absolute;
    top: 6px;
    bottom: 6px;
    width: 28px;
    pointer-events: none;
    z-index: 2;
    border-radius: var(--ngs-pt-radius);
}
.ngs-pt.is-overflow .ngs-pt__inner::before {
    left: 6px;
    background: linear-gradient(to right, var(--ngs-pt-surface) 0%, rgba(250, 250, 248, 0) 100%);
}
.ngs-pt.is-overflow .ngs-pt__inner::after {
    right: 6px;
    background: linear-gradient(to left,  var(--ngs-pt-surface) 0%, rgba(250, 250, 248, 0) 100%);
}
.ngs-pt[data-style="compact"].is-overflow .ngs-pt__inner::before,
.ngs-pt[data-style="compact"].is-overflow .ngs-pt__inner::after {
    background: linear-gradient(to right, var(--ngs-pt-bg) 0%, rgba(255, 255, 255, 0) 100%);
}
.ngs-pt[data-style="compact"].is-overflow .ngs-pt__inner::after {
    background: linear-gradient(to left,  var(--ngs-pt-bg) 0%, rgba(255, 255, 255, 0) 100%);
}
.ngs-pt.is-overflow.is-scroll-start .ngs-pt__inner::before,
.ngs-pt.is-overflow.is-scroll-end   .ngs-pt__inner::after { display: none; }

/* =====================================================================
 * Mobile — scale the showcase tabs down so they still fit nicely
 * ===================================================================== */
@media (max-width: 720px) {
    .ngs-pt { --ngs-pt-radius: 12px; --ngs-pt-tab-radius: 8px; }
    .ngs-pt[data-style="showcase"] .ngs-pt__tab {
        gap: 10px;
        min-height: 56px;
        padding: 8px 12px 8px 8px;
    }
    .ngs-pt__tab-chip { width: 32px; height: 32px; flex-basis: 32px; border-radius: 8px; }
    .ngs-pt__tab-chip svg { width: 16px; height: 16px; }
    .ngs-pt__tab-label { font-size: 11px; letter-spacing: 0.05em; }
    .ngs-pt__tab-meta  { font-size: 11px; }

    .ngs-pt[data-style="pills"] .ngs-pt__tab { height: 40px; padding: 0 12px; font-size: 12.5px; }
    .ngs-pt[data-style="compact"] .ngs-pt__tab { height: 34px; padding: 0 10px; font-size: 12px; }

    /* On touch devices hide the arrow buttons — swipe to scroll. */
    .ngs-pt__scroll-arrow { display: none !important; }
}

/* =====================================================================
 * Fallback for browsers without color-mix() — fall back to the accent
 * itself on the chip background; still readable, just less subtle.
 * ===================================================================== */
@supports not (background: color-mix(in srgb, red 10%, white)) {
    .ngs-pt__tab-chip {
        background: rgba(0, 0, 0, 0.05);
    }
}

/* =====================================================================
 * Reduced motion
 * ===================================================================== */
@media (prefers-reduced-motion: reduce) {
    .ngs-pt__track,
    .ngs-pt__indicator { scroll-behavior: auto; transition: none; }
    .ngs-pt__tab,
    .ngs-pt__tab-chip,
    .ngs-pt__scroll-arrow { transition: none; }
}
