/* ============================================================
   whe.bike 增強樣式 — cherry-picked from Ghost theme ecosystem
   追加於 Headline 之後,不修改原始樣式
   ============================================================ */

/* === A. Dark Mode (from Solo theme pattern) === */
:root {
    --whe-bg: #ffffff;
    --whe-text: #1a1a1a;
    --whe-card-bg: #f8f8f8;
    --whe-border: #e0e0e0;
    --whe-accent: #0a6cff;
    --whe-muted: #888;
    --whe-progress: #0a6cff;
}

[data-theme="dark"] {
    --whe-bg: #0f1116;
    --whe-text: #e0e0e0;
    --whe-card-bg: #1a1d24;
    --whe-border: #2a2d34;
    --whe-accent: #4a9fff;
    --whe-muted: #777;
    --whe-progress: #4a9fff;
    --color-darker-gray: #e0e0e0;
    --color-mid-gray: #aaa;
    --color-light-gray: #2a2d34;
    --color-border: #2a2d34;
    --color-white: #0f1116;
    background-color: var(--whe-bg);
    color: var(--whe-text);
}

[data-theme="dark"] body {
    background-color: var(--whe-bg);
    color: var(--whe-text);
}

[data-theme="dark"] .gh-head {
    background-color: var(--whe-bg);
    border-bottom-color: var(--whe-border);
}

[data-theme="dark"] .gh-head-logo,
[data-theme="dark"] .gh-head-link,
[data-theme="dark"] .gh-head-menu a {
    color: var(--whe-text);
}

[data-theme="dark"] .gh-card {
    background-color: var(--whe-card-bg);
}

[data-theme="dark"] .gh-card-title {
    color: var(--whe-text);
}

[data-theme="dark"] .gh-card-author,
[data-theme="dark"] .gh-card-date {
    color: var(--whe-muted);
}

[data-theme="dark"] .gh-article-title,
[data-theme="dark"] .gh-article-excerpt,
[data-theme="dark"] .gh-content p,
[data-theme="dark"] .gh-content h2,
[data-theme="dark"] .gh-content h3,
[data-theme="dark"] .gh-content li,
[data-theme="dark"] .gh-content strong {
    color: var(--whe-text);
}

[data-theme="dark"] .gh-foot {
    border-top-color: var(--whe-border);
    background-color: var(--whe-bg);
}

[data-theme="dark"] .gh-topic-grid .gh-card:not(:only-child).large {
    border-bottom-color: var(--whe-border);
}

[data-theme="dark"] .gh-topic-footer {
    border-top-color: var(--whe-border);
}

[data-theme="dark"] a {
    color: var(--whe-accent);
}

[data-theme="dark"] .gh-content table {
    color: var(--whe-text);
}

/* Dark mode toggle button */
.whe-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.5rem;
    border-radius: 50%;
    transition: background 0.2s;
    -webkit-appearance: none;
    position: relative;
    z-index: 1000;
}
.whe-theme-toggle:hover {
    background: var(--whe-border);
}
.whe-theme-toggle .moon { display: none; }
.whe-theme-toggle .sun { display: inline; }
[data-theme="dark"] .whe-theme-toggle .moon { display: inline; }
[data-theme="dark"] .whe-theme-toggle .sun { display: none; }

/* === B. CJK Typography (中文排版優化) === */
.gh-content {
    font-size: 1.7rem;
    line-height: 1.85;
    letter-spacing: 0.02em;
}

.gh-content p {
    line-height: 1.85;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* CSS3 text-spacing for CJK (Chrome 119+, Safari 17.2+) */
@supports (text-spacing: trim-start auto trim-end auto) {
    .gh-content {
        text-spacing: trim-start auto trim-end auto;
    }
}

.gh-content h2 {
    margin-top: 2.5em;
    margin-bottom: 0.8em;
    font-size: 2.2rem;
    font-weight: 700;
}

.gh-content h3 {
    margin-top: 2em;
    margin-bottom: 0.6em;
    font-size: 1.9rem;
    font-weight: 600;
}

/* === C. Reading Progress Bar (from Casper pattern) === */
.whe-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--whe-progress);
    z-index: 9999;
    transition: width 0.1s ease-out;
}

/* === D. Reading Time + Tag Badge (文章頁) === */
.whe-post-meta-extra {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    font-size: 1.4rem;
    color: var(--whe-muted);
}

.whe-reading-time::before {
    content: "⏱ ";
}

/* === E. TOC (Table of Contents) — from Lyra pattern === */
.whe-toc {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 20px;
    border-left: 3px solid var(--whe-accent);
    font-size: 1.4rem;
    line-height: 1.6;
}

.whe-toc-title {
    font-size: 1.3rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--whe-muted);
    margin-bottom: 12px;
}

.whe-toc ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.whe-toc li {
    margin-bottom: 6px;
}

.whe-toc a {
    color: var(--whe-muted);
    text-decoration: none;
    transition: color 0.2s;
    display: block;
    padding: 2px 0;
}

.whe-toc a:hover,
.whe-toc a.active {
    color: var(--whe-accent);
    font-weight: 500;
}

.whe-toc .toc-h3 {
    padding-left: 16px;
    font-size: 0.95em;
}

/* TOC layout: sidebar on desktop, hidden on mobile */
.whe-toc-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

@media (max-width: 1023px) {
    .whe-toc-layout {
        grid-template-columns: 1fr;
    }
    .whe-toc {
        display: none;
    }
}

/* === F. Newsletter CTA (from Edition pattern) === */
.whe-newsletter-cta {
    max-width: 600px;
    margin: 60px auto;
    padding: 40px;
    text-align: center;
    background: var(--whe-card-bg);
    border-radius: 12px;
    border: 1px solid var(--whe-border);
}

.whe-newsletter-cta h3 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.whe-newsletter-cta p {
    color: var(--whe-muted);
    font-size: 1.5rem;
    margin-bottom: 24px;
}

.whe-newsletter-cta .whe-btn {
    display: inline-block;
    padding: 12px 32px;
    background: var(--whe-accent);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.whe-newsletter-cta .whe-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(10, 108, 255, 0.3);
}

/* === G. Card Hover Enhancement === */
.gh-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    border-radius: 8px;
    padding: 8px;
    margin: -8px;
}

.gh-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .gh-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.gh-card-title {
    transition: color 0.2s;
}

/* Tag accent color on cards */
.gh-card.tag-industry .gh-card-title { border-left: 3px solid #0a6cff; padding-left: 10px; }
.gh-card.tag-expo .gh-card-title { border-left: 3px solid #e8590c; padding-left: 10px; }
.gh-card.tag-race .gh-card-title { border-left: 3px solid #2f9e44; padding-left: 10px; }
.gh-card.tag-review .gh-card-title { border-left: 3px solid #ae3ec9; padding-left: 10px; }

/* === H. Table Styling (壯騎文有表格) === */
.gh-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 1.4rem;
    overflow-x: auto;
    display: block;
}

.gh-content thead {
    background: var(--whe-card-bg);
}

.gh-content th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid var(--whe-border);
    white-space: nowrap;
}

.gh-content td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--whe-border);
}

.gh-content tbody tr:hover {
    background: var(--whe-card-bg);
}

/* === I. Footer 中文化 + Social links === */
.gh-copyright {
    font-size: 1.3rem;
}

/* === J. Hero Section (首頁頂部亮點) === */
.whe-hero {
    text-align: center;
    padding: 60px 20px 40px;
    border-bottom: 1px solid var(--whe-border);
    margin-bottom: 40px;
}

.whe-hero h2 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.whe-hero p {
    font-size: 1.6rem;
    color: var(--whe-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* === K. Back to top button === */
.whe-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--whe-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    z-index: 9998;
}

.whe-back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.whe-back-to-top:hover {
    transform: translateY(-3px);
}


/* === FIX: TOC empty state === */
.whe-toc-layout:has(.whe-toc[style*="display: none"]),
.whe-toc-layout:has(.whe-toc[style*="display:none"]) {
    grid-template-columns: 1fr !important;
}


/* === FIX: Mobile single column grid === */
@media (max-width: 768px) {
    .gh-topic-grid .gh-topic-content {
        grid-template-columns: 1fr !important;
    }

    /* Mobile article padding: ensure content doesn't touch screen edges */
    /* 正文窄一點(20px),標題/meta 寬一點(12px),層次分明 */
    .gh-article-header.gh-canvas {
        max-width: 100% !important;
        padding: 0 12px !important;
        box-sizing: border-box !important;
    }
    .gh-article-meta.gh-canvas {
        max-width: 100% !important;
        padding: 0 12px !important;
        box-sizing: border-box !important;
    }
    .whe-post-meta-extra {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .whe-toc-layout .gh-content {
        padding: 0 20px !important;
        box-sizing: border-box !important;
    }
    .whe-newsletter-cta {
        margin-left: 20px !important;
        margin-right: 20px !important;
        padding: 30px 20px !important;
        box-sizing: border-box !important;
    }
    
    .whe-newsletter-cta {
        margin-left: 20px !important;
        margin-right: 20px !important;
        box-sizing: border-box !important;
    }
}
