/* OSJ AI Matrix
   Matches Old Stack Journal's warm, practical theme style.
*/

.osj-ai-matrix {
    --osj-ai-matrix-sticky-top: 112px;
    margin: 1.5rem 0 3rem;
    color: var(--osj-text);
}

body.admin-bar .osj-ai-matrix {
    --osj-ai-matrix-sticky-top: 144px;
}

.osj-ai-matrix * {
    box-sizing: border-box;
}

.osj-ai-matrix-hero {
    margin: 0 0 1rem;
    padding: clamp(1rem, 2.2vw, 1.45rem);
    background: linear-gradient(180deg, var(--osj-surface-strong), var(--osj-surface));
    border: 1px solid var(--osj-border);
    border-radius: calc(var(--osj-radius) + 6px);
    box-shadow: var(--osj-shadow);
}


.osj-ai-matrix-hero p {
    max-width: 920px;
    margin: 0;
    color: var(--osj-muted);
    font-size: clamp(0.98rem, 1.45vw, 1.08rem);
}

.osj-ai-matrix-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.2rem;
}

.osj-ai-matrix-stats span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--osj-border);
    border-radius: 999px;
    background: rgba(255, 250, 240, 0.7);
    color: var(--osj-muted);
    font-size: 0.9rem;
    line-height: 1.25;
}

.osj-ai-matrix-stats strong {
    color: var(--osj-text);
}

.osj-ai-matrix-controls {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 1fr)) auto;
    gap: 0.7rem;
    align-items: end;
    margin: 1rem 0 0.8rem;
    padding: 1rem;
    background: var(--osj-surface);
    border: 1px solid var(--osj-border);
    border-radius: var(--osj-radius);
    box-shadow: 0 1px 0 rgba(40, 32, 24, 0.03);
}

.osj-ai-matrix-controls label {
    display: grid;
    gap: 0.25rem;
    margin: 0;
    color: var(--osj-muted);
    font-size: 0.82rem;
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.osj-ai-matrix-controls input,
.osj-ai-matrix-controls select {
    width: 100%;
    min-height: 42px;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--osj-border-strong);
    border-radius: var(--osj-radius-small);
    background: var(--osj-surface-strong);
    color: var(--osj-text);
    font: inherit;
    font-size: 0.96rem;
    line-height: 1.25;
    text-transform: none;
    letter-spacing: 0;
}

.osj-ai-matrix-controls input:focus,
.osj-ai-matrix-controls select:focus {
    outline: 2px solid rgba(63, 111, 91, 0.28);
    border-color: var(--osj-accent);
}

.osj-ai-matrix-reset {
    min-height: 42px;
    white-space: nowrap;
}

.osj-ai-matrix-count {
    margin: 0 0 0.7rem;
    color: var(--osj-muted);
    font-family: var(--osj-mono);
    font-size: 0.9rem;
}

.osj-ai-matrix-count span {
    color: var(--osj-text);
    font-weight: 800;
}

.osj-ai-matrix-table-wrap {
    width: 100%;
    overflow: visible;
    border: 1px solid var(--osj-border);
    border-radius: var(--osj-radius);
    background: var(--osj-surface);
    box-shadow: var(--osj-shadow);
}

.osj-ai-matrix-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
}

.entry-content .osj-ai-matrix-table {
    border-collapse: separate;
}

.osj-ai-matrix-table th,
.osj-ai-matrix-table td,
.entry-content .osj-ai-matrix-table th,
.entry-content .osj-ai-matrix-table td {
    vertical-align: top;
    padding: 0.8rem 0.65rem;
    border: 0;
    border-bottom: 1px solid var(--osj-border);
    text-align: left;
    overflow-wrap: break-word;
}

/* Keep the column widths under 100% so the matrix sits inside the OSJ content well. */
.osj-ai-matrix-table th:nth-child(1),
.osj-ai-matrix-table td:nth-child(1) {
    width: 11%;
}

.osj-ai-matrix-table th:nth-child(2),
.osj-ai-matrix-table td:nth-child(2) {
    width: 10.5%;
}

.osj-ai-matrix-table th:nth-child(3),
.osj-ai-matrix-table td:nth-child(3) {
    width: 20%;
}

.osj-ai-matrix-table th:nth-child(4),
.osj-ai-matrix-table td:nth-child(4),
.osj-ai-matrix-table th:nth-child(5),
.osj-ai-matrix-table td:nth-child(5),
.osj-ai-matrix-table th:nth-child(6),
.osj-ai-matrix-table td:nth-child(6),
.osj-ai-matrix-table th:nth-child(7),
.osj-ai-matrix-table td:nth-child(7) {
    width: 6.8%;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    text-align: center;
    overflow-wrap: normal;
}

.osj-ai-matrix-table th:nth-child(8),
.osj-ai-matrix-table td:nth-child(8) {
    width: 10%;
    text-align: center;
}

.osj-ai-matrix-table th:nth-child(9),
.osj-ai-matrix-table td:nth-child(9) {
    width: 21.3%;
}

.osj-ai-matrix-table th {
    position: sticky;
    top: var(--osj-ai-matrix-sticky-top, 0px);
    z-index: 10;
    background: #efe5d5;
    box-shadow: 0 1px 0 var(--osj-border), 0 4px 10px rgba(40, 32, 24, 0.06);
    color: var(--osj-text);
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.055em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}


.osj-ai-matrix-table th button {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-transform: inherit;
    letter-spacing: inherit;
    white-space: nowrap;
}

.osj-ai-matrix-table th:nth-child(4) button,
.osj-ai-matrix-table th:nth-child(5) button,
.osj-ai-matrix-table th:nth-child(6) button,
.osj-ai-matrix-table th:nth-child(7) button,
.osj-ai-matrix-table th:nth-child(8) button {
    justify-content: center;
    margin: 0 auto;
}

.osj-ai-matrix-table th button::after {
    content: "↕";
    color: var(--osj-muted);
    font-size: 0.8em;
}

.osj-ai-matrix-table tbody tr.osj-ai-matrix-row {
    background: var(--osj-surface);
}

.osj-ai-matrix-table tbody tr.osj-ai-matrix-row:hover {
    background: #fffdf7;
}

.osj-ai-matrix-table tbody tr.is-hidden,
.osj-ai-matrix-table tbody tr[hidden] {
    display: none;
}

.osj-ai-matrix-tool strong {
    display: block;
    margin: 0 0 0.15rem;
    color: var(--osj-text);
    font-size: 1rem;
    line-height: 1.2;
}

.osj-ai-matrix-tool span,
.osj-ai-matrix-muted {
    display: block;
    color: var(--osj-muted);
    font-size: 0.82rem;
    line-height: 1.35;
}

.osj-ai-matrix-price {
    display: block;
    font-weight: 800;
    color: var(--osj-text);
}

.osj-ai-matrix-score {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.12rem;
    min-width: 48px;
    padding: 0.24rem 0.45rem;
    border: 1px solid #c3d7c6;
    border-radius: 999px;
    background: var(--osj-success-bg);
    color: var(--osj-accent-dark);
    font-family: var(--osj-mono);
    font-size: 0.82rem;
    line-height: 1.1;
}

.osj-ai-matrix-score strong {
    font-size: 1rem;
}

.osj-ai-matrix-score-empty {
    justify-content: center;
    border-color: var(--osj-border);
    background: rgba(255, 250, 240, 0.8);
    color: var(--osj-muted);
}

.osj-ai-matrix-score-overall {
    min-width: 62px;
    justify-content: center;
    border-color: var(--osj-border-strong);
    background: #fffdf7;
    color: var(--osj-rust);
}

.osj-ai-matrix-badge {
    display: inline-flex;
    width: fit-content;
    margin: 0 0.25rem 0.35rem 0;
    padding: 0.22rem 0.48rem;
    border: 1px solid var(--osj-border);
    border-radius: 999px;
    background: rgba(255, 250, 240, 0.85);
    color: var(--osj-muted);
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1.1;
}

.osj-ai-matrix-badge.is-good {
    border-color: #c3d7c6;
    background: var(--osj-success-bg);
    color: var(--osj-accent-dark);
}

.osj-ai-matrix-badge.is-warning {
    border-color: #e5c79d;
    background: var(--osj-warning-bg);
    color: var(--osj-rust);
}

.osj-ai-matrix-badge.is-muted {
    background: #f3efe8;
}

.osj-ai-matrix-rating-cell {
    text-align: center;
}

.osj-ai-matrix-status-cell .osj-ai-matrix-detail-button {
    display: flex;
    margin: 0 0 0.35rem;
}

.osj-ai-matrix-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}

.osj-ai-matrix-actions a,
.osj-ai-matrix-detail-button {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    min-height: 28px;
    padding: 0.22rem 0.52rem;
    border: 1px solid var(--osj-border-strong);
    border-radius: 999px;
    background: rgba(255, 250, 240, 0.7);
    color: var(--osj-accent-dark);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.1;
}

.osj-ai-matrix-actions a:hover,
.osj-ai-matrix-actions a:focus,
.osj-ai-matrix-detail-button:hover,
.osj-ai-matrix-detail-button:focus {
    border-color: var(--osj-rust);
    color: var(--osj-rust);
}

.osj-ai-matrix-detail-button {
    cursor: pointer;
    font-family: inherit;
}

.osj-ai-matrix-links {
    display: grid;
    gap: 0.28rem;
}

.osj-ai-matrix-links a {
    color: var(--osj-accent-dark);
    font-weight: 750;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

.osj-ai-matrix-links a:hover,
.osj-ai-matrix-links a:focus {
    color: var(--osj-rust);
}

.osj-ai-matrix-details td {
    background: #fffdf7;
}

.osj-ai-matrix-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    padding: 0.25rem;
}

.osj-ai-matrix-detail-grid h4 {
    margin: 0 0 0.25rem;
    color: var(--osj-text);
    font-size: 0.86rem;
    line-height: 1.2;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.osj-ai-matrix-detail-grid p {
    margin: 0;
    color: var(--osj-muted);
    font-size: 0.92rem;
}

.osj-ai-matrix-empty,
.osj-ai-matrix-footnote {
    margin: 1rem 0 0;
    padding: 1rem;
    border: 1px dashed var(--osj-border-strong);
    border-radius: var(--osj-radius);
    background: rgba(255, 250, 240, 0.65);
    color: var(--osj-muted);
}

.osj-ai-matrix-footnote {
    font-size: 0.92rem;
}

@media (max-width: 980px) {
    .osj-ai-matrix-table-wrap {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .osj-ai-matrix-table {
        min-width: 920px;
        table-layout: auto;
    }

    .osj-ai-matrix-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .osj-ai-matrix-reset {
        width: 100%;
    }

    .osj-ai-matrix-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .osj-ai-matrix-controls {
        grid-template-columns: 1fr;
    }

    .osj-ai-matrix-stats {
        display: grid;
        grid-template-columns: 1fr;
    }

    .osj-ai-matrix-detail-grid {
        grid-template-columns: 1fr;
    }
}
