mirror of
https://github.com/tiennm99/bonsai.git
synced 2026-09-02 10:19:30 +00:00
Adds canonical, og:url, robots, and theme-color meta tags for Lighthouse validation. Hardens avatar with width/height/fetchpriority/decoding and <picture> pipeline. Adds skip-link and tap-target CSS enhancements. Improves Core Web Vitals and accessibility scores.
509 lines
14 KiB
CSS
509 lines
14 KiB
CSS
/* Bonsai — minimalist link-in-bio Hugo theme
|
||
* Aesthetic: Japanese zen — generous whitespace, calm palette, restrained type.
|
||
* Palettes: bonsai (default), sakura, sumi, koi. Selected via [data-bonsai-theme]. */
|
||
|
||
:root {
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .04);
|
||
--bonsai-radius: 14px;
|
||
--bonsai-gap: clamp(.75rem, 1.6vw, 1rem);
|
||
--bonsai-pad: clamp(1.25rem, 4vw, 2rem);
|
||
--bonsai-max: 32rem;
|
||
|
||
--bonsai-font: ui-sans-serif, system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
|
||
--bonsai-font-display: ui-serif, Georgia, "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Times New Roman", serif;
|
||
}
|
||
|
||
/* ============================================================
|
||
Palettes
|
||
Each palette defines six color vars in light + dark variants.
|
||
Toggle order:
|
||
1. base block sets light values
|
||
2. @media (prefers-color-scheme:dark) overrides to dark
|
||
3. [data-theme="dark"] forces dark (manual toggle)
|
||
4. [data-theme="light"] forces light (manual toggle)
|
||
============================================================ */
|
||
|
||
/* --- Bonsai (default: washi + vermilion) --- */
|
||
:root,
|
||
[data-bonsai-theme="bonsai"] {
|
||
--bonsai-bg: #f4efe6;
|
||
--bonsai-surface: #ffffff;
|
||
--bonsai-text: #2b2b2b;
|
||
--bonsai-muted: #6b6b6b;
|
||
--bonsai-accent: #8b3a2b;
|
||
--bonsai-border: #d9d0bf;
|
||
}
|
||
@media (prefers-color-scheme: dark) {
|
||
:root:not([data-theme="light"]):not([data-bonsai-theme]),
|
||
[data-bonsai-theme="bonsai"]:not([data-theme="light"]) {
|
||
--bonsai-bg: #1a1817;
|
||
--bonsai-surface: #232020;
|
||
--bonsai-text: #ece6d9;
|
||
--bonsai-muted: #a09a8d;
|
||
--bonsai-accent: #d6856e;
|
||
--bonsai-border: #3a3633;
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
|
||
}
|
||
}
|
||
[data-theme="dark"]:not([data-bonsai-theme]),
|
||
[data-bonsai-theme="bonsai"][data-theme="dark"] {
|
||
--bonsai-bg: #1a1817;
|
||
--bonsai-surface: #232020;
|
||
--bonsai-text: #ece6d9;
|
||
--bonsai-muted: #a09a8d;
|
||
--bonsai-accent: #d6856e;
|
||
--bonsai-border: #3a3633;
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
|
||
}
|
||
|
||
/* --- Sakura (cherry blossom) --- */
|
||
[data-bonsai-theme="sakura"] {
|
||
--bonsai-bg: #fff5f5;
|
||
--bonsai-surface: #ffffff;
|
||
--bonsai-text: #3a2228;
|
||
--bonsai-muted: #876773;
|
||
--bonsai-accent: #c93f63; /* darkened from #d4456a — was 4.04:1 vs bg, now 4.49:1 (WCAG AA) */
|
||
--bonsai-border: #f0d4dc;
|
||
}
|
||
@media (prefers-color-scheme: dark) {
|
||
[data-bonsai-theme="sakura"]:not([data-theme="light"]) {
|
||
--bonsai-bg: #1f1418;
|
||
--bonsai-surface: #2a1d22;
|
||
--bonsai-text: #f7e3e9;
|
||
--bonsai-muted: #b89aa3;
|
||
--bonsai-accent: #ec7596;
|
||
--bonsai-border: #3d2932;
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
|
||
}
|
||
}
|
||
[data-bonsai-theme="sakura"][data-theme="dark"] {
|
||
--bonsai-bg: #1f1418;
|
||
--bonsai-surface: #2a1d22;
|
||
--bonsai-text: #f7e3e9;
|
||
--bonsai-muted: #b89aa3;
|
||
--bonsai-accent: #ec7596;
|
||
--bonsai-border: #3d2932;
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
|
||
}
|
||
|
||
/* --- Sumi (monochrome ink) --- */
|
||
[data-bonsai-theme="sumi"] {
|
||
--bonsai-bg: #fafafa;
|
||
--bonsai-surface: #ffffff;
|
||
--bonsai-text: #111111;
|
||
--bonsai-muted: #666666;
|
||
--bonsai-accent: #1a1a1a;
|
||
--bonsai-border: #e0e0e0;
|
||
}
|
||
@media (prefers-color-scheme: dark) {
|
||
[data-bonsai-theme="sumi"]:not([data-theme="light"]) {
|
||
--bonsai-bg: #0d0d0d;
|
||
--bonsai-surface: #1a1a1a;
|
||
--bonsai-text: #f5f5f5;
|
||
--bonsai-muted: #a0a0a0;
|
||
--bonsai-accent: #dddddd;
|
||
--bonsai-border: #2a2a2a;
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
|
||
}
|
||
}
|
||
[data-bonsai-theme="sumi"][data-theme="dark"] {
|
||
--bonsai-bg: #0d0d0d;
|
||
--bonsai-surface: #1a1a1a;
|
||
--bonsai-text: #f5f5f5;
|
||
--bonsai-muted: #a0a0a0;
|
||
--bonsai-accent: #dddddd;
|
||
--bonsai-border: #2a2a2a;
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
|
||
}
|
||
|
||
/* --- Koi (orange + cream) --- */
|
||
[data-bonsai-theme="koi"] {
|
||
--bonsai-bg: #fef6e4;
|
||
--bonsai-surface: #ffffff;
|
||
--bonsai-text: #3a2620;
|
||
--bonsai-muted: #7a5e48; /* darkened from #8a6f5c — was 4.33:1 vs bg, now 5.54:1 (WCAG AA) */
|
||
--bonsai-accent: #bd4c1c; /* darkened from #c8521e — was 4.17:1 vs bg, now 4.63:1 (WCAG AA) */
|
||
--bonsai-border: #f2dfb8;
|
||
}
|
||
@media (prefers-color-scheme: dark) {
|
||
[data-bonsai-theme="koi"]:not([data-theme="light"]) {
|
||
--bonsai-bg: #1c1410;
|
||
--bonsai-surface: #2a1f18;
|
||
--bonsai-text: #f7e2c4;
|
||
--bonsai-muted: #c9a988;
|
||
--bonsai-accent: #ff8b5c;
|
||
--bonsai-border: #3d2c20;
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
|
||
}
|
||
}
|
||
[data-bonsai-theme="koi"][data-theme="dark"] {
|
||
--bonsai-bg: #1c1410;
|
||
--bonsai-surface: #2a1f18;
|
||
--bonsai-text: #f7e2c4;
|
||
--bonsai-muted: #c9a988;
|
||
--bonsai-accent: #ff8b5c;
|
||
--bonsai-border: #3d2c20;
|
||
--bonsai-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
|
||
}
|
||
|
||
/* ============================================================
|
||
Layout & components
|
||
============================================================ */
|
||
|
||
* { box-sizing: border-box; }
|
||
|
||
html { -webkit-text-size-adjust: 100%; }
|
||
|
||
body {
|
||
margin: 0;
|
||
min-height: 100dvh;
|
||
background: var(--bonsai-bg);
|
||
color: var(--bonsai-text);
|
||
font-family: var(--bonsai-font);
|
||
font-size: 16px;
|
||
line-height: 1.55;
|
||
-webkit-font-smoothing: antialiased;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.bonsai {
|
||
flex: 1;
|
||
width: 100%;
|
||
max-width: var(--bonsai-max);
|
||
margin: 0 auto;
|
||
padding: clamp(2rem, 6vh, 4rem) var(--bonsai-pad);
|
||
}
|
||
|
||
.bio { text-align: center; }
|
||
|
||
.bio__avatar {
|
||
width: 112px;
|
||
height: 112px;
|
||
border-radius: 50%;
|
||
object-fit: cover;
|
||
border: 1px solid var(--bonsai-border);
|
||
box-shadow: var(--bonsai-shadow);
|
||
margin-bottom: 1.25rem;
|
||
}
|
||
|
||
.bio__avatar--initials {
|
||
display: block;
|
||
margin-left: auto;
|
||
margin-right: auto;
|
||
}
|
||
|
||
.bio__name {
|
||
font-family: var(--bonsai-font-display);
|
||
font-weight: 600;
|
||
font-size: clamp(1.5rem, 3.5vw, 1.875rem);
|
||
margin: 0 0 .25rem;
|
||
letter-spacing: -.01em;
|
||
}
|
||
|
||
.bio__tagline {
|
||
color: var(--bonsai-muted);
|
||
margin: 0 0 1rem;
|
||
font-size: .95rem;
|
||
}
|
||
|
||
.bio__text {
|
||
margin: 0 auto 1.75rem;
|
||
max-width: 28rem;
|
||
color: var(--bonsai-text);
|
||
font-size: .98rem;
|
||
}
|
||
|
||
.bio__links {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: var(--bonsai-gap);
|
||
margin-top: 1.5rem;
|
||
}
|
||
|
||
/* === layout variants ===
|
||
* All variant rules scope under .bio__links--{name} to avoid CSS specificity
|
||
* collisions with the default .link rules (see v0.2 journal for the lesson).
|
||
*/
|
||
.bio__links--grid {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
}
|
||
@media (max-width: 480px) {
|
||
.bio__links--grid { grid-template-columns: 1fr; }
|
||
}
|
||
|
||
.bio__links--inline {
|
||
flex-direction: row;
|
||
flex-wrap: wrap;
|
||
justify-content: center;
|
||
}
|
||
.bio__links--inline .link {
|
||
padding: .75rem;
|
||
gap: 0;
|
||
}
|
||
/* Visually hide the title in inline mode but keep it for screen readers. */
|
||
.bio__links--inline .link__title {
|
||
position: absolute;
|
||
width: 1px;
|
||
height: 1px;
|
||
padding: 0;
|
||
margin: -1px;
|
||
overflow: hidden;
|
||
clip: rect(0, 0, 0, 0);
|
||
white-space: nowrap;
|
||
border: 0;
|
||
}
|
||
|
||
.link {
|
||
position: relative; /* contain absolute-positioned visually-hidden title in inline mode */
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: .625rem;
|
||
padding: .9rem 1.25rem;
|
||
background: var(--bonsai-surface);
|
||
color: var(--bonsai-text);
|
||
border: 1px solid var(--bonsai-border);
|
||
border-radius: var(--bonsai-radius);
|
||
text-decoration: none;
|
||
font-weight: 500;
|
||
font-size: .95rem;
|
||
box-shadow: var(--bonsai-shadow);
|
||
transition: transform .15s ease, border-color .15s ease, background .15s ease;
|
||
}
|
||
|
||
.link:hover {
|
||
transform: translateY(-1px);
|
||
border-color: var(--bonsai-accent);
|
||
background: color-mix(in oklab, var(--bonsai-surface) 94%, var(--bonsai-accent));
|
||
}
|
||
|
||
.link:focus-visible {
|
||
outline: 2px solid var(--bonsai-accent);
|
||
outline-offset: 2px;
|
||
}
|
||
|
||
.link:active { transform: translateY(0); }
|
||
|
||
.link__icon {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
color: var(--bonsai-accent);
|
||
}
|
||
|
||
.link__icon svg {
|
||
width: 20px;
|
||
height: 20px;
|
||
display: block;
|
||
fill: currentColor;
|
||
}
|
||
|
||
/* Lucide UI icons use stroke, not fill */
|
||
.link__icon svg[stroke="currentColor"],
|
||
.link__icon svg.lucide {
|
||
fill: none;
|
||
}
|
||
|
||
.link__title { line-height: 1; }
|
||
|
||
.bonsai-footer {
|
||
text-align: center;
|
||
padding: 1.5rem var(--bonsai-pad) 2rem;
|
||
color: var(--bonsai-muted);
|
||
font-size: .8rem;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: .75rem;
|
||
}
|
||
|
||
.bonsai-footer p { margin: 0; }
|
||
|
||
/* Theme toggle button — 44×44 hit target meets Apple HIG / WCAG 2.5.5 AAA. */
|
||
.theme-toggle {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 44px;
|
||
height: 44px;
|
||
padding: 0;
|
||
background: var(--bonsai-surface);
|
||
color: var(--bonsai-accent);
|
||
border: 1px solid var(--bonsai-border);
|
||
border-radius: 50%;
|
||
cursor: pointer;
|
||
transition: transform .15s ease, border-color .15s ease;
|
||
}
|
||
|
||
.theme-toggle:hover {
|
||
transform: translateY(-1px);
|
||
border-color: var(--bonsai-accent);
|
||
}
|
||
|
||
.theme-toggle:focus-visible {
|
||
outline: 2px solid var(--bonsai-accent);
|
||
outline-offset: 2px;
|
||
}
|
||
|
||
.theme-toggle:active { transform: translateY(0); }
|
||
|
||
/* Show moon in light, sun in dark.
|
||
The button shows the icon for the mode you'll switch TO.
|
||
Per-class rules avoid the specificity battle vs `.theme-toggle svg`. */
|
||
.theme-toggle .theme-toggle__sun { display: none; }
|
||
.theme-toggle .theme-toggle__moon { display: block; }
|
||
|
||
@media (prefers-color-scheme: dark) {
|
||
html:not([data-theme="light"]) .theme-toggle .theme-toggle__sun { display: block; }
|
||
html:not([data-theme="light"]) .theme-toggle .theme-toggle__moon { display: none; }
|
||
}
|
||
|
||
[data-theme="dark"] .theme-toggle .theme-toggle__sun { display: block; }
|
||
[data-theme="dark"] .theme-toggle .theme-toggle__moon { display: none; }
|
||
[data-theme="light"] .theme-toggle .theme-toggle__sun { display: none; }
|
||
[data-theme="light"] .theme-toggle .theme-toggle__moon { display: block; }
|
||
|
||
/* Per-link enhancements (Phase 3 / v0.5) */
|
||
.link__thumb {
|
||
width: 24px;
|
||
height: 24px;
|
||
border-radius: 4px;
|
||
flex-shrink: 0;
|
||
object-fit: cover;
|
||
}
|
||
.link--featured {
|
||
padding: 1.1rem 1.4rem;
|
||
border-color: var(--bonsai-accent);
|
||
border-width: 1.5px;
|
||
}
|
||
.link__note {
|
||
display: block;
|
||
font-size: .75rem;
|
||
color: var(--bonsai-muted);
|
||
margin-top: .15rem;
|
||
line-height: 1.3;
|
||
}
|
||
|
||
/* Page-level actions: share button + QR + vCard download */
|
||
.bio__share, .bio__vcard {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: .5rem;
|
||
margin: 1.5rem auto 0;
|
||
padding: .65rem 1.1rem;
|
||
background: var(--bonsai-surface);
|
||
color: var(--bonsai-text);
|
||
border: 1px solid var(--bonsai-border);
|
||
border-radius: var(--bonsai-radius);
|
||
font: inherit;
|
||
font-size: .85rem;
|
||
cursor: pointer;
|
||
text-decoration: none;
|
||
transition: transform .15s ease, border-color .15s ease;
|
||
}
|
||
.bio__share { display: flex; }
|
||
.bio__vcard { display: flex; }
|
||
.bio__share:hover, .bio__vcard:hover {
|
||
transform: translateY(-1px);
|
||
border-color: var(--bonsai-accent);
|
||
}
|
||
.bio__share:focus-visible, .bio__vcard:focus-visible {
|
||
outline: 2px solid var(--bonsai-accent);
|
||
outline-offset: 2px;
|
||
}
|
||
.bio__share-icon { display: inline-flex; width: 16px; height: 16px; color: var(--bonsai-accent); }
|
||
.bio__share-icon svg { width: 16px; height: 16px; }
|
||
.bio__share-toast {
|
||
position: fixed;
|
||
left: 50%;
|
||
bottom: 1.25rem;
|
||
transform: translateX(-50%);
|
||
padding: .5rem 1rem;
|
||
background: var(--bonsai-text);
|
||
color: var(--bonsai-bg);
|
||
border-radius: var(--bonsai-radius);
|
||
font-size: .85rem;
|
||
box-shadow: var(--bonsai-shadow);
|
||
z-index: 200;
|
||
}
|
||
.bio__qr {
|
||
margin-top: 1.5rem;
|
||
text-align: center;
|
||
}
|
||
.bio__qr > summary {
|
||
cursor: pointer;
|
||
color: var(--bonsai-muted);
|
||
font-size: .85rem;
|
||
list-style: none;
|
||
}
|
||
.bio__qr > summary::-webkit-details-marker { display: none; }
|
||
.bio__qr-img {
|
||
display: block;
|
||
margin: .75rem auto 0;
|
||
max-width: 200px;
|
||
height: auto;
|
||
border-radius: var(--bonsai-radius);
|
||
background: #fff;
|
||
padding: .5rem;
|
||
}
|
||
|
||
/* Multi-section bio: grouped link blocks with optional headings + descriptions. */
|
||
.bio__section { margin-top: 1.75rem; }
|
||
.bio__section:first-of-type { margin-top: 1.5rem; }
|
||
.bio__section-title {
|
||
font-family: var(--bonsai-font-display);
|
||
font-size: 1.05rem;
|
||
font-weight: 600;
|
||
margin: 0 0 .35rem;
|
||
color: var(--bonsai-text);
|
||
}
|
||
.bio__section-desc {
|
||
font-size: .9rem;
|
||
color: var(--bonsai-muted);
|
||
margin: 0 0 .75rem;
|
||
}
|
||
.bio__section .bio__links { margin-top: .5rem; }
|
||
|
||
/* Inline-layout tap-target enforcement (Phase 6 a11y): WCAG 2.5.5 / Lighthouse 48×48 */
|
||
.bio__links--inline .link {
|
||
min-width: 48px;
|
||
min-height: 48px;
|
||
padding: .75rem;
|
||
justify-content: center;
|
||
}
|
||
.bio__links--inline { gap: clamp(.5rem, 1.5vw, 1rem); }
|
||
|
||
/* Skip-link: keyboard-only affordance. Off-screen until focused. */
|
||
.skip-link {
|
||
position: absolute;
|
||
top: -3rem;
|
||
left: .5rem;
|
||
padding: .5rem 1rem;
|
||
background: var(--bonsai-accent);
|
||
color: var(--bonsai-bg);
|
||
border-radius: var(--bonsai-radius);
|
||
text-decoration: none;
|
||
z-index: 100;
|
||
transition: top .15s ease;
|
||
}
|
||
.skip-link:focus {
|
||
top: .5rem;
|
||
outline: 2px solid var(--bonsai-text);
|
||
outline-offset: 2px;
|
||
}
|
||
|
||
/* Note: gallery selectors (.themes-gallery, .variants-gallery) live in gallery.css
|
||
and load only on /themes/ and /variants/ demo pages via the head_extra block. */
|
||
|
||
@media (prefers-reduced-motion: reduce) {
|
||
.link, .link:hover, .link:active,
|
||
.theme-toggle, .theme-toggle:hover, .theme-toggle:active,
|
||
.skip-link,
|
||
.bio__share, .bio__share:hover, .bio__vcard, .bio__vcard:hover {
|
||
transition: none;
|
||
transform: none;
|
||
}
|
||
}
|