/*
    imuslab shared site styles
    Used by index.php, talks.php and toby.php (header, tokens, buttons, sections).
    Page specific styles stay inline in each page.
*/

:root{
    --bg: #fafaf9;
    --surface: #ffffff;
    --surface-2: #f1f1ef;
    --ink: #111113;
    --ink-2: #4a4a50;
    --ink-3: #6c6c72;
    --line: #e6e6e2;
    --line-2: #d2d2cd;
    --accent: #286eac;
    --accent-ink: #ffffff;
    --shadow: 0 1px 2px rgba(17,17,19,.04), 0 12px 32px -16px rgba(17,17,19,.18);
    --radius: 16px;
    --radius-sm: 10px;
    --maxw: 1120px;
    --gutter: 24px;
    --header-h: 64px;
    --font: "Inter", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans TC", monospace;
    color-scheme: light;
}

/* Dark theme: follows the system unless the visitor picked light / dark (html[data-theme]) */
@media (prefers-color-scheme: dark){
    :root:not([data-theme="light"]){
        --bg: #0d0e10;
        --surface: #15171a;
        --surface-2: #1c1f23;
        --ink: #ececee;
        --ink-2: #a8abb2;
        --ink-3: #8b8e95;
        --line: #25282d;
        --line-2: #363a40;
        --accent: #7ab0e3;
        --accent-ink: #0d0e10;
        --shadow: 0 1px 2px rgba(0,0,0,.3), 0 16px 40px -20px rgba(0,0,0,.7);
        color-scheme: dark;
    }
    :root:not([data-theme="light"]) .logo-img{ filter: invert(1); }
}

:root[data-theme="dark"]{
    --bg: #0d0e10;
    --surface: #15171a;
    --surface-2: #1c1f23;
    --ink: #ececee;
    --ink-2: #a8abb2;
    --ink-3: #8b8e95;
    --line: #25282d;
    --line-2: #363a40;
    --accent: #7ab0e3;
    --accent-ink: #0d0e10;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 16px 40px -20px rgba(0,0,0,.7);
    color-scheme: dark;
}
:root[data-theme="dark"] .logo-img{ filter: invert(1); }

*, *::before, *::after{ box-sizing: border-box; }

html{
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 16px);
    -webkit-text-size-adjust: 100%;
}

body{
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

img, video{ display: block; max-width: 100%; }
a{ color: inherit; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure{ margin: 0; }

.wrap{
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.ico{
    width: 1em;
    height: 1em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.eyebrow{
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-3);
}

/* ---------- Header ---------- */
.site-header{
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid transparent;
    transition: border-color .25s ease;
}

.site-header.scrolled{ border-bottom-color: var(--line); }

.header-inner{
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 40px;
}

.brand{ display: flex; align-items: center; flex: none; }
.logo-img{ height: 34px; width: auto; }

.nav{
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: auto;
}

.nav a{
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-2);
    text-decoration: none;
    transition: color .15s ease, background-color .15s ease;
}

.nav a:hover{ color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"]{ color: var(--ink); }

.header-actions{ display: flex; align-items: center; gap: 8px; margin-left: auto; }

.lang, .theme{
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}

.lang button, .theme button{
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--ink-3);
    font: 500 12px/1 var(--font);
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease;
}

.theme button{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 7px;
}

.theme .ico{ width: 14px; height: 14px; }

.lang button:hover, .theme button:hover{ color: var(--ink); }
.lang button[aria-pressed="true"], .theme button[aria-pressed="true"]{ background: var(--ink); color: var(--bg); }

.menu-btn{
    display: none;
    appearance: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}

/* ---------- Buttons & links ---------- */
.btn{
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    border-radius: 999px;
    border: 1px solid var(--line-2);
    background: var(--surface);
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: transform .15s ease, background-color .15s ease, border-color .15s ease;
}

.btn:hover{ border-color: var(--ink-3); }
.btn:active{ transform: translateY(1px); }

.btn-primary{
    background: var(--ink);
    border-color: var(--ink);
    color: var(--bg);
}

.btn-primary:hover{ background: color-mix(in srgb, var(--ink) 85%, var(--bg)); border-color: transparent; }

.link-arrow{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--line-2);
    transition: border-color .15s ease;
}

.link-arrow:hover{ border-color: var(--ink); }

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

/* ---------- Page heading (inner pages) ---------- */
.page-head{
    padding-top: 80px;
    padding-bottom: 40px;
}

.page-head h1{
    margin-top: 18px;
    font-size: clamp(2.25rem, 3.6vw + 1rem, 3.75rem);
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: -0.035em;
    text-wrap: balance;
}

html[lang^="zh"] .page-head h1{ letter-spacing: -0.01em; }

.page-head .lead{
    margin-top: 20px;
    max-width: 38em;
    font-size: clamp(1.05rem, .4vw + 1rem, 1.2rem);
    line-height: 1.65;
    color: var(--ink-2);
}

/* ---------- Sections ---------- */
.section{ padding-top: 120px; }

.section-head{
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.section-head h2{
    margin-top: 14px;
    font-size: clamp(1.75rem, 2vw + 1rem, 2.5rem);
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.section-sub{
    margin-top: 10px;
    color: var(--ink-2);
    font-size: 16px;
}

.spacer{ height: 120px; }

/* entrance */
.rise{ animation: rise .8s cubic-bezier(.2,.7,.2,1) both; }
.rise-2{ animation-delay: .08s; }
.rise-3{ animation-delay: .16s; }
.rise-4{ animation-delay: .24s; }

@keyframes rise{
    from{ opacity: 0; transform: translateY(14px); }
    to{ opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px){
    :root{ --gutter: 16px; --header-h: 60px; }

    .menu-btn{ display: inline-flex; }
    .header-inner{ gap: 12px; }
    .header-actions{ gap: 6px; }
    .logo-img{ height: 30px; }

    .nav{
        position: absolute;
        top: var(--header-h);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px var(--gutter) 16px;
        background: var(--bg);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow);
        display: none;
    }

    .menu-open .nav{ display: flex; }
    .menu-open .site-header{ border-bottom-color: var(--line); }

    .nav a{
        padding: 14px 4px;
        font-size: 17px;
        border-radius: 0;
        border-bottom: 1px solid var(--line);
        color: var(--ink);
    }

    .nav a:last-child{ border-bottom: 0; }
    .nav a:hover{ background: transparent; }

    .page-head{ padding-top: 40px; padding-bottom: 28px; }
    .section{ padding-top: 80px; }
    .section-head{ flex-direction: column; align-items: flex-start; }
    .spacer{ height: 80px; }
}

@media (prefers-reduced-motion: reduce){
    html{ scroll-behavior: auto; }
    *, *::before, *::after{
        animation-duration: .01ms !important;
        animation-delay: 0s !important;
        transition-duration: .01ms !important;
    }
}
