dramaling-vocab-learning/docs/02_design/component-library/assets/styles/components.css

723 lines
14 KiB
CSS

/*
* Drama Ling Component Library - Components
* 核心元件樣式
*
* 建立日期: 2025-09-14
* 版本: v1.0
*/
/* ========================================
🎯 按鈕元件 (Buttons)
======================================== */
/* 基礎按鈕 */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--space-2);
padding: var(--space-3) var(--space-6);
border: 2px solid transparent;
border-radius: var(--radius-lg);
font-weight: 600;
font-size: var(--text-base);
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
white-space: nowrap;
font-family: inherit;
}
.btn:focus {
outline: none;
box-shadow: var(--focus-ring);
}
.btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none !important;
}
/* 主要按鈕 */
.btn-primary {
background: linear-gradient(135deg, var(--primary-teal), var(--primary-teal-light));
color: var(--background-dark);
border-color: var(--primary-teal);
}
.btn-primary:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0, 229, 204, 0.3);
}
.btn-primary:active:not(:disabled) {
transform: translateY(0);
}
/* 次要按鈕 */
.btn-secondary {
background: transparent;
color: var(--primary-teal);
border-color: var(--primary-teal);
}
.btn-secondary:hover:not(:disabled) {
background: rgba(0, 229, 204, 0.1);
transform: translateY(-1px);
}
/* 成功按鈕 */
.btn-success {
background: linear-gradient(135deg, var(--success-green), #66BB6A);
color: white;
border-color: var(--success-green);
}
.btn-success:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3);
}
/* 危險按鈕 */
.btn-danger {
background: linear-gradient(135deg, var(--error-red), #C0392B);
color: white;
border-color: var(--error-red);
}
.btn-danger:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(231, 76, 60, 0.3);
}
/* 文字按鈕 */
.btn-text {
background: transparent;
color: var(--text-secondary);
border: none;
padding: var(--space-2) var(--space-3);
}
.btn-text:hover:not(:disabled) {
color: var(--primary-teal);
background: rgba(0, 229, 204, 0.05);
}
/* 圖標按鈕 */
.btn-icon {
padding: var(--space-3);
width: 44px;
height: 44px;
border-radius: var(--radius-full);
}
/* 按鈕尺寸 */
.btn-sm {
padding: var(--space-2) var(--space-4);
font-size: var(--text-sm);
}
.btn-lg {
padding: var(--space-4) var(--space-8);
font-size: var(--text-lg);
}
/* 按鈕群組 */
.btn-group {
display: inline-flex;
border-radius: var(--radius-lg);
overflow: hidden;
}
.btn-group .btn {
border-radius: 0;
margin: 0;
}
.btn-group .btn:not(:last-child) {
border-right: 1px solid rgba(0, 0, 0, 0.1);
}
.btn-group .btn:first-child {
border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.btn-group .btn:last-child {
border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
/* ========================================
📝 輸入元件 (Input Fields)
======================================== */
/* 基礎輸入框 */
.input-group {
margin-bottom: var(--space-4);
}
.input-label {
display: block;
margin-bottom: var(--space-2);
font-weight: 600;
color: var(--text-primary);
font-size: var(--text-sm);
}
.input-label.required::after {
content: ' *';
color: var(--error-red);
}
.input-field {
width: 100%;
padding: var(--space-3) var(--space-4);
background: var(--background-secondary);
border: 2px solid var(--divider);
border-radius: var(--radius-lg);
font-size: var(--text-base);
color: var(--text-primary);
transition: all 0.3s ease;
font-family: inherit;
}
.input-field:focus {
outline: none;
background: var(--card-background);
border-color: var(--primary-teal);
box-shadow: var(--focus-ring);
}
.input-field::placeholder {
color: var(--text-tertiary);
}
/* 輸入狀態 */
.input-field.error {
border-color: var(--error-red);
background: rgba(231, 76, 60, 0.05);
}
.input-field.success {
border-color: var(--success-green);
background: rgba(76, 175, 80, 0.05);
}
/* 輸入提示 */
.input-hint {
display: block;
margin-top: var(--space-1);
font-size: var(--text-xs);
color: var(--text-tertiary);
}
.input-error {
display: block;
margin-top: var(--space-1);
font-size: var(--text-xs);
color: var(--error-red);
}
/* 圖標輸入框 */
.input-with-icon {
position: relative;
}
.input-with-icon .input-field {
padding-left: var(--space-10);
}
.input-icon {
position: absolute;
left: var(--space-4);
top: 50%;
transform: translateY(-50%);
color: var(--text-tertiary);
pointer-events: none;
}
/* 搜尋輸入框 */
.search-input {
position: relative;
}
.search-input .input-field {
padding-right: var(--space-10);
}
.search-clear {
position: absolute;
right: var(--space-4);
top: 50%;
transform: translateY(-50%);
background: transparent;
border: none;
color: var(--text-tertiary);
cursor: pointer;
padding: var(--space-1);
transition: color 0.2s ease;
}
.search-clear:hover {
color: var(--text-primary);
}
/* 文字區域 */
.textarea {
min-height: 120px;
resize: vertical;
}
/* ========================================
🃏 卡片元件 (Cards)
======================================== */
/* 基礎卡片 */
.card {
background: var(--card-background);
border-radius: var(--radius-xl);
padding: var(--space-6);
border: 1px solid var(--divider);
transition: all 0.3s ease;
}
.card:hover {
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
transform: translateY(-2px);
}
/* 卡片頭部 */
.card-header {
padding-bottom: var(--space-4);
margin-bottom: var(--space-4);
border-bottom: 1px solid var(--divider);
}
.card-title {
font-size: var(--text-lg);
font-weight: 700;
color: var(--text-primary);
margin: 0;
}
.card-subtitle {
font-size: var(--text-sm);
color: var(--text-secondary);
margin-top: var(--space-1);
}
/* 卡片內容 */
.card-body {
color: var(--text-secondary);
line-height: 1.6;
}
/* 卡片底部 */
.card-footer {
padding-top: var(--space-4);
margin-top: var(--space-4);
border-top: 1px solid var(--divider);
display: flex;
justify-content: space-between;
align-items: center;
}
/* 互動卡片 */
.card-interactive {
cursor: pointer;
position: relative;
overflow: hidden;
}
.card-interactive::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: linear-gradient(90deg, var(--primary-teal), var(--accent-violet));
transform: scaleX(0);
transition: transform 0.3s ease;
}
.card-interactive:hover::before {
transform: scaleX(1);
}
/* 學習卡片 */
.card-learning {
background: linear-gradient(135deg, var(--card-background), rgba(0, 229, 204, 0.05));
border: 2px solid var(--primary-teal);
}
.card-learning .card-progress {
margin-top: var(--space-4);
padding-top: var(--space-4);
border-top: 1px solid rgba(0, 229, 204, 0.2);
}
.progress-bar {
width: 100%;
height: 8px;
background: rgba(0, 229, 204, 0.2);
border-radius: var(--radius-full);
overflow: hidden;
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, var(--primary-teal), var(--primary-teal-light));
border-radius: inherit;
transition: width 0.6s ease;
}
/* 成就卡片 */
.card-achievement {
text-align: center;
position: relative;
overflow: visible;
}
.achievement-icon {
width: 80px;
height: 80px;
margin: 0 auto var(--space-4);
background: linear-gradient(135deg, var(--gold), var(--warning-yellow));
border-radius: var(--radius-full);
display: flex;
align-items: center;
justify-content: center;
font-size: var(--text-2xl);
box-shadow: 0 8px 32px rgba(255, 215, 0, 0.3);
}
.achievement-locked {
filter: grayscale(1);
opacity: 0.5;
}
/* ========================================
🔔 警告元件 (Alerts)
======================================== */
/* 基礎警告 */
.alert {
padding: var(--space-4) var(--space-5);
border-radius: var(--radius-lg);
border-left: 4px solid transparent;
margin-bottom: var(--space-4);
display: flex;
align-items: center;
gap: var(--space-3);
animation: alertSlideIn 0.3s ease-out;
}
@keyframes alertSlideIn {
from {
opacity: 0;
transform: translateX(-20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
/* 警告圖標 */
.alert-icon {
flex-shrink: 0;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
}
/* 警告內容 */
.alert-content {
flex: 1;
}
.alert-title {
font-weight: 600;
margin-bottom: var(--space-1);
}
.alert-message {
font-size: var(--text-sm);
line-height: 1.5;
}
/* 關閉按鈕 */
.alert-close {
flex-shrink: 0;
background: transparent;
border: none;
color: inherit;
opacity: 0.6;
cursor: pointer;
padding: var(--space-1);
transition: opacity 0.2s ease;
}
.alert-close:hover {
opacity: 1;
}
/* 成功警告 */
.alert-success {
background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(76, 175, 80, 0.05));
border-left-color: var(--success-green);
color: var(--success-green);
}
/* 錯誤警告 */
.alert-error {
background: linear-gradient(135deg, rgba(231, 76, 60, 0.1), rgba(231, 76, 60, 0.05));
border-left-color: var(--error-red);
color: var(--error-red);
}
/* 警告警告 */
.alert-warning {
background: linear-gradient(135deg, rgba(243, 156, 18, 0.1), rgba(243, 156, 18, 0.05));
border-left-color: var(--warning-yellow);
color: var(--warning-yellow);
}
/* 資訊警告 */
.alert-info {
background: linear-gradient(135deg, rgba(0, 229, 204, 0.1), rgba(0, 229, 204, 0.05));
border-left-color: var(--primary-teal);
color: var(--primary-teal);
}
/* ========================================
🏷️ 徽章元件 (Badges)
======================================== */
.badge {
display: inline-flex;
align-items: center;
padding: var(--space-1) var(--space-2);
border-radius: var(--radius-full);
font-size: var(--text-xs);
font-weight: 600;
white-space: nowrap;
}
.badge-primary {
background: var(--primary-teal);
color: var(--background-dark);
}
.badge-secondary {
background: var(--secondary-purple);
color: white;
}
.badge-success {
background: var(--success-green);
color: white;
}
.badge-danger {
background: var(--error-red);
color: white;
}
.badge-warning {
background: var(--warning-yellow);
color: var(--background-dark);
}
.badge-info {
background: var(--info-cyan);
color: white;
}
/* 等級徽章 */
.badge-level {
background: linear-gradient(135deg, var(--level-background), var(--secondary-purple-dark));
color: white;
padding: var(--space-1) var(--space-3);
font-size: var(--text-sm);
font-weight: 700;
box-shadow: 0 4px 12px rgba(142, 68, 173, 0.3);
}
/* ========================================
🔄 載入元件 (Loading)
======================================== */
.spinner {
width: 40px;
height: 40px;
border: 3px solid var(--divider);
border-top-color: var(--primary-teal);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.spinner-sm {
width: 20px;
height: 20px;
border-width: 2px;
}
.spinner-lg {
width: 60px;
height: 60px;
border-width: 4px;
}
/* 骨架屏 */
.skeleton {
background: linear-gradient(90deg, var(--divider) 25%, var(--background-secondary) 50%, var(--divider) 75%);
background-size: 200% 100%;
animation: shimmer 1.5s infinite;
border-radius: var(--radius-sm);
}
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
.skeleton-text {
height: 14px;
margin-bottom: var(--space-2);
}
.skeleton-title {
height: 24px;
width: 60%;
margin-bottom: var(--space-3);
}
.skeleton-avatar {
width: 48px;
height: 48px;
border-radius: var(--radius-full);
}
/* ========================================
📊 進度條元件 (Progress)
======================================== */
.progress {
width: 100%;
height: 8px;
background: var(--divider);
border-radius: var(--radius-full);
overflow: hidden;
}
.progress-bar {
height: 100%;
background: linear-gradient(90deg, var(--primary-teal), var(--primary-teal-light));
border-radius: inherit;
transition: width 0.6s ease;
position: relative;
}
.progress-bar::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
animation: progressShimmer 2s infinite;
}
@keyframes progressShimmer {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
.progress-lg {
height: 12px;
}
.progress-striped .progress-bar {
background-image: linear-gradient(
45deg,
rgba(255, 255, 255, 0.15) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, 0.15) 50%,
rgba(255, 255, 255, 0.15) 75%,
transparent 75%,
transparent
);
background-size: 1rem 1rem;
animation: progressStripe 1s linear infinite;
}
@keyframes progressStripe {
0% { background-position: 1rem 0; }
100% { background-position: 0 0; }
}
/* ========================================
🎮 遊戲化元件
======================================== */
/* 生命值 */
.life-bar {
display: flex;
gap: var(--space-1);
align-items: center;
}
.life-heart {
font-size: var(--text-xl);
color: var(--error-red);
transition: all 0.3s ease;
}
.life-heart.empty {
color: var(--text-tertiary);
opacity: 0.3;
}
.life-heart.pulse {
animation: heartPulse 0.6s ease;
}
@keyframes heartPulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.2); }
}
/* 星級評分 */
.star-rating {
display: flex;
gap: var(--space-1);
}
.star {
font-size: var(--text-xl);
color: var(--star-inactive);
cursor: pointer;
transition: all 0.2s ease;
}
.star.active {
color: var(--star-active);
transform: scale(1.1);
}
.star:hover {
color: var(--star-active);
transform: scale(1.2);
}