Files
Bkk1234 0bfbefd930 feat(hero): make the three floating cards open their project
- cards are links to the same project_url as the grid card (new tab, noopener)
- drop aria-hidden from the stack and restore pointer events; add hover/focus/active states
- entrance animation moves to the translate property with fill-mode backwards so the
  staggered offsets/rotation and the hover lift are no longer overridden
- reduced-motion keeps the stagger (translate: none) without killing the layout
2026-11-20 14:37:43 +07:00

503 lines
11 KiB
CSS

/* ==========================================================================
home.css — หน้าแรก: ฮีโร่ + ช่องค้นหา + การ์ดโปรเจค
========================================================================== */
.hero {
position: relative;
overflow: hidden;
border: 1px solid var(--border);
border-radius: var(--radius-xl);
background:
radial-gradient(120% 140% at 12% 0%, #fff 0%, var(--brand-50) 46%, var(--brand-100) 100%);
padding: var(--space-8) var(--space-5);
}
.hero__inner {
position: relative;
z-index: 1;
max-width: 46rem;
}
.hero__eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 14px;
border-radius: var(--radius-pill);
background: #fff;
border: 1px solid var(--brand-200);
color: var(--brand-700);
font-size: 13px;
font-weight: 500;
}
.hero__eyebrow svg {
width: 15px;
height: 15px;
}
.hero__title {
margin-top: var(--space-3);
font-size: clamp(1.6rem, 1.15rem + 2.05vw, 2.5rem);
letter-spacing: -0.015em;
line-height: 1.35;
max-width: 24ch;
}
/* --------------------------------------------------- คำว่า hobbyproject */
.hero__wordmark {
margin-top: var(--space-4);
font-size: clamp(1.5rem, 1.15rem + 1.05vw, 2rem);
font-weight: 700;
line-height: 1.15;
letter-spacing: -0.02em;
}
.hero__wordmark .wm-dark {
color: var(--brand-900); /* 12.21:1 บนพื้นฮีโร่เข้มสุด */
}
.hero__wordmark .wm-light {
color: var(--brand-500); /* 3.12:1 — ผ่านเกณฑ์ large text (≥24px ตัวหนา) */
}
.hero__title em {
font-style: normal;
color: var(--brand-600);
}
.hero__lead {
margin-top: var(--space-3);
max-width: 44ch;
color: #4b3a30;
font-size: clamp(0.98rem, 0.94rem + 0.3vw, 1.08rem);
}
/* ------------------------------------------------------------- searchbar */
.searchbar {
margin-top: var(--space-6);
display: flex;
align-items: center;
gap: 8px;
padding: 8px;
border: 1px solid var(--border-strong);
border-radius: var(--radius-pill);
background: #fff;
box-shadow: var(--shadow-md);
max-width: 560px;
}
.searchbar:focus-within {
border-color: var(--brand-500);
box-shadow: 0 0 0 4px rgba(196, 112, 60, 0.16);
}
.searchbar__icon {
flex: none;
margin-left: 8px;
color: var(--brand-500);
}
.searchbar__icon svg {
width: 20px;
height: 20px;
}
.searchbar input {
flex: 1 1 auto;
min-width: 0;
border: 0;
background: transparent;
padding: 8px 0;
font-size: 15px;
}
.searchbar input:focus {
outline: none;
}
.searchbar input::placeholder {
color: #8d7d73;
}
.searchbar__clear {
flex: none;
display: inline-flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: 0;
border-radius: 50%;
background: var(--brand-50);
color: var(--brand-700);
cursor: pointer;
}
.searchbar__clear[hidden] {
display: none;
}
.searchbar__clear svg {
width: 16px;
height: 16px;
}
.hero__meta {
margin-top: var(--space-5);
display: flex;
flex-wrap: wrap;
gap: var(--space-3) var(--space-6);
font-size: 14px;
color: var(--muted-foreground);
}
.hero__meta span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.hero__meta svg {
width: 16px;
height: 16px;
color: var(--brand-500);
}
/* --------------------------------------------------- ฮีโร่: การ์ดลอย (จอใหญ่) */
.hero__deco {
display: none;
}
@media (min-width: 1080px) {
.hero__deco {
display: flex;
flex-direction: column;
gap: 12px;
position: absolute;
top: 50%;
inset-inline-end: var(--space-10);
width: 302px;
transform: translateY(-50%);
}
.hero__deco-card {
display: flex;
align-items: center;
gap: 10px;
padding: 12px 16px;
border: 1px solid var(--border-strong);
border-radius: var(--radius-md);
background: #fff;
box-shadow: var(--shadow-md);
font-size: 14px;
font-weight: 500;
color: var(--brand-900);
text-decoration: none;
cursor: pointer;
transform: translateX(calc(var(--i) * 14px)) rotate(calc((var(--i) - 1) * -0.8deg));
opacity: 0.97;
transition:
border-color 180ms var(--ease),
box-shadow 180ms var(--ease),
translate 180ms var(--ease);
}
.hero__deco-card:hover,
.hero__deco-card:focus-visible {
border-color: var(--brand-300);
box-shadow: var(--shadow-lg);
opacity: 1;
translate: 0 -3px;
text-decoration: none;
}
.hero__deco-card:active {
translate: 0 -1px;
}
.hero__deco-card:nth-child(2) {
border-color: var(--brand-300);
}
.hero__deco-icon {
flex: none;
display: grid;
place-items: center;
width: 30px;
height: 30px;
border-radius: 9px;
background: var(--brand-50);
border: 1px solid var(--brand-200);
color: var(--brand-700);
}
.hero__deco-icon svg {
width: 17px;
height: 17px;
}
.hero__deco-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
/* ---------------------------------------------------------------- chips */
.chips {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: var(--space-8);
}
.chip {
display: inline-flex;
align-items: center;
gap: 7px;
min-height: 40px;
padding: 8px 16px;
border: 1px solid var(--border);
border-radius: var(--radius-pill);
background: #fff;
color: var(--brand-800);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition:
background 160ms var(--ease),
border-color 160ms var(--ease),
color 160ms var(--ease);
}
.chip:hover {
background: var(--brand-50);
border-color: var(--brand-300);
}
.chip[aria-pressed="true"] {
background: var(--brand-700);
border-color: var(--brand-700);
color: var(--on-brand);
}
.chip svg {
width: 16px;
height: 16px;
}
/* ------------------------------------------------------------- section */
.section-head {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: var(--space-4);
margin-top: var(--space-12);
margin-bottom: var(--space-5);
}
.section-head__title {
font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
}
.section-head__sub {
margin-top: 4px;
font-size: 14px;
color: var(--muted-foreground);
}
.section-head__count {
flex: none;
font-size: 13px;
color: var(--brand-700);
background: var(--brand-100);
border-radius: var(--radius-pill);
padding: 5px 12px;
font-weight: 500;
white-space: nowrap;
}
/* ---------------------------------------------------------------- grid */
.project-grid {
display: grid;
gap: var(--space-4);
grid-template-columns: 1fr;
}
.project-card {
position: relative;
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: var(--space-5);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
background: var(--surface);
transition:
border-color 180ms var(--ease),
box-shadow 180ms var(--ease),
transform 180ms var(--ease);
}
.project-card:hover,
.project-card:focus-within {
border-color: var(--brand-300);
box-shadow: var(--shadow-md);
/* ใช้ translate (คนละพร็อพเพอร์ตีกับ transform) เพื่อไม่ชนกับคีย์เฟรม reveal */
translate: 0 -3px;
}
.project-card__top {
display: flex;
align-items: flex-start;
gap: var(--space-3);
}
.project-card__icon {
flex: none;
display: grid;
place-items: center;
width: 46px;
height: 46px;
border-radius: 13px;
background: var(--brand-50);
border: 1px solid var(--brand-200);
color: var(--brand-700);
}
.project-card__icon svg {
width: 24px;
height: 24px;
}
.project-card__heading {
min-width: 0;
flex: 1 1 auto;
}
.project-card__name {
font-size: 1.02rem;
font-weight: 700;
color: var(--brand-900);
line-height: 1.35;
}
.project-card__name a {
color: inherit;
text-decoration: none;
}
.project-card__name a::after {
/* ขยายพื้นที่คลิกให้ครอบการ์ดทั้งใบ */
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
}
.project-card__name a:hover {
text-decoration: none;
}
.project-card__desc {
margin-top: 6px;
color: var(--muted-foreground);
font-size: 14.5px;
line-height: 1.55;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.project-card__foot {
margin-top: auto;
padding-top: var(--space-3);
border-top: 1px solid var(--brand-50);
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-3);
}
.project-card__host {
font-size: 13px;
color: var(--muted-foreground);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.project-card__go {
flex: none;
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 14px;
font-weight: 500;
color: var(--brand-700);
pointer-events: none;
}
.project-card__go svg {
width: 16px;
height: 16px;
transition: transform 160ms var(--ease);
}
.project-card:hover .project-card__go svg {
transform: translateX(3px);
}
.badge {
position: absolute;
top: var(--space-4);
inset-inline-end: var(--space-4);
padding: 3px 10px;
border-radius: var(--radius-pill);
background: var(--brand-100);
color: var(--brand-800);
font-size: 12px;
font-weight: 500;
}
.project-card[draggable="true"] {
cursor: grab;
}
/* ------------------------------------------------------------ empty state */
.empty {
margin-top: var(--space-4);
padding: var(--space-10) var(--space-5);
border: 1px dashed var(--border-strong);
border-radius: var(--radius-lg);
background: var(--surface-2);
text-align: center;
}
.empty__icon {
display: inline-grid;
place-items: center;
width: 48px;
height: 48px;
border-radius: 14px;
background: #fff;
border: 1px solid var(--brand-200);
color: var(--brand-600);
margin-bottom: var(--space-3);
}
.empty__icon svg {
width: 24px;
height: 24px;
}
.empty__title {
font-weight: 700;
color: var(--brand-900);
}
.empty__text {
margin-top: 6px;
color: var(--muted-foreground);
font-size: 14.5px;
}
/* -------------------------------------------------------- skeleton/loading */
.loading {
display: grid;
gap: var(--space-4);
grid-template-columns: 1fr;
margin-top: var(--space-4);
}
.skeleton {
height: 168px;
border-radius: var(--radius-lg);
border: 1px solid var(--border);
background: linear-gradient(100deg, var(--surface-2) 30%, #fff 50%, var(--surface-2) 70%);
background-size: 220% 100%;
animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer {
from {
background-position: 130% 0;
}
to {
background-position: -30% 0;
}
}
@media (min-width: 700px) {
.project-grid,
.loading {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.hero {
padding: var(--space-12) var(--space-10);
}
}
@media (min-width: 1000px) {
.project-grid,
.loading {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (prefers-reduced-motion: reduce) {
.skeleton {
animation: none;
}
.project-card:hover,
.project-card:focus-within {
transform: none;
}
}