- 'hobbyp' + 'j' in brand-900 (12.21:1), 'ro' + 'ect' in brand-500 (3.12:1) so the reader connects hobbypj with hobby project - caption under it: 'hobbypj ย่อมาจาก hobby project' - wordmark is 24-32px bold, the size at which the light brown still passes AA large text - entrance animation with the rest of the hero; aria-label keeps the whole word for screen readers - DESIGN.md records the colour split and the size rule
305 lines
8.0 KiB
CSS
305 lines
8.0 KiB
CSS
/* ==========================================================================
|
|
motion.css — ลูกเล่นภาพเคลื่อนไหว
|
|
สัญญา: ซ่อนเนื้อหาเฉพาะเมื่อ <html> มีคลาส .fx-motion (JS ใส่ให้)
|
|
ถ้า JS ปิด/บล็อก หรือผู้ใช้ตั้ง reduced-motion → เนื้อหาทั้งหมดเห็นปกติทันที
|
|
อนิเมตเฉพาะ transform / opacity / filter เท่านั้น
|
|
========================================================================== */
|
|
|
|
/* --------------------------------------------------- แถบความคืบหน้าการเลื่อน */
|
|
.scroll-progress {
|
|
position: fixed;
|
|
inset-block-start: 0;
|
|
inset-inline: 0;
|
|
height: 3px;
|
|
z-index: 25;
|
|
background: transparent;
|
|
pointer-events: none;
|
|
}
|
|
.scroll-progress__bar {
|
|
display: block;
|
|
height: 100%;
|
|
transform-origin: 0 50%;
|
|
transform: scaleX(0);
|
|
background: linear-gradient(90deg, var(--brand-500), var(--brand-700) 55%, var(--brand-900));
|
|
opacity: 0;
|
|
transition: opacity 240ms var(--ease);
|
|
}
|
|
html.fx-motion .scroll-progress__bar {
|
|
opacity: 0.95;
|
|
}
|
|
|
|
/* ------------------------------------------------------------ keyframes */
|
|
@keyframes fx-word-in {
|
|
from {
|
|
opacity: 0;
|
|
transform: translate3d(0, 0.55em, 0) scale(0.97);
|
|
filter: blur(5px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: none;
|
|
filter: none;
|
|
}
|
|
}
|
|
@keyframes fx-drop-in {
|
|
from {
|
|
opacity: 0;
|
|
transform: translate3d(0, -14px, 0);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: none;
|
|
}
|
|
}
|
|
@keyframes fx-rise-in {
|
|
from {
|
|
opacity: 0;
|
|
transform: translate3d(0, 26px, 0) scale(0.985);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: none;
|
|
}
|
|
}
|
|
@keyframes fx-pop-in {
|
|
from {
|
|
opacity: 0;
|
|
transform: scale(0.92);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: none;
|
|
}
|
|
}
|
|
@keyframes fx-fade-in {
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
@keyframes fx-slide-in {
|
|
from {
|
|
opacity: 0;
|
|
transform: translate3d(-22px, 0, 0);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: none;
|
|
}
|
|
}
|
|
@keyframes fx-orb-a {
|
|
from {
|
|
transform: translate3d(0, 0, 0) scale(1);
|
|
}
|
|
to {
|
|
transform: translate3d(-38px, 46px, 0) scale(1.12);
|
|
}
|
|
}
|
|
@keyframes fx-orb-b {
|
|
from {
|
|
transform: translate3d(0, 0, 0) scale(1.05);
|
|
}
|
|
to {
|
|
transform: translate3d(48px, -30px, 0) scale(0.94);
|
|
}
|
|
}
|
|
@keyframes fx-sheen {
|
|
from {
|
|
transform: translate3d(-140%, 0, 0) rotate(12deg);
|
|
}
|
|
to {
|
|
transform: translate3d(240%, 0, 0) rotate(12deg);
|
|
}
|
|
}
|
|
|
|
/* ---------------------------------------------------- ฮีโร่: เข้าฉากแบบหนัง */
|
|
html.fx-motion .hero__eyebrow {
|
|
animation: fx-drop-in 520ms var(--ease) 60ms both;
|
|
}
|
|
html.fx-motion .hero__lead {
|
|
animation: fx-rise-in 620ms var(--ease) 520ms both;
|
|
}
|
|
html.fx-motion .hero__wordmark {
|
|
animation: fx-rise-in 640ms cubic-bezier(0.16, 0.84, 0.28, 1) 260ms both;
|
|
}
|
|
html.fx-motion .hero__wordmark-note {
|
|
animation: fx-fade-in 520ms var(--ease) 420ms both;
|
|
}
|
|
html.fx-motion .searchbar {
|
|
animation: fx-pop-in 680ms cubic-bezier(0.16, 0.84, 0.28, 1) 600ms both;
|
|
}
|
|
html.fx-motion .hero__meta {
|
|
animation: fx-fade-in 620ms var(--ease) 760ms both;
|
|
}
|
|
html.fx-motion .hero__deco-card {
|
|
animation: fx-slide-in 700ms var(--ease) both;
|
|
}
|
|
html.fx-motion .hero__deco-card:nth-child(1) {
|
|
animation-delay: 320ms;
|
|
}
|
|
html.fx-motion .hero__deco-card:nth-child(2) {
|
|
animation-delay: 440ms;
|
|
}
|
|
html.fx-motion .hero__deco-card:nth-child(3) {
|
|
animation-delay: 560ms;
|
|
}
|
|
|
|
/* คำในหัวเรื่อง: เลื่อนเข้ามาทีละคำ */
|
|
.fx-word {
|
|
display: inline-block;
|
|
}
|
|
.fx-word > span {
|
|
display: inline-block;
|
|
}
|
|
html.fx-motion .fx-word > span {
|
|
animation: fx-word-in 760ms cubic-bezier(0.16, 0.84, 0.28, 1) both;
|
|
animation-delay: var(--fx-delay, 0ms);
|
|
}
|
|
|
|
/* แสงอบอุ่นด้านหลังฮีโร่ — เคลื่อนช้า ๆ */
|
|
.hero__ambience {
|
|
position: absolute;
|
|
inset: 0;
|
|
overflow: hidden;
|
|
border-radius: inherit;
|
|
pointer-events: none;
|
|
z-index: 0;
|
|
}
|
|
.hero__orb {
|
|
position: absolute;
|
|
border-radius: 50%;
|
|
filter: blur(46px);
|
|
opacity: 0;
|
|
transition: opacity 900ms var(--ease);
|
|
}
|
|
.hero__orb--a {
|
|
width: 340px;
|
|
height: 340px;
|
|
inset-block-start: -130px;
|
|
inset-inline-start: -80px;
|
|
background: radial-gradient(circle at 40% 40%, rgba(217, 147, 104, 0.55), rgba(217, 147, 104, 0) 68%);
|
|
}
|
|
.hero__orb--b {
|
|
width: 420px;
|
|
height: 420px;
|
|
inset-block-end: -190px;
|
|
inset-inline-end: -60px;
|
|
background: radial-gradient(circle at 50% 50%, rgba(196, 112, 60, 0.42), rgba(196, 112, 60, 0) 70%);
|
|
}
|
|
html.fx-motion .hero__orb {
|
|
opacity: 1;
|
|
animation: fx-orb-a 19s ease-in-out infinite alternate;
|
|
}
|
|
html.fx-motion .hero__orb--b {
|
|
animation: fx-orb-b 23s ease-in-out infinite alternate;
|
|
}
|
|
|
|
/* เส้น светлоวิ่งผ่านปุ่มหลัก */
|
|
.btn--primary {
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
html.fx-motion .btn--primary::after {
|
|
content: "";
|
|
position: absolute;
|
|
inset-block: -60%;
|
|
inset-inline-start: 0;
|
|
width: 42%;
|
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
|
|
transform: translate3d(-140%, 0, 0) rotate(12deg);
|
|
pointer-events: none;
|
|
}
|
|
html.fx-motion .btn--primary:hover::after,
|
|
html.fx-motion .btn--primary:focus-visible::after {
|
|
animation: fx-sheen 900ms var(--ease);
|
|
}
|
|
|
|
/* ------------------------------------------------ reveal เมื่อเลื่อนถึง */
|
|
html.fx-motion [data-reveal] {
|
|
opacity: 0;
|
|
}
|
|
html.fx-motion [data-reveal][data-revealed] {
|
|
animation: fx-rise-in 660ms cubic-bezier(0.16, 0.84, 0.28, 1) both;
|
|
animation-delay: var(--fx-delay, 0ms);
|
|
}
|
|
html.fx-motion [data-reveal="pop"][data-revealed] {
|
|
animation-name: fx-pop-in;
|
|
}
|
|
html.fx-motion [data-reveal="fade"][data-revealed] {
|
|
animation-name: fx-fade-in;
|
|
}
|
|
html.fx-motion [data-reveal="slide"][data-revealed] {
|
|
animation-name: fx-slide-in;
|
|
}
|
|
|
|
/* การ์ดโปรเจค: ยกขึ้นเฉพาะตอน hover (ไม่ชนกับ keyframe ของ reveal) */
|
|
html.fx-motion .project-card {
|
|
will-change: transform;
|
|
}
|
|
html.fx-motion .project-card[data-revealed] {
|
|
animation-fill-mode: both;
|
|
}
|
|
|
|
/* หัวข้อ section: ขีดเส้นใต้วาดจากซ้าย */
|
|
.section-head__title {
|
|
position: relative;
|
|
display: inline-block;
|
|
padding-bottom: 6px;
|
|
}
|
|
.section-head__title::after {
|
|
content: "";
|
|
position: absolute;
|
|
inset-inline-start: 0;
|
|
inset-block-end: 0;
|
|
width: 100%;
|
|
height: 3px;
|
|
border-radius: 3px;
|
|
background: linear-gradient(90deg, var(--brand-500), var(--brand-200));
|
|
transform: scaleX(0);
|
|
transform-origin: 0 50%;
|
|
}
|
|
html.fx-motion .section-head[data-revealed] .section-head__title::after {
|
|
animation: fx-line 760ms var(--ease) 240ms both;
|
|
}
|
|
@keyframes fx-line {
|
|
from {
|
|
transform: scaleX(0);
|
|
}
|
|
to {
|
|
transform: scaleX(1);
|
|
}
|
|
}
|
|
|
|
/* ลูกเล่น hover: ไอคอนการ์ดเอียงขึ้นเล็กน้อย */
|
|
@media (hover: hover) {
|
|
.project-card:hover .project-card__icon {
|
|
transform: rotate(-4deg) scale(1.04);
|
|
transition: transform 220ms var(--ease);
|
|
}
|
|
.project-card__icon {
|
|
transition: transform 220ms var(--ease);
|
|
}
|
|
}
|
|
|
|
/* --------------------------------------------------- ทางออกสำหรับทุกกรณี */
|
|
@media (prefers-reduced-motion: reduce) {
|
|
html.fx-motion [data-reveal],
|
|
html.fx-motion [data-reveal][data-revealed],
|
|
html.fx-motion .hero__eyebrow,
|
|
html.fx-motion .hero__lead,
|
|
html.fx-motion .hero__deco-card,
|
|
html.fx-motion .fx-word > span,
|
|
html.fx-motion .section-head[data-revealed] .section-head__title::after,
|
|
html.fx-motion .btn--primary::after {
|
|
animation: none !important;
|
|
opacity: 1 !important;
|
|
transform: none !important;
|
|
filter: none !important;
|
|
}
|
|
html.fx-motion .hero__orb {
|
|
animation: none !important;
|
|
}
|
|
}
|