|
@import url('https://api.fonts.coollabs.io/css2?family=Red+Hat+Text:wght@700&display=swap') cover; |
|
|
|
:root { |
|
// timer settings |
|
--days: 0; |
|
--hours: 1; |
|
--minutes: 1; |
|
--seconds: 0; |
|
// colors variables |
|
--grayish-blue: hsl(237, 18%, 59%); |
|
--desaturated-blue: hsl(236, 21%, 26%); |
|
--dark-blue-800: hsl(235, 16%, 14%); |
|
--dark-blue-900: hsl(234, 17%, 12%); |
|
--soft-red: hsl(345, 95%, 68%); |
|
// global variables |
|
--bg-clr-body: var(--dark-blue-800); |
|
--bg-clr-card: var(--desaturated-blue); |
|
--bg-clr-card-shadow: var(--dark-blue-900); |
|
--txt-clr-card: var(--soft-red); |
|
--txt-clr-card-title: var(--grayish-blue); |
|
--txt-size-card: 4.5rem; |
|
} |
|
|
|
// resets |
|
*, *::before, *::after { |
|
box-sizing: border-box; |
|
margin: 0; |
|
padding: 0; |
|
} |
|
|
|
body { |
|
background: |
|
url('https://launch-countdown-timer-sebasec.vercel.app/images/bg-stars.svg'), |
|
url('https://launch-countdown-timer-sebasec.vercel.app/images/pattern-hills.svg') bottom/100% no-repeat var(--bg-clr-body); |
|
font-family: 'Red Hat Text', sans-serif; |
|
} |
|
|
|
// center content grid |
|
.container { |
|
display: flex; |
|
align-items: center; |
|
justify-content: center; |
|
height: 100vh; |
|
height: 100dvh; |
|
} |
|
|
|
.content-grid { |
|
display: grid; |
|
gap: 32px; |
|
grid-template: repeat(2, 1fr) / repeat(4, 1fr); |
|
} |
|
|
|
.flip-card { |
|
--_flip-card-size: 150px; |
|
background: |
|
linear-gradient(to bottom, #2F3047 50%, var(--bg-clr-card) 0); |
|
border-radius: 0.5rem; |
|
box-shadow: 0 1rem 0 var(--bg-clr-card-shadow); |
|
color: var(--txt-clr-card); |
|
display: inline-flex; |
|
flex-direction: column; |
|
font-size: var(--txt-size-card); |
|
font-weight: 700; |
|
position: relative; |
|
perspective: 800px; |
|
perspective-orgin: center; |
|
height: var(--_flip-card-size); |
|
width: var(--_flip-card-size); |
|
|
|
&::before, &::after { |
|
--_pivot-pt-size: 12px; |
|
content: ""; |
|
background: var(--dark-blue-900); |
|
border-radius: 50%; |
|
height: var(--_pivot-pt-size); |
|
width: var(--_pivot-pt-size); |
|
top: 50%; |
|
position: absolute; |
|
transform: translateY(-50%); |
|
z-index: 99; |
|
} |
|
|
|
// pivot positions |
|
&::before { |
|
left: calc(var(--_pivot-pt-size) / -2); |
|
} |
|
&::after { |
|
right: calc(var(--_pivot-pt-size) / -2); |
|
} |
|
|
|
// top card shadow |
|
.top::before { |
|
content: ''; |
|
background: var(--bg-clr-card-shadow); |
|
inset: 0; |
|
opacity: 0.2; |
|
z-index: 99; |
|
} |
|
} |
|
|
|
// timer styles & settings |
|
.flip-card { |
|
.time { |
|
display: flex; |
|
align-items: center; |
|
justify-content: center; |
|
position: absolute; |
|
inset: 0; |
|
z-index: -1; |
|
} |
|
|
|
.top, |
|
.bottom { |
|
--_flip-speed: 450ms; |
|
background: var(--bg-clr-card); |
|
display: flex; |
|
justify-content: center; |
|
position: absolute; |
|
overflow: hidden; |
|
height: 50%; |
|
width: 100%; |
|
transform-style: preserve-3d; |
|
} |
|
|
|
// top animation |
|
.top[data-flip=true]{ |
|
animation: top-to-bottom var(--_flip-speed) ease-in; |
|
} |
|
|
|
// bottom animation |
|
.bottom[data-flip=true]{ |
|
animation: bottom-to-top var(--_flip-speed) ease-out var(--_flip-speed); |
|
} |
|
|
|
.top { |
|
border-radius: 0.5rem 0.5rem 0 0; |
|
transform-origin: bottom; |
|
} |
|
|
|
.bottom { |
|
border-radius: 0 0 0.5rem 0.5rem; |
|
top: 50%; |
|
transform-origin: top; |
|
} |
|
|
|
.top::after { |
|
top: 50%; |
|
} |
|
|
|
.top::after, |
|
.top::before, |
|
.bottom::after { |
|
position: absolute; |
|
} |
|
|
|
.bottom::after { |
|
top: -50%; |
|
} |
|
|
|
&:nth-child(1) { |
|
.top::after, .bottom::after { |
|
counter-reset: days var(--days); |
|
content: counter(days, decimal-leading-zero); |
|
} |
|
} |
|
|
|
&:nth-child(2) { |
|
.top::after, .bottom::after { |
|
counter-reset: hours var(--hours); |
|
content: counter(hours, decimal-leading-zero); |
|
} |
|
} |
|
|
|
&:nth-child(3) { |
|
.top::after, .bottom::after { |
|
counter-reset: minutes var(--minutes); |
|
content: counter(minutes, decimal-leading-zero); |
|
} |
|
} |
|
|
|
&:nth-child(4) { |
|
.top::after, .bottom::after { |
|
counter-reset: seconds var(--seconds); |
|
content: counter(seconds, decimal-leading-zero); |
|
} |
|
} |
|
} |
|
|
|
.card-title { |
|
color: var(--txt-clr-card-title); |
|
justify-self: center; |
|
letter-spacing: 0.3em; |
|
text-transform: uppercase; |
|
} |
|
|
|
@keyframes top-to-bottom { |
|
100% { |
|
transform: rotateX(-90deg); |
|
} |
|
} |
|
|
|
@keyframes bottom-to-top { |
|
0% { |
|
transform: rotateX(90deg); |
|
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.3); |
|
} |
|
100% { |
|
transform: rotateX(0deg); |
|
box-shadow: 0 5px 5px rgba(0, 0, 0, 0); |
|
} |
|
} |