/*
 * Yi Cheng Perspective - Theme CSS Variables
 * 三種視覺主題定義 (FR-05, FR-06)
 * 個人化閱讀設定 (US-21, FR-46, FR-47)
 * Dark / Natural / Custom
 */

/* ========================================
   Dark Theme (Default)
   ======================================== */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #b8b8b8;
    --text-muted: #888888;
    --accent-color: #e94560;
    --accent-hover: #ff6b6b;
    --border-color: #333333;
    --card-bg: #16213e;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --link-color: #4dabf7;
    --link-hover: #74c0fc;
    --success-color: #51cf66;
    --warning-color: #fcc419;
    --error-color: #ff6b6b;
}

/* Texture Background for Dark Theme */
[data-theme="dark"] body {
    background-image: url('/images/bg-texture-dark.png');
    background-repeat: repeat;
    background-attachment: fixed;
}

/* ========================================
   Natural Theme (Light)
   ======================================== */
[data-theme="natural"] {
    --bg-primary: #f5f5dc;
    --bg-secondary: rgba(255, 255, 255, 0.95);
    /* High opacity White for clear Header/Footer */
    --bg-tertiary: #fffaf0;
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #707070;
    --accent-color: #00838f;
    /* Teal */
    --accent-hover: #006064;
    --border-color: #e0e0e0;
    --card-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --link-color: #0277bd;
    --link-hover: #01579b;
    --success-color: #2e7d32;
    --warning-color: #f9a825;
    --error-color: #c62828;


}

/* Natural Theme Specific Overrides */
[data-theme="natural"] .badge,
[data-theme="natural"] .badge.bg-secondary {
    background-color: var(--accent-color) !important;
    color: white !important;
}

[data-theme="natural"] .nav-link {
    color: var(--text-primary) !important;
}

[data-theme="natural"] .navbar-brand {
    color: var(--text-primary) !important;
}

[data-theme="natural"] .nav-link:hover,
[data-theme="natural"] .nav-link.active {
    color: var(--accent-color) !important;
}

[data-theme="natural"] .navbar-toggler-icon {
    filter: invert(1);
}

/* Texture Background for Natural Theme */
[data-theme="natural"] body {
    background-image: url('/images/bg-texture.png');
    background-repeat: repeat;
    background-attachment: fixed;
}

/* Readability Fix: Content Background */
[data-theme="natural"] .article-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-top: 1rem;
    margin-bottom: 2rem;
}

/* ========================================
   Custom Theme (High Contrast)
   ======================================== */
[data-theme="custom"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-color: #58a6ff;
    --accent-hover: #79c0ff;
    --border-color: #30363d;
    --card-bg: #161b22;
    --shadow-color: rgba(0, 0, 0, 0.6);
    --link-color: #58a6ff;
    --link-hover: #79c0ff;
    --success-color: #3fb950;
    --warning-color: #d29922;
    --error-color: #f85149;


}

/* ========================================
   Apply Theme Variables
   ======================================== */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.navbar {
    background-color: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color);
}

.card {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.footer {
    background-color: var(--bg-secondary) !important;
    border-top: 1px solid var(--border-color);
}

a {
    color: var(--link-color);
}

a:hover {
    color: var(--link-hover);
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-primary {
    color: var(--accent-color) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-warning {
    color: var(--warning-color) !important;
}

.text-danger {
    color: var(--error-color) !important;
}

.btn-primary {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-outline-primary {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-outline-primary:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--bg-primary);
}

.badge.bg-secondary {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary);
}

.form-control {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--accent-color), 0.25);
}

.sidebar {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
}

/* Scrollbar styling for dark themes */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}





/* ========================================
   Global Post Styles (Aggressive Overrides)
   確保圖片縮放與閱讀設定全域生效
   ======================================== */


/* 限制內容寬度 */
.post-content,
.article-content,
article {
    max-width: 900px;
    margin: 0 auto;
}

/* 強制圖片縮放 (處理 Markdown 轉 HTML 後的圖片) */
.post-content img,
.article-content img,
.article-content p img,
article img,
.post-content p img,
article p img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 70vh !important;
    object-fit: contain !important;
    display: block !important;
    margin: 1.5rem auto !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Social Icon Visibility Fix */
.social-icon {
    color: var(--text-primary) !important;
    transition: color 0.3s ease;
}

.social-icon:hover {
    color: var(--accent-color) !important;
}

/* GLOBAL RESET: EMERGENCY FIX */
img {
    max-width: 100% !important;
    height: auto !important;
    box-sizing: border-box !important;
}