|
4 | 4 | } |
5 | 5 |
|
6 | 6 | .carousel-container { |
| 7 | + position: relative; |
7 | 8 | width: 100%; |
8 | 9 | max-width: 36rem; /* 576px */ |
9 | 10 | margin: 0 auto; |
|
14 | 15 | position: relative; |
15 | 16 | height: calc(87px + 26px); |
16 | 17 | width: 100%; |
| 18 | + display: flex; |
| 19 | + justify-content: center; |
| 20 | + perspective: 1000px; |
17 | 21 | } |
18 | 22 |
|
19 | 23 | .card { |
20 | 24 | position: absolute; |
21 | 25 | width: 16rem; |
| 26 | + max-width: 70%; /* Responsive cap */ |
| 27 | + height: 100%; |
22 | 28 | background-color: white; |
23 | 29 | border-radius: 0.5rem; |
24 | | - transition: all 500ms ease-in-out; |
| 30 | + transition: all 500ms cubic-bezier(0.25, 0.8, 0.25, 1); |
25 | 31 | overflow: hidden; |
26 | | - |
27 | | - &.animating { |
28 | | - pointer-events: none; |
29 | | - } |
| 32 | + cursor: pointer; |
| 33 | + will-change: transform, opacity, left, right; |
30 | 34 |
|
31 | 35 | &.new { |
32 | 36 | --tint: 150; |
|
47 | 51 | } |
48 | 52 | } |
49 | 53 |
|
50 | | -.card-content { |
51 | | - padding: 16px 24px; |
52 | | - height: 100%; |
53 | | - display: flex; |
54 | | - flex-direction: column; |
55 | | - |
56 | | - * { |
57 | | - margin: 0; |
58 | | - } |
59 | | - |
60 | | - .card-header { |
61 | | - display: flex; |
62 | | - justify-content: space-between; |
63 | | - align-items: center; |
64 | | - margin-bottom: 12px; |
65 | | - |
66 | | - > span:first-child { |
67 | | - display: flex; |
68 | | - gap: 0.25rem; |
69 | | - align-items: center; |
70 | | - background-color: hsl(var(--tint), 100%, 86%, 0.5); |
71 | | - color: hsl(var(--tint), 100%, 30%); |
72 | | - border-radius: 4px; |
73 | | - padding: 0.25rem 0.5rem; |
74 | | - font-size: 0.8rem; |
75 | | - font-weight: 500; |
76 | | - } |
77 | | - } |
78 | | -} |
79 | | - |
80 | | -:host-context(.dark) .card-header > span:first-child { |
81 | | - background-color: hsl(var(--tint), 100%, 25%, 0.4); |
82 | | - color: hsl(var(--tint), 100%, 95%); |
83 | | -} |
84 | | - |
85 | | -/* Card positions */ |
86 | 54 | .center { |
87 | | - left: 50%; |
88 | | - transform: translateX(-50%) scale(1); |
89 | | - top: 0; |
90 | | - width: 18rem; |
91 | | - z-index: 2; |
| 55 | + z-index: 10; |
92 | 56 | opacity: 1; |
| 57 | + /* Use translate3d for hardware acceleration */ |
| 58 | + transform: translateX(0) scale(1); |
| 59 | + left: 0; |
| 60 | + right: 0; |
| 61 | + margin: auto; |
| 62 | + width: 18rem; |
93 | 63 | box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); |
94 | | - cursor: pointer; |
| 64 | +} |
95 | 65 |
|
96 | | - &:hover { |
97 | | - box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); |
98 | | - } |
| 66 | +.center:hover { |
| 67 | + box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); |
99 | 68 | } |
100 | 69 |
|
101 | 70 | .left { |
102 | | - left: 0; |
103 | | - transform: translateX(-1.5rem) scale(0.9); |
104 | | - z-index: 1; |
| 71 | + z-index: 5; |
105 | 72 | opacity: 0.7; |
106 | | - box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); |
107 | | - cursor: pointer; |
108 | | - |
109 | | - &:hover { |
110 | | - opacity: 0.9; |
111 | | - } |
| 73 | + transform: translateX(-55%) scale(0.9); |
| 74 | + left: 0; right: 0; margin: auto; /* Base center */ |
| 75 | + box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); |
112 | 76 | } |
113 | 77 |
|
114 | 78 | .right { |
115 | | - right: 0; |
116 | | - transform: translateX(1.5rem) scale(0.9); |
117 | | - z-index: 1; |
| 79 | + z-index: 5; |
118 | 80 | opacity: 0.7; |
119 | | - box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); |
120 | | - cursor: pointer; |
| 81 | + transform: translateX(55%) scale(0.9); |
| 82 | + left: 0; right: 0; margin: auto; /* Base center */ |
| 83 | + box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); |
| 84 | +} |
121 | 85 |
|
122 | | - &:hover { |
123 | | - opacity: 0.9; |
124 | | - } |
| 86 | +:is(.left, .right):hover { |
| 87 | + opacity: 0.85; |
125 | 88 | } |
126 | 89 |
|
127 | 90 | .hidden { |
| 91 | + z-index: 0; |
128 | 92 | opacity: 0; |
129 | 93 | transform: scale(0.75); |
130 | 94 | pointer-events: none; |
| 95 | + /* Keep them centered so they animate OUT from the center */ |
| 96 | + left: 0; right: 0; margin: auto; |
| 97 | +} |
| 98 | + |
| 99 | +.card-content { |
| 100 | + padding: 16px 24px; |
| 101 | + height: 100%; |
| 102 | + display: flex; |
| 103 | + flex-direction: column; |
| 104 | + |
| 105 | + p { |
| 106 | + margin: 0; |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | +.card-header { |
| 111 | + display: flex; |
| 112 | + justify-content: space-between; |
| 113 | + align-items: center; |
| 114 | + margin-bottom: 12px; |
| 115 | + |
| 116 | + > span:first-child { |
| 117 | + display: flex; |
| 118 | + gap: 0.25rem; |
| 119 | + align-items: center; |
| 120 | + background-color: hsl(var(--tint), 100%, 86%, 0.5); |
| 121 | + color: hsl(var(--tint), 100%, 30%); |
| 122 | + border-radius: 4px; |
| 123 | + padding: 0.25rem 0.5rem; |
| 124 | + font-size: 0.8rem; |
| 125 | + font-weight: 500; |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +:host-context(.dark) .card-header > span:first-child { |
| 130 | + background-color: hsl(var(--tint), 100%, 25%, 0.4); |
| 131 | + color: hsl(var(--tint), 100%, 95%); |
131 | 132 | } |
132 | 133 |
|
133 | 134 | /* Navigation buttons */ |
134 | 135 | .nav-button { |
135 | 136 | position: absolute; |
136 | | - top: calc(87px / 2); |
| 137 | + top: 50%; |
137 | 138 | transform: translateY(-50%); |
138 | 139 | width: 28px; |
139 | 140 | height: 28px; |
140 | | - display: flex; |
141 | | - align-items: center; |
142 | | - justify-content: center; |
143 | 141 | border-radius: 9999px; |
144 | 142 | background-color: rgba(255, 255, 255, 0.9); |
145 | 143 | box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); |
146 | | - z-index: 3; |
| 144 | + z-index: 20; |
147 | 145 | border: none; |
148 | 146 | cursor: pointer; |
149 | | - transition: all 300ms; |
| 147 | + display: flex; |
| 148 | + align-items: center; |
| 149 | + justify-content: center; |
| 150 | + transition: all 200ms; |
150 | 151 |
|
151 | 152 | &:hover { |
152 | 153 | background-color: white; |
153 | 154 | box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); |
154 | 155 | } |
155 | | - |
156 | | - &:focus-visible { |
157 | | - outline: 2px solid #3B82F6; |
158 | | - outline-offset: 2px; |
159 | | - } |
160 | | - |
161 | | - &:disabled { |
162 | | - opacity: 0.5; |
163 | | - cursor: not-allowed; |
164 | | - } |
165 | 156 | } |
166 | 157 |
|
167 | 158 | :host-context(.dark) .nav-button { |
|
174 | 165 | } |
175 | 166 | } |
176 | 167 |
|
177 | | -.prev { |
178 | | - left: -70px; |
179 | | -} |
| 168 | +.prev { left: 0; } |
| 169 | +.next { right: 0; } |
| 170 | +.next svg { transform: rotate(180deg); } |
| 171 | + |
| 172 | +/* Mobile: Hide Buttons, rely on swipe */ |
| 173 | +@media (max-width: 600px) { |
| 174 | + .nav-button { |
| 175 | + display: none; |
| 176 | + } |
180 | 177 |
|
181 | | -.next { |
182 | | - right: -70px; |
| 178 | + /* Adjust scaling for small screens so cards don't overlap too much */ |
| 179 | + .left { transform: translateX(-20%) scale(0.85); opacity: 0.5; } |
| 180 | + .right { transform: translateX(20%) scale(0.85); opacity: 0.5; } |
183 | 181 |
|
184 | | - svg { |
185 | | - transform: rotate(180deg); |
| 182 | + .card-content { |
| 183 | + padding: 12px 16px; |
| 184 | + font-size: 0.9rem; |
186 | 185 | } |
187 | 186 | } |
188 | 187 |
|
189 | | -/* Indicators */ |
| 188 | +/* Desktop: Push buttons outside slightly if there is room */ |
| 189 | +@media (min-width: 601px) { |
| 190 | + .prev { left: -40px; } |
| 191 | + .next { right: -40px; } |
| 192 | +} |
| 193 | + |
190 | 194 | .indicators { |
191 | | - position: absolute; |
192 | | - bottom: 0; |
193 | | - left: 0; |
194 | | - right: 0; |
195 | 195 | display: flex; |
196 | 196 | justify-content: center; |
197 | 197 | gap: 0.5rem; |
198 | | - z-index: 3; |
| 198 | + margin-top: 1rem; |
199 | 199 | } |
200 | 200 |
|
201 | 201 | .indicator { |
202 | | - width: 0.5rem; |
203 | | - height: 0.5rem; |
| 202 | + width: 0.6rem; |
| 203 | + height: 0.6rem; |
204 | 204 | border-radius: 9999px; |
205 | 205 | background-color: rgba(0, 0, 0, 0.25); |
206 | 206 | border: none; |
207 | | - transition: all 300ms; |
208 | | - padding: 0; |
209 | 207 | cursor: pointer; |
| 208 | + transition: all 300ms cubic-bezier(0.25, 0.8, 0.25, 1); |
| 209 | + padding: 0; |
| 210 | + position: relative; |
| 211 | + overflow: hidden; |
210 | 212 |
|
211 | 213 | &:hover { |
212 | 214 | background-color: rgba(var(--picton-blue-500), 0.4); |
213 | 215 | } |
214 | 216 |
|
215 | 217 | &.active { |
216 | | - background-color: rgba(var(--picton-blue-500), 0.75); |
217 | | - width: 1.5rem; |
| 218 | + width: 1.75rem; /* Pill shape */ |
218 | 219 | } |
| 220 | +} |
219 | 221 |
|
220 | | - &:focus-visible { |
221 | | - outline: 2px solid rgba(var(--picton-blue-500), 0.75); |
222 | | - outline-offset: 2px; |
223 | | - } |
| 222 | +/* Progress bar fill for active indicator */ |
| 223 | +.indicator.active::after { |
| 224 | + content: ''; |
| 225 | + position: absolute; |
| 226 | + top: 0; |
| 227 | + left: 0; |
| 228 | + height: 100%; |
| 229 | + background-color: rgba(var(--picton-blue-500), 0.75); |
| 230 | + width: 0; |
| 231 | + animation: fillProgress 5000ms linear forwards; |
| 232 | +} |
224 | 233 |
|
225 | | - &:disabled { |
226 | | - cursor: not-allowed; |
227 | | - } |
| 234 | +@keyframes fillProgress { |
| 235 | + from { width: 0; } |
| 236 | + to { width: 100%; } |
228 | 237 | } |
229 | 238 |
|
230 | 239 | :host-context(.dark) .indicator { |
|
234 | 243 | background-color: rgba(255, 255, 255, 0.5); |
235 | 244 | } |
236 | 245 |
|
237 | | - &.active { |
| 246 | + &.active::after { |
238 | 247 | background-color: #91b9ef; |
239 | 248 | } |
240 | 249 | } |
0 commit comments