@casoon/dragonfly
Version:
Modular, lightweight CSS framework and design system for modern web projects. Optimized for Astro JS, LightningCSS and Container Queries with @layer-based architecture and comprehensive accessibility.
304 lines (227 loc) • 9.12 kB
CSS
/*
* Typografie
*
* @layer tokens → Schriftarten und Grundwerte
* @layer base → body, p, a, code, etc.
* @layer headings → h1–h6 und .h1–.h6
* @layer text → blockquote, figcaption, pull-quote, etc.
* @layer utilities → text-, font-, spacing- und alignment-Utilities
* @layer responsive → container queries und responsive Textklassen
* @layer fluid → flüssige Typografie mit interpolate-size
*/
@layer typography {
:root {
--font-family-sans: system-ui, -apple-system, blinkmacsystemfont, "segoe ui", roboto, "helvetica neue", arial, sans-serif;
--font-family-serif: georgia, cambria, "times new roman", times, serif;
--font-family-mono: ui-monospace, sfmono-regular, menlo, monaco, consolas, "liberation mono", "courier new", monospace;
}
@layer base {
body {
color: var(--color-gray-900);
font-family: var(--font-family-sans);
font-size: var(--font-size-base);
line-height: var(--line-height-normal);
}
p { margin-bottom: 1em; }
a { color: var(--color-primary); text-decoration: underline; }
a:hover { text-decoration: none; }
ul, ol { margin-bottom: 1em; padding-left: 1%.5em; }
li { margin-bottom: 0%.5em; }
code {
background-color: var(--color-gray-100);
border-radius: var(--border-radius-sm);
font-family: var(--font-family-mono);
font-size: var(--font-size-sm);
padding: var(--space-1);
}
pre {
background-color: var(--color-gray-100);
border-radius: var(--border-radius-md);
font-family: var(--font-family-mono);
font-size: var(--font-size-sm);
overflow-x: auto;
padding: var(--space-4);
}
}
@layer headings {
h1, .h1 { font-size: var(--font-size-4xl); font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); margin-bottom: var(--space-4); text-wrap: balance; }
h2, .h2 { font-size: var(--font-size-3xl); font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); margin-bottom: var(--space-3); text-wrap: balance; }
h3, .h3 { font-size: var(--font-size-2xl); font-weight: var(--font-weight-semibold); line-height: var(--line-height-snug); margin-bottom: var(--space-3); text-wrap: balance; }
h4, .h4 { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); line-height: var(--line-height-snug); margin-bottom: var(--space-2); text-wrap: balance; }
h5, .h5 { font-size: var(--font-size-lg); font-weight: var(--font-weight-medium); line-height: var(--line-height-normal); margin-bottom: var(--space-2); text-wrap: balance; }
h6, .h6 { font-size: var(--font-size-base); font-weight: var(--font-weight-medium); line-height: var(--line-height-normal); margin-bottom: var(--space-2); text-wrap: balance; }
}
@layer text {
em, i, .italic { font-style: italic; }
figcaption, .caption { color: var(--color-gray-600); font-size: var(--font-size-sm); font-style: italic; margin-top: var(--space-2); }
blockquote, .blockquote {
border-left: 4px solid var(--color-gray-200);
color: var(--color-gray-700);
font-size: var(--font-size-lg);
font-style: italic;
margin-bottom: var(--space-6);
padding-left: var(--space-4);
}
blockquote cite, .blockquote-cite {
color: var(--color-gray-600);
display: block;
font-size: var(--font-size-sm);
font-style: normal;
font-weight: var(--font-weight-medium);
margin-top: var(--space-2);
}
.pull-quote {
color: var(--color-primary);
font-size: var(--font-size-2xl);
font-style: italic;
font-weight: var(--font-weight-medium);
line-height: var(--line-height-tight);
margin: var(--space-8) 0;
padding: var(--space-6) var(--space-8);
position: relative;
text-align: center;
}
.pull-quote::before, .pull-quote::after {
background-repeat: no-repeat;
background-size: contain;
content: "";
height: var(--space-12);
opacity: 2000%;
position: absolute;
width: var(--space-12);
}
}
@layer utilities {
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }
.text-4xl { font-size: var(--font-size-4xl); }
.text-5xl { font-size: var(--font-size-5xl); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }
.leading-none { line-height: var(--line-height-none); }
.leading-tight { line-height: var(--line-height-tight); }
.leading-snug { line-height: var(--line-height-snug); }
.leading-normal { line-height: var(--line-height-normal); }
.leading-relaxed { line-height: var(--line-height-relaxed); }
.leading-loose { line-height: var(--line-height-loose); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
/* Text-Wrap Utilities
* - balance: Optimiert Zeilenumbrüche für gleiche Zeilenlängen, ideal für Überschriften
* - pretty: Optimiert Zeilenumbrüche für bessere Lesbarkeit, ideal für längere Texte
*/
.text-balance { text-wrap: balance; }
.text-pretty { text-wrap: pretty; }
.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }
.capitalize { text-transform: capitalize; }
.normal-case { text-transform: none; }
.truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.hover-underline {
text-decoration: none;
transition: text-decoration 0.2s ease;
}
.hover-underline:hover {
text-decoration: underline;
}
}
@layer responsive {
@container root (max-width: 640px) {
body {
font-size: var(--font-size-sm);
line-height: var(--line-height-snug);
}
h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }
}
}
@layer fluid {
/* Flüssige Überschriften */
.fluid-heading {
font-weight: var(--font-weight-bold);
line-height: var(--line-height-tight);
text-wrap: balance;
/* Interpoliert flüssig zwischen Größen abhängig vom Container/Viewport */
&.xxl {
font-size: clamp(var(--text-2xl), 5vw + 1rem, var(--text-4xl));
}
&.xl {
font-size: clamp(var(--text-xl), 4vw + 0.5rem, var(--text-3xl));
}
&.lg {
font-size: clamp(var(--text-lg), 3vw + 0.5rem, var(--text-2xl));
}
&.md {
font-size: clamp(var(--text-base), 2vw + 0.5rem, var(--text-xl));
}
&.sm {
font-size: clamp(var(--text-sm), 1vw + 0.5rem, var(--text-lg));
}
}
/* Container-adaptive Textgrößen */
.adaptive-text {
/* Nutzt Container-Queries für präzisere Größenanpassungen */
font-size: var(--text-base);
@container (min-width: 400px) {
font-size: var(--text-lg);
}
@container (min-width: 600px) {
font-size: var(--text-xl);
}
}
/* Responsive Absätze mit optimaler Lesbarkeit */
.fluid-paragraph {
font-size: clamp(var(--text-sm), 1vw + 0.5rem, var(--text-base));
line-height: var(--line-height-normal);
max-width: 70%ch; /* Optimale Lesbarkeit */
}
/* Blockzitate mit flüssiger Größenanpassung */
.fluid-quote {
border-left: 4px solid var(--color-primary);
font-size: clamp(var(--text-lg), 2vw + 0.5rem, var(--text-2xl));
font-style: italic;
line-height: var(--line-height-tight);
margin: var(--space-6) 0;
padding-left: var(--space-4);
}
/* Beschriftungen mit Größenanpassung */
.fluid-caption {
color: var(--color-gray-600);
font-size: clamp(var(--text-xs), 0.8vw + 0.2rem, var(--text-sm));
line-height: var(--line-height-normal);
}
/* Nutzt interpolate-size: allow-keywords für flüssige Interpolation
zwischen Schlüsselwörtern wie large und medium */
.size-keyword-text {
font-size: medium; /* Wird mit interpolate-size: allow-keywords flüssig skaliert */
&.larger {
font-size: large;
}
&.largest {
font-size: x-large;
}
&.smaller {
font-size: small;
}
&.smallest {
font-size: x-small;
}
}
}
}