/* ============================================
   Screen 3p: Data-driven подход в развитии персонала
   Prefix: .s3p-
   ============================================ */

/* === Section wrapper === */
.s3p-section {
    width: 100%;
    scroll-margin-top: var(--nav-height, 72px);
}

.s3p-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 80px 40px 60px;
    box-sizing: border-box;
}

/* === Header === */
.s3p-header {
    text-align: center;
    margin-bottom: 52px;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s var(--ease-out-expo, cubic-bezier(0.16,1,0.3,1)),
                transform 0.6s var(--ease-out-expo, cubic-bezier(0.16,1,0.3,1));
}

.s3p-header.s3p-visible {
    opacity: 1;
    transform: translateY(0);
}

.s3p-header__title {
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--text-primary, #f0f0f5);
    margin: 0 auto 14px;
    max-width: 800px;
}

.s3p-header__subtitle {
    font-size: 1rem;
    color: var(--text-secondary, #8888a0);
    margin: 0 auto;
    line-height: 1.6;
    max-width: 640px;
}

/* === Two-column grid === */
.s3p-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 32px;
    align-items: start;
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.7s 0.15s var(--ease-out-expo, cubic-bezier(0.16,1,0.3,1)),
                transform 0.7s 0.15s var(--ease-out-expo, cubic-bezier(0.16,1,0.3,1));
}

.s3p-grid.s3p-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   LEFT: Leaderboard table
   ============================================ */
.s3p-table-wrap {
    background: var(--bg-card, rgba(18,18,30,0.6));
    border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.s3p-table-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.s3p-table-icon {
    font-size: 2rem;
    line-height: 1;
}

.s3p-table-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #f0f0f5);
    line-height: 1.3;
}

.s3p-table-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary, #8888a0);
    margin-top: 2px;
}

.s3p-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

/* Table head */
.s3p-th {
    padding: 8px 10px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary, #8888a0);
    border-bottom: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    white-space: nowrap;
}

.s3p-th--name {
    text-align: left;
    padding-left: 12px;
    min-width: 110px;
}

.s3p-th--trend {
    min-width: 110px;
}

/* Table rows */
.s3p-tr {
    border-bottom: 1px solid var(--glass-border, rgba(255,255,255,0.06));
    transition: background 0.2s;
}

.s3p-tr:last-child {
    border-bottom: none;
}

.s3p-tr:hover {
    background: var(--glass-bg, rgba(255,255,255,0.03));
}

.s3p-td {
    padding: 11px 10px;
    text-align: center;
    color: var(--text-primary, #f0f0f5);
    font-size: 0.875rem;
    font-weight: 500;
}

.s3p-td--name {
    text-align: left;
    padding-left: 12px;
    font-weight: 600;
    color: var(--text-primary, #f0f0f5);
}

.s3p-td--trend {
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Trend text colors */
.s3p-up    { color: #57F357; }
.s3p-down  { color: #f05757; }
.s3p-stable { color: #f0c547; }

/* Mini progress bar behind percentage */
.s3p-cell {
    display: inline-block;
    position: relative;
    padding: 3px 8px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        rgba(87, 243, 87, 0.85) calc(var(--pct, 0) * 1%),
        rgba(87, 243, 87, 0.15) calc(var(--pct, 0) * 1%)
    );
    font-variant-numeric: tabular-nums;
}

.s3p-cell--down {
    background: linear-gradient(
        90deg,
        rgba(240, 87, 87, 0.85) calc(var(--pct, 0) * 1%),
        rgba(240, 87, 87, 0.15) calc(var(--pct, 0) * 1%)
    );
}

.s3p-cell--neutral {
    background: linear-gradient(
        90deg,
        rgba(240, 197, 71, 0.75) calc(var(--pct, 0) * 1%),
        rgba(240, 197, 71, 0.15) calc(var(--pct, 0) * 1%)
    );
}

/* ============================================
   RIGHT: AI Insight Cards
   ============================================ */
.s3p-insights {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.s3p-insight {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--bg-card, rgba(18,18,30,0.6));
    border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    border-left-width: 3px;
    border-radius: 12px;
    padding: 16px 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.2s var(--ease-out-expo, cubic-bezier(0.16,1,0.3,1)),
                box-shadow 0.2s;
}

.s3p-insight:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}

.s3p-insight--green { border-left-color: #57F357; }
.s3p-insight--red   { border-left-color: #f05757; }
.s3p-insight--blue  { border-left-color: #57a4f3; }

.s3p-insight__icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.s3p-insight__body {
    flex: 1;
    min-width: 0;
}

.s3p-insight__title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary, #f0f0f5);
    margin-bottom: 5px;
    line-height: 1.3;
}

.s3p-insight--green .s3p-insight__title { color: #57F357; }
.s3p-insight--red   .s3p-insight__title { color: #f05757; }
.s3p-insight--blue  .s3p-insight__title { color: #57a4f3; }

.s3p-insight__text {
    font-size: 0.8rem;
    color: var(--text-secondary, #8888a0);
    line-height: 1.55;
}

/* AI label badge */
.s3p-insights::before {
    content: '✦ AI-инсайты';
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary, #8888a0);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    border-radius: 20px;
    padding: 4px 12px;
    width: fit-content;
    margin-bottom: 4px;
    background: var(--glass-bg, rgba(255,255,255,0.03));
}

/* ============================================
   Stagger animation helpers
   ============================================ */
.s3p-tr {
    opacity: 0;
    transform: translateX(-16px);
    transition: opacity 0.45s var(--ease-out-expo, cubic-bezier(0.16,1,0.3,1)),
                transform 0.45s var(--ease-out-expo, cubic-bezier(0.16,1,0.3,1)),
                background 0.2s;
}

.s3p-tr.s3p-row-visible {
    opacity: 1;
    transform: translateX(0);
}

.s3p-insight {
    opacity: 0;
    transform: translateY(16px);
}

.s3p-insight.s3p-card-visible {
    opacity: 1;
    transform: translateY(0);
    /* preserve hover transform via separate transition */
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
    .s3p-grid {
        grid-template-columns: 1fr;
    }
    .s3p-inner {
        padding: 60px 20px 48px;
    }
}

@media (max-width: 768px) {
    .s3p-inner {
        padding: 48px 16px 40px;
    }
    .s3p-header__title {
        font-size: 1.5rem;
    }
    .s3p-table {
        font-size: 0.8rem;
    }
    .s3p-td, .s3p-th {
        padding: 8px 6px;
    }
    .s3p-th--trend,
    .s3p-td--trend {
        font-size: 0.72rem;
    }
}

@media (max-width: 400px) {
    .s3p-th--trend,
    .s3p-td--trend {
        display: none;
    }
}

/* ===== Light Theme Overrides ===== */
:root.light-theme .s3p-card {
    background: rgba(255,255,255,0.85);
    border-color: rgba(0,0,0,0.08);
}

:root.light-theme .s3p-header__title {
    color: #0a0a14;
}

:root.light-theme .s3p-header__subtitle {
    color: #444455;
}

:root.light-theme .s3p-th {
    color: #444455;
    border-bottom-color: rgba(0,0,0,0.1);
}

:root.light-theme .s3p-tr {
    border-bottom-color: rgba(0,0,0,0.06);
}

:root.light-theme .s3p-tr:hover {
    background: rgba(0,0,0,0.03);
}

:root.light-theme .s3p-td--name {
    color: #1a1a2e;
}

:root.light-theme .s3p-td--score {
    color: #1a1a2e;
}

:root.light-theme .s3p-insight {
    background: rgba(255,255,255,0.85);
    border-color: rgba(0,0,0,0.08);
}

:root.light-theme .s3p-insight--green {
    border-left-color: #14aa14;
}

:root.light-theme .s3p-insight--red {
    border-left-color: #cc3333;
}

:root.light-theme .s3p-insight--blue {
    border-left-color: #4477cc;
}

:root.light-theme .s3p-insight--green .s3p-insight__title {
    color: #0d8a0d;
}

:root.light-theme .s3p-insight--red .s3p-insight__title {
    color: #cc3333;
}

:root.light-theme .s3p-insight--blue .s3p-insight__title {
    color: #4455cc;
}

:root.light-theme .s3p-insight__body {
    color: #444455;
}

:root.light-theme .s3p-badge {
    background: rgba(0,0,0,0.06);
    border-color: rgba(0,0,0,0.1);
    color: #333;
}


/* Mobile fix: table overflow */
.s3p-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
    .s3p-th:nth-child(2),
    .s3p-th:nth-child(3),
    .s3p-td:nth-child(2),
    .s3p-td:nth-child(3) {
        display: none;
    }
    .s3p-th--name,
    .s3p-td--name {
        min-width: 80px;
    }
    .s3p-th--trend,
    .s3p-td--trend {
        min-width: 70px;
        font-size: 0.7rem;
    }
    .s3p-table {
        font-size: 0.75rem;
    }
    .s3p-td, .s3p-th {
        padding: 6px 4px;
    }
    .s3p-insight {
        padding: 14px;
    }
    .s3p-insight__icon {
        font-size: 1.2rem;
    }
    .s3p-header__title {
        font-size: 1.3rem;
    }
    .s3p-header__subtitle {
        font-size: 0.85rem;
    }
    .s3p-inner {
        padding: 40px 12px 32px;
    }
}
