Projektarbeit-MYP/backend/static/css/caching-optimizations.css
2025-06-01 23:41:02 +02:00

288 lines
5.2 KiB
CSS

/**
* MYP Platform - CSS Caching-Optimierungen
* Performance-optimierte Styles für besseres Caching und schnellere Ladezeiten
*/
/* ===== KRITISCHE ABOVE-THE-FOLD STYLES ===== */
/* Diese Styles sollten inline im HTML-Head geladen werden */
.critical-header {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(8px);
position: sticky;
top: 0;
z-index: 1000;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.critical-nav {
display: flex;
align-items: center;
padding: 1rem;
max-width: 1200px;
margin: 0 auto;
}
.critical-logo {
font-weight: 700;
font-size: 1.25rem;
color: #0073ce;
}
.critical-main {
min-height: 100vh;
background: linear-gradient(135deg, #fafbfc 0%, #f5f7f9 100%);
}
/* ===== LAZY LOADING PLACEHOLDER ===== */
.lazy-placeholder {
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 200% 100%;
animation: skeleton-loading 1.5s infinite ease-in-out;
border-radius: 4px;
}
@keyframes skeleton-loading {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
.dark .lazy-placeholder {
background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
background-size: 200% 100%;
}
/* ===== PRELOAD HINTS ===== */
.preload-image {
content-visibility: auto;
contain-intrinsic-size: 300px 200px;
}
.preload-component {
content-visibility: auto;
contain-intrinsic-size: 100px;
}
/* ===== CACHE-OPTIMIERTE KOMPONENTEN ===== */
.cache-card {
background: rgba(255, 255, 255, 0.9);
border: 1px solid rgba(229, 231, 235, 0.5);
border-radius: 8px;
padding: 1rem;
margin-bottom: 1rem;
transition: transform 0.2s ease;
contain: layout style paint;
}
.cache-card:hover {
transform: translateY(-1px);
}
.cache-button {
background: #0073ce;
color: white;
border: none;
border-radius: 6px;
padding: 0.5rem 1rem;
font-weight: 600;
transition: background-color 0.2s ease;
contain: layout style;
}
.cache-button:hover {
background: #005a9f;
}
.cache-input {
background: rgba(255, 255, 255, 0.9);
border: 1px solid rgba(229, 231, 235, 0.8);
border-radius: 4px;
padding: 0.5rem;
transition: border-color 0.2s ease;
contain: layout style;
}
.cache-input:focus {
outline: none;
border-color: #0073ce;
box-shadow: 0 0 0 2px rgba(0, 115, 206, 0.1);
}
/* ===== LAYOUT SHIFT PREVENTION ===== */
.prevent-cls {
min-height: 200px; /* Prevent layout shift */
contain: layout;
}
.image-container {
aspect-ratio: 16/9;
overflow: hidden;
border-radius: 8px;
background: #f3f4f6;
}
.image-container img {
width: 100%;
height: 100%;
object-fit: cover;
transition: opacity 0.3s ease;
}
.image-container img[loading="lazy"] {
opacity: 0;
}
.image-container img[loading="lazy"].loaded {
opacity: 1;
}
/* ===== OPTIMIERTE TYPOGRAPHY ===== */
.text-heading {
font-weight: 700;
line-height: 1.2;
color: #111827;
contain: layout style;
}
.text-body {
line-height: 1.6;
color: #374151;
contain: layout style;
}
.text-muted {
color: #6b7280;
contain: layout style;
}
/* ===== DARK MODE CACHE OPTIMIZATIONS ===== */
.dark .cache-card {
background: rgba(30, 41, 59, 0.9);
border-color: rgba(100, 116, 139, 0.3);
}
.dark .cache-input {
background: rgba(30, 41, 59, 0.9);
border-color: rgba(100, 116, 139, 0.5);
color: #e2e8f0;
}
.dark .text-heading {
color: #f8fafc;
}
.dark .text-body {
color: #e2e8f0;
}
.dark .text-muted {
color: #94a3b8;
}
.dark .image-container {
background: #374151;
}
/* ===== RESPONSIVE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
.critical-nav {
padding: 0.75rem;
}
.cache-card {
padding: 0.75rem;
margin-bottom: 0.75rem;
}
.cache-button {
padding: 0.75rem 1.25rem;
font-size: 0.875rem;
}
}
/* ===== PRINT OPTIMIZATIONS ===== */
@media print {
.critical-header,
.cache-button {
display: none;
}
.cache-card {
box-shadow: none;
border: 1px solid #000;
break-inside: avoid;
}
}
/* ===== GPU ACCELERATION HINTS ===== */
.gpu-accelerated {
transform: translateZ(0);
will-change: transform;
}
/* ===== EFFICIENT ANIMATIONS ===== */
.fade-in-optimized {
opacity: 0;
transform: translateY(10px);
transition: opacity 0.3s ease, transform 0.3s ease;
}
.fade-in-optimized.visible {
opacity: 1;
transform: translateY(0);
}
/* ===== CONTAINER QUERIES SUPPORT ===== */
@container (min-width: 300px) {
.cache-card {
display: grid;
grid-template-columns: 1fr auto;
gap: 1rem;
align-items: center;
}
}
/* ===== CONTENT VISIBILITY OPTIMIZATIONS ===== */
.auto-height {
content-visibility: auto;
contain-intrinsic-size: 0 200px;
}
.hidden-content {
content-visibility: hidden;
}
/* ===== REDUCED MOTION PREFERENCES ===== */
@media (prefers-reduced-motion: reduce) {
.fade-in-optimized,
.cache-card,
.cache-button,
.cache-input {
transition: none !important;
}
.lazy-placeholder {
animation: none !important;
background: #f0f0f0 !important;
}
}
/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
.cache-card {
border-width: 2px;
border-color: #000;
}
.cache-button {
border: 2px solid #000;
}
.cache-input {
border-width: 2px;
border-color: #000;
}
}