/* 首頁：字標、控制迴路模擬器與各區塊 */
:root {
    --gutter: clamp(16px, 2.2vw, 32px);
    --gap-section: clamp(96px, 12vw, 192px);
    --step-small: 0.875rem;
    --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
    --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
    --step-head: clamp(2rem, 1.3rem + 3.2vw, 4rem);
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-text);
    font-size: var(--step-body);
    line-height: 1.6;
    overflow-x: hidden;
}

h1,
h2,
h3,
p {
    margin: 0;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

/* 頁首：sticky，永遠可點、不被內容蓋住 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 28px;
    padding: 12px var(--gutter);
    background: var(--bg);
    border-bottom: 1px solid var(--surface);
}

.brand {
    position: relative;
    z-index: 1;
    font-weight: 500;
    text-decoration: none;
    margin-right: auto;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.topbar-cta {
    min-height: 44px;
    padding: 0 16px;
}

.site-nav {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 22px;
}

.site-nav a {
    text-decoration: none;
    padding: 10px 0;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    transition: color 0.2s;
}

.site-nav a:hover {
    color: var(--accent);
}

.lang-switch {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 2px;
}

.lang-btn {
    min-height: 44px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: var(--step-small);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.lang-btn:hover {
    background: var(--surface);
}

.lang-btn.active {
    background: var(--ink);
    color: var(--bg);
}

/* 按鈕 */
.button {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 24px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s var(--ease), color 0.2s, border-color 0.2s;
}

.button:hover {
    background: var(--ink);
}

.button:active {
    transform: scale(0.98);
}

.button-ghost {
    background: transparent;
    color: var(--ink);
    border: 1.5px solid color-mix(in srgb, var(--ink) 28%, transparent);
}

.button-ghost:hover {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}

/* 第一屏：文案清楚 + 模擬器證明卡 */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: clamp(28px, 4vw, 56px);
    align-items: start;
    padding: clamp(28px, 4vw, 48px) var(--gutter) var(--gutter);
}

.hero-copy {
    max-width: 34rem;
}

.hero-kicker {
    margin: 0 0 12px;
    font-size: var(--step-small);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
}

.hero h1 {
    margin: 0;
    font-size: inherit;
    font-weight: 500;
}

.wordmark {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 2rem + 3.5vw, 4.5rem);
    font-weight: 400;
    font-kerning: none;
    line-height: 0.9;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
}

.tagline {
    display: block;
    font-size: clamp(1.5rem, 1.15rem + 1.4vw, 2.125rem);
    font-weight: 500;
    line-height: 1.25;
}

.hero-desc {
    margin: 18px 0 0;
    max-width: 34em;
    color: var(--muted);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

/* 模擬器：互動只在卡片內 */
.sim {
    background: var(--surface);
    padding: clamp(16px, 2vw, 24px);
    border: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
    isolation: isolate;
}

.sim-kicker {
    margin: 0 0 4px;
    font-size: var(--step-small);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
}

.sim h2 {
    font-size: var(--step-lead);
    font-weight: 500;
    line-height: 1.25;
    margin: 0;
}

.sim-layout {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 20px;
    margin-top: 16px;
}

.sim-chart-wrap {
    min-width: 0;
}

.sim-control label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.sim-control output {
    font-weight: 500;
}

.sim-control input {
    width: 100%;
    height: 44px;
    margin: 0;
    accent-color: var(--accent);
    cursor: grab;
}

.readouts {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin: 8px 0 0;
}

.readouts div {
    min-width: 0;
}

.readouts dt {
    font-size: var(--step-small);
}

.readouts dd {
    margin: 0;
    font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2.25rem);
    font-weight: 500;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.readouts small {
    font-size: var(--step-small);
    font-weight: 400;
}

.relay {
    color: var(--muted);
}

.relay.is-on {
    color: var(--accent);
}

.chart {
    display: block;
    width: 100%;
    height: 124px;
    background: var(--paper);
}

.chart polyline {
    fill: none;
    stroke: var(--ink);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.chart line {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 6 5;
    vector-effect: non-scaling-stroke;
}

.chart-legend {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    font-size: var(--step-small);
}

.chart-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-legend i {
    width: 16px;
    height: 3px;
    background: var(--ink);
}

.chart-legend .legend-target i {
    background: var(--accent);
}

.sim-note {
    margin-top: 12px;
    font-size: var(--step-small);
    line-height: 1.45;
}

/* 技術跑馬燈 */
.marquee {
    overflow: hidden;
    margin-top: clamp(48px, 6vw, 96px);
    background: var(--ink);
    color: var(--bg);
    font-size: var(--step-lead);
}

.marquee-track {
    display: flex;
    width: max-content;
    animation: marquee 40s linear infinite;
}

.marquee ul {
    display: flex;
    gap: 48px;
    margin: 0;
    padding: 12px 24px;
    list-style: none;
    white-space: nowrap;
}

@keyframes marquee {
    to {
        transform: translateX(-50%);
    }
}

/* 區塊共用 */
.section {
    padding: 0 var(--gutter);
    margin-top: var(--gap-section);
}

.section h2 {
    font-size: var(--step-head);
    font-weight: 500;
    line-height: 1.12;
    letter-spacing: -0.02em;
}

/* 案例 */
.case-main {
    display: grid;
    grid-template-columns: 7fr 5fr;
    gap: clamp(24px, 4vw, 64px);
    align-items: center;
}

.case-main img {
    width: 100%;
}

.case-desc {
    margin: 20px 0;
    max-width: 34em;
}

.case-link {
    font-weight: 500;
    text-underline-offset: 4px;
    transition: color 0.2s;
}

.case-link:hover {
    color: var(--accent);
}

.case-gallery {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: var(--gutter);
    margin: var(--gutter) 0 0;
    align-items: end;
}

.case-gallery figure {
    margin: 0;
}

.case-gallery figcaption {
    margin-top: 8px;
    font-size: var(--step-small);
}

/* 服務 */
.services {
    background: var(--surface);
    padding-top: clamp(64px, 8vw, 128px);
    padding-bottom: clamp(64px, 8vw, 128px);
}

.service {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: var(--gutter);
    margin-top: clamp(40px, 5vw, 72px);
}

.service h3 {
    font-size: var(--step-lead);
    font-weight: 500;
    line-height: 1.25;
}

.service p {
    max-width: 38em;
}

/* 合作流程 */
.process {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: var(--gutter);
    align-items: start;
}

.process ol {
    margin: 0;
    padding: 0;
    list-style: none;
    max-width: 38em;
}

.process li + li {
    margin-top: 32px;
}

.process strong {
    font-weight: 500;
    display: block;
    font-size: var(--step-lead);
    line-height: 1.3;
    margin-bottom: 6px;
}

/* 最新文章 */
.latest-list {
    margin-top: clamp(32px, 4vw, 56px);
}

.latest-row {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: var(--gutter);
    padding: 16px 0;
    font-size: var(--step-lead);
    line-height: 1.35;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.latest-row:hover {
    background: var(--surface);
    color: var(--accent);
}

.latest-meta {
    font-size: var(--step-body);
}

.latest-all {
    display: inline-block;
    margin-top: 20px;
    font-weight: 500;
    text-underline-offset: 4px;
}

/* 預約 */
.booking {
    margin-top: var(--gap-section);
    padding: clamp(64px, 8vw, 128px) var(--gutter);
    background: var(--accent);
    color: var(--accent-ink);
}

.booking h2 {
    font-size: var(--step-lead);
    font-weight: 500;
}

.booking-link {
    display: inline-block;
    margin: 16px 0 24px;
    font-size: clamp(3rem, 11vw, 10.5rem);
    font-weight: 500;
    line-height: 1.05;
    letter-spacing: -0.03em;
    text-underline-offset: 0.12em;
    text-decoration-thickness: 0.05em;
    transition: transform 0.3s var(--ease);
}

.booking-link:hover {
    transform: translateX(12px);
}

.booking a:focus-visible {
    outline-color: var(--accent-ink);
}

/* 頁尾 */
.site-footer {
    background: var(--ink);
    color: var(--bg);
    padding: 24px var(--gutter) 0;
    overflow: hidden;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
}

.footer-links a {
    text-underline-offset: 4px;
}

.footer-name {
    font-family: var(--font-display);
    font-size: calc((100vw - 2 * var(--gutter)) / 2.13);
    font-kerning: none;
    line-height: 0.8;
    white-space: nowrap;
    margin-top: 32px;
    margin-bottom: -0.2em;
}

/* 進場動畫：沒有 JS 時內容照常顯示 */
.js .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
    transition-delay: var(--delay, 0ms);
}

.js .reveal.is-in {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .marquee-track {
        animation: none;
    }

    .js .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .button,
    .booking-link {
        transition: none;
    }
}

/* 平板 */
@media (max-width: 1000px) {
    .hero,
    .case-main,
    .process {
        grid-template-columns: minmax(0, 1fr);
    }

    .topbar-cta {
        display: none;
    }

    .process ol {
        margin-top: 12px;
    }
}

/* 手機 */
@media (max-width: 640px) {
    .topbar {
        gap: 6px 12px;
        padding: 10px var(--gutter);
    }

    .brand {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .brand-domain {
        display: none;
    }

    .site-nav {
        order: 3;
        flex: 1 0 100%;
        gap: 8px 16px;
        padding-top: 4px;
        border-top: 1px solid var(--surface);
    }

    .site-nav a {
        padding: 8px 0;
        min-height: 40px;
    }

    .lang-switch {
        margin-left: auto;
    }

    .lang-btn {
        padding: 0 8px;
        min-height: 40px;
    }

    .hero {
        padding-top: 20px;
    }

    .hero-actions {
        width: 100%;
    }

    .hero-actions .button {
        flex: 1 1 auto;
        min-width: 140px;
    }

    .sim-layout,
    .case-gallery,
    .service,
    .latest-row {
        grid-template-columns: 1fr;
    }

    .service,
    .latest-row {
        gap: 6px;
    }
}

/* 不支援 color-mix 時，頂欄改用不透明底 */
@supports not (background: color-mix(in srgb, white 50%, black)) {
    .topbar {
        background: var(--bg);
    }

    .button-ghost {
        border-color: var(--muted);
    }
}
