/*
 * Yi Cheng Perspective - Main Stylesheet
 * 主要樣式表，包含基礎樣式與按鈕互動效果
 */

/* ========================================
   CSS Variables (主題系統)
   ======================================== */
:root {
    /* Dark Theme (預設) */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #a0a0a0;
    --accent-color: #e94560;
    --accent-hover: #ff6b6b;
    --border-color: #2a2a4a;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

[data-theme="natural"] {
    /* Natural Theme (羊皮紙色) */
    --bg-primary: #f5deb3;
    --bg-secondary: #faebd7;
    --bg-card: #fffaf0;
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #777777;
    --accent-color: #8b4513;
    --accent-hover: #a0522d;
    --border-color: #d2b48c;
    --shadow-color: rgba(139, 69, 19, 0.2);
}

[data-theme="custom"] {
    /* Custom Theme (可由使用者自訂) */
    --bg-primary: #2d2d2d;
    --bg-secondary: #3d3d3d;
    --bg-card: #4d4d4d;
    --text-primary: #f0f0f0;
    --text-secondary: #d0d0d0;
    --text-muted: #a0a0a0;
    --accent-color: #00bcd4;
    --accent-hover: #26c6da;
    --border-color: #5d5d5d;
    --shadow-color: rgba(0, 0, 0, 0.4);
}

/* ========================================
   Base Styles
   ======================================== */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}

/* ========================================
   Button Styles (FR-31)
   ======================================== */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px var(--shadow-color);
}

.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);
}

/* ========================================
   Card Styles
   ======================================== */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-color);
}

/* ========================================
   Sidebar Styles (FR-07)
   ======================================== */
.sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
}

/* ========================================
   Content Protection (FR-08)
   ======================================== */
.content-protected,
.content-protected *,
.article-content,
.article-content * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-user-drag: none !important;
    cursor: default;
}

/* 隱藏意外選取的文字 */
.content-protected::selection,
.content-protected *::selection,
.article-content::selection,
.article-content *::selection {
    background: transparent !important;
    color: inherit !important;
}

.content-protected::-moz-selection,
.content-protected *::-moz-selection,
.article-content::-moz-selection,
.article-content *::-moz-selection {
    background: transparent !important;
    color: inherit !important;
}

.content-protected pre,
.content-protected code,
.content-protected pre *,
.content-protected code *,
.article-content pre,
.article-content code,
.article-content pre *,
.article-content code * {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    cursor: text;
}

/* 程式碼區塊允許可見選取 */
.content-protected pre::selection,
.content-protected code::selection,
.content-protected pre *::selection,
.content-protected code *::selection,
.article-content pre::selection,
.article-content code::selection,
.article-content pre *::selection,
.article-content code *::selection {
    background: rgba(100, 149, 237, 0.4) !important;
    color: inherit !important;
}

.content-protected pre::-moz-selection,
.content-protected code::-moz-selection,
.content-protected pre *::-moz-selection,
.content-protected code *::-moz-selection,
.article-content pre::-moz-selection,
.article-content code::-moz-selection,
.article-content pre *::-moz-selection,
.article-content code *::-moz-selection {
    background: rgba(100, 149, 237, 0.4) !important;
    color: inherit !important;
}

/* ========================================
   Touch Targets (FR-42)
   ======================================== */
.social-icon,
.nav-link,
.btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Responsive Utilities
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        position: relative;
        top: 0;
    }
}

/* ========================================
   Responsive Images (US-19, FR-22)
   圖片自動符合視窗大小
   ======================================== */
.post-content img,
.article-content img,
article img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 70vh;
    /* 最大高度不超過視窗 70% */
    object-fit: contain;
    display: block;
    margin: 1.5rem auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
}

/* 限制圖片容器寬度以提升閱讀體驗 */
.post-content,
.article-content {
    max-width: 900px;
    margin: 0 auto;
}

/* ========================================
   Magnetic Parallax Effect (US-20)
   圖片懸停微互動視覺增強
   ======================================== */
.post-content img,
.article-content img,
article img {
    cursor: pointer;
    transition: transform 0.2s ease-out, box-shadow 0.3s ease;
}

.post-content img:hover,
.article-content img:hover,
article img:hover {
    box-shadow: 0 8px 24px var(--shadow-color);
}