/*
 * Site stylesheet for howard0911.github.io.
 * Design tokens live in :root. Dark mode follows the OS until the visitor picks a theme;
 * js/theme.js then sets html[data-theme] from localStorage before first paint.
 */

/* ===== Design tokens ===== */
:root {
  --accent-light: #9f1239;
  --accent-dark: #fb7185;

  --font-sans: "Inter", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 14px;
  --radius-sm: 8px;
  --container: 1080px;
  --gutter: 24px;
  --nav-h: 64px;

  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f3f3f1;
  --text: #121417;
  /* Long-form reading text; slightly softer than --text so dark mode doesn't glare */
  --text-body: #1f2328;
  --muted: #5c6370;
  --subtle: #8b919b;
  --border: #e6e6e3;
  --accent: var(--accent-light);
  --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(16, 18, 23, .04), 0 10px 30px rgba(16, 18, 23, .07);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0f;
    --surface: #121419;
    --surface-2: #191c22;
    --text: #ececee;
    --text-body: #cfd2d8;
    --muted: #a3a9b4;
    --subtle: #737a87;
    --border: #24272e;
    --accent: var(--accent-dark);
    --on-accent: #0b0c0f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0f;
  --surface: #121419;
  --surface-2: #191c22;
  --text: #ececee;
  --text-body: #cfd2d8;
  --muted: #a3a9b4;
  --subtle: #737a87;
  --border: #24272e;
  --accent: var(--accent-dark);
  --on-accent: #0b0c0f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
}
img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.icon { width: 18px; height: 18px; flex: none; }

/* ===== Nav ===== */
/* The include slot is the sticky element: a sticky child inside a same-height wrapper would never stick. */
.nav-slot { position: sticky; top: 0; z-index: 50; min-height: var(--nav-h); }
.site-nav {
  position: relative;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-nav.is-scrolled { border-bottom-color: var(--border); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: var(--nav-h); gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em;
}
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-links { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  display: block; padding: 7px 12px; border-radius: 999px;
  color: var(--muted); font-size: 14.5px; font-weight: 500;
  transition: color .15s, background-color .15s;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--text); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  cursor: pointer; transition: color .15s;
}
.icon-btn:hover { color: var(--text); }
.icon-btn .icon { width: 17px; height: 17px; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}
.menu-btn { display: none; }

/* ===== Buttons and links ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: transform .15s, border-color .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--text) 30%, var(--border)); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn-primary:hover { border-color: transparent; opacity: .9; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 15px; white-space: nowrap; }
.link-arrow .icon { width: 16px; height: 16px; transition: transform .15s; }
.link-arrow:hover .icon { transform: translateX(3px); }

/* ===== Hero and page heads ===== */
.hero { position: relative; padding: 96px 0 88px; overflow: hidden; }
.page-head { position: relative; padding: 80px 0 56px; overflow: hidden; }
.hero::before, .page-head::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(var(--border) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 65% 70% at 25% 35%, #000 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 65% 70% at 25% 35%, #000 30%, transparent 100%);
}
.page-head .container { position: relative; }
.hero-grid { position: relative; display: grid; grid-template-columns: 1.4fr 1fr; gap: 56px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 14px 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.eyebrow-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.hero h1 {
  margin: 22px 0 20px;
  font-size: clamp(2.3rem, 4.4vw + .6rem, 3.8rem);
  line-height: 1.04; letter-spacing: -.038em; font-weight: 700;
  text-wrap: balance;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.page-head h1 {
  font-size: clamp(2.1rem, 3.4vw + .8rem, 3.3rem);
  line-height: 1.08; letter-spacing: -.035em; font-weight: 700;
  text-wrap: balance;
}
.lede { margin: 0 0 32px; max-width: 58ch; color: var(--muted); font-size: 1.125rem; }
.page-head .lede { margin: 18px 0 0; }
.intro { margin-top: 28px; max-width: 70ch; color: var(--muted); font-size: 1.0625rem; }
.intro p { margin: 0 0 1em; }
.intro p:last-child { margin-bottom: 0; }

.profile-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px; box-shadow: var(--shadow);
}
.profile-top { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 68px; height: 68px; border-radius: 18px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
  color: var(--on-accent); font-size: 22px; font-weight: 700; letter-spacing: .02em;
}
.profile-name { margin: 0; font-weight: 650; font-size: 1.05rem; letter-spacing: -.01em; }
.profile-role { margin: 0; color: var(--muted); font-size: 14.5px; }
.facts { margin: 24px 0; display: grid; gap: 14px; }
.facts div { display: grid; grid-template-columns: 92px 1fr; gap: 12px; }
.facts dt { padding-top: 3px; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--subtle); }
.facts dd { margin: 0; font-size: 15px; line-height: 1.55; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tag {
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--muted); font-size: 12.5px; font-weight: 500;
}

/* ===== Sections ===== */
.section { padding: 80px 0; }
.section + .section, .page-head + .section { border-top: 1px solid var(--border); }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px 32px; margin-bottom: 36px; }
.kicker { margin: 0 0 10px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.section h2 { font-size: clamp(1.6rem, 1.6vw + 1.1rem, 2.25rem); line-height: 1.15; letter-spacing: -.028em; font-weight: 700; }
.section-sub { margin: 12px 0 0; max-width: 58ch; color: var(--muted); }
.subhead { margin: 48px 0 18px; font-size: 1.1rem; font-weight: 650; letter-spacing: -.01em; }

/* ===== Timeline (experience and projects) ===== */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { display: grid; grid-template-columns: 190px 1fr; gap: 32px; padding: 30px 0; border-top: 1px solid var(--border); }
.tl-item:last-child { border-bottom: 1px solid var(--border); }
.tl-date { padding-top: 4px; font-family: var(--font-mono); font-size: 13px; color: var(--subtle); }
.tl-item.is-current .tl-date { color: var(--accent); }
.tl-role { font-size: 1.15rem; font-weight: 650; letter-spacing: -.012em; line-height: 1.4; }
.tl-role a:hover { color: var(--accent); }
.tl-org { margin: 3px 0 12px; color: var(--muted); font-size: 15px; }
.tl-group { margin: 20px 0 8px; font-size: .95rem; font-weight: 650; }
.tl-item ul:not(.tags) { margin: 0; padding-left: 1.15em; max-width: 72ch; display: grid; gap: 8px; color: var(--text-body); }
.tl-item li::marker { color: var(--subtle); }
.tl-item .tags { margin: 4px 0 14px; }
.tl-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 12px; font-size: 14.5px; }
.tl-links a { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; }

/* ===== Education, coursework, skills, lists ===== */
.edu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.edu {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 22px 24px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
}
.edu-school { margin: 0; font-weight: 650; }
.edu-school a:hover { color: var(--accent); }
.edu-degree { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.edu-years { font-family: var(--font-mono); font-size: 12.5px; color: var(--subtle); white-space: nowrap; padding-top: 3px; }

.course-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.course { padding: 22px 24px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.course h4 { margin-bottom: 10px; font-size: .95rem; font-weight: 650; }
.course ul { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; color: var(--muted); font-size: 15px; }
.course li::marker { color: var(--subtle); }

.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; margin: 0; }
.skills div { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); }
.skills dt { font-weight: 600; font-size: 15px; }
.skills dd { margin: 0; color: var(--muted); font-size: 15px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.split h2 { margin-bottom: 20px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); font-size: 15px; }
.plain-list li:last-child { border-bottom: 1px solid var(--border); }
.plain-list a { font-weight: 600; }
.plain-list a:hover { color: var(--accent); }
.issuer { flex: none; color: var(--subtle); font-size: 14px; }

/* ===== Article cards ===== */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: color .15s, background-color .15s, border-color .15s;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .2s, box-shadow .2s;
}
.card[hidden] { display: none; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-media { aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
.card-media img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.card:hover .card-media img { transform: scale(1.04); }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.card-cat { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--accent); }
/* Two-class selector so it beats `.section h2` when the card title is an h2 (articles.html). */
.card .card-title { font-size: 1.05rem; font-weight: 650; line-height: 1.45; letter-spacing: -.005em; }
.card-sub { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.card-meta { margin-top: auto; padding-top: 12px; display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 12.5px; color: var(--subtle); }
.card.is-featured { grid-column: 1 / -1; flex-direction: row; }
.card.is-featured .card-media { flex: 0 0 56%; aspect-ratio: 16 / 8; }
.card.is-featured .card-body { justify-content: center; gap: 10px; padding: 32px 36px; }
.card.is-featured .card-title { font-size: 1.6rem; line-height: 1.35; letter-spacing: -.02em; }
.card.is-featured .card-sub { font-size: 15px; }
.card.is-featured .card-meta { margin-top: 10px; }

/* ===== Article page ===== */
.post { padding: 56px 0 88px; }
.post-layout .prose { margin: 0 auto; }
.toc { display: none; }
.toc-title { margin: 0 0 10px; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--subtle); }
.toc ol { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--border); display: grid; gap: 8px; }
.toc a { display: block; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.toc a:hover, .toc a[aria-current="true"] { color: var(--text); }
.toc a[aria-current="true"] { font-weight: 600; }

.prose { max-width: 70ch; font-size: 17px; line-height: 1.85; color: var(--text-body); }
.prose > h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6, .prose b, .prose strong { color: var(--text); }
.prose .crumbs { margin: 0; font-size: 13.5px; color: var(--subtle); }
.prose .crumbs a { color: var(--accent); font-weight: 500; text-decoration: none; }
.prose > h1 { margin: 12px 0 10px; font-size: clamp(1.7rem, 2vw + 1rem, 2.4rem); line-height: 1.25; letter-spacing: -.02em; font-weight: 700; }
.prose .post-en { margin: 0 0 4px; color: var(--muted); font-size: 1.05rem; line-height: 1.5; }
.prose .post-sub { margin: 0; color: var(--muted); font-size: 1.05rem; line-height: 1.5; }
.prose .post-meta { margin: 16px 0 28px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--font-mono); font-size: 12.5px; color: var(--subtle); }
.prose .cover { display: block; width: 100%; aspect-ratio: 21 / 9; object-fit: cover; border-radius: 12px; margin: 0 0 40px; }
.prose h2 { margin: 2.2em 0 .6em; font-size: 1.4rem; line-height: 1.4; letter-spacing: -.012em; font-weight: 700; }
.prose .cover + h2 { margin-top: 0; }
.prose h3 { margin: 1.8em 0 .5em; font-size: 1.15rem; line-height: 1.45; font-weight: 650; }
.prose h4, .prose h5, .prose h6 { margin: 1.6em 0 .4em; font-size: 1rem; line-height: 1.5; font-weight: 650; }
.prose p { margin: 0 0 1.15em; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--subtle); }
.prose b, .prose strong { font-weight: 650; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
/* Article figures are white-background diagrams; framing them keeps them readable in dark mode. */
.prose img:not(.cover) { display: block; margin: 1.6em auto; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: #fff; }

/* ===== Contact ===== */
.cta {
  position: relative; overflow: hidden; text-align: center;
  padding: 64px 32px; border-radius: 24px;
  border: 1px solid var(--border); background: var(--surface);
}
.cta::before {
  content: ""; position: absolute; inset: -40% 10% auto; height: 120%; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 16%, transparent), transparent);
}
.cta > * { position: relative; }
.cta h2 { max-width: 22ch; margin: 0 auto; text-wrap: balance; }
.cta .section-sub { margin: 14px auto 30px; }
.cta .cta-row { justify-content: center; }

.contact-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.contact-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 24px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  transition: transform .15s, box-shadow .15s;
}
.contact-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.contact-icon { width: 40px; height: 40px; margin-bottom: 12px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.contact-label { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--subtle); }
.contact-value { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.contact-note { color: var(--muted); font-size: 14.5px; }

/* ===== Footer ===== */
.site-footer { padding: 32px 0 40px; border-top: 1px solid var(--border); }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; color: var(--subtle); font-size: 14px; }
.footer-inner p { margin: 0; }
.socials { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }

/* ===== Responsive ===== */
@media (min-width: 1024px) {
  .post-layout.has-toc { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 56px; }
  .post-layout.has-toc .prose { margin: 0; }
  .post-layout.has-toc .toc {
    display: block; position: sticky; top: calc(var(--nav-h) + 32px); align-self: start;
    max-height: calc(100vh - var(--nav-h) - 64px); overflow-y: auto;
  }
}
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .profile-card { max-width: 520px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .course-grid, .skills, .split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .menu-btn { display: inline-grid; }
  .nav-resume { display: none; }
  .nav-links {
    display: none; position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 8px var(--gutter) 16px; background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .site-nav.is-open .nav-links { display: flex; }
  .nav-links a { padding: 12px; border-radius: 10px; font-size: 16px; }
  .contact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .hero { padding: 56px 0 56px; }
  .page-head { padding: 56px 0 40px; }
  .section { padding: 56px 0; }
  .tl-item { grid-template-columns: 1fr; gap: 6px; padding: 24px 0; }
  .edu-grid, .cards { grid-template-columns: 1fr; }
  .edu { flex-direction: column; gap: 6px; }
  .skills div { grid-template-columns: 1fr; gap: 4px; }
  .plain-list li { flex-direction: column; gap: 2px; }
  .card.is-featured { flex-direction: column; }
  .card.is-featured .card-media { flex: none; aspect-ratio: 16 / 9; }
  .card.is-featured .card-body { padding: 18px 20px; gap: 6px; }
  .card.is-featured .card-title { font-size: 1.15rem; }
  .post { padding: 32px 0 56px; }
  .prose { font-size: 16.5px; }
  .cta { padding: 44px 20px; }
  .cta .btn { flex: 1 1 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  html { scroll-behavior: auto; }
}
