/* =========================================================================
   國家中山科學研究院 中文站 v0.01 — 全站共用樣式
   數值來源：Figma「01-首頁」Copy as code → CSS（all layers），2026-11-20 取得。
   Figma 為 1440px 桌機線框稿；平板與手機的斷點規則為工程端暫定，待設計公司的響應式規範定稿後替換。
   撰寫規則：純 CSS，不用前處理器、不用巢狀語法；不寫行內 style（CSP 禁止）。
   ========================================================================= */

/* ---------- 1. 設計數值（Figma 色彩、字級、間距） ---------- */
:root {
    /* 色彩 */
    --color-ink: #1A1A1A;          /* 標題、主要按鈕底色 */
    --color-text: #333333;         /* 內文 */
    --color-muted: #666666;        /* 次要文字 */
    --color-subtle: #9AA5B1;       /* 小標（eyebrow）、日期、序號 */
    --color-border: #E0E0E0;       /* 頁首框線、分隔線 */
    --color-border-strong: #CCCCCC;/* 頁籤外框 */
    --color-control: #999999;      /* 圓形箭頭按鈕外框 */
    --color-white: #FFFFFF;
    --color-bar: #F5F5F5;          /* 頂部工具列 */
    --color-section: #F7F8FA;      /* 淺灰區塊底色（S3、S5） */
    --color-card: #F0F2F5;         /* 卡片、標籤底色 */
    --color-placeholder: #D1D5DB;  /* 首屏底色、圖示底框 */
    --color-media: #E8EAED;        /* 圖片／影片底框 */
    --color-footer: #1A1A1A;       /* 頁尾底色 */
    --color-footer-box: #2A2A2A;   /* 頁尾標誌底框 */
    --color-footer-line: #333333;  /* 頁尾分隔線 */
    --color-footer-text: #999999;  /* 頁尾文字 */

    /* 字型：Figma 為 Inter；網站不載入外部字型服務，未安裝 Inter 時依序使用系統中文字型 */
    --font-family: "Inter", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;

    /* 版面 */
    --page-max: 1440px;            /* Figma 畫板寬 */
    --gutter: 80px;                /* 左右邊界（內容寬 1280px） */
    --section-space: 120px;        /* 區塊上下留白 */
    --radius-small: 4px;
    --radius-card: 8px;

    /* 動態（暫定值，待設計公司範例確認後替換） */
    --motion-fast: 200ms;
    --motion-slow: 600ms;
    --motion-ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- 2. 基礎 ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--color-white);
    color: var(--color-text);
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.8;
}

img,
svg {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

a {
    color: inherit;
}

h1,
h2,
h3,
p,
ul,
figure {
    margin: 0;
}

ul {
    padding: 0;
    list-style: none;
}

button {
    font: inherit;
    color: inherit;
}

address {
    font-style: normal;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid var(--color-ink);
    outline-offset: 2px;
}

main:focus {
    outline: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 100;
    padding: 12px 20px;
    background: var(--color-ink);
    color: var(--color-white);
    text-decoration: none;
}

.skip-link:focus {
    top: 16px;
}

/* ---------- 3. 版面容器與共用元件 ---------- */
.container {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.section {
    padding: var(--section-space) 0;
    background: var(--color-white);
}

.section--muted {
    background: var(--color-section);
}

/* 區塊小標：13px / 500 / 字距 0.12em / 大寫 */
.eyebrow {
    color: var(--color-subtle);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.eyebrow--dark {
    color: var(--color-muted);
}

/* 區塊標題：36px / 700 / 行高 130% */
.section-title {
    margin-top: 16px;
    color: var(--color-ink);
    font-size: 36px;
    font-weight: 700;
    line-height: 1.3;
}

.section-title__line {
    display: block;
}

/* 區塊說明：20px / 行高 180% */
.section-lead {
    color: var(--color-text);
    font-size: 20px;
    line-height: 1.8;
}

/* 區塊標頭左右兩欄（各 632px，間距 16px） */
.section-head {
    margin-bottom: 64px;
}

.section-head--split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: end;
}

.section-head__aside {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* 按鈕：高 56px、內距 14px 24px、圓角 4px、16px / 500 */
.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    padding: 14px 24px;
    border-radius: var(--radius-small);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.8;
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--motion-ease), color var(--motion-fast) var(--motion-ease);
}

.button--primary {
    background: var(--color-ink);
    color: var(--color-white);
}

.button--primary:hover {
    background: var(--color-text);
}

.button--ghost {
    background: transparent;
    color: var(--color-text);
}

.button--ghost:hover {
    text-decoration: underline;
}

/* 文字連結（「探索相關技術 →」「查看全部消息 →」）：16px / 500 */
.text-link {
    color: var(--color-ink);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.8;
    text-decoration: none;
}

.text-link:hover {
    text-decoration: underline;
}

/* 圓形箭頭按鈕：40×40、外框 1px #999、圓角 20px */
.round-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--color-control);
    border-radius: 20px;
    background: transparent;
    color: var(--color-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: background-color var(--motion-fast) var(--motion-ease), opacity var(--motion-fast) var(--motion-ease);
}

.round-button:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* 不可點：40% 透明（產品分類第 1 頁的「上一組」、最後一頁的「下一組」） */
.round-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.round-button:disabled:hover {
    background: transparent;
}

.carousel-arrows {
    display: flex;
    gap: 8px;
}

/* 標籤：內距 4px 12px、底色 #F0F2F5、12px / 500 */
.tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-small);
    background: var(--color-card);
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.25;
}

/* 頁籤按鈕（AI 驅動專區）：內距 10px 20px、圓角 4px */
.chip {
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--color-text);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.8;
    cursor: pointer;
    transition: background-color var(--motion-fast) var(--motion-ease), color var(--motion-fast) var(--motion-ease);
}

.chip[aria-pressed="true"] {
    border-color: var(--color-ink);
    background: var(--color-ink);
    color: var(--color-white);
}

/* ---------- 4. 頁首：工具列（高 40px）＋主選單（高 88px） ---------- */
.site-header {
    position: relative;
    z-index: 20;
    background: var(--color-white);
}

.utility-bar {
    background: var(--color-bar);
    border-bottom: 1px solid var(--color-border);
}

.utility-bar__inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.utility-bar__list {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 24px;
    min-height: 40px;
}

.utility-bar__link {
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.6;
    text-decoration: none;
}

.utility-bar__link:hover {
    text-decoration: underline;
}

.main-nav {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-white);
}

.main-nav__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    max-width: var(--page-max);
    min-height: 88px;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* 標誌：原圖為「徽章＋白色院名」透明圖，白色頁首只取左側徽章，院名改以文字呈現 */
.brand {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-ink);
    text-decoration: none;
}

/* 頁首白底：完整標誌＋書法字（深色字版），不再用徽章裁切加文字（2026-11-25 院方測試結果第一項） */
.brand__logo {
    width: auto;
    height: auto;
    max-height: 48px;
}

.primary-nav__list {
    display: flex;
    align-items: center;
    gap: 40px;
}

.primary-nav__item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.primary-nav__link {
    padding: 12px 0;
    color: var(--color-text);
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.primary-nav__link:hover {
    color: var(--color-ink);
    text-decoration: underline;
}

.primary-nav__caret {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-text);
    font-size: 14px;
    cursor: pointer;
}

.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: -16px;
    min-width: 200px;
    padding: 8px 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);
    background: var(--color-white);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* 子選單開合：有 JavaScript 時只由 .is-open 決定（滑鼠、▾ 按鈕、Esc、點外側都改同一個狀態，aria-expanded 同步）；
   沒有 JavaScript 時改由滑過與鍵盤聚焦展開 */
.no-js .primary-nav__item:hover .submenu,
.no-js .primary-nav__item:focus-within .submenu,
.primary-nav__item.is-open .submenu {
    display: block;
}

.submenu__link {
    display: block;
    padding: 10px 16px;
    color: var(--color-text);
    font-size: 15px;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
}

.submenu__link:hover {
    background: var(--color-card);
}

.search-link {
    flex: 0 0 auto;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    color: var(--color-text);
}

.search-link__icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.nav-toggle {
    display: none;
}

/* ---------- 5. 頁尾（底色 #1A1A1A） ---------- */
.site-footer {
    background: var(--color-footer);
    color: var(--color-footer-text);
}

.site-footer__inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.site-footer__main {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding: 48px 0;
}

.site-footer__contact {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 頁尾深色底：完整標誌（白色書法字版）原色顯示，不加濾鏡（2026-11-25 院方測試結果第六項） */
.site-footer__logo {
    align-self: flex-start;        /* 父層為直向 flex，預設 stretch 會把標誌橫向拉寬變形 */
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 48px;
}

.site-footer__address {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: 1.6;
}

.site-footer__title {
    margin-bottom: 12px;
    color: var(--color-white);
    font-size: 20px;
    font-weight: 500;
    line-height: 1.5;
}

.site-footer__links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.site-footer__link {
    color: var(--color-footer-text);
    font-size: 14px;
    line-height: 1.6;
    text-decoration: none;
}

.site-footer__link:hover {
    color: var(--color-white);
    text-decoration: underline;
}

.site-footer__mark {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 144px;
    padding: 16px;
    border-radius: var(--radius-small);
    background: var(--color-footer-box);
}

.site-footer__mark img {
    width: auto;
    max-height: 96px;
    filter: brightness(0) invert(1);
    opacity: 0.4;
}

.site-footer__bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: 80px;
    padding: 16px;
    border-top: 1px solid var(--color-footer-line);
}

.site-footer__copyright {
    color: var(--color-muted);
    font-size: 14px;
    line-height: 1.6;
}

.site-footer__top {
    color: var(--color-footer-text);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    text-decoration: none;
}

.site-footer__top:hover {
    color: var(--color-white);
}

.site-footer :focus-visible {
    outline-color: var(--color-white);
}

/* ---------- 6. 響應式（工程端暫定） ---------- */
/* 1280 以下：左右邊界 40px，主選單間距縮小 */
@media (max-width: 1279px) {
    :root {
        --gutter: 40px;
    }

    .primary-nav__list {
        gap: 24px;
    }
}

/* 1023 以下：主選單收合為「選單」按鈕（需 JavaScript；無 JavaScript 時選單直接展開） */
@media (max-width: 1023px) {
    :root {
        --section-space: 80px;
    }

    .main-nav__inner {
        flex-wrap: wrap;
        min-height: 72px;
    }

    .primary-nav {
        order: 3;
        flex: 1 0 100%;
    }

    .primary-nav__list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding-bottom: 16px;
    }

    .primary-nav__item {
        flex-wrap: wrap;
        justify-content: space-between;
        border-top: 1px solid var(--color-border);
    }

    .primary-nav__link {
        padding: 14px 0;
    }

    .primary-nav__caret {
        width: 44px;
    }

    .submenu {
        position: static;
        flex: 1 0 100%;
        min-width: 0;
        margin-bottom: 8px;
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .no-js .primary-nav__item:hover .submenu {
        display: none;
    }

    .primary-nav__item.is-open .submenu {
        display: block;
    }

    .submenu__link {
        padding: 10px 16px;
    }

    .js .nav-toggle {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        order: 2;
        width: 44px;
        height: 44px;
        margin-left: auto;
        padding: 0;
        border: 1px solid var(--color-border-strong);
        border-radius: var(--radius-small);
        background: transparent;
        cursor: pointer;
    }

    .nav-toggle__bar,
    .nav-toggle__bar::before,
    .nav-toggle__bar::after {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--color-ink);
    }

    .nav-toggle__bar {
        position: relative;
    }

    .nav-toggle__bar::before,
    .nav-toggle__bar::after {
        content: "";
        position: absolute;
        left: 0;
    }

    .nav-toggle__bar::before {
        top: -6px;
    }

    .nav-toggle__bar::after {
        top: 6px;
    }

    .js .primary-nav {
        display: none;
    }

    .js .primary-nav.is-open {
        display: block;
    }

    .search-link {
        order: 1;
    }

    .site-footer__main {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 32px 16px;
    }

    .section-title {
        font-size: 30px;
    }

    .section-lead {
        font-size: 18px;
    }
}

/* 767 以下（手機）：左右邊界 16px，單欄 */
@media (max-width: 767px) {
    :root {
        --gutter: 16px;
        --section-space: 56px;
    }

    .utility-bar__list {
        gap: 16px;
    }

    /* 完整標誌較寬，手機縮為 40px 高，讓標誌、搜尋、選單鈕維持同一列 */
    .brand__logo {
        max-height: 40px;
    }

    .section-head {
        margin-bottom: 32px;
    }

    .section-head--split {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .section-head__aside {
        justify-content: flex-start;
    }

    .section-title {
        font-size: 26px;
    }

    .section-lead {
        font-size: 16px;
    }

    .site-footer__main {
        grid-template-columns: 1fr;
    }

    .site-footer__bottom {
        padding: 16px 0;
    }
}

/* 使用者設定「減少動態效果」：取消轉場 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}
