|
| 1 | +body { |
| 2 | + font-family: 'Inter', Arial, sans-serif; /* Using Inter as per instructions */ |
| 3 | + background-color: #f4f7f6; |
| 4 | + display: flex; |
| 5 | + flex-direction: column; |
| 6 | + align-items: center; |
| 7 | + padding: 30px 20px; |
| 8 | + margin: 0; |
| 9 | + min-height: 100vh; |
| 10 | +} |
| 11 | + |
| 12 | +h1 { |
| 13 | + color: #333; |
| 14 | + font-size: 2rem; |
| 15 | + margin-bottom: 10px; |
| 16 | +} |
| 17 | + |
| 18 | +.instruction { |
| 19 | + color: #666; |
| 20 | + margin-bottom: 40px; |
| 21 | + font-style: italic; |
| 22 | +} |
| 23 | + |
| 24 | +.alert-container { |
| 25 | + width: 90%; |
| 26 | + max-width: 600px; |
| 27 | + margin-bottom: 20px; |
| 28 | +} |
| 29 | + |
| 30 | +/* --- BASE ALERT STYLES (Applies to all) --- */ |
| 31 | +.alert-box { |
| 32 | + border-radius: 8px; |
| 33 | + padding: 20px; |
| 34 | + position: relative; |
| 35 | + opacity: 1; |
| 36 | + transform: translateY(0); |
| 37 | + transition: opacity 0.4s ease-out, transform 0.4s ease-out, margin-bottom 0.4s ease-out, height 0.4s ease-out, padding 0.4s ease-out; |
| 38 | + box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); |
| 39 | + border-left: 5px solid; /* For colored accent */ |
| 40 | + overflow: hidden; /* Crucial for transition */ |
| 41 | + min-height: 80px; /* Ensure consistent initial height */ |
| 42 | +} |
| 43 | + |
| 44 | +.alert-title { |
| 45 | + margin-top: 0; |
| 46 | + font-size: 1.25rem; |
| 47 | + font-weight: 600; |
| 48 | +} |
| 49 | + |
| 50 | +.alert-message { |
| 51 | + margin-bottom: 0; |
| 52 | + line-height: 1.5; |
| 53 | +} |
| 54 | + |
| 55 | +.alert-close { |
| 56 | + position: absolute; |
| 57 | + top: 50%; |
| 58 | + right: 15px; |
| 59 | + transform: translateY(-50%); |
| 60 | + font-size: 1.5rem; |
| 61 | + cursor: pointer; |
| 62 | + text-decoration: none; |
| 63 | + line-height: 1; |
| 64 | + opacity: 0.7; |
| 65 | + transition: opacity 0.2s; |
| 66 | +} |
| 67 | + |
| 68 | +.alert-close:hover { |
| 69 | + opacity: 1; |
| 70 | +} |
| 71 | + |
| 72 | +/* --- THEME COLORS --- */ |
| 73 | + |
| 74 | +/* SUCCESS (Green) */ |
| 75 | +.alert--success { |
| 76 | + background-color: #d4edda; |
| 77 | + color: #155724; |
| 78 | + border-left-color: #28a745; |
| 79 | +} |
| 80 | +.alert--success .alert-close { color: #155724; } |
| 81 | + |
| 82 | +/* ERROR (Red) */ |
| 83 | +.alert--error { |
| 84 | + background-color: #f8d7da; |
| 85 | + color: #721c24; |
| 86 | + border-left-color: #dc3545; |
| 87 | +} |
| 88 | +.alert--error .alert-close { color: #721c24; } |
| 89 | + |
| 90 | +/* WARNING (Yellow/Orange) */ |
| 91 | +.alert--warning { |
| 92 | + background-color: #fff3cd; |
| 93 | + color: #856404; |
| 94 | + border-left-color: #ffc107; |
| 95 | +} |
| 96 | +.alert--warning .alert-close { color: #856404; } |
| 97 | + |
| 98 | +/* INFO (Blue) */ |
| 99 | +.alert--info { |
| 100 | + background-color: #d1ecf1; |
| 101 | + color: #0c5460; |
| 102 | + border-left-color: #17a2b8; |
| 103 | +} |
| 104 | +.alert--info .alert-close { color: #0c5460; } |
| 105 | + |
| 106 | + |
| 107 | +/* --- THE PURE CSS MAGIC (DISMISSAL LOGIC) --- */ |
| 108 | + |
| 109 | +/* Selects the sibling alert-container when the toggle is checked */ |
| 110 | +.alert-toggle:checked + .alert-container { |
| 111 | + /* Set container height/padding to 0 */ |
| 112 | + max-height: 0; |
| 113 | + margin-top: 0; |
| 114 | + margin-bottom: 0; |
| 115 | + padding: 0; |
| 116 | + transition: max-height 0.4s ease-out, margin-bottom 0.4s ease-out; |
| 117 | +} |
| 118 | + |
| 119 | +/* Hide the inner content once the container collapses */ |
| 120 | +.alert-toggle:checked + .alert-container .alert-box { |
| 121 | + opacity: 0; |
| 122 | + padding-top: 0; |
| 123 | + padding-bottom: 0; |
| 124 | + transform: translateY(-10px); |
| 125 | + transition: opacity 0.3s ease-out 0.1s, transform 0.3s ease-out 0.1s, padding 0.3s ease-out 0.1s; |
| 126 | +} |
0 commit comments