Files
programming-fengshui/style.css
T
tiennm99 5efccffede feat: add classic/modern dual-mode with HSL color classifier
Classic mode reproduces the 2018 toidicodedao image and its 5 hardcoded
element cards verbatim. Modern mode renders a data-driven grid built from
GitHub Linguist colors classified into Ngũ Hành elements via a deterministic
HSL rule set. Toggle persists via URL hash; both panels coexist in DOM with
a CSS opacity fade. Includes a collapsed debug panel listing skipped (no
color) and borderline (near hue boundary) entries.

- data/github-colors.json: vendored from ozh/github-colors (722 entries)
- js/classify-element.js: pure HSL classifier (664 lang sample, 22/22 fixtures pass)
- js/mode-toggle.js: tablist with hash persistence + arrow-key nav
- js/render-elements.js: chip rendering with YIQ contrast + debug panel
- js/main.js: fetch + classify + render entry point
- style.css: segmented toggle, panel fade, chip pill, debug-panel, mobile
2026-04-27 09:19:18 +07:00

322 lines
5.6 KiB
CSS

:root {
--bg: #fdf6ec;
--fg: #2b2118;
--muted: #6b5a48;
--accent: #b8312f;
--gold: #c79b3c;
--card-bg: #ffffff;
--shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
--kim: #d4af37;
--thuy: #2e6fb5;
--moc: #3a8f4a;
--hoa: #c0392b;
--tho: #8a6d3b;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
}
body {
font-family: "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
background: var(--bg);
color: var(--fg);
line-height: 1.55;
}
.page {
max-width: 880px;
margin: 0 auto;
padding: 2.5rem 1.25rem 3rem;
}
.hero {
text-align: center;
margin-bottom: 2rem;
}
.hero h1 {
margin: 0;
font-size: clamp(1.6rem, 4vw, 2.4rem);
color: var(--accent);
letter-spacing: 0.5px;
}
.hero .subtitle {
margin: 0.5rem 0 0;
color: var(--muted);
font-style: italic;
}
.figure {
display: flex;
justify-content: center;
margin: 1.5rem 0 2.5rem;
}
.figure figure {
margin: 0;
background: var(--card-bg);
padding: 1rem;
border-radius: 12px;
box-shadow: var(--shadow);
max-width: 100%;
}
.figure img {
display: block;
max-width: 100%;
height: auto;
border-radius: 8px;
}
.figure figcaption {
text-align: center;
margin-top: 0.75rem;
color: var(--muted);
font-size: 0.9rem;
}
.elements h2,
.credit h2 {
text-align: center;
color: var(--accent);
margin: 2rem 0 1rem;
}
.grid {
display: grid;
gap: 0.9rem;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.card {
background: var(--card-bg);
border-radius: 10px;
padding: 1rem 1rem 1.1rem;
box-shadow: var(--shadow);
border-top: 4px solid var(--gold);
transition: transform 0.15s ease;
}
.card:hover {
transform: translateY(-2px);
}
.card h3 {
margin: 0 0 0.4rem;
font-size: 1.1rem;
letter-spacing: 1px;
}
.card p {
margin: 0;
color: var(--muted);
}
.card.kim { border-top-color: var(--kim); }
.card.kim h3 { color: var(--kim); }
.card.thuy { border-top-color: var(--thuy); }
.card.thuy h3 { color: var(--thuy); }
.card.moc { border-top-color: var(--moc); }
.card.moc h3 { color: var(--moc); }
.card.hoa { border-top-color: var(--hoa); }
.card.hoa h3 { color: var(--hoa); }
.card.tho { border-top-color: var(--tho); }
.card.tho h3 { color: var(--tho); }
.disclaimer {
text-align: center;
color: var(--muted);
font-size: 0.85rem;
margin-top: 1rem;
}
.credit {
margin-top: 2.5rem;
background: var(--card-bg);
border-radius: 12px;
padding: 1.25rem 1.5rem;
box-shadow: var(--shadow);
}
.credit p {
margin: 0.4rem 0;
}
.credit ul {
margin: 0.5rem 0 0.75rem 1.25rem;
padding: 0;
}
.credit a {
color: var(--accent);
text-decoration: none;
border-bottom: 1px dotted var(--accent);
}
.credit a:hover {
color: var(--gold);
border-bottom-color: var(--gold);
}
.credit .note {
font-size: 0.85rem;
color: var(--muted);
font-style: italic;
}
/* ===== Dual-mode toggle + panels ===== */
.mode-toggle {
display: flex;
justify-content: center;
gap: 0.5rem;
margin: 1rem 0 1.5rem;
}
.mode-toggle [role="tab"] {
font: inherit;
padding: 0.45rem 1rem;
border-radius: 999px;
border: 1px solid var(--muted);
background: var(--card-bg);
color: var(--fg);
cursor: pointer;
transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.mode-toggle [role="tab"][aria-selected="true"] {
background: var(--accent);
color: #fff;
border-color: var(--accent);
}
.mode-toggle [role="tab"]:hover {
border-color: var(--accent);
}
.mode-toggle [role="tab"]:focus-visible {
outline: 2px solid var(--gold);
outline-offset: 2px;
}
[role="tabpanel"][hidden] { display: none; }
.mode-tag {
font-size: 0.85rem;
font-style: italic;
color: var(--muted);
font-weight: normal;
margin-left: 0.4rem;
}
.original-image {
margin: 2rem 0 0;
background: var(--card-bg);
padding: 0.75rem 1rem;
border-radius: 12px;
box-shadow: var(--shadow);
}
.original-image summary {
cursor: pointer;
color: var(--muted);
font-style: italic;
}
.original-image figure { margin: 0.75rem 0 0; }
.original-image img {
display: block;
max-width: 100%;
height: auto;
border-radius: 8px;
}
.original-image figcaption {
text-align: center;
margin-top: 0.5rem;
color: var(--muted);
font-size: 0.9rem;
}
@media (prefers-reduced-motion: no-preference) {
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
[role="tabpanel"]:not([hidden]) { animation: fadeIn 150ms ease; }
}
/* ===== Chip grid (modern panel) ===== */
.card-count {
display: block;
margin: 0 0 0.6rem;
color: var(--muted);
font-size: 0.8rem;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 0.35rem;
}
.chip {
display: inline-block;
padding: 0.18rem 0.55rem;
border-radius: 999px;
font-size: 0.78rem;
line-height: 1.4;
border: 1px solid rgba(0, 0, 0, 0.08);
white-space: nowrap;
background: var(--bg);
color: var(--fg);
}
.legend {
text-align: center;
font-style: italic;
color: var(--muted);
font-size: 0.85rem;
margin: 1rem 0 0;
}
.render-error {
text-align: center;
color: var(--accent);
padding: 1rem;
border: 1px dashed var(--accent);
border-radius: 8px;
}
#debug-panel {
margin-top: 1rem;
background: var(--card-bg);
padding: 0.75rem 1rem;
border-radius: 8px;
box-shadow: var(--shadow);
font-size: 0.9rem;
}
#debug-panel summary {
cursor: pointer;
color: var(--muted);
}
#debug-panel h4 {
margin: 0.75rem 0 0.4rem;
font-size: 0.9rem;
color: var(--fg);
}
@media (max-width: 500px) {
.chip { font-size: 0.72rem; padding: 0.15rem 0.45rem; }
.grid { grid-template-columns: 1fr; }
.mode-toggle [role="tab"] { padding: 0.35rem 0.75rem; font-size: 0.9rem; }
}