File size: 12,182 Bytes
efde01b
 
fa3f2ca
3b56d1c
 
 
 
 
 
 
 
 
 
 
 
 
 
efde01b
13d47e7
 
 
 
 
fa3f2ca
40f4a8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
efde01b
 
 
 
 
 
 
 
3b56d1c
 
efde01b
 
 
 
 
 
 
 
 
 
 
ca83a13
 
efde01b
 
 
3b56d1c
 
efde01b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b56d1c
 
efde01b
 
 
 
 
 
 
 
 
 
 
 
 
3b56d1c
 
 
efde01b
fa3f2ca
efde01b
13d47e7
efde01b
ca83a13
fa3f2ca
13d47e7
ca83a13
 
 
 
 
 
fa3f2ca
13d47e7
ca83a13
13d47e7
 
40f4a8e
13d47e7
 
 
fa3f2ca
13d47e7
 
 
ca83a13
 
 
 
 
13d47e7
 
ca83a13
13d47e7
 
 
 
 
ca83a13
13d47e7
ca83a13
 
13d47e7
 
 
ca83a13
13d47e7
40f4a8e
 
 
 
 
 
 
 
13d47e7
40f4a8e
ca83a13
13d47e7
 
 
 
 
ca83a13
fa3f2ca
ca83a13
 
 
 
13d47e7
 
 
 
3b56d1c
ca83a13
fa3f2ca
ca83a13
 
 
 
 
 
 
 
 
 
 
 
 
13d47e7
ca83a13
13d47e7
ca83a13
 
 
 
 
 
 
 
 
 
 
efde01b
ca83a13
 
 
 
 
 
 
 
 
 
 
 
 
3b56d1c
ca83a13
 
 
 
 
 
efde01b
ca83a13
 
efde01b
ca83a13
fa3f2ca
ca83a13
 
 
 
 
 
 
 
 
efde01b
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
'use client'

import React from 'react'

type Mode = 'models' | 'guardrails'

interface ToggleOption {
  key: string
  label: string
  subtitle: string
}

interface Props {
  mode: Mode
  onModeChange: (mode: Mode) => void
  options: ToggleOption[]
}

const MODE_COLORS: Record<Mode, { color: string; dim: string }> = {
  models:     { color: '#BA2FA2', dim: 'rgba(186,47,162,0.07)' },
  guardrails: { color: '#00C0F3', dim: 'rgba(0,192,243,0.07)' },
}

const TAB_ICONS: Record<Mode, (p: { color: string }) => React.ReactNode> = {
  models: ({ color }) => (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden>
      <rect x="7" y="7" width="10" height="10" rx="2" stroke={color} strokeWidth="1.5"/>
      <line x1="10" y1="7" x2="10" y2="4" stroke={color} strokeWidth="1.5" strokeLinecap="round"/>
      <line x1="14" y1="7" x2="14" y2="4" stroke={color} strokeWidth="1.5" strokeLinecap="round"/>
      <line x1="10" y1="17" x2="10" y2="20" stroke={color} strokeWidth="1.5" strokeLinecap="round"/>
      <line x1="14" y1="17" x2="14" y2="20" stroke={color} strokeWidth="1.5" strokeLinecap="round"/>
      <line x1="7" y1="10" x2="4" y2="10" stroke={color} strokeWidth="1.5" strokeLinecap="round"/>
      <line x1="7" y1="14" x2="4" y2="14" stroke={color} strokeWidth="1.5" strokeLinecap="round"/>
      <line x1="17" y1="10" x2="20" y2="10" stroke={color} strokeWidth="1.5" strokeLinecap="round"/>
      <line x1="17" y1="14" x2="20" y2="14" stroke={color} strokeWidth="1.5" strokeLinecap="round"/>
      <rect x="10" y="10" width="4" height="4" rx="1" fill={color} opacity="0.4"/>
    </svg>
  ),
  guardrails: ({ color }) => (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden>
      <path d="M3 4h18l-7 7.5V19l-4 2V11.5L3 4z" stroke={color} strokeWidth="1.5" strokeLinejoin="round" strokeLinecap="round"/>
      <line x1="7" y1="8.5" x2="17" y2="8.5" stroke={color} strokeWidth="1.2" strokeLinecap="round" opacity="0.45"/>
    </svg>
  ),
}

const CRITERIA = [
  {
    num: '01',
    color: '#00C0F3',
    colorDim: 'rgba(0,192,243,0.10)',
    title: 'Localised Undesired Content',
    abbr: 'Refusal Rate',
    tagline: 'Can the model refuse contextually harmful prompts?',
    guardrailDetail: 'Scored on: Recall, Precision, F1 · Sub-tests: General, Physics, Career, JD',
    modes: ['models', 'guardrails'] as Mode[],
    Icon: ({ color }: { color: string }) => (
      <svg width="22" height="22" viewBox="0 0 28 28" fill="none" aria-hidden>
        <path d="M14 2L4 6v8c0 5.5 4 10.4 10 12 6-1.6 10-6.5 10-12V6L14 2z"
          stroke={color} strokeWidth="1.4" strokeLinejoin="round" fill="none" opacity="0.9" />
        <line x1="9" y1="14" x2="13" y2="18" stroke={color} strokeWidth="1.6" strokeLinecap="round" />
        <line x1="13" y1="18" x2="20" y2="10" stroke={color} strokeWidth="1.6" strokeLinecap="round" />
      </svg>
    ),
  },
  {
    num: '02',
    color: '#6366F1',
    colorDim: 'rgba(99,102,241,0.08)',
    title: 'RAG Knowledge Robustness',
    abbr: 'Robustness',
    tagline: "Does it know what it doesn't know?",
    guardrailDetail: null,
    modes: ['models'] as Mode[],
    Icon: ({ color }: { color: string }) => (
      <svg width="22" height="22" viewBox="0 0 28 28" fill="none" aria-hidden>
        <circle cx="14" cy="14" r="3" stroke={color} strokeWidth="1.4" fill="none" />
        <circle cx="6"  cy="7"  r="2" stroke={color} strokeWidth="1.2" fill="none" />
        <circle cx="22" cy="7"  r="2" stroke={color} strokeWidth="1.2" fill="none" />
        <circle cx="22" cy="21" r="2" stroke={color} strokeWidth="1.2" fill="none" />
        <line x1="14" y1="11" x2="8"  y2="9"  stroke={color} strokeWidth="1.2" strokeLinecap="round" />
        <line x1="14" y1="11" x2="20" y2="9"  stroke={color} strokeWidth="1.2" strokeLinecap="round" />
        <line x1="14" y1="17" x2="20" y2="19" stroke={color} strokeWidth="1.2" strokeLinecap="round" strokeDasharray="2.5 2" opacity="0.5" />
        <circle cx="6" cy="22" r="2" stroke={color} strokeWidth="1.2" fill="none" opacity="0.3" />
        <line x1="14" y1="17" x2="7" y2="21" stroke={color} strokeWidth="1.2" strokeLinecap="round" strokeDasharray="2.5 2" opacity="0.25" />
      </svg>
    ),
  },
  {
    num: '03',
    color: '#BA2FA2',
    colorDim: 'rgba(186,47,162,0.10)',
    title: 'Demographic Fairness',
    abbr: 'Fairness Disparity',
    tagline: 'Does it produce equitable outputs for all users?',
    guardrailDetail: null,
    modes: ['models'] as Mode[],
    Icon: ({ color }: { color: string }) => (
      <svg width="22" height="22" viewBox="0 0 28 28" fill="none" aria-hidden>
        <line x1="14" y1="4" x2="14" y2="24" stroke={color} strokeWidth="1.3" strokeLinecap="round" opacity="0.6" />
        <line x1="5"  y1="11" x2="23" y2="11" stroke={color} strokeWidth="1.5" strokeLinecap="round" />
        <path d="M5 11 Q5 18 9 18 Q13 18 13 11" stroke={color} strokeWidth="1.2" fill="none" />
        <path d="M15 11 Q15 18 19 18 Q23 18 23 11" stroke={color} strokeWidth="1.2" fill="none" />
        <line x1="10" y1="21" x2="18" y2="21" stroke={color} strokeWidth="1.2" strokeLinecap="round" opacity="0.5" />
        <line x1="11" y1="23" x2="17" y2="23" stroke={color} strokeWidth="1.2" strokeLinecap="round" opacity="0.3" />
      </svg>
    ),
  },
]

export default function BenchmarkExplainer({ mode, onModeChange, options }: Props) {
  const visibleCriteria = CRITERIA.filter(c => c.modes.includes(mode))

  return (
    <section className="explainer-section" id="criteria">
      <div className="section-wrap" style={{ paddingBottom: '1.5rem' }}>


        {/* Mode switcher — full-width toggle */}
        <div className="mode-toggle-grid" style={{
          display: 'grid', gridTemplateColumns: '1fr 1fr',
          padding: 5,
          background: 'var(--bg-0)',
          border: '1.5px solid var(--border-1)',
          borderRadius: 14,
          marginBottom: '1.75rem',
          gap: 5,
          animation: 'fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both',
        }}>
          {options.map(o => {
            const isActive = mode === o.key
            const { color, dim } = MODE_COLORS[o.key as Mode]
            const TabIcon = TAB_ICONS[o.key as Mode]
            return (
              <button
                key={o.key}
                className="mode-toggle-btn"
                onClick={() => onModeChange(o.key as Mode)}
                style={{
                  position: 'relative',
                  padding: '1.25rem 1.75rem',
                  border: 'none',
                  borderRadius: 10,
                  background: isActive ? 'var(--bg-1)' : 'transparent',
                  boxShadow: isActive ? '0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px var(--border-1)' : 'none',
                  cursor: 'pointer',
                  textAlign: 'left',
                  transition: 'background 0.25s, box-shadow 0.25s',
                  display: 'block',
                }}
              >
                {/* Top accent bar */}
                <div style={{
                  position: 'absolute', top: 0, left: 12, right: 12, height: 3,
                  background: color, opacity: isActive ? 1 : 0,
                  borderRadius: '0 0 2px 2px',
                  transition: 'opacity 0.25s',
                }} />

                {/* Label row */}
                <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 8 }}>
                  <div style={{
                    width: 36, height: 36, borderRadius: 8, flexShrink: 0,
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                    background: isActive ? dim : 'var(--bg-0)',
                    border: `1.5px solid ${isActive ? color : 'var(--border-1)'}`,
                    transition: 'all 0.2s',
                  }}>
                    <TabIcon color={isActive ? color : 'var(--border-2)'} />
                  </div>
                  <span style={{
                    fontSize: 18, fontWeight: 900, letterSpacing: '-0.01em',
                    color: isActive ? color : 'var(--text-2)',
                    fontFamily: 'var(--font-lato), sans-serif',
                    transition: 'color 0.2s',
                  }}>{o.label}</span>
                </div>

                {/* Subtitle */}
                <p className="mode-toggle-subtitle" style={{
                  fontSize: 13, color: isActive ? 'var(--text-2)' : 'var(--text-3)',
                  margin: 0, lineHeight: 1.6, paddingLeft: 48,
                  transition: 'color 0.2s',
                }}>{o.subtitle}</p>
              </button>
            )
          })}
        </div>

        {/* Criteria rows — keyed by mode to trigger transition */}
        <div key={mode} style={{ animation: 'fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both' }}>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 0, border: '1.5px solid var(--border-1)', borderRadius: 10, overflow: 'hidden', background: 'var(--bg-1)' }}>
            {visibleCriteria.map((c, i) => (
              <div
                key={c.num}
                style={{
                  display: 'flex',
                  alignItems: 'center',
                  gap: '1rem',
                  padding: '1.1rem 1.5rem',
                  borderBottom: i < visibleCriteria.length - 1 ? '1px solid var(--border-0)' : 'none',
                }}
              >
                {/* Numbered icon badge */}
                <div style={{
                  width: 40, height: 40, borderRadius: 8, flexShrink: 0,
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  background: c.colorDim, position: 'relative',
                }}>
                  <c.Icon color={c.color} />
                  <div style={{
                    position: 'absolute', top: -5, right: -5,
                    fontSize: 9, fontWeight: 900, fontFamily: 'inherit',
                    color: '#fff', background: c.color,
                    minWidth: 16, height: 16, borderRadius: 4,
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                    padding: '0 3px', lineHeight: 1,
                  }}>{c.num}</div>
                </div>

                {/* Content */}
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem', flexWrap: 'wrap' }}>
                    <span style={{ fontSize: 15, fontWeight: 900, color: 'var(--text-0)' }}>{c.title}</span>
                    <span style={{
                      fontSize: 10, fontWeight: 700, letterSpacing: '0.06em', textTransform: 'uppercase',
                      color: c.color, background: c.colorDim, border: `1px solid ${c.color}`,
                      padding: '2px 7px', borderRadius: 4,
                    }}>{c.abbr}</span>
                  </div>
                  <p style={{ fontSize: 13, color: 'var(--text-2)', marginTop: 3, fontStyle: 'italic' }}>
                    &ldquo;{c.tagline}&rdquo;
                  </p>
                  {mode === 'guardrails' && c.guardrailDetail && (
                    <p style={{ fontSize: 11, color: 'var(--text-3)', marginTop: 4, fontStyle: 'normal' }}>
                      {c.guardrailDetail}
                    </p>
                  )}
                </div>
              </div>
            ))}
          </div>

          {/* CTA */}
          <div className="explainer-cta" style={{ animation: 'fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both' }}>
            <span className="explainer-cta-text">Want to understand what the scores mean?</span>
            <a href="#about" className="explainer-cta-link">
              Our methodology
              <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
                <line x1="12" y1="5" x2="12" y2="19" />
                <polyline points="19 12 12 19 5 12" />
              </svg>
            </a>
          </div>
        </div>
      </div>
    </section>
  )
}