rmcg.dev/projects/FrontendMentor/newbie/faq-accordion-card/css/style.css

268 lines
4.6 KiB
CSS

/*
Info:
desktop size 1440x768
mobile size 375x768
*/
@import url("https://fonts.googleapis.com/css2?family=Kumbh+Sans:wght@400;700&display=swap");
:root {
/* colors: */
/* Text */
--col-red-soft: hsl(14, 88%, 65%);
--col-blue-very-dark-desaturated: hsl(238, 29%, 16%);
--col-blue-very-dark-grayish: hsl(237, 12%, 33%);
--col-blue-dark-grayish: hsl(240, 6%, 50%);
/* divider */
--col-blue-light-grayish: hsl(240, 5%, 91%);
/* background gradient */
--col-violet-soft: hsl(273, 75%, 66%);
--col-blue-soft: hsl(240, 73%, 65%);
--clr-test: rgb(255, 111, 000);
/* Fonts */
--fs-header: 2rem;
--fs-question: 0.8125rem;
--fs-answer: 0.75rem;
--fw-400: 400;
--fw-700: 700;
--lh-header: 2.5rem;
--lh-question: 1rem;
--lh-answer: 1.125rem;
}
*,
::after,
::before {
box-sizing: border-box;
}
html,
body {
min-height: 100vh;
width: 100%;
}
img {
width: 100%;
}
/* Base page styling */
body {
background: linear-gradient(
180deg,
var(--col-violet-soft) 0%,
var(--col-blue-soft) 100%
);
display: grid;
place-items: center;
}
.card {
display: flex;
flex-direction: column;
font-family: "Kumbh Sans", sans-serif;
background-color: white;
width: 87%;
border-radius: 23px;
background-image: var(--card-image);
max-width: 400px;
}
.card__title {
text-align: center;
font-weight: var(--fw-700);
font-size: var(--fs-header);
line-height: var(--lh-header);
margin-bottom: 2.375rem;
}
.card__header {
margin-bottom: 40px;
height: 90px;
}
.card__header_image {
background: url(../images/bg-pattern-mobile.svg) center bottom no-repeat;
background-position-x: 0px;
background-position-y: 125px;
background-size: 95%;
margin: 0 auto;
max-width: 245px;
margin-top: -130px;
}
.desktop {
display: none;
}
.mobile {
display: block;
}
.woman {
margin-left: -16px;
padding: 30px 0px;
}
.faq {
color: var(--col-red-soft);
margin: 0 1.5rem 3rem;
}
/* FAQ Section */
details {
font-size: var(--fs-answer);
line-height: 1.125rem;
padding: 1rem 0;
color: var(--col-blue-dark-grayish);
border-bottom: 1px solid var(--col-blue-light-grayish);
border-width: 75%;
}
h1 + details {
padding: 0 0 1rem 0;
}
summary {
font-size: var(--fs-question);
font-weight: var(--fw-400);
line-height: var(--lh-question);
color: var(--col-blue-very-dark-grayish);
outline: none;
text-align: left;
cursor: pointer;
position: relative;
display: block;
}
summary:hover {
color: var(--col-red-soft);
}
details > summary::after {
position: absolute;
content: url(../images/icon-arrow-down.svg);
right: 0px;
}
details[open] > summary {
font-weight: var(--fw-700);
color: var(--col-blue-very-dark-desaturated);
}
details[open] > summary::after {
transform: rotate(180deg);
}
details > summary::-webkit-details-marker {
display: none;
}
details[open] summary ~ * {
animation: sweep 0.5s ease-in-out;
}
/* ! In polypane, this only works in desktop, not mobile */
@media (prefers-reduced-motion) {
details[open] summary ~ * {
animation: none;
}
}
@keyframes sweep {
0% {
opacity: 0;
margin-top: -10px;
}
100% {
opacity: 1;
margin-top: 0px;
}
}
.faq__content {
width: 90%;
margin-top: 0.6875rem;
}
@media screen and (min-width: 900px) {
:root {
--fs-question: 0.875rem;
--lh-question: 1.0625rem;
}
.card {
flex-direction: row;
max-width: 920px;
height: 509px;
}
.card__header {
display: flex;
align-items: center;
height: 100%;
justify-content: center;
}
.card__header_image {
display: flex;
align-items: center;
background-image: url(../images/illustration-woman-online-desktop.svg),
url(../images/bg-pattern-desktop.svg);
background-position: -65px center, -571px -270px;
background-size: 100%, 200%;
height: 100%;
min-width: 300px;
margin: 0;
padding: 0;
width: 472px;
max-width: 500px;
position: relative;
}
.mobile {
display: none;
}
.desktop {
display: block;
position: absolute;
margin-top: 100px;
left: -90px;
width: 40%;
}
article {
width: 45%;
}
.faq {
margin-top: 65px;
}
.faq__content {
width: 95%;
}
.card__title {
text-align: start;
}
/* .box {
width: 90px;
} */
}