
/* ---------- Tokens ---------- */
:root {
  --blue-900: #0b2a66;
  --blue-700: #1d4ed8;
  --blue-500: #3b82f6;
  --blue-100: #dbe8ff;
  --blue-50:  #eef4ff;
  --white:    #ffffff;
  --ink:      #12203d;
  --muted:    #5b6b8c;
  --radius:   14px;
  --gap:      1.25rem;
  --max:      1120px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Base (mobile first) ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--blue-500); outline-offset: 3px; }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e8ecf4;
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 60px;
}
.logo {
  font-family: var(--serif); font-weight: 700; font-size: 1.35rem;
  color: var(--blue-900); text-decoration: none;
  border-bottom: 3px solid var(--blue-700); padding-bottom: 1px;
}
/* Mobile: menu button toggles a dropdown list */
.menu-btn {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
  width: 44px; height: 44px; padding: 0 11px; margin-right: -11px;
  background: none; border: 0; cursor: pointer;
}
.menu-btn span {
  display: block; height: 2px; background: var(--ink); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav {
  display: none; flex-direction: column;
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--white); border-bottom: 1px solid #e8ecf4;
  padding: .5rem 1.25rem 1rem;
}
.nav.open { display: flex; }
.nav a {
  text-decoration: none; font-size: 1rem; color: var(--muted);
  padding: .8rem 0; border-bottom: 1px solid #f0f3f9;
}
.nav a:last-child { border-bottom: 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--blue-700); }

/* ---------- Hero ---------- */
.hero {
  background: var(--white);
  color: var(--ink);
  padding: 2.75rem 0 1.5rem;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 7vw, 3.5rem);
  line-height: 1.1; margin: 0 0 .9rem; max-width: 16ch;
}
.hero h1::after {
  content: ""; display: block; width: 96px; height: 5px; margin-top: 1.1rem;
  background: var(--blue-700); border-radius: 4px;
}
.hero p { margin: 0; max-width: 46ch; color: var(--muted); font-size: 1.05rem; }

/* ---------- Filter chips ---------- */
.filters {
  display: flex; gap: .5rem; overflow-x: auto;
  padding: 1.5rem 0 .25rem; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font: inherit; font-size: .9rem; cursor: pointer;
  padding: .4rem .95rem; border-radius: 999px;
  border: 1px solid #e3e8f2; background: var(--white); color: var(--muted);
}
.chip:hover { border-color: var(--blue-500); }
.chip[aria-pressed="true"] {
  background: var(--white); border-color: var(--blue-700); color: var(--blue-700); font-weight: 600;
}

/* ---------- Post grid ---------- */
.grid {
  display: grid; gap: var(--gap);
  grid-template-columns: 1fr;          /* mobile: one column */
  padding: 1.25rem 0 3rem; margin: 0; list-style: none;
}
.card {
  display: flex; flex-direction: column; height: 100%;
  text-decoration: none;
  background: var(--white);
  border: 1px solid #e8ecf4;
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.card:hover, .card:focus-visible {
  border-color: var(--blue-500);
  box-shadow: 0 10px 26px rgba(18,32,61,.08);
  transform: translateY(-3px);
}
.thumb {
  aspect-ratio: 16 / 9; width: 100%; object-fit: cover;
  background: #f6f8fc;
}
.thumb.ph { display: grid; place-items: center; }
.thumb.ph span {
  font-family: var(--serif); font-size: 2.6rem; color: var(--blue-500);
}
.card-body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.tag {
  align-self: flex-start; font-size: .78rem; font-weight: 600;
  color: var(--blue-700); background: none;
  padding: 0; border-radius: 0;
}
.card h2 { font-family: var(--serif); font-size: 1.25rem; line-height: 1.3; margin: 0; color: var(--ink); }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }
.meta { margin-top: auto; padding-top: .5rem; font-size: .83rem; color: var(--muted); }
.empty { padding: 3rem 0; color: var(--muted); }

/* ---------- Single post view ---------- */
.post { padding: 2rem 0 4rem; max-width: 720px; }
.back {
  display: inline-block; margin-bottom: 1.5rem; text-decoration: none;
  color: var(--blue-700); font-weight: 600;
}
.back:hover { text-decoration: underline; }
.post h1 { font-family: var(--serif); font-size: clamp(1.9rem, 6vw, 2.8rem); line-height: 1.15; color: var(--ink); margin: .6rem 0; }
.post .meta { padding: 0; margin-bottom: 1.5rem; }
.post .cover { border-radius: var(--radius); margin-bottom: 1.75rem; width: 100%; }
.post .content { font-family: var(--serif); font-size: 1.12rem; line-height: 1.8; }
.post .content p { margin: 0 0 1.2rem; }
.post .content h2 { font-family: var(--sans); color: var(--blue-700); font-size: 1.3rem; margin: 2rem 0 .6rem; }
.post .content blockquote {
  margin: 1.5rem 0; padding: .6rem 1.2rem;
  border-left: 4px solid var(--blue-700); background: var(--white); color: var(--ink); font-style: italic;
}

.post .content pre {
  background: #f6f8fc; border: 1px solid #e8ecf4; border-left: 4px solid var(--blue-700);
  border-radius: 8px; padding: 1rem 1.1rem; margin: 0 0 1.4rem;
  overflow-x: auto; font-size: .92rem; line-height: 1.6;
}
.post .content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.post .content :not(pre) > code { background: #f6f8fc; padding: .1rem .35rem; border-radius: 4px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--white); color: var(--muted); border-top: 1px solid #e8ecf4; padding: 2rem 0; font-size: .9rem; }
.site-footer .wrap { display: flex; flex-direction: column; gap: .6rem; }

/* ---------- Tablet ---------- */
@media (min-width: 640px) {
  .wrap { padding: 0 2rem; }
  .menu-btn { display: none; }
  .nav {
    display: flex; flex-direction: row; position: static; gap: 1.5rem;
    padding: 0; border: 0; background: none;
  }
  .nav a { padding: .25rem 0; border-bottom: 2px solid transparent; font-size: .95rem; }
  .nav a:last-child { border-bottom: 2px solid transparent; }
  .nav a:hover, .nav a[aria-current="page"] { border-color: var(--blue-700); }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 4.5rem 0; }
  .site-footer .wrap { flex-direction: row; justify-content: space-between; }
}

/* ---------- Desktop ---------- */
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 1.75rem; }
  .hero { padding: 6rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
  .card:hover, .card:focus-visible { transform: none; }
}

/* ---------- Multi-page additions ---------- */
.card[hidden], li[hidden] { display: none; }
.related { border-top: 1px solid #e8ecf4; margin-top: 3rem; padding-top: 1.5rem; }
.related h2 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 .75rem; color: var(--ink); }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.related a { color: var(--blue-700); text-decoration: none; font-weight: 600; }
.related a:hover { text-decoration: underline; }
.post .cover { aspect-ratio: 3 / 2; object-fit: cover; }
.thumb { aspect-ratio: 3 / 2; }
.post .content h3 { font-family: var(--sans); font-size: 1.1rem; color: var(--ink); margin: 1.6rem 0 .5rem; }
.post .content ul, .post .content ol { margin: 0 0 1.2rem; padding-left: 1.3rem; }
.post .content li { margin-bottom: .3rem; }
.table-wrap { overflow-x: auto; margin: 0 0 1.4rem; }
.post .content table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .93rem; line-height: 1.5; }
.post .content th, .post .content td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid #e8ecf4; white-space: nowrap; }
.post .content th { color: var(--blue-700); border-bottom: 2px solid var(--blue-700); }
.quiz { padding-left: 1.3rem; }
.quiz li { margin-bottom: 1.4rem; }
.quiz details { font-family: var(--sans); font-size: .95rem; }
.quiz summary { cursor: pointer; color: var(--blue-700); font-weight: 600; }
.quiz details p { margin: .4rem 0 0; }

/* ---------- Structure upgrade for notes ---------- */
:root { --serif: var(--sans); }
.post { max-width: 760px; margin-left: auto; margin-right: auto; }
.post .content { font-family: var(--sans); font-size: 1.04rem; line-height: 1.75; }
.post h1 { font-weight: 800; letter-spacing: -.01em; }
.post .content h2 {
  font-size: 1.5rem; line-height: 1.25; color: var(--ink); font-weight: 800;
  margin: 3rem 0 1rem; padding: .15rem 0 .15rem .8rem;
  border-left: 5px solid var(--blue-700); scroll-margin-top: 80px;
}
.post .content h3 {
  font-size: 1.12rem; color: var(--blue-700); font-weight: 700;
  margin: 2rem 0 .6rem; padding-bottom: .35rem; border-bottom: 1px solid #e8ecf4;
}
.post .content blockquote {
  background: #f3f7ff; border: 1px solid var(--blue-100); border-left: 5px solid var(--blue-700);
  border-radius: 8px; font-style: normal; padding: .9rem 1.1rem; margin: 1.6rem 0;
}
.post .content strong { color: var(--ink); }
.table-wrap { border: 1px solid #e8ecf4; border-radius: 10px; }
.post .content th { background: #f3f7ff; border-bottom: 2px solid var(--blue-700); }
.post .content tbody tr:nth-child(even) td { background: #fafbfe; }
.post .content tbody tr:last-child td { border-bottom: 0; }
.post .content pre { border-radius: 10px; }
.post .back { display: block; width: fit-content; }
.post > .tag { display: inline-block; margin-top: .25rem; }
.report { font-family: var(--sans); font-size: .95rem; color: var(--muted); margin: 2.5rem 0 0; }
.report a, .site-footer a { color: var(--blue-700); }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } }
.toc { background: #fafbfe; border: 1px solid #e8ecf4; border-radius: 12px; padding: 1rem 1.2rem 1.1rem; margin: 0 0 2rem; font-family: var(--sans); }
.toc strong { display: block; margin-bottom: .5rem; color: var(--ink); }
.toc ol { margin: 0; padding-left: 1.3rem; display: grid; gap: .3rem; }
.toc a { color: var(--blue-700); text-decoration: none; font-weight: 500; }
.toc a:hover { text-decoration: underline; }
@media (min-width: 640px) { .toc ol { grid-template-columns: 1fr 1fr; column-gap: 2rem; } }
