/* ============================================================
   article-style.css — 阿偉的物理 x AI 實驗室
   教學文章統一樣式表 (Article Template Style)
   版本 1.0 | 2026-04
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;900&display=swap');

/* ── CSS 品牌變數（繼承主站風格）── */
:root {
    --brand-primary:    #657954;
    --brand-dark:       #4a5e3a;
    --brand-light:      #eef4ea;
    --action-blue:      #3B82F6;
    --bg-light:         #F8FAFC;
    --bg-white:         #ffffff;
    --text-main:        #1E293B;
    --text-muted:       #64748B;
    --border-color:     #E2E8F0;
    --shadow-sm:        0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md:        0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg:        0 8px 32px rgba(0, 0, 0, 0.10);
    --radius-sm:        8px;
    --radius-md:        12px;
    --radius-lg:        16px;
    --art-max-width:    860px;    /* 最大閱讀寬度，防止長螢幕文字過長 */
    --art-navbar-h:     56px;    /* 文章頁 Navbar 高度 */
}

/* ── 全局重置 ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    /* 確保文章頁面捲動順暢 */
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.85;
    overflow-x: hidden;
    /* 允許文章整頁垂直捲動 */
    overflow-y: auto;
}

/* ============================================================
   NAVBAR（簡易文章頁頂欄）
   【注意】文章頁面嵌入 App Shell iframe 時，以下 Navbar 樣式不會作用。
   僅在「獨立瀏覽」模式（直接開啟 .html 檔案）時才需要此樣式。
   ============================================================ */
.art-navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--art-navbar-h);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 16px;
}

.art-navbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--brand-primary);
    font-weight: 900;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.art-navbar-logo:hover { opacity: 0.75; }

.art-back-btn {
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    white-space: nowrap;
}
.art-back-btn:hover {
    background: var(--brand-light);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* ============================================================
   主內容框架
   ============================================================ */
.art-main {
    width: 100%;
    padding-bottom: 60px;
}

/* ── 窄版容器：限制文字最大閱讀寬度，左右置中 ── */
.art-container {
    max-width: var(--art-max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* ── 寬版容器：供模擬器使用，突破文字閱讀寬度限制 ── */
/* ★ art-container-wide：最大寬 1200px，模擬器在大螢幕可以充分展開 */
.art-container-wide {
    max-width: 1200px;
    width: 100%;          /* 手機版自動縮小至螢幕寬度，不會爆版 */
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
   HERO 主視覺區
   ============================================================ */
.art-hero {
    background: linear-gradient(
        135deg,
        var(--brand-dark) 0%,
        var(--brand-primary) 60%,
        #7a9468 100%
    );
    color: #ffffff;
    padding: 56px 0 48px;
    position: relative;
    overflow: hidden;
}

/* 裝飾性背景圓圈 */
.art-hero::before {
    content: '';
    position: absolute;
    top: -80px;
    right: -80px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    pointer-events: none;
}
.art-hero::after {
    content: '';
    position: absolute;
    bottom: -60px;
    left: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

/* 麵包屑導航 */
.art-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.art-breadcrumb a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s;
}
.art-breadcrumb a:hover { color: #fff; }
.art-breadcrumb .art-current-page { color: rgba(255, 255, 255, 0.5); }

/* 主標題 */
.art-hero-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 900;
    line-height: 1.25;
    letter-spacing: -0.5px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

/* 副標 */
.art-hero-subtitle {
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.7;
    max-width: 600px;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

/* Meta 標籤列 */
.art-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.art-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.art-tag-mechanics {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}
.art-tag-kinematics {
    background: rgba(59, 130, 246, 0.25);
    color: #ffffff;
    border: 1px solid rgba(59, 130, 246, 0.4);
}
.art-tag-em {
    background: rgba(139, 92, 246, 0.25);
    color: #ffffff;
    border: 1px solid rgba(139, 92, 246, 0.4);
}
.art-tag-measurement {
    background: rgba(13, 148, 136, 0.25);
    color: #ffffff;
    border: 1px solid rgba(13, 148, 136, 0.4);
}
.art-tag-level {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.art-tag-time {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ============================================================
   封面大圖
   ============================================================ */
.art-cover-img-wrap {
    background: var(--bg-light);
    padding: 32px 0;
}

.art-cover-figure {
    margin: 0;
}

.art-cover-img {
    width: 100%;
    height: auto;
    max-height: 480px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: block;
}

.art-cover-caption {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* ============================================================
   通用 Section 間距
   ============================================================ */
.art-section {
    padding: 48px 0;
    border-bottom: 1px solid var(--border-color);
}
.art-section:last-of-type {
    border-bottom: none;
}

/* 深色背景 Section（模擬區） */
.art-section-sim {
    background: #0f172a;
    border-bottom: none;
    padding: 56px 0;
}
.art-section-sim .art-section-title {
    color: #f1f5f9;
}
.art-section-sim .art-body-text {
    color: #94a3b8;
}

/* 影片 Section */
.art-section-video {
    background: var(--bg-white);
}

/* Section 標題 */
.art-section-title {
    font-size: clamp(1.25rem, 2.5vw, 1.6rem);
    font-weight: 900;
    color: var(--text-main);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--brand-primary);
    display: inline-block;
}

/* ============================================================
   引言與知識點卡片
   ============================================================ */
.art-intro-block {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 32px;
    font-size: 1.05rem;
    color: var(--text-main);
    line-height: 1.9;
}

.art-intro-block p { margin: 0; }

.art-knowledge-card {
    background: var(--brand-light);
    border: 1px solid #c4d9b8;
    border-left: 5px solid var(--brand-primary);
    border-radius: var(--radius-md);
    padding: 24px 28px;
}

.art-knowledge-title {
    font-size: 1rem;
    font-weight: 900;
    color: var(--brand-dark);
    margin-bottom: 14px;
}

.art-knowledge-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.art-knowledge-list li {
    position: relative;
    padding-left: 28px;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.6;
}

.art-knowledge-list li::before {
    content: '✅';
    position: absolute;
    left: 0;
    top: 2px;
}

/* ============================================================
   文章內文排版
   ============================================================ */
.art-body-text {
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.9;
    margin-bottom: 20px;
}

/* ============================================================
   數學公式區塊
   ============================================================ */
.art-formula-block {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px 28px;
    margin: 28px 0;
}

.art-formula-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.art-formula {
    font-size: 1.2rem;
    text-align: center;
    padding: 16px 0;
    overflow-x: auto;
}

.art-formula-legend {
    list-style: none;
    padding: 0;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.art-formula-legend li strong {
    color: var(--text-main);
    font-family: 'Courier New', monospace;
    background: rgba(59, 130, 246, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
}

/* ============================================================
   提示/資訊框（三種樣式）
   ============================================================ */

/* 共用基礎 */
.art-info-box, .art-tip-box, .art-warning-box {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    margin: 24px 0;
    font-size: 0.93rem;
    line-height: 1.7;
}

.art-info-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    line-height: 1.4;
}

/* 資訊（藍） */
.art-info-box {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    color: #1e3a62;
}

/* 提示（綠） */
.art-tip-box {
    background: var(--brand-light);
    border: 1px solid #c4d9b8;
    color: #263d1e;
}

/* 警告（橘） */
.art-warning-box {
    background: #FFF7ED;
    border: 1px solid #FED7AA;
    color: #7c2d12;
}

/* ============================================================
   比較表格
   ============================================================ */
.art-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin: 28px 0;
    box-shadow: var(--shadow-sm);
}

.art-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    min-width: 480px;
}

.art-table caption {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 10px 16px;
    text-align: left;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    caption-side: top;
    font-weight: 700;
}

.art-table thead th {
    background: var(--brand-light);
    color: var(--brand-dark);
    font-weight: 700;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid #c4d9b8;
}

.art-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.art-table tbody tr:last-child td {
    border-bottom: none;
}

.art-table tbody tr:hover td {
    background: var(--bg-light);
}

/* ============================================================
   互動模擬容器 ⭐️（核心功能）
   ============================================================ */
.art-sim-container {
    position: relative;                /* 讓全螢幕按鈕能絕對定位 */
    width: 100%;
    height: clamp(400px, 72vh, 640px); /* 最小 400px，最大 640px */
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 28px rgba(0, 0, 0, 0.35);
    background: #111827;               /* loading 前的佔位背景色 */
    margin: 24px 0 12px;
}

/* iframe 本體：填滿容器 */
.art-sim-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* 全螢幕按鈕（右下角懸浮） */
.art-fullscreen-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 20;

    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;

    background: rgba(15, 23, 42, 0.70);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;

    font-size: 0.85rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, border-color 0.2s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.art-fullscreen-btn:hover {
    background: rgba(101, 121, 84, 0.85);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.03);
}

.art-fullscreen-btn:active {
    transform: scale(0.97);
}

/* 全螢幕圖示文字 */
#fullscreenIcon {
    font-size: 1rem;
    line-height: 1;
}

/* 手機版隱藏文字標籤，只顯示 icon */
@media (max-width: 480px) {
    .art-fullscreen-label { display: none; }
    .art-fullscreen-btn { padding: 8px 10px; }
}

/* 全螢幕狀態下的容器調整（桌機 / Android Chrome / iPadOS Safari） */
.art-sim-container:fullscreen,
.art-sim-container:-webkit-full-screen,
.art-sim-container:-moz-full-screen {
    border-radius: 0;
    width: 100vw;
    height: 100vh;
}

/* ── iOS 偽全螢幕降級方案（iPhone Safari 不支援 requestFullscreen） ──
   由 article-script.js 偵測 API 不支援時動態套用此 class。
   使用 position:fixed 模擬全螢幕，覆蓋整個視口。
   退出時移除此 class 即可恢復原狀。 ── */
.ios-pseudo-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background-color: #1a1a1a; /* 配合模擬器暗色主題 */
    /* 確保偽全螢幕下的全螢幕按鈕仍可見並保持在右下角 */
}

/* 偽全螢幕模式時，按鈕固定在畫面右下角 */
.ios-pseudo-fullscreen .art-fullscreen-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100000; /* 高於容器的 z-index */
}

/* 操作提示文字 */
.art-sim-hint {
    font-size: 0.85rem;
    color: #64748b;
    text-align: center;
    margin-top: 8px;
    padding: 0 8px;
}

.art-section-sim .art-sim-hint {
    color: #64748b;
}

/* ============================================================
   YouTube 影片 Grid
   ============================================================ */
.art-video-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-top: 24px;
}

/* 手機版：堆疊為單欄 */
@media (max-width: 640px) {
    .art-video-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.art-video-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 16:9 影片比例容器 */
.art-video-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #0f172a;
    box-shadow: var(--shadow-md);
}

.art-video-wrap iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.art-video-caption {
    font-size: 0.83rem;
    color: var(--text-muted);
    text-align: center;
}

/* ============================================================
   延伸思考習題區
   ============================================================ */
.art-question-list {
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 28px;
    counter-reset: question-counter;
}

.art-question-list li {
    position: relative;
    font-size: 0.97rem;
    color: var(--text-main);
    line-height: 1.75;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px 16px 68px; /* Left padding makes room for absolute ::before badge */
    box-shadow: var(--shadow-sm);
    counter-increment: question-counter;
}

.art-question-list li::before {
    content: 'Q' counter(question-counter);
    position: absolute;
    left: 20px;
    top: 18px; /* Aligns with the first line of text */
    font-size: 0.72rem;
    font-weight: 900;
    color: var(--brand-primary);
    background: var(--brand-light);
    border: 1.5px solid #c4d9b8;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

/* ============================================================
   AI 助教 CTA
   ============================================================ */
.art-ai-cta {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #f0fdf4, #fafffe);
    border: 1.5px solid #c4d9b8;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.art-ai-cta-icon {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1;
}

.art-ai-cta-text {
    font-size: 0.93rem;
    color: var(--text-main);
    line-height: 1.75;
}

/* ============================================================
   響應式斷點
   ============================================================ */
@media (max-width: 768px) {
    .art-hero {
        padding: 40px 0 36px;
    }

    .art-section {
        padding: 36px 0;
    }

    .art-section-sim {
        padding: 40px 0;
    }

    .art-sim-container {
        height: clamp(300px, 60vh, 480px);
    }

    .art-formula-block {
        padding: 18px 16px;
    }

    .art-knowledge-card {
        padding: 18px 20px;
    }
}

@media (max-width: 480px) {
    .art-container {
        padding: 0 16px;
    }

    .art-navbar {
        padding: 0 16px;
    }

    .art-cover-img {
        border-radius: var(--radius-md);
        max-height: 240px;
    }

    .art-sim-container {
        border-radius: var(--radius-md);
    }
}

/* ============================================================
   程式碼展示框（art-code-block）⭐️
   使用方式：在教學文章 HTML 中貼入以下結構：

   <div class="art-code-block">
     <div class="art-code-header">
       <div class="art-code-header-left">
         <div class="art-code-dots">
           <span></span><span></span><span></span>
         </div>
         <span class="art-code-lang html">HTML</span>
         <span class="art-code-title">範例標題（可選）</span>
       </div>
     </div>
     <pre class="art-code-pre"><code class="art-code">在這裡貼程式碼</code></pre>
   </div>

   ※ 複製按鈕由 article-script.js 自動注入，不需手動加入。
   ============================================================ */

/* 外層容器 */
.art-code-block {
    position: relative;
    margin: 28px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* 頂端工具列 */
.art-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

/* 左側：圓點 + 語言 + 標題 */
.art-code-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

/* macOS 風格三個裝飾圓點 */
.art-code-dots {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}
.art-code-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: block;
}
.art-code-dots span:nth-child(1) { background: #FF5F57; }
.art-code-dots span:nth-child(2) { background: #FFBD2E; }
.art-code-dots span:nth-child(3) { background: #28C840; }

/* 語言標籤 */
.art-code-lang {
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.art-code-lang.html { background: rgba(239,68,68,0.18);  color: #f87171;  border-color: rgba(239,68,68,0.3); }
.art-code-lang.js,
.art-code-lang.javascript { background: rgba(234,179,8,0.18); color: #fbbf24; border-color: rgba(234,179,8,0.3); }
.art-code-lang.css { background: rgba(139,92,246,0.18); color: #c4b5fd; border-color: rgba(139,92,246,0.3); }
.art-code-lang.python { background: rgba(34,197,94,0.18); color: #86efac; border-color: rgba(34,197,94,0.3); }

/* 標題文字 */
.art-code-title {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.42);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 複製按鈕（由 JS 動態注入） */
.art-code-copy-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: inherit;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.art-code-copy-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    transform: scale(1.03);
}
.art-code-copy-btn:active { transform: scale(0.97); }

/* 複製成功狀態 */
.art-code-copy-btn.copied {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #86efac;
    animation: art-code-copied-pulse 0.4s ease;
}
@keyframes art-code-copied-pulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* 程式碼本體 */
.art-code-pre {
    margin: 0;
    padding: 20px 24px;
    overflow-x: auto;
    max-height: 520px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.art-code-pre::-webkit-scrollbar { width: 5px; height: 5px; }
.art-code-pre::-webkit-scrollbar-track { background: transparent; }
.art-code-pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.art-code-pre code,
.art-code {
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.75;
    color: #e2e8f0;
    white-space: pre;
    display: block;
    tab-size: 2;
}

/* 可選的說明文字列（框底部） */
.art-code-caption {
    font-size: 0.8rem;
    color: rgba(148, 163, 184, 0.8);
    padding: 8px 16px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
}

/* 手機版 */
@media (max-width: 640px) {
    .art-code-pre {
        padding: 14px 16px;
        max-height: 380px;
    }
    .art-code-pre code, .art-code { font-size: 0.78rem; }
    .art-code-title { display: none; }
}

/* ============================================================
   延伸閱讀模組（Related Articles）
   由 /components/related-articles.js 動態注入至 #art-related
   ============================================================ */

/* ── 整體區塊 ── */
.art-related-section {
    padding: 56px 0 64px;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
    /* 防止任何子元素撐破橫向版面 */
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

/* ── 區塊標題列 ── */
.art-related-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
}

/* 品牌色左側裝飾短線 */
.art-related-header::before {
    content: '';
    display: block;
    width: 4px;
    height: 28px;
    background: linear-gradient(180deg, var(--brand-primary), var(--brand-dark));
    border-radius: 4px;
    flex-shrink: 0;
}

.art-related-title {
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: -0.3px;
    margin: 0;
}

/* ── 三欄 Grid（電腦版）── */
.art-related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    /* 防止 grid 撐破容器 */
    min-width: 0;
    width: 100%;
}

/* ── 平板：兩欄 ── */
@media (max-width: 900px) {
    .art-related-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── 手機：單欄 ── */
@media (max-width: 768px) {
    .art-related-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .art-related-section {
        padding: 40px 0 48px;
    }
}

/* ── 卡片本體 ── */
/* 關鍵：overflow:hidden 確保圖片被圓角裁切，不會刺穿出去 */
.art-related-card {
    display: flex;
    flex-direction: column;   /* 圖片在上，文字在下 */
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);    /* 12px */
    box-shadow: var(--shadow-md);
    overflow: hidden;          /* ★ 必須：裁切溢出的圖片 */
    text-decoration: none;
    color: inherit;
    /* 防止 grid 子元素橫向撐破 */
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.22s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.2s;
    cursor: pointer;
}

.art-related-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: #c4d9b8;
}

.art-related-card:active {
    transform: translateY(-2px);
}

/* ── 卡片封面縮圖容器 ── */
/* 固定高度容器，overflow:hidden 雙保險 */
.art-related-card-img-wrap {
    width: 100%;
    height: 180px;             /* ★ 固定高度，呈現 16:9 類似比例 */
    min-height: 180px;         /* 防止被壓扁 */
    max-height: 180px;         /* 防止被撐高 */
    overflow: hidden;          /* ★ 必須 */
    background: var(--bg-light);
    flex-shrink: 0;            /* 不被 flex 縮小 */
    display: block;
    position: relative;
}

/* ── 卡片封面圖片本體 ── */
/* 直接設定 height: 180px，不用 height:100%（在 flex 子元素中不可靠）*/
.art-related-card-img {
    display: block;            /* ★ 消除圖片底部預設空白 */
    width: 100%;
    height: 180px;             /* ★ 與容器同高，不依賴 height:100% */
    min-height: 180px;
    max-height: 180px;
    object-fit: cover;         /* ★ 裁切填滿，不變形 */
    object-position: center;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.art-related-card:hover .art-related-card-img {
    transform: scale(1.05);
}

/* ── 無封面圖時的 Placeholder ── */
.art-related-card-placeholder {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand-light), #e0edd9);
    font-size: 2.5rem;
}

/* ── 卡片內文區域 ── */
.art-related-card-body {
    padding: 18px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;                   /* 撐滿剩餘高度，讓三張卡高度一致 */
    min-width: 0;              /* 防止文字撐破卡片 */
}

/* 文章標題（最多 2 行截斷）*/
.art-related-card-name {
    font-size: 0.95rem;
    font-weight: 900;
    color: var(--text-main);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* 文章摘要（最多 2 行截斷）*/
.art-related-card-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
    word-break: break-word;
}

/* Tag 列 */
.art-related-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.art-related-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--brand-light);
    color: var(--brand-dark);
    border: 1px solid #c4d9b8;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

/* ── 底部「繼續閱讀 →」提示 ── */
.art-related-card-cta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--brand-primary);
    margin-top: 4px;
    transition: gap 0.2s;
}

.art-related-card:hover .art-related-card-cta {
    gap: 8px;
}



