File size: 5,469 Bytes
b9e7b9b
 
 
 
 
 
 
 
 
 
 
 
 
 
72cfb5a
b8e1b6c
b9e7b9b
 
 
72cfb5a
b9e7b9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72cfb5a
 
 
b9e7b9b
 
 
 
72cfb5a
 
 
 
 
a153fdf
72cfb5a
 
 
 
 
 
 
b9e7b9b
a153fdf
 
72cfb5a
 
 
 
 
 
b9e7b9b
 
72cfb5a
 
 
b9e7b9b
9e27095
 
 
b8e1b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
code {
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background-color: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 0.3em;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  font-weight: 400;
  line-height: 1.5;
}

/* Sync Shiki variables with current theme */
/* Standard wrapper look for code blocks */
.astro-code { border: 1px solid var(--border-color); border-radius: 6px; padding: 0; font-size: 14px; --code-gutter-width: 2.5em; }
.astro-code { position: relative; }

/* Prevent code blocks from breaking layout on small screens */
.astro-code { overflow-x: auto; width: 100%; max-width: 100%; box-sizing: border-box; -webkit-overflow-scrolling: touch; }
section.content-grid pre { overflow-x: auto; width: 100%; max-width: 100%; box-sizing: border-box; -webkit-overflow-scrolling: touch; padding: 0; }
section.content-grid pre code { display: inline-block; min-width: 100%; }

/* Wrap long lines on mobile to avoid overflow (URLs, etc.) */
/* Wrap long lines only on small screens to prevent layout overflow */
@media (max-width: 1100px) {
  .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; }
}

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

html[data-theme='dark'] .astro-code { background-color: var(--shiki-dark-bg); }

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

/* Token color remapping using Shiki CSS variables on the wrapper */
/* Optional: boost contrast for light theme */
html[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: .30; 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; }

/* (Removed JS fallback chip: label handled via CSS in _base.css) */

/* Rehype-injected wrapper for non-Shiki pre blocks */
.code-card { position: relative; }
.code-card .code-copy {
  position: absolute; top: 6px; right: 6px; z-index: 3; padding: 6px 12px; border: none;
}
.code-card .code-copy svg { width: 16px; height: 16px; display: block; fill: currentColor; }
.code-card pre { margin: 0; margin-bottom: var(--spacing-1);}

/* Discreet filetype/language label shown under the Copy button */
.code-card::after {
  content: attr(data-language);
  position: absolute;
  top: 8px;
  right: 56px; /* leave room for copy button */
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--muted-color);
  pointer-events: none;
  z-index: 2;
}

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



/* Overrides inside Accordion: remove padding and border on code containers */
.accordion .astro-code { padding: 0; border: none; }

/* Language/extension vignette for Shiki blocks (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: 0.5;
  border-radius: 8px 0 0 0; /* round only top-left */
  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); }

/* Normalize to extensions for common languages */
.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; }