/* cg.com.tw RWD 首頁 v1
 * Mobile First
 * 既有縮圖大多為 310 x 207，本版面以 contain 保留完整畫面，不強制裁切。
 */

:root {
    --max-width: 1080px;
    --radius: 16px;
    --radius-small: 11px;
    --gap: 16px;
    --transition: 180ms ease;
}

.theme-dark {
    --bg: #101317;
    --surface: #171b21;
    --surface-2: #1d232b;
    --surface-3: #252c36;
    --text: #f1f4f7;
    --muted: #9da8b5;
    --line: #2e3743;
    --accent: #5fb7ff;
    --accent-2: #88ccff;
    --shadow: 0 10px 30px rgba(0,0,0,.22);
}

.theme-light {
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --surface-3: #eef2f6;
    --text: #18202a;
    --muted: #697586;
    --line: #dce3ea;
    --accent: #176fbd;
    --accent-2: #0f5f9f;
    --shadow: 0 10px 28px rgba(25,40,60,.10);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

a {
    color: inherit;
}

img {
    max-width: 100%;
}

.container {
    width: min(100% - 28px, var(--max-width));
    margin-inline: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.header-row {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
}

.brand-logo {
    width: auto;
    height: 42px;
    max-width: 220px;
    object-fit: contain;
}

.brand-title {
    display: none;
    font-weight: 700;
}

.nav-toggle {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 13px;
    font: inherit;
    cursor: pointer;
}

.category-nav {
    display: none;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 0 14px;
}

.category-nav.open {
    display: flex;
}

.category-nav a,
.related-links a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    text-decoration: none;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.category-nav a:hover,
.related-links a:hover {
    color: var(--text);
    border-color: var(--accent);
    background: var(--surface-2);
}

.hero {
    padding: 28px 0 14px;
}

.hero-panel {
    display: grid;
    gap: 22px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background:
        radial-gradient(circle at 100% 0, color-mix(in srgb, var(--accent) 15%, transparent), transparent 40%),
        var(--surface);
    box-shadow: var(--shadow);
}

.eyebrow,
.section-kicker {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
}

.hero h1,
.section-heading h2 {
    margin: 0;
    line-height: 1.25;
}

.hero h1 {
    font-size: clamp(28px, 7vw, 48px);
}

.hero-copy {
    margin: 10px 0 0;
    color: var(--muted);
}

.search-box label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 700;
}

.search-box input {
    width: 100%;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    padding: 0 14px;
    font: inherit;
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.search-status {
    min-height: 22px;
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.related-section,
.latest-section {
    padding: 16px 0;
}

.related-links {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: thin;
}

.related-links a {
    flex: 0 0 auto;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.compact-heading {
    margin-bottom: 10px;
}

.section-heading h2 {
    font-size: clamp(23px, 5vw, 32px);
}

.back-top {
    display: none;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}

.latest-list {
    display: grid;
    gap: 8px;
}

.latest-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
    text-decoration: none;
    transition: transform var(--transition), border-color var(--transition);
}

.latest-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.arrow,
.card-arrow {
    color: var(--accent);
}

.categories-wrap {
    padding-top: 10px;
}

.content-section {
    scroll-margin-top: 125px;
    padding: 26px 0;
    border-top: 1px solid var(--line);
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
}

.resource-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    box-shadow: 0 0 0 rgba(0,0,0,0);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.resource-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
    box-shadow: var(--shadow);
}

.thumb-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 310 / 207;
    overflow: hidden;
    background: var(--surface-3);
    border-bottom: 1px solid var(--line);
}

.thumb-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px 15px;
}

.card-body strong {
    min-width: 0;
    font-size: 15px;
    line-height: 1.45;
}

.text-only .card-body {
    min-height: 66px;
    background: var(--surface-2);
}

.no-results {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

.site-footer {
    margin-top: 30px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.footer-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px 0 28px;
    color: var(--muted);
    font-size: 14px;
}

.footer-row > div {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-row a {
    color: var(--accent-2);
    text-decoration: none;
}

[hidden] {
    display: none !important;
}

/* 小型平板 / 大型手機 */
@media (min-width: 620px) {
    .container {
        width: min(100% - 40px, var(--max-width));
    }

    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .latest-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-panel {
        padding: 30px;
    }

    .brand-title {
        display: inline;
    }
}

/* 桌機 */
@media (min-width: 900px) {
    .site-header {
        position: relative;
    }

    .nav-toggle {
        display: none;
    }

    .category-nav,
    .category-nav.open {
        display: flex;
        padding-top: 0;
    }

    .hero {
        padding-top: 34px;
    }

    .hero-panel {
        grid-template-columns: 1.25fr .75fr;
        align-items: end;
        padding: 38px;
    }

    .card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .latest-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .back-top {
        display: inline;
    }

    .footer-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* color-mix 不支援時的基本 fallback */
@supports not (color: color-mix(in srgb, white, black)) {
    .site-header {
        background: var(--bg);
    }

    .hero-panel {
        background: var(--surface);
    }

    .resource-card:hover {
        border-color: var(--accent);
    }
}
