File size: 8,873 Bytes
b565d01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/* ============================================================================ */
/* Inline code */
/* ============================================================================ */
code {
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background-color: var(--code-bg);
  border-radius: 0.3em;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  font-weight: 400;
  line-height: 1.5;
}

p code, .note code {
  white-space: nowrap;
  padding: calc(var(--spacing-1)/3) calc(var(--spacing-1)/2);
}


/* ============================================================================ */
/* Shiki code blocks */
/* ============================================================================ */
.astro-code {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0;
  font-size: 14px;
  --code-gutter-width: 2.5em;
}

/* Shared sizing & horizontal scroll for code containers */
.astro-code,
section.content-grid pre {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  margin-bottom: var(--block-spacing-y) !important;
  overflow-x: auto;
}

section.content-grid pre.astro-code { margin: 0; padding: var(--spacing-1) 0; }

section.content-grid pre code {
  display: inline-block;
  min-width: 100%;
}

/* Wrap long lines only on small screens to prevent layout overflow */
@media (--bp-content-collapse) {
  .astro-code,
  section.content-grid pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  section.content-grid pre code {
    white-space: pre-wrap;
    display: block;
    min-width: 0;
  }
}

/* Themes */
[data-theme='light'] .astro-code { background-color: var(--code-bg); }

/* Apply token color from per-span vars exposed by Shiki dual themes */
[data-theme='light'] .astro-code span { color: var(--shiki-light) !important; }
[data-theme='dark'] .astro-code span { color: var(--shiki-dark) !important; }

/* Optional: boost contrast for light theme */
[data-theme='light'] .astro-code {
  --shiki-foreground: #24292f;
  --shiki-background: #ffffff;
}

/* Line numbers for Shiki-rendered code blocks */
.astro-code code {
  counter-reset: astro-code-line;
  display: block;
  background: none;
  border: none;
}

.astro-code .line {
  display: inline-block;
  position: relative;
  padding-left: calc(var(--code-gutter-width) + var(--spacing-1));
  min-height: 1.25em;
}

.astro-code .line::before {
  counter-increment: astro-code-line;
  content: counter(astro-code-line);
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--code-gutter-width));
  text-align: right;
  color: var(--muted-color);
  opacity: .3;
  user-select: none;
  padding-right: var(--spacing-2);
  border-right: 1px solid var(--border-color);
}

.astro-code .line:empty::after { content: "\00a0"; }

/* Hide trailing empty line added by parsers */
.astro-code code > .line:last-child:empty { display: none; }

/* ============================================================================ */
/* Non-Shiki pre wrapper (rehype) */
/* ============================================================================ */
.code-card { position: relative; }

.code-card .code-copy {
  position: absolute;
  top: var(--spacing-2);
  right: var(--spacing-2);
  z-index: 3;
  display: none;
}

.code-card:hover .code-copy {
  display: block;
}

.code-card .code-copy svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
}

.code-card pre { margin: 0 0 var(--spacing-1); }

/* When no copy button (single-line), keep the label in the top-right corner */
.code-card.no-copy::after { top: 8px; right: 8px; }

/* ============================================================================ */
/* Contextual overrides */
/* ============================================================================ */
/* Inside Accordions: remove padding and border on code containers */
.accordion .astro-code { padding: 0; border: none; }
.accordion .astro-code { margin-bottom: 0 !important; }
.accordion .code-output { border: none; border-top: 1px solid var(--border-color)!important; }
.accordion pre { margin-bottom: 0 !important; }
.accordion .code-card pre { margin: 0 !important; }

/* ============================================================================ */
/* Language/extension vignette (bottom-right, discreet) */
/* ============================================================================ */
/* .astro-code::after {
  content: attr(data-language);
  position: absolute;
  right: 0;
  bottom: 0;
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--muted-color);
  background: var(--surface-bg);
  border-top: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
  opacity: 1;
  border-radius: 8px 0 0 0; 
  padding: 4px 6px;
  pointer-events: none;
} */

/* Fallback if Shiki uses data-lang instead of data-language */
/* .astro-code[data-lang]::after { content: attr(data-lang); }
.astro-code[data-language="typescript"]::after { content: "ts"; }
.astro-code[data-language="tsx"]::after { content: "tsx"; }
.astro-code[data-language="javascript"]::after,
.astro-code[data-language="node"]::after,
.astro-code[data-language="jsx"]::after { content: "js"; }
.astro-code[data-language="python"]::after { content: "py"; }
.astro-code[data-language="bash"]::after,
.astro-code[data-language="shell"]::after,
.astro-code[data-language="sh"]::after { content: "sh"; }
.astro-code[data-language="markdown"]::after { content: "md"; }
.astro-code[data-language="yaml"]::after,
.astro-code[data-language="yml"]::after { content: "yml"; }
.astro-code[data-language="html"]::after { content: "html"; }
.astro-code[data-language="css"]::after { content: "css"; }
.astro-code[data-language="json"]::after { content: "json"; } */

/* In Accordions, keep same bottom-right placement */
.accordion .astro-code::after { right: 0; bottom: 0; }

/* ============================================================================ */
/* Results blocks glued to code blocks */
/* ============================================================================ */
.code-output {
  position: relative;
  background: oklch(from var(--code-bg) calc(l - 0.005) c h);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-top: 0;
  margin-bottom: var(--block-spacing-y);
  padding: 0 !important;
}

.code-output pre {
  padding: calc(var(--spacing-3) + 6px) var(--spacing-3) var(--spacing-3) var(--spacing-3) !important;
}

/* If immediately following a code container, keep tight visual connection */
.code-card + .code-output,
.astro-code + .code-output,
section.content-grid pre + .code-output {
  margin-top: 0;
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-shadow: inset 0 8px 12px -12px rgba(0, 0, 0, 0.15);
}

/* Remove bottom margin on code when immediately followed by results */
.astro-code:has(+ .code-output) {
  margin-bottom: 0 !important;
}
.code-card:has(+ .code-output) .astro-code {
  margin-bottom: 0 !important;
}
section.content-grid pre:has(+ .code-output) {
  margin-bottom: 0 !important;
}

/* Remove bottom border radius on code when followed by results */
.astro-code:has(+ .code-output) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.code-card:has(+ .code-output) .astro-code {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
section.content-grid pre:has(+ .code-output) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* Small top-left label */
.code-output::before {
  content: "Output";
  position: absolute;
  top: 0;
  right: 0;
  font-size: 10px;
  line-height: 1;
  color: var(--muted-color);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-top: none;
  border-right: none;
  border-radius: 0 0 0 6px;
  padding: 10px 10px;
}

/* Very subtle top shadow so results feels under the code */
.code-output {
}

.code-output > :where(*):first-child {
  margin-top: 0 !important;
}

.code-output > :where(*):last-child {
  margin-bottom: 0 !important;
}

/* ============================================================================ */
/* Optional filename tag above code blocks */
/* ============================================================================ */
.code-filename {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  color: var(--muted-color);
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 4px 8px;
  margin: 0;
}

.code-filename + .code-card .astro-code,
.code-filename + .astro-code,
.code-filename + section.content-grid pre {
  border-top-left-radius: 0;
  border-top-right-radius: 6px;
}