Files
cv-site/static/css/04-interactive/_tooltips.css
T
juanatsap 2497dbaa3e fix: Correct fixed button tooltip positioning and add mobile support
- Remove tooltip-left class from zoom and shortcuts buttons (all left-side buttons show tooltips on RIGHT)
- Add mobile CSS rules for fixed-btn tooltips to appear on TOP (like macOS Dock)
- Update button template comments to reflect correct positioning
- Mobile: All fixed buttons now show tooltips above (top position)
- Desktop: All left-side fixed buttons show tooltips on right
2025-11-20 18:31:31 +00:00

216 lines
6.0 KiB
CSS

/* ============================================================================
MACOS DOCK-STYLE TOOLTIPS
Modern tooltips with smooth fade and scale animations
============================================================================ */
/* Tooltip Container */
.has-tooltip {
position: relative;
}
/* Tooltip Base Styles - Using ::before for the bubble */
.has-tooltip::before {
content: attr(data-tooltip);
position: absolute;
/* macOS Dock styling */
background: rgba(0, 0, 0, 0.85);
color: white;
font-size: 11px;
font-weight: 600;
padding: 4px 8px;
border-radius: 6px;
white-space: nowrap;
letter-spacing: 0.01em;
line-height: 1.3;
/* Shadow for depth */
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
/* Hidden by default */
opacity: 0;
visibility: hidden;
/* Smooth fade + scale animation */
transition: opacity 0.2s ease,
transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
visibility 0.2s ease;
/* Start scaled down slightly */
transform: scale(0.8);
/* Prevent tooltip from blocking interactions */
pointer-events: none;
/* Layer above content */
z-index: 1000;
}
/* Show tooltip on hover */
.has-tooltip:hover::before {
opacity: 1;
visibility: visible;
transform: scale(1);
}
/* ============================================================================
POSITIONING VARIANTS
============================================================================ */
/* DEFAULT: Right position (for vertical action bar buttons in desktop) */
.has-tooltip::before {
left: calc(100% + 12px); /* 12px gap from button */
top: 50%;
transform: translateY(-50%) scale(0.8);
}
.has-tooltip:hover::before {
transform: translateY(-50%) scale(1);
}
/* LEFT position (for back-to-top button) */
.has-tooltip.tooltip-left::before {
right: calc(100% + 12px); /* 12px gap from button */
left: auto;
top: 50%;
transform: translateY(-50%) scale(0.8);
}
.has-tooltip.tooltip-left:hover::before {
transform: translateY(-50%) scale(1);
}
/* TOP position (for mobile view - like macOS Dock) */
.has-tooltip.tooltip-top::before {
bottom: calc(100% + 12px); /* 12px gap above button */
left: 50%;
top: auto;
right: auto;
transform: translateX(-50%) scale(0.8);
}
.has-tooltip.tooltip-top:hover::before {
transform: translateX(-50%) scale(1);
}
/* BOTTOM position (alternative) */
.has-tooltip.tooltip-bottom::before {
top: calc(100% + 12px); /* 12px gap below button */
left: 50%;
bottom: auto;
right: auto;
transform: translateX(-50%) scale(0.8);
}
.has-tooltip.tooltip-bottom:hover::before {
transform: translateX(-50%) scale(1);
}
/* ============================================================================
MOBILE RESPONSIVE BEHAVIOR
============================================================================ */
/* Mobile: Switch all tooltips to TOP position (like macOS Dock) */
@media (max-width: 900px) {
/* Action bar buttons get TOP tooltips on mobile */
.action-btn.has-tooltip::before {
bottom: calc(100% + 8px); /* 8px gap above button */
left: 50%;
top: auto;
right: auto;
transform: translateX(-50%) scale(0.8);
}
.action-btn.has-tooltip:hover::before {
transform: translateX(-50%) scale(1);
}
/* Fixed buttons (left side) get TOP tooltips on mobile - like macOS Dock */
.fixed-btn.has-tooltip::before {
bottom: calc(100% + 8px); /* 8px gap above button */
left: 50%;
top: auto;
right: auto;
transform: translateX(-50%) scale(0.8);
}
.fixed-btn.has-tooltip:hover::before {
transform: translateX(-50%) scale(1);
}
/* Back-to-top button keeps LEFT position on mobile */
.back-to-top.has-tooltip.tooltip-left::before {
right: calc(100% + 8px);
left: auto;
top: 50%;
bottom: auto;
transform: translateY(-50%) scale(0.8);
}
.back-to-top.has-tooltip.tooltip-left:hover::before {
transform: translateY(-50%) scale(1);
}
}
/* Very narrow mobile - Adjust back-to-top tooltip for higher position */
@media (max-width: 483px) {
/* Back-to-top moves up, tooltip stays with it */
.back-to-top.has-tooltip.tooltip-left::before {
right: calc(100% + 8px);
top: 50%;
transform: translateY(-50%) scale(0.8);
}
.back-to-top.has-tooltip.tooltip-left:hover::before {
transform: translateY(-50%) scale(1);
}
}
/* ============================================================================
ACCESSIBILITY & PERFORMANCE
============================================================================ */
/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
.has-tooltip::before {
transition: opacity 0.1s ease, visibility 0.1s ease;
transform: scale(1) !important; /* No scale animation */
}
.has-tooltip:hover::before {
transform: scale(1) !important;
}
.has-tooltip.tooltip-left::before,
.has-tooltip.tooltip-left:hover::before {
transform: translateY(-50%) scale(1) !important;
}
.has-tooltip.tooltip-top::before,
.has-tooltip.tooltip-top:hover::before {
transform: translateX(-50%) scale(1) !important;
}
}
/* Hide tooltips on touch devices (avoid sticky tooltips) */
@media (hover: none) and (pointer: coarse) {
.has-tooltip::before {
display: none;
}
}
/* ============================================================================
THEME SUPPORT
============================================================================ */
/* Dark theme - slightly lighter tooltip for better contrast */
[data-color-theme="dark"] .has-tooltip::before {
background: rgba(40, 40, 40, 0.95);
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}
/* Light theme - keep default dark tooltip (better contrast) */
[data-color-theme="light"] .has-tooltip::before {
background: rgba(0, 0, 0, 0.85);
}