/**
 * ACSS Accessibility Checker — Table & Tabs Styles
 * v1.6.0
 */

/* ===== Wrapper ===== */
.acss-act-wrapper {
    --act-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --act-radius: 6px;
    --act-gap: 1rem;
    --act-cell-min: 90px;
    --act-border: 1px solid rgba(128, 128, 128, 0.2);
    --act-bg: transparent;
    --act-text: inherit;

    font-family: var(--act-font);
    padding: var(--act-gap);
    color: var(--act-text);
    background: var(--act-bg);
}

/* ===== Header ===== */
.acss-act-header {
    margin-bottom: 1.5rem;
}

.acss-act-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1rem;
}

.acss-act-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.acss-act-legend p {
    margin: 0;
    width: 100%;
}

.acss-act-axes {
    display: flex;
    gap: 2rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

/* ===== Controls & Toggles ===== */
.acss-act-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.acss-act-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid rgba(128, 128, 128, 0.3);
    border-radius: 20px;
    background: rgba(128, 128, 128, 0.08);
    color: inherit;
    font-family: var(--act-font);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.acss-act-toggle:hover {
    background: rgba(128, 128, 128, 0.15);
}

.acss-act-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.acss-act-toggle--dnp[aria-pressed="true"] {
    background: rgba(220, 20, 60, 0.15);
    border-color: rgba(220, 20, 60, 0.4);
}

.acss-act-toggle--aa-large[aria-pressed="true"] {
    background: rgba(218, 165, 32, 0.15);
    border-color: rgba(218, 165, 32, 0.4);
}

/* ===== Badges ===== */
.acss-act-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: middle;
}

.acss-act-badge--aaa {
    background: #228B22;
    color: #fff;
}

.acss-act-badge--aa {
    background: #2E8B57;
    color: #fff;
}

.acss-act-badge--aa-large {
    background: #DAA520;
    color: #000;
}

.acss-act-badge--dnp {
    background: #DC143C;
    color: #fff;
}

/* ===== Table Scroll Container ===== */
.acss-act-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: var(--act-border);
    border-radius: var(--act-radius);
}

/* ===== Table ===== */
.acss-act-table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    font-size: 0.78rem;
    table-layout: fixed;
}

.acss-act-table th,
.acss-act-table td {
    border: 1px solid rgba(128, 128, 128, 0.15);
    text-align: center;
    vertical-align: middle;
    padding: 0;
    min-width: var(--act-cell-min);
    height: 64px;
}

/* Corner cell */
.acss-act-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: rgba(40, 40, 40, 0.95);
    color: #fff;
    font-size: 0.7rem;
    min-width: 120px;
}

/* Column headers (text colors) */
.acss-act-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 6px;
    font-weight: 600;
    font-size: 0.72rem;
    white-space: nowrap;
    height: auto;
}

/* Row headers (background colors) */
.acss-act-table tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 0.72rem;
    white-space: nowrap;
    text-align: right;
    min-width: 120px;
}

/* ===== Table Cells ===== */
.acss-act-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 100%;
    padding: 6px 4px;
    box-sizing: border-box;
}

.acss-act-cell__ratio {
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
}

.acss-act-cell__badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: nowrap;
}

.acss-act-cell__badge--aaa {
    background: #228B22;
    color: #fff;
}

.acss-act-cell__badge--aa {
    background: #2E8B57;
    color: #fff;
}

.acss-act-cell__badge--aa-large {
    background: #DAA520;
    color: #000;
}

.acss-act-cell__badge--dnp {
    background: #DC143C;
    color: #fff;
}

/* Diagonal / same-color cells */
.acss-act-cell--same {
    opacity: 0.3;
}

/* "Hide DNP" toggle — hide cell contents, keep background */
.acss-act-wrapper.acss-act-hide-dnp .acss-act-cell--dnp .acss-act-cell__ratio,
.acss-act-wrapper.acss-act-hide-dnp .acss-act-cell--dnp .acss-act-cell__badge {
    visibility: hidden;
}

/* "Hide AA Large" toggle — hide cell contents, keep background */
.acss-act-wrapper.acss-act-hide-aa-large .acss-act-cell--aa-large .acss-act-cell__ratio,
.acss-act-wrapper.acss-act-hide-aa-large .acss-act-cell--aa-large .acss-act-cell__badge {
    visibility: hidden;
}

/* ===== Swatch dots in headers ===== */
.acss-act-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(128, 128, 128, 0.3);
    vertical-align: middle;
    margin-right: 4px;
    flex-shrink: 0;
}

.acss-act-header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.acss-act-header-content--row {
    flex-direction: row;
    justify-content: flex-end;
}

/* ===== Loading State ===== */
.acss-act-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    font-size: 1rem;
    opacity: 0.6;
}

.acss-act-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    margin-left: 0.75rem;
    animation: acss-act-spin 0.6s linear infinite;
}

@keyframes acss-act-spin {
    to { transform: rotate(360deg); }
}


/* =========================================================================
 * TABS VIEW
 * ========================================================================= */

.acss-act-tabs {
    margin-top: 0.5rem;
}

/* ----- Tab List (the row of buttons) ----- */
.acss-act-tabs__list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 2px solid rgba(128, 128, 128, 0.2);
    padding-bottom: 0;
    margin-bottom: 0;
}

/* ----- Individual Tab Button ----- */
.acss-act-tabs__tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid rgba(128, 128, 128, 0.15);
    border-bottom: none;
    border-radius: var(--act-radius) var(--act-radius) 0 0;
    background: rgba(128, 128, 128, 0.06);
    color: inherit;
    font-family: var(--act-font);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    bottom: -2px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    text-transform: capitalize;
}

.acss-act-tabs__tab:hover {
    background: rgba(128, 128, 128, 0.12);
}

.acss-act-tabs__tab:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

/* Active tab */
.acss-act-tabs__tab.is-active {
    background: var(--act-bg, #fff);
    border-color: rgba(128, 128, 128, 0.2);
    border-bottom-color: var(--act-bg, #fff);
    z-index: 1;
}

/* On dark backgrounds, active tab needs a visible bottom cover */
[data-theme="dark"] .acss-act-tabs__tab.is-active {
    border-bottom-color: transparent;
    background: rgba(255, 255, 255, 0.05);
}

/* ----- Tab Swatch (color dot in tab button) ----- */
.acss-act-tabs__tab-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(128, 128, 128, 0.3);
    flex-shrink: 0;
}

/* ----- Tab Panels ----- */
.acss-act-tabs__panel {
    padding-top: 1rem;
}

.acss-act-tabs__panel[hidden] {
    display: none;
}

/* Tab panel tables may be narrower (fewer rows), so remove min-width: 100% */
.acss-act-table--tab {
    min-width: auto;
}

/* ----- Hidden (empty) tabs and panels ----- */
.acss-act-tabs__tab.is-empty {
    display: none;
}

.acss-act-tabs__panel.is-empty {
    display: none;
}

/* ----- Empty-state warning ----- */
.acss-act-tabs__empty-warning {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    font-size: 1rem;
    opacity: 0.6;
    text-align: center;
}


/* ===== Responsive ===== */
@media (max-width: 768px) {
    .acss-act-table {
        font-size: 0.7rem;
    }
    .acss-act-table th,
    .acss-act-table td {
        min-width: 72px;
        height: 56px;
    }
    .acss-act-table tbody th,
    .acss-act-table thead th:first-child {
        min-width: 90px;
    }

    /* Tabs wrap nicely on mobile */
    .acss-act-tabs__tab {
        font-size: 0.78rem;
        padding: 8px 12px;
    }
}
