@import url('https://cdn.jsdelivr.net/npm/@fontsource/iansui@5.0.0/index.css');

:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Iansui', 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

p.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Category Navigation */
.nav-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 3rem;
    animation: fadeIn 1s ease-out;
}

.category-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
}

.nav-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
    font-weight: 700;
    backdrop-filter: blur(10px);
}

.nav-btn.wide-btn {
    width: auto;
    height: auto;
    padding: 0.8rem 2.5rem;
    border-radius: 50px;
    font-size: 1rem;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

/* Category Specific Colors - Dim by default, Bright when active */
.nav-btn[data-category="all"].active { background: #38bdf8; color: #0f172a; }

.nav-btn[data-category="紅色"] { background: #450a0a; border-color: #7f1d1d; }
.nav-btn[data-category="紅色"].active { background: #b91c1c; box-shadow: 0 0 15px rgba(185, 28, 28, 0.5); }

.nav-btn[data-category="黃色"] { background: #422006; border-color: #78350f; }
.nav-btn[data-category="黃色"].active { background: #b45309; box-shadow: 0 0 15px rgba(180, 83, 9, 0.5); }

.nav-btn[data-category="藍色"] { background: #172554; border-color: #1e3a8a; }
.nav-btn[data-category="藍色"].active { background: #1d4ed8; box-shadow: 0 0 15px rgba(29, 78, 216, 0.5); }

.nav-btn[data-category="綠色"] { background: #022c22; border-color: #064e3b; }
.nav-btn[data-category="綠色"].active { background: #047857; box-shadow: 0 0 15px rgba(4, 120, 87, 0.5); }

.nav-btn[data-category="黑色"] { background: #020617; border-color: #1e293b; }
.nav-btn[data-category="黑色"].active { background: #334155; box-shadow: 0 0 15px rgba(51, 65, 85, 0.5); }

.nav-btn[data-category="白色"] { background: #1e293b; border-color: #475569; }
.nav-btn[data-category="白色"].active { background: #f8fafc; color: #0f172a; box-shadow: 0 0 15px rgba(248, 250, 252, 0.5); }

.nav-btn[data-category="灰色/陪色"] { background: #1e293b; border-color: #334155; }
.nav-btn[data-category="灰色/陪色"].active { background: #64748b; box-shadow: 0 0 15px rgba(100, 116, 139, 0.5); }

.nav-btn[data-category="紫色"] { background: #2e1065; border-color: #4c1d95; }
.nav-btn[data-category="紫色"].active { background: #7e22ce; box-shadow: 0 0 15px rgba(126, 34, 206, 0.5); }

.nav-btn[data-category="咖啡色/土色"] { background: #431407; border-color: #78350f; }
.nav-btn[data-category="咖啡色/土色"].active { background: #92400e; box-shadow: 0 0 15px rgba(146, 64, 14, 0.5); }

.nav-btn[data-category="非特定顏色/其他"] { background: #0f172a; border-color: #334155; }
.nav-btn[data-category="非特定顏色/其他"].active { background: #475569; box-shadow: 0 0 15px rgba(71, 85, 105, 0.5); }

.nav-btn.active {
    transform: scale(1.1);
    z-index: 10;
}

/* Color Grid */
#color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    animation: fadeInUp 1s ease-out;
}

/* Color Card */
.color-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    overflow: hidden;
    backdrop-filter: blur(12px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.color-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.card-visual {
    height: 180px;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}

.card-visual.has-image {
    background-blend-mode: normal;
}

.card-hex {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    font-size: 0.8rem;
    color: white;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-info {
    padding: 1.5rem 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.card-title, .card-reading, .card-definition {
    word-break: break-word;
    overflow-wrap: break-word;
}

.card-title {
    font-size: 1.8rem;
    font-weight: 700;
}

.card-reading {
    font-size: 1rem;
    color: var(--accent-color);
    font-weight: 500;
}

.card-definition {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

@media (max-width: 640px) {
    h1 { font-size: 2rem; }
    .container { padding: 1rem; }
    #color-grid { grid-template-columns: 1fr; }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

#modal-body .color-card {
    width: 100%;
    max-width: none;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: default;
}

#modal-body .card-visual {
    height: 400px;
    border-radius: 16px;
}

#modal-body .card-info {
    padding: 24px 0 0 0;
}

#modal-body .card-title {
    font-size: 2.5rem;
}

#modal-body .card-reading {
    font-size: 1.5rem;
}

#modal-body .card-definition {
    font-size: 1.2rem;
    -webkit-line-clamp: unset;
}

.nav-controls {
    margin-left: auto;
}

.nav-btn.accent {
    background: var(--accent-color);
    color: var(--bg-color);
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn.accent:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}
