/* Layout: one narrow reading column (720px), sticky top bar with a four-color Google strip.
   Google colors are accents only: the strip, tag dots, section markers, and link underlines. */
:root {
  /* Google brand colors (source: w3schools.com/colors/colors_brands.asp) */
  --blue: #4285F4;
  --red: #EA4335;
  --yellow: #FBBC05;
  --green: #34A853;

  /* Neutrals, light theme (slight blue bias). */
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f5f7fa;
  --fg: #1a1c20;
  --muted: #5b6370;
  --line: #e1e5eb;
  --focus: #4285F4;

  --font-ui: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-read: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --col: 720px;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.6;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--bg);
}

/* ---------- Links & focus ---------- */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover { color: var(--blue); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

/* ---------- Page frame ---------- */
.wrap {
  max-width: var(--col);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap.wide { max-width: 880px; }

.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  background: var(--bg);
}
.site-header::after { /* the four-color strip */
  content: ""; display: block; height: 3px;
  background: linear-gradient(90deg,
    var(--blue) 0 25%, var(--red) 25% 50%, var(--yellow) 50% 75%, var(--green) 75% 100%);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-block: 14px;
}
.wordmark {
  font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em;
  text-decoration: none; white-space: nowrap;
}
.wordmark:hover { color: var(--fg); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav a:hover { color: var(--fg); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--fg); box-shadow: inset 0 -2px 0 var(--blue); border-radius: 0; }


main { padding-block: 48px 64px; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.site-footer .wrap {
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; padding-block: 24px;
}
.site-footer .wrap { align-items: center; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 14px; }
.icon-link { display: block; border-radius: 6px; line-height: 0; transition: transform .15s ease, opacity .15s ease; }
.icon-link img { width: 28px; height: 28px; display: block; }
.icon-link:hover { transform: translateY(-2px); opacity: 0.85; }

/* ---------- Type ---------- */
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.9rem, 5vw, 2.5rem); font-weight: 600; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 60ch; }
.eyebrow {
  font-family: var(--font-mono); font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.section { display: flex; flex-direction: column; gap: 20px; margin-top: 56px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); font: inherit; font-size: 0.95rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface); color: var(--fg); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.primary:hover { opacity: 0.88; color: var(--bg); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Tags (color = topic) ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
}
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.tag[data-tag="physics"]::before { background: var(--blue); }
.tag[data-tag="project"]::before { background: var(--green); }
.tag[data-tag="paper"]::before { background: var(--red); }
.tag[data-tag="note"]::before { background: var(--yellow); }

/* ---------- Post list ---------- */
.post-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.post-list li {
  position: relative; margin-inline: -12px; padding-inline: 12px; border-radius: 8px;
  display: grid; grid-template-columns: 8.5rem 1fr; gap: 6px 20px;
  padding-block: 20px;
  background: linear-gradient(var(--line), var(--line)) no-repeat center bottom / calc(100% - 24px) 1px;
}
.post-list time { font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); padding-top: 3px; font-variant-numeric: tabular-nums; }
.post-list .body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.post-list h3 a { text-decoration: none; }
.post-list h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 8px; } /* makes the whole row clickable */
.post-list h3 a:focus-visible { outline: none; }
.post-list li:has(a:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.post-list li:hover { background-color: var(--surface); }
.post-list h3 a:hover { text-decoration: underline; text-decoration-color: var(--blue); }
.post-list p { color: var(--muted); font-size: 0.97rem; }
@media (max-width: 560px) { .post-list li { grid-template-columns: 1fr; } }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; }

/* ---------- Home ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.facts dt { font-family: var(--font-mono); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding-top: 3px; }
.facts dd { margin: 0; min-width: 0; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 10px; } }

/* ---------- Resume ---------- */
.resume-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px 20px; }

.r-section h2 { display: flex; align-items: center; gap: 10px; }
.r-section h2::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--c, var(--blue)); }
.entry { display: flex; flex-direction: column; gap: 6px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; padding-bottom: 0; }
/* Entries with an organization logo: logo in a left column, text in the right */
.entry.has-logo { display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 16px; row-gap: 6px; align-items: start; }
.entry.has-logo > :not(.logo) { grid-column: 2; }
.entry .logo {
  grid-column: 1; grid-row: 1 / span 2;
  width: 44px; height: 44px; border-radius: 8px; object-fit: contain;
}
@media (max-width: 420px) { .entry.has-logo { grid-template-columns: 36px minmax(0, 1fr); column-gap: 12px; } .entry .logo { width: 36px; height: 36px; } }
.entry-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; }
.entry-top h3 { min-width: 0; }
.entry-top .dates { font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry .where { color: var(--muted); }
.entry .where strong { color: var(--fg); font-weight: 600; }
.entry .label { font-weight: 600; }
.entry ul { margin: 4px 0 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 4px; }
.skills { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.skills dt { font-weight: 600; }
.skills dd { margin: 0; color: var(--muted); min-width: 0; }
@media (max-width: 480px) { .skills { grid-template-columns: 1fr; gap: 0; } .skills dd { margin-bottom: 10px; } }

/* ---------- Article (blog post) ---------- */
.back { font-size: 0.92rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--fg); }
.post-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; color: var(--muted); }
.post-meta time { font-family: var(--font-mono); font-size: 0.85rem; }
.prose { font-family: var(--font-read); font-size: 1.15rem; line-height: 1.7; display: flex; flex-direction: column; gap: 18px; }
.prose h2 { font-family: var(--font-ui); margin-top: 22px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.prose code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.equation {
  font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.7;
  background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 0;
  overflow-x: auto; white-space: pre;
}
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 0.85rem; }
td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.note { font-family: var(--font-ui); font-size: 0.92rem; color: var(--muted); border-left: 3px solid var(--yellow); padding-left: 14px; }
.sources { font-family: var(--font-ui); font-size: 0.95rem; }

/* ---------- Reading lists (book posts) ---------- */
/* Diagram box. Wide diagrams scroll sideways on phones instead of shrinking the text. */
.diagram { margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow-x: auto; }
.diagram .mermaid { margin: 0; font-family: var(--font-ui); text-align: center; color: var(--muted); font-size: 0.9rem; white-space: pre; }
.diagram svg { min-width: 560px; height: auto; }
.diagram figcaption { margin-top: 10px; font-family: var(--font-ui); position: sticky; left: 0; }
.swipe-hint { display: none !important; font-style: italic; }
@media (max-width: 620px) { .swipe-hint { display: inline-flex !important; } }
/* One block per subject (h3), one card per book */
.prose h3 { font-family: var(--font-ui); margin-top: 14px; }
.book {
  font-family: var(--font-ui); font-size: 0.97rem; line-height: 1.55;
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; align-items: start;
}
/* Book cover slot (2:3, like a real cover). Empty div = dashed placeholder; <img class="cover"> = the real cover. */
.cover {
  width: 64px; aspect-ratio: 2 / 3; border-radius: 4px;
  background: var(--surface); border: 1px dashed var(--line);
}
img.cover { display: block; height: auto; aspect-ratio: auto; object-fit: cover; border: 1px solid var(--line); background: none; }
.book-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.book-title { font-weight: 600; }
.book-title i { font-style: normal; }
.book-title .by { font-weight: 400; color: var(--muted); }
.level {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; vertical-align: 2px;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 400; text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid var(--line); color: var(--muted);
}
.level.ug { border-color: var(--blue); }
.level.grad { border-color: var(--red); }
.book-links { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.92rem; }
.book-links b { font-weight: 600; }
@media (max-width: 420px) { .book { grid-template-columns: 52px minmax(0, 1fr); gap: 12px; } .cover { width: 52px; } }

/* Diagram legend (colored dots + labels) */
.key { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.85rem; color: var(--muted); }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Small centered arrow between textbook sections */
.next-arrow { display: flex; justify-content: center; color: #000; margin: 4px 0 -6px; }
.next-arrow svg { display: block; }
