/* ============================================================
   Home (zh-TW) — Editorial redesign
   Self-contained styles for /tw/index.html. Does not depend on
   style.css; the page intentionally opts out of the global theme.
   ============================================================ */

/* ---------- TOKENS ---------- */
:root {
    /* Warm light "newsprint" palette */
    --paper:        oklch(97% 0.012 80deg);
    --paper-2:      oklch(94% 0.015 75deg);
    --paper-edge:   oklch(88% 0.020 75deg);
    --ink:          oklch(22% 0.025 50deg);
    --ink-2:        oklch(40% 0.020 50deg);
    --ink-3:        oklch(55% 0.015 55deg);
    --rule:         oklch(85% 0.018 70deg);
    --accent:       oklch(62% 0.13 60deg);
    --accent-soft:  oklch(62% 0.13 60deg / 12%);
    --highlight:    oklch(92% 0.09 75deg);
    --serif: "Source Serif 4", "Noto Serif TC", georgia, "Times New Roman", serif;
    --sans:  "Noto Sans TC", -apple-system, blinkmacsystemfont, "Segoe UI", system-ui, sans-serif;
    --mono:  "JetBrains Mono", ui-monospace, "SFMono-Regular", menlo, monospace;
    --maxw: 1240px;
    --gutter: clamp(20px, 4vw, 56px);
    --r: 4px;
}

[data-theme="dark"] {
    --paper:        oklch(18% 0.015 50deg);
    --paper-2:      oklch(22% 0.018 50deg);
    --paper-edge:   oklch(30% 0.020 50deg);
    --ink:          oklch(94% 0.020 80deg);
    --ink-2:        oklch(78% 0.020 75deg);
    --ink-3:        oklch(62% 0.020 65deg);
    --rule:         oklch(32% 0.020 55deg);
    --accent:       oklch(78% 0.14 65deg);
    --accent-soft:  oklch(78% 0.14 65deg / 16%);
    --highlight:    oklch(50% 0.10 75deg / 55%);
}

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

html, body {
    margin: 0;
    padding: 0;
}
html { color-scheme: light dark; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizelegibility;
    transition: background-color .25s ease, color .25s ease;
}

::selection {
    background: var(--accent);
    color: var(--paper);
}

a {
    color: inherit;
    text-decoration: none;
}

/* Subtle paper texture (pure CSS, no http) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, var(--accent-soft), transparent 60%);
    opacity: .8;
    z-index: 0;
}

main, header.masthead {
    position: relative;
    z-index: 1;
}

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

/* ---------- MASTHEAD ---------- */
.masthead {
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
    background: color-mix(in oklab, var(--paper) 90%, transparent);
    backdrop-filter: saturate(140%) blur(6px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.masthead-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
}

.brand {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: -0.01em;
    line-height: 1;
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
}

.brand .mark {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
    transform: translateY(2px);
    position: relative;
}

.brand .mark::after {
    content: "";
    position: absolute;
    inset: 6px;
    background: var(--paper);
    border-radius: 50%;
}

.brand small {
    font-family: var(--sans);
    font-weight: 500;
    font-size: 12px;
    color: var(--ink-3);
    letter-spacing: .14em;
    text-transform: uppercase;
    margin-left: 4px;
}

nav.primary {
    display: flex;
    gap: 26px;
    align-items: center;
}

.mobile-nav {
    display: none;
}

.mobile-nav .wrap {
    display: flex;
    flex-direction: column;
}

.mobile-nav a {
    font-size: 15px;
    color: var(--ink-2);
    padding: 13px 0;
    border-top: 1px solid var(--rule);
}

nav.primary a {
    font-size: 14px;
    color: var(--ink-2);
    position: relative;
    padding: 6px 0;
}
nav.primary a:hover { color: var(--ink); }

nav.primary a:hover::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--accent);
}

nav.primary .lang {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--ink-3);
    border: 1px solid var(--rule);
    padding: 4px 8px;
    border-radius: var(--r);
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--rule);
    border-radius: var(--r);
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    transition: all .15s ease;
}

.icon-btn:hover {
    color: var(--ink);
    border-color: var(--ink-3);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.nav-toggle { display: none; }

@media (width <= 820px) {
    nav.primary .nav-link { display: none; }
    .nav-toggle { display: inline-flex; }
    .mobile-nav.is-open { display: block; }
}

/* On phones the brand + the EN / theme / menu controls overflow the masthead,
   pushing the nav-toggle (hamburger) off-screen so mobile nav is unreachable.
   Hide the "BRUCE JHANG" sub-wordmark and tighten the control gap so all three
   controls stay on screen. */
@media (width <= 480px) {
    .brand small { display: none; }
    nav.primary { gap: 14px; }
}

/* ---------- ISSUE BAR ---------- */
.issue-bar {
    border-bottom: 1px solid var(--rule);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.issue-bar .wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px var(--gutter);
}

/* ---------- HERO ---------- */
.hero {
    padding: clamp(40px, 7vw, 96px) 0 clamp(32px, 5vw, 64px);
    border-bottom: 1px solid var(--rule);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: clamp(24px, 5vw, 64px);
    align-items: end;
}

.kicker {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kicker::before {
    content: "";
    width: 28px;
    height: 1px;
    background: var(--accent);
}

h1.display {
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(40px, 6.4vw, 88px);
    line-height: 0.98;
    letter-spacing: -0.025em;
    margin: 0 0 24px;
    text-wrap: balance;
}

h1.display em {
    /* CJK has no real italic glyphs; lean on colour + weight, not faux slant. */
    font-style: normal;
    color: var(--accent);
    font-weight: 600;
}

h1.display .nowrap {
    display: inline-block;
    white-space: nowrap;
}

.lede {
    font-family: var(--serif);
    font-size: clamp(17px, 1.4vw, 21px);
    line-height: 1.55;
    color: var(--ink-2);
    max-width: 60ch;
    margin: 0;
}

.lede::first-letter {
    font-weight: 700;
    color: var(--ink);
}

.author-card {
    border-left: 1px solid var(--rule);
    padding-left: 28px;
    font-size: 14px;
    color: var(--ink-2);
    line-height: 1.6;
}

.author-card .label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 8px;
}

.author-card .name {
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 6px;
}

.author-card ul {
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
}

.author-card li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 5px 0;
    border-top: 1px dashed var(--rule);
    font-size: 13px;
}
.author-card li:first-child { border-top: 0; }

.author-card li span:first-child {
    color: var(--ink-3);
    width: 60px;
    flex-shrink: 0;
}

.author-card li span:last-child {
    min-width: 0;
    flex: 1;
    text-align: right;
    white-space: nowrap;
}

@media (width <= 760px) {
    .hero-grid { grid-template-columns: 1fr; }

    .author-card {
        border-left: 0;
        border-top: 1px solid var(--rule);
        padding-left: 0;
        padding-top: 24px;
    }
}

/* ---------- SECTION SCAFFOLD ---------- */
section.col {
    padding: clamp(48px, 6vw, 88px) 0;
    border-bottom: 1px solid var(--rule);
}

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

.section-title {
    font-family: var(--serif);
    font-size: clamp(28px, 3.2vw, 40px);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.05;
    margin: 0;
}

.section-title small {
    display: block;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 500;
    margin-bottom: 10px;
}

.section-meta {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-3);
    border-top: 1px solid var(--ink);
    padding-top: 8px;
    text-align: right;
    min-width: 120px;
}

/* ---------- CHIP FILTERS ---------- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 28px;
}

.chip {
    font-family: var(--sans);
    font-size: 13px;
    padding: 6px 12px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    transition: all .15s ease;
    user-select: none;
}

.chip:hover {
    border-color: var(--ink-3);
    color: var(--ink);
}

.chip.is-active {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.chip .count {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-3);
    margin-left: 6px;
}
.chip.is-active .count { color: color-mix(in oklab, var(--paper) 60%, transparent); }

/* ---------- EDITORIAL CARD GRID ---------- */
.topics {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0;
    border-top: 1px solid var(--rule);
}

.card {
    grid-column: span 4;
    padding: 28px 28px 28px 0;
    border-bottom: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background-color .15s ease;
    cursor: pointer;
}

.card:nth-child(3n) {
    border-right: 0;
    padding-right: 0;
}
.card:nth-child(3n+1) { padding-left: 0; }

.card:nth-child(3n+2),
.card:nth-child(3n) { padding-left: 28px; }

.card:hover { background: var(--paper-2); }

.card .num {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-3);
    letter-spacing: .14em;
    margin-bottom: 16px;
}

.card .cat {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
}

.card h3 {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 24px;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 10px;
    color: var(--ink);
    text-wrap: balance;
}

.card .dek {
    font-size: 14px;
    color: var(--ink-2);
    line-height: 1.55;
    margin: 0 0 18px;
    flex-grow: 1;
}

.card .meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-3);
    letter-spacing: .08em;
    display: flex;
    gap: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--rule);
}

.card .meta .dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--ink-3);
    align-self: center;
}

.card .arrow {
    position: absolute;
    top: 28px;
    right: 28px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-3);
    transition: all .2s ease;
}
.card:nth-child(3n) .arrow { right: 0; }

.card:hover .arrow {
    color: var(--accent);
    transform: translate(2px, -2px);
}

/* JS toggles .is-hidden for filter / show-more. On .is-extra cards it also
   serves as the no-JS default so extras stay collapsed without inline styles. */
#topics .card.is-hidden { display: none; }

/* Visible-position classes (JS-managed on #topics) override :nth-child so the
   layout stays correct when category filter / show-more reorders visibility. */
#topics .card.is-row-start {
    padding-left: 0;
    padding-right: 28px;
    border-right: 1px solid var(--rule);
}

#topics .card.is-row-mid {
    padding-left: 28px;
    padding-right: 28px;
    border-right: 1px solid var(--rule);
}

#topics .card.is-row-end {
    padding-left: 28px;
    padding-right: 0;
    border-right: 0;
}

#topics .card.is-row-start .arrow,
#topics .card.is-row-mid .arrow { right: 28px; }
#topics .card.is-row-end .arrow { right: 0; }

@media (width <= 920px) {
    .card { grid-column: span 6; }

    .card:nth-child(3n) {
        border-right: 1px solid var(--rule);
        padding-right: 28px;
    }
    .card:nth-child(3n+1) { padding-left: 0; }

    .card:nth-child(odd) {
        border-right: 1px solid var(--rule);
        padding-right: 28px;
        padding-left: 0;
    }

    .card:nth-child(even) {
        border-right: 0;
        padding-right: 0;
        padding-left: 28px;
    }
    .card:nth-child(odd) .arrow { right: 28px; }
    .card:nth-child(even) .arrow { right: 0; }

    /* Reset desktop column overrides on mobile, then apply 2-col layout. */
    #topics .card.is-row-start,
    #topics .card.is-row-mid,
    #topics .card.is-row-end {
        padding: 28px 28px 28px 0;
        border-right: 1px solid var(--rule);
    }

    #topics .card.is-row-start .arrow,
    #topics .card.is-row-mid .arrow,
    #topics .card.is-row-end .arrow { right: 28px; }

    #topics .card.is-mobile-end {
        padding-left: 28px;
        padding-right: 0;
        border-right: 0;
    }
    #topics .card.is-mobile-end .arrow { right: 0; }
}

@media (width <= 600px) {
    .card {
        grid-column: span 12;
        padding: 22px 0 !important;
        border-right: 0 !important;
    }
    .card .arrow { right: 0 !important; }
}

/* ---------- VIEW MORE ---------- */
.view-more {
    margin-top: 32px;
    display: flex;
    justify-content: center;
}

.btn {
    font-family: var(--sans);
    font-size: 14px;
    padding: 12px 22px;
    background: var(--ink);
    color: var(--paper);
    border: 1px solid var(--ink);
    border-radius: var(--r);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all .15s ease;
}

.btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.btn.ghost {
    background: transparent;
    color: var(--ink);
}

.btn.ghost:hover {
    background: var(--ink);
    color: var(--paper);
}

.btn svg {
    width: 14px;
    height: 14px;
    transition: transform .2s ease;
}

.btn.is-open svg { transform: rotate(180deg); }

/* ---------- LATEST WRITING (asymmetric editorial spread) ---------- */
.spread {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: 0;
    border-top: 1px solid var(--rule);
}

.spread > * {
    padding: 36px;
    border-bottom: 1px solid var(--rule);
}

.spread .lead-story {
    grid-row: span 2;
    border-right: 1px solid var(--rule);
    padding-left: 0;
    background: transparent;
    cursor: pointer;
    transition: background .15s ease;
}
.spread .lead-story:hover { background: var(--paper-2); }

.spread .lead-story .pic {
    aspect-ratio: 4 / 3;
    background:
        repeating-linear-gradient(135deg, var(--paper-edge) 0 1px, transparent 1px 14px),
        var(--paper-2);
    border: 1px solid var(--rule);
    margin-bottom: 24px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-3);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.spread .lead-story h3 {
    font-family: var(--serif);
    font-size: clamp(28px, 3vw, 36px);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.015em;
    margin: 0 0 14px;
    text-wrap: balance;
}

.spread .lead-story .dek {
    font-family: var(--serif);
    font-size: 17px;
    color: var(--ink-2);
    line-height: 1.55;
    margin: 0;
}

.spread .lead-story .cat {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 10px;
}

.spread .side-story {
    padding-right: 0;
    cursor: pointer;
    transition: background .15s ease;
}
.spread .side-story:hover { background: var(--paper-2); }

.spread .side-story h3 {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 8px 0;
    text-wrap: balance;
}

.spread .side-story .dek {
    font-size: 14px;
    color: var(--ink-2);
    line-height: 1.55;
    margin: 0;
}

.spread .side-story .meta {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--accent);
}

@media (width <= 760px) {
    .spread { grid-template-columns: 1fr; }

    .spread .lead-story {
        border-right: 0;
        padding-left: 0;
        padding-right: 0;
        grid-row: auto;
    }
    .spread > * { padding: 28px 0; }
}

/* ---------- FOOTER ---------- */
footer.foot {
    padding: 56px 0 64px;
    background: var(--paper);
}

.foot-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 36px;
    padding-bottom: 36px;
    border-bottom: 1px solid var(--rule);
}

.foot-grid h4 {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin: 0 0 14px;
    font-weight: 500;
}

.foot-grid ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* stylelint-disable-next-line no-descending-specificity */
.foot-grid li {
    padding: 5px 0;
    font-size: 14px;
}

/* stylelint-disable-next-line no-descending-specificity */
.foot-grid li a { color: var(--ink-2); }
.foot-grid li a:hover { color: var(--accent); }

.foot-blurb {
    font-family: var(--serif);
    font-size: 16px;
    color: var(--ink-2);
    line-height: 1.55;
    max-width: 32ch;
}

.colophon {
    margin-top: 24px;
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-3);
}

@media (width <= 760px) {
    .foot-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- DROP-CAP UTILITY ---------- */
.drop-cap::first-letter {
    font-family: var(--serif);
    font-size: 4.2em;
    line-height: .85;
    float: left;
    padding: 4px 10px 0 0;
    font-weight: 700;
    color: var(--accent);
}

/* Highlight marker */
.hl {
    background: linear-gradient(transparent 60%, var(--highlight) 60%);
    padding: 0 2px;
}
