:root {
  --ink: #111111;
  --paper: #f5f2e9;
  --white: #fffdf7;
  --blue: #1557ff;
  --blue-dark: #0b37b9;
  --yellow: #ffd928;
  --mint: #5bd9a1;
  --purple: #a66cff;
  --muted: #68645c;
  --line: 3px solid var(--ink);
  --shadow: 7px 7px 0 var(--ink);
  --max: 1480px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 1px 1px, rgba(17, 17, 17, .12) 1px, transparent 1.2px) 0 0 / 18px 18px,
    var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.5;
}

a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 4px solid var(--yellow); outline-offset: 4px; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 1000; padding: 12px 16px; background: var(--yellow); border: var(--line); font-weight: 900; }
.skip-link:focus { top: 16px; }

.reading-progress { position: fixed; inset: 0 0 auto; height: 6px; z-index: 200; background: var(--ink); }
.reading-progress span { display: block; width: 0; height: 100%; background: var(--yellow); }

.site-header {
  width: min(calc(100% - 32px), var(--max));
  margin: 16px auto 0;
  min-height: 78px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  background: var(--white);
  border: var(--line);
  box-shadow: var(--shadow);
}

.wordmark { display: flex; align-items: center; text-decoration: none; }
.wordmark-main { align-self: stretch; display: grid; place-items: center; padding: 0 22px; color: var(--white); background: var(--blue); border-right: var(--line); font: 900 clamp(1.15rem, 2vw, 1.6rem)/1 Impact, Haettenschweiler, "Arial Black", sans-serif; letter-spacing: .04em; }
.wordmark-sub { padding: 0 18px; font-size: .76rem; font-weight: 900; letter-spacing: .16em; }
.site-nav { display: flex; align-items: stretch; }
.site-nav a { min-width: 88px; display: grid; place-items: center; padding: 0 16px; border-left: var(--line); text-decoration: none; font-weight: 900; letter-spacing: .08em; transition: background .15s ease, color .15s ease; }
.site-nav a:hover, .site-nav a.active { background: var(--ink); color: var(--white); }
.site-nav .language-switch { min-width: 68px; background: var(--yellow); color: var(--ink); }

#content { width: min(calc(100% - 32px), var(--max)); margin: 40px auto 64px; }
.index-hero { overflow: hidden; background: var(--blue); color: var(--white); border: var(--line); box-shadow: var(--shadow); }
.index-kicker { display: flex; justify-content: space-between; padding: 12px 18px; color: var(--ink); background: var(--yellow); border-bottom: var(--line); font-size: .78rem; font-weight: 900; letter-spacing: .14em; }
.index-hero h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; padding: clamp(24px, 4vw, 58px); font: 900 clamp(5rem, 14vw, 13rem)/.78 Impact, Haettenschweiler, "Arial Black", sans-serif; letter-spacing: -.055em; text-transform: uppercase; }
.index-hero h1 span { display: block; }
.index-hero h1 .outline { color: transparent; -webkit-text-stroke: clamp(2px, .35vw, 5px) var(--white); text-shadow: none; }
.index-intro { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: 22px clamp(24px, 4vw, 58px); border-top: var(--line); background: var(--white); color: var(--ink); }
.index-intro p { max-width: 760px; margin: 0; font-size: clamp(1rem, 2vw, 1.35rem); font-weight: 700; }
.feed-link { padding: 10px 14px; background: var(--mint); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); text-decoration: none; font-weight: 900; }

.post-list { margin-top: 56px; }
.list-heading { display: flex; align-items: end; justify-content: space-between; padding: 0 0 12px; border-bottom: var(--line); }
.list-heading h2 { margin: 0; font: 900 clamp(2rem, 5vw, 4.5rem)/.9 Impact, Haettenschweiler, "Arial Black", sans-serif; letter-spacing: -.02em; }
.list-heading > span { padding: 7px 10px; background: var(--yellow); border: 2px solid var(--ink); font-weight: 900; }
.post-card { position: relative; display: grid; grid-template-columns: 92px 1fr 86px; min-height: 240px; margin-top: 24px; background: var(--white); border: var(--line); box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease; animation: card-in .55s both; }
.post-card:nth-of-type(2) { animation-delay: .08s; }
.post-card:nth-of-type(3) { animation-delay: .16s; }
.post-card:hover { transform: translate(-3px, -3px); box-shadow: 11px 11px 0 var(--ink); }
.post-number { display: grid; place-items: start center; padding-top: 24px; background: var(--yellow); border-right: var(--line); font: 900 2.8rem/1 Impact, Haettenschweiler, "Arial Black", sans-serif; }
.post-card-main { padding: clamp(22px, 3vw, 38px); }
.post-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .72rem; font-weight: 900; letter-spacing: .08em; color: var(--muted); }
.post-card h3 { max-width: 980px; margin: 15px 0 12px; font: 900 clamp(2rem, 4.5vw, 4.5rem)/.95 Impact, Haettenschweiler, "Arial Black", sans-serif; letter-spacing: -.025em; }
.post-card h3 a { text-decoration: none; background: linear-gradient(var(--yellow), var(--yellow)) 0 100% / 0 12px no-repeat; transition: background-size .2s ease; }
.post-card:hover h3 a { background-size: 100% 12px; }
.post-card p { max-width: 860px; margin: 0; font-family: ui-serif, Georgia, "Noto Serif TC", serif; font-size: 1.05rem; }
.post-tags, .rail-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 20px; }
.post-tags span, .rail-tags span { padding: 4px 7px; background: var(--paper); border: 1.5px solid var(--ink); font-size: .68rem; font-weight: 900; text-transform: uppercase; }
.post-arrow { display: grid; place-items: center; border-left: var(--line); background: var(--mint); text-decoration: none; font-size: 2.3rem; font-weight: 900; }
.empty-state { padding: 60px 24px; border: var(--line); border-top: 0; background: var(--white); }

.article-page { background: var(--white); border: var(--line); box-shadow: var(--shadow); }
.article-header { position: relative; overflow: hidden; padding: clamp(28px, 6vw, 86px); padding-top: clamp(80px, 10vw, 120px); background: var(--blue); color: var(--white); border-bottom: var(--line); }
.article-header::after { content: ""; position: absolute; width: 230px; height: 230px; right: -64px; bottom: -88px; background: var(--yellow); border: var(--line); transform: rotate(14deg); }
.back-link { position: absolute; left: clamp(28px, 6vw, 86px); top: 28px; z-index: 2; text-decoration: none; font-size: .78rem; font-weight: 900; letter-spacing: .1em; }
.article-stamp { display: inline-block; margin-bottom: 20px; padding: 7px 10px; background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); transform: rotate(-1.2deg); font-weight: 900; letter-spacing: .1em; }
.article-header h1 { position: relative; z-index: 1; max-width: 1160px; margin: 0; font: 900 clamp(3.4rem, 8vw, 8rem)/.91 Impact, Haettenschweiler, "Arial Black", sans-serif; letter-spacing: -.035em; }
.article-deck { position: relative; z-index: 1; max-width: 860px; margin: 28px 0 0; font-family: ui-serif, Georgia, "Noto Serif TC", serif; font-size: clamp(1.1rem, 2vw, 1.45rem); font-weight: 700; }
.article-meta { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; margin-top: 34px; font-size: .75rem; font-weight: 900; letter-spacing: .08em; }
.article-meta a { padding: 7px 10px; background: var(--white); color: var(--ink); border: 2px solid var(--ink); text-decoration: none; }
.article-grid { display: grid; grid-template-columns: minmax(210px, 280px) minmax(0, 850px); justify-content: center; gap: clamp(34px, 6vw, 90px); padding: clamp(36px, 6vw, 88px); }
.article-rail { min-width: 0; }
.rail-block { padding-top: 14px; border-top: var(--line); }
.rail-block + .rail-block { margin-top: 38px; }
.rail-label { display: block; margin-bottom: 12px; font-size: .72rem; font-weight: 900; letter-spacing: .14em; }
.toc-block { position: sticky; top: 24px; }
.toc-details summary { margin-bottom: 12px; list-style: none; cursor: default; font-size: .72rem; font-weight: 900; letter-spacing: .14em; }
.toc-details summary::-webkit-details-marker { display: none; }
#tableOfContents ul { margin: 0; padding: 0; list-style: none; }
#tableOfContents ul ul { padding-left: 12px; border-left: 2px solid var(--ink); }
#tableOfContents li { margin: 8px 0; }
#tableOfContents a { display: inline-block; color: var(--muted); text-decoration: none; font-size: .75rem; line-height: 1.3; }
#tableOfContents a:hover, #tableOfContents a.current { color: var(--blue); font-weight: 900; }
.article-content { min-width: 0; font-family: ui-serif, Georgia, "Noto Serif TC", "PingFang TC", serif; font-size: clamp(1.04rem, 1.7vw, 1.22rem); line-height: 1.85; }
.article-content > :first-child { margin-top: 0; }
.article-content h1 { display: none; }
.article-content h2, .article-content h3 { scroll-margin-top: 24px; font-family: Impact, Haettenschweiler, "Arial Black", "PingFang TC", sans-serif; line-height: 1.08; letter-spacing: -.015em; }
.article-content h2 { margin: 2.5em 0 .7em; padding: 12px 16px; background: var(--yellow); border: var(--line); box-shadow: 4px 4px 0 var(--ink); font-size: clamp(2rem, 4vw, 3.4rem); }
.article-content h3 { margin: 2em 0 .6em; color: var(--blue-dark); font-size: clamp(1.45rem, 3vw, 2.1rem); }
.article-content .headerlink { margin-left: .25em; color: var(--blue); text-decoration: none; opacity: 0; }
.article-content h2:hover .headerlink, .article-content h3:hover .headerlink { opacity: 1; }
.article-content a { color: var(--blue-dark); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.article-content strong { background: linear-gradient(transparent 58%, rgba(255, 217, 40, .8) 58%); }
.article-content blockquote { margin: 2em 0; padding: 18px 22px; background: var(--paper); border: var(--line); border-left: 12px solid var(--purple); font-family: ui-monospace, monospace; font-size: .92em; }
.article-content blockquote p { margin: 0; }
.article-content pre { position: relative; overflow-x: auto; margin: 2em 0; padding: 22px; background: var(--ink); color: var(--white); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--blue); font: .86rem/1.65 ui-monospace, monospace; }
.article-content :not(pre) > code { padding: .12em .35em; background: #e6e1d5; border: 1px solid var(--ink); font: .86em/1.2 ui-monospace, monospace; }
.article-content table { display: block; overflow-x: auto; width: 100%; margin: 2em 0; border-collapse: collapse; font-family: ui-monospace, monospace; font-size: .82em; }
.article-content th, .article-content td { min-width: 150px; padding: 10px 12px; border: 2px solid var(--ink); text-align: left; }
.article-content th { background: var(--yellow); }
.article-content img { max-width: 100%; height: auto; border: var(--line); box-shadow: var(--shadow); }
.article-content li { margin: .4em 0; }
.article-content hr { margin: 3em 0; border: 0; border-top: var(--line); }
.copy-code { position: absolute; right: 8px; top: 8px; padding: 5px 8px; border: 1px solid var(--white); background: var(--ink); color: var(--white); font: 700 .68rem ui-monospace, monospace; cursor: pointer; }
.mermaid-frame { overflow-x: auto; margin: 2em 0; padding: 22px; background: var(--paper); border: var(--line); box-shadow: 5px 5px 0 var(--purple); }
.article-end { display: flex; justify-content: space-between; gap: 24px; padding: 26px clamp(28px, 6vw, 86px); background: var(--yellow); border-top: var(--line); font-weight: 900; }
.article-end a { text-decoration: none; }

.blog-footer { width: min(calc(100% - 32px), var(--max)); margin: 0 auto 24px; display: flex; justify-content: space-between; gap: 20px; padding: 18px 20px; background: var(--ink); color: var(--white); border: var(--line); font-size: .72rem; font-weight: 900; letter-spacing: .08em; }

@keyframes card-in { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  .article-grid { grid-template-columns: 1fr; }
  .article-rail { display: grid; grid-template-columns: 1fr 1.5fr; gap: 24px; }
  .rail-block + .rail-block { margin-top: 0; }
  .toc-block { position: static; }
}

@media (max-width: 680px) {
  .site-header { min-height: 64px; }
  .wordmark-main { padding: 0 12px; font-size: 1rem; }
  .wordmark-sub { display: none; }
  .site-nav a { min-width: 0; padding: 0 11px; font-size: .72rem; }
  #content { margin-top: 24px; }
  .index-hero h1 { padding: 32px 20px; font-size: clamp(4.2rem, 23vw, 8rem); }
  .index-intro { grid-template-columns: 1fr; }
  .feed-link { justify-self: start; }
  .post-card { grid-template-columns: 54px 1fr; }
  .post-number { padding-top: 20px; font-size: 1.9rem; }
  .post-arrow { grid-column: 1 / -1; min-height: 54px; border-top: var(--line); border-left: 0; }
  .article-header::after { width: 130px; height: 130px; }
  .article-header h1 { font-size: clamp(2.8rem, 15vw, 5rem); }
  .article-grid { padding: 32px 20px; }
  .article-rail { grid-template-columns: 1fr; }
  .toc-details summary { display: flex; align-items: center; justify-content: space-between; margin: 0; cursor: pointer; }
  .toc-details summary::after { content: "+"; font-size: 1.25rem; line-height: 1; }
  .toc-details[open] summary { margin-bottom: 12px; }
  .toc-details[open] summary::after { content: "−"; }
  .article-content { font-size: 1rem; }
  .article-content h2 { margin-left: -8px; margin-right: -8px; }
  .article-end, .blog-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
