/* ==================================================================
   gowrishankar.me/blog — reader styles
   Lightweight, Medium-inspired: white canvas, sans interface, serif reading
   text at a comfortable measure, side space used for navigation and tools.
   System fonts only; no external requests.
   ================================================================== */

:root {
  --bg: #ffffff;
  --ink: #1f2328;
  --muted: #5f6b7a;
  --rule: #e6e9ee;
  --soft: #f5f7f9;
  --accent: #0b6e8a;
  --accent-ink: #ffffff;
  --link: #0b6e8a;
  --heart: #d1345b;
  --mark: #ffe9a8;
  --code-bg: #0f1a24;
  --code-ink: #dbe4ec;
  --tip: #1f7a45;
  --warn: #9a5b00;
  --danger: #b42318;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style", Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;

  --max: 76rem;
  --measure: 46rem;
  --header-h: 3.5rem;
  --radius: 8px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --ink: #e6eaef;
    --muted: #9aa6b5;
    --rule: #262d36;
    --soft: #181d23;
    --accent: #5fc0dc;
    --accent-ink: #0b1a20;
    --link: #74c9e2;
    --heart: #ff6b8b;
    --mark: #5c4d16;
    --code-bg: #0a0e13;
    --tip: #5cc28a;
    --warn: #e0a54a;
    --danger: #ff8a7f;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 1rem); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 1rem; line-height: 1.55; }
a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
img { max-width: 100%; height: auto; }
mark { background: var(--mark); color: inherit; padding: 0 0.1em; }
button { font: inherit; color: inherit; }
summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }

.icon { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-sm { width: 0.9rem; height: 0.9rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 1rem; top: -4rem; background: var(--ink); color: var(--bg); padding: 0.5rem 0.75rem; z-index: 100; border-radius: 4px; }
.skip-link:focus { top: 0.75rem; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding-inline: clamp(1rem, 3vw, 2rem); }
.wrap.narrow { max-width: 50rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.empty { color: var(--muted); padding: 1.5rem 0; }

.btn, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border-radius: 999px; padding: 0.55rem 1.1rem; font-weight: 600; cursor: pointer; border: 1px solid transparent;
}
.btn { background: var(--ink); color: var(--bg); }
.btn-secondary { background: transparent; border-color: var(--rule); }
.btn:hover { opacity: 0.88; }

/* ------------------------------ Reading progress ------------------------------ */

.read-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; will-change: transform; }

/* ----------------------------------- Header ----------------------------------- */

/* Solid background, deliberately no backdrop-filter: that property makes the header the containing
   block for position:fixed children, which would squeeze the full-screen mobile menu into the header. */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--bg); border-bottom: 1px solid var(--rule); }
.header-bar { display: flex; align-items: center; gap: 1.5rem; height: var(--header-h); }
.site-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; white-space: nowrap; margin-right: auto; }

.menu { display: flex; align-items: center; gap: 0.25rem; list-style: none; margin: 0; padding: 0; }
.menu > li > a, .menu summary { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.45rem 0.7rem; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 0.95rem; list-style: none; }
.menu > li > a:hover, .menu summary:hover, .dropdown[open] > summary { color: var(--ink); background: var(--soft); }
.dropdown { position: relative; }
.dropdown[open] > summary .icon-sm { transform: rotate(180deg); }
.submenu {
  position: absolute; top: calc(100% + 0.4rem); left: 0; min-width: 15rem; max-height: 70vh; overflow-y: auto;
  list-style: none; margin: 0; padding: 0.5rem; background: var(--bg); border: 1px solid var(--rule);
  border-radius: var(--radius); box-shadow: 0 12px 32px rgb(15 23 42 / 0.12); z-index: 60;
}
.submenu a { display: block; padding: 0.45rem 0.6rem; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 0.95rem; }
.submenu a:hover { background: var(--soft); }
.submenu ul { list-style: none; margin: 0 0 0.25rem; padding: 0 0 0 0.75rem; border-left: 1px solid var(--rule); margin-left: 0.6rem; }
.submenu ul a { color: var(--muted); font-size: 0.9rem; padding-block: 0.3rem; }
.submenu-all { font-weight: 600; }

.icon-link { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; color: var(--muted); }
.icon-link:hover { background: var(--soft); color: var(--ink); }

.nav-mobile { display: none; }
.nav-mobile > summary { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; list-style: none; color: var(--ink); }
.nav-mobile[open] > summary { background: var(--soft); }
.nav-mobile > nav {
  position: fixed; inset: var(--header-h) 0 0 0; overflow-y: auto; background: var(--bg);
  padding: 1rem clamp(1rem, 4vw, 2rem) 3rem; border-top: 1px solid var(--rule);
}
.nav-mobile ul { list-style: none; margin: 0; padding: 0; }
.nav-mobile li a, .m-group > summary { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 0; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; font-size: 1.05rem; list-style: none; }
.m-group[open] > summary .icon-sm { transform: rotate(180deg); }
.m-group ul { padding-left: 1rem; }
.m-group ul a { font-size: 1rem; color: var(--muted); }
.m-search input { width: 100%; font: inherit; padding: 0.7rem 0.9rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--soft); color: var(--ink); margin-bottom: 0.5rem; }

@media (max-width: 900px) {
  .nav-desktop, .search-link { display: none; }
  .nav-mobile { display: block; }
}

/* ----------------------------------- Footer ----------------------------------- */

.site-footer { border-top: 1px solid var(--rule); margin-top: 4rem; color: var(--muted); font-size: 0.9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem 2rem; padding-block: 1.75rem 2.5rem; }
.footer-inner p { margin: 0; }
.footer-inner ul { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; list-style: none; margin: 0; padding: 0; }
.footer-inner a { color: var(--muted); }

/* ------------------------------- Page structure ------------------------------- */

.intro { padding-block: clamp(2rem, 5vw, 3.25rem) clamp(1.5rem, 3vw, 2rem); border-bottom: 1px solid var(--rule); margin-bottom: 2rem; }
.statement { font-size: clamp(1.75rem, 3.6vw, 2.6rem); line-height: 1.15; letter-spacing: -0.025em; font-weight: 800; margin: 0; max-width: 28ch; text-wrap: balance; }
.intro-by { margin: 0.75rem 0 0; color: var(--muted); }
.page-title { font-size: clamp(1.7rem, 3.4vw, 2.3rem); line-height: 1.15; letter-spacing: -0.02em; font-weight: 800; margin: 2rem 0 0.75rem; }
.section-title { font-size: 0.95rem; font-weight: 700; margin: 2rem 0 0.5rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--rule); }

.layout-2col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
@media (min-width: 960px) {
  .layout-2col { grid-template-columns: minmax(0, 1fr) 18.5rem; gap: 3.5rem; }
  .layout-2col > .sidebar { position: sticky; top: calc(var(--header-h) + 1.5rem); align-self: start; }
}

/* ---------------------------------- Sidebar ---------------------------------- */

.sidebar { display: grid; gap: 1.75rem; align-content: start; font-size: 0.95rem; }
.side-block h2 { font-size: 0.95rem; font-weight: 700; margin: 0 0 0.6rem; }
.side-block p { margin: 0 0 0.4rem; }
.popular { margin: 0; padding: 0; list-style: none; counter-reset: pop; display: grid; gap: 0.75rem; }
.popular li { counter-increment: pop; display: grid; grid-template-columns: 1.75rem 1fr; line-height: 1.35; }
.popular li::before { content: counter(pop, decimal-leading-zero); color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.popular a { color: var(--ink); text-decoration: none; font-weight: 600; }
.popular a:hover { color: var(--link); text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; margin: 0; padding: 0; }
.chips a, .chips span { display: inline-block; padding: 0.3rem 0.75rem; border-radius: 999px; background: var(--soft); color: var(--ink); text-decoration: none; font-size: 0.875rem; }
.chips a:hover { background: color-mix(in srgb, var(--accent) 14%, var(--soft)); }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }

/* ----------------------------------- Cards ----------------------------------- */

.card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; padding-block: 1.5rem; border-bottom: 1px solid var(--rule); }
.card.has-image { grid-template-columns: minmax(0, 1fr) 10rem; align-items: start; }
.card-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--muted); }
.card-meta a { color: var(--ink); font-weight: 600; text-decoration: none; }
.card-meta a:hover { text-decoration: underline; }
.card-title { font-size: 1.3rem; line-height: 1.3; letter-spacing: -0.01em; font-weight: 800; margin: 0 0 0.35rem; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { color: var(--link); }
.card-excerpt { font-family: var(--serif); color: var(--muted); font-size: 1.02rem; line-height: 1.5; margin: 0 0 0.55rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin: 0; font-size: 0.85rem; color: var(--muted); }
.card-image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; }
@media (max-width: 560px) { .card.has-image { grid-template-columns: minmax(0, 1fr) 6.5rem; } .card-title { font-size: 1.12rem; } }

.lead { padding-bottom: 1.75rem; border-bottom: 1px solid var(--rule); }
.lead-image img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); display: block; margin-bottom: 1rem; }
.lead-title { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.2; letter-spacing: -0.02em; font-weight: 800; margin: 0 0 0.5rem; }
.lead-title a { color: var(--ink); text-decoration: none; }
.lead-title a:hover { color: var(--link); }
.lead-excerpt { font-family: var(--serif); font-size: 1.12rem; color: var(--muted); line-height: 1.5; margin: 0 0 0.6rem; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 1.75rem; font-size: 0.95rem; }
.pager a { font-weight: 600; }
.pager-pos { color: var(--muted); }

/* ---------------------------------- Article ---------------------------------- */

.post-grid { display: grid; grid-template-columns: minmax(0, var(--measure)); justify-content: center; gap: 4rem; }
@media (min-width: 1100px) {
  .post-grid { grid-template-columns: minmax(0, var(--measure)) 17rem; }
  .aside-sticky { position: sticky; top: calc(var(--header-h) + 1.75rem); display: grid; gap: 2rem; max-height: calc(100vh - var(--header-h) - 3rem); overflow-y: auto; padding-right: 0.25rem; }
  .toc-inline { display: none; }
}
@media (max-width: 1099px) { .post-aside { display: none; } }

.post-header { padding-top: clamp(1.5rem, 4vw, 2.75rem); }
.breadcrumbs ol { display: flex; flex-wrap: wrap; list-style: none; margin: 0 0 1rem; padding: 0; font-size: 0.875rem; }
.breadcrumbs li + li::before { content: "/"; color: var(--rule); margin: 0 0.55rem; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--ink); text-decoration: underline; }
.post-title { font-size: clamp(1.9rem, 4.4vw, 2.75rem); line-height: 1.14; letter-spacing: -0.025em; font-weight: 800; margin: 0 0 0.75rem; text-wrap: balance; }
.post-lede { font-family: var(--serif); font-size: clamp(1.12rem, 2vw, 1.3rem); line-height: 1.5; color: var(--muted); margin: 0 0 1.5rem; }
.byline { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.25rem; }
.byline p { margin: 0; }
.byline-name a { color: var(--ink); font-weight: 700; text-decoration: none; }
.byline-name a:hover { text-decoration: underline; }
.byline-dates { display: flex; flex-wrap: wrap; gap: 0 0.9rem; color: var(--muted); font-size: 0.9rem; }
.byline-avatar img, .author-card-avatar img { width: 2.75rem; height: 2.75rem; border-radius: 50%; object-fit: cover; display: block; }

/* Action bar: likes, share, contact, report */
.actions-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; padding-block: 0.5rem; border-block: 1px solid var(--rule); margin-bottom: 2rem; }
.actions-bottom { margin-top: 2.5rem; margin-bottom: 0; }
.act { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.75rem; border: 0; background: none; border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 0.9rem; list-style: none; }
.act:hover { background: var(--soft); color: var(--ink); }
.act-quiet { margin-left: auto; }
.like-btn[aria-pressed="true"] { color: var(--heart); }
.like-btn[aria-pressed="true"] .icon { fill: currentColor; }
.like-btn span[data-like-count] { font-variant-numeric: tabular-nums; font-weight: 600; }
.share { position: relative; }
.share-menu {
  position: absolute; top: calc(100% + 0.35rem); left: 0; z-index: 40; min-width: 12rem; list-style: none; margin: 0; padding: 0.4rem;
  background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: 0 12px 32px rgb(15 23 42 / 0.12);
}
.share-menu a, .share-menu button { display: block; width: 100%; text-align: left; padding: 0.45rem 0.6rem; border-radius: 6px; border: 0; background: none; color: var(--ink); text-decoration: none; font-size: 0.92rem; cursor: pointer; }
.share-menu a:hover, .share-menu button:hover { background: var(--soft); }
.actions-bottom .share-menu { top: auto; bottom: calc(100% + 0.35rem); }

.post-hero { margin: 0 0 2rem; }
.post-hero img { width: 100%; display: block; border-radius: var(--radius); }
.post-hero figcaption, .prose figcaption { color: var(--muted); font-size: 0.875rem; margin-top: 0.5rem; text-align: center; }

.takeaways { background: var(--soft); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 2rem; }
.takeaways h2 { font-size: 0.95rem; margin: 0 0 0.5rem; }
.takeaways ul { margin: 0; padding-left: 1.2rem; line-height: 1.6; }
.takeaways li + li { margin-top: 0.35rem; }

.toc-inline { border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0 0 2rem; }
.toc-inline > summary { font-weight: 700; }
.toc-inline ol, .toc ol { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.toc h2 { font-size: 0.95rem; margin: 0 0 0.5rem; }
.toc ol { border-left: 1px solid var(--rule); font-size: 0.9rem; }
.toc a, .toc-inline a { display: block; padding: 0.28rem 0 0.28rem 0.85rem; color: var(--muted); text-decoration: none; line-height: 1.35; border-left: 2px solid transparent; margin-left: -1px; }
.toc a:hover, .toc-inline a:hover { color: var(--ink); }
.toc a[aria-current="true"] { color: var(--ink); border-left-color: var(--accent); font-weight: 600; }
.toc .toc-l3 a, .toc-inline .toc-l3 a { padding-left: 1.7rem; font-size: 0.86rem; }

/* Long-form text */
.prose { font-family: var(--serif); font-size: 1.175rem; line-height: 1.72; overflow-wrap: break-word; }
.prose > * { margin: 0; }
.prose > * + * { margin-top: 1.15em; }
.prose h2, .prose h3, .prose h4 { font-family: var(--sans); line-height: 1.25; letter-spacing: -0.015em; font-weight: 800; }
.prose h2 { font-size: 1.5rem; margin-top: 2em; }
.prose h3 { font-size: 1.22rem; margin-top: 1.7em; }
.prose h4 { font-size: 1.05rem; margin-top: 1.5em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0.55em; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35em; }
.prose blockquote { margin-left: 0; padding-left: 1.2rem; border-left: 3px solid var(--ink); font-style: italic; }
.prose hr { border: 0; text-align: center; margin: 2.25em 0; }
.prose hr::after { content: "* * *"; color: var(--muted); letter-spacing: 0.6em; }
.prose :not(pre) > code { font-family: var(--mono); font-size: 0.84em; background: var(--soft); border: 1px solid var(--rule); border-radius: 4px; padding: 0.08em 0.3em; }
.prose figure { margin-inline: 0; }
.prose figure img { display: block; border-radius: 6px; }

/* Code blocks */
.prose pre, .code-block { font-family: var(--mono); font-size: 0.875rem; line-height: 1.6; background: var(--code-bg); color: var(--code-ink); border-radius: var(--radius); }
.prose pre { padding: 1rem 1.15rem; overflow-x: auto; tab-size: 2; }
.code-block { overflow: hidden; }
.code-block pre { margin: 0; border-radius: 0; }
.code-bar { min-height: 2.2rem; display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0.75rem 0.35rem 1.15rem; border-bottom: 1px solid rgb(255 255 255 / 0.08); font-family: var(--sans); font-size: 0.8rem; color: #93a4b5; }
.code-copy { font: inherit; color: inherit; background: none; border: 1px solid rgb(255 255 255 / 0.15); border-radius: 4px; padding: 0.15rem 0.55rem; cursor: pointer; }
.code-copy:hover { color: #fff; border-color: rgb(255 255 255 / 0.35); }
.hljs-comment, .hljs-quote { color: #7f93a6; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-meta .hljs-keyword { color: #8fb8ff; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute .hljs-string { color: #a5d8a0; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: #f2c48d; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #e6c3ff; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: #8ad7e6; }
.hljs-type, .hljs-title.class_ { color: #ffd88a; }
.hljs-meta, .hljs-doctag { color: #b0bfcc; }
.hljs-deletion { color: #ff9a9a; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* Callouts */
.callout { font-family: var(--sans); font-size: 1rem; line-height: 1.6; border-left: 3px solid var(--accent); background: var(--soft); padding: 0.9rem 1.15rem; border-radius: 0 var(--radius) var(--radius) 0; }
.callout > * { margin: 0; }
.callout > * + * { margin-top: 0.6em; }
.callout::before { display: block; font-weight: 700; font-size: 0.875rem; margin-bottom: 0.3rem; content: "Note"; color: var(--accent); }
.callout-tip { border-left-color: var(--tip); }
.callout-tip::before { content: "Tip"; color: var(--tip); }
.callout-warning { border-left-color: var(--warn); }
.callout-warning::before { content: "Warning"; color: var(--warn); }
.callout-security { border-left-color: var(--danger); }
.callout-security::before { content: "Security advisory"; color: var(--danger); }

.references, .changelog { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); font-size: 0.95rem; }
.references h2, .changelog h2 { font-size: 1rem; margin: 0 0 0.6rem; }
.references ol { padding-left: 1.3rem; margin: 0; }
.references li + li { margin-top: 0.3rem; }
.changelog p { margin: 0 0 0.6rem; color: var(--muted); }
.changelog ol { list-style: none; margin: 0; padding: 0; }
.changelog li { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; padding: 0.4rem 0; border-top: 1px solid var(--rule); }
.changelog time { color: var(--muted); font-variant-numeric: tabular-nums; }

.post-tags { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; margin: 2rem 0 0; padding: 0; }
.post-tags a { display: inline-block; font-size: 0.875rem; padding: 0.3rem 0.75rem; border-radius: 999px; background: var(--soft); color: var(--ink); text-decoration: none; }
.post-tags a:hover { background: color-mix(in srgb, var(--accent) 14%, var(--soft)); }

.author-card { display: flex; gap: 1rem; align-items: flex-start; margin-top: 2rem; padding: 1.25rem; background: var(--soft); border-radius: var(--radius); font-size: 0.95rem; }
.author-card p { margin: 0; }
.author-card-name { font-weight: 700; }
.author-card-name a { color: var(--ink); }
.author-card-role { color: var(--muted); margin-bottom: 0.3rem !important; }

.related { margin-top: 3rem; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 2.5rem; }
.related-grid .card.has-image { grid-template-columns: minmax(0, 1fr) 6rem; }

/* Report dialog */
.report-dialog { width: min(32rem, calc(100vw - 2rem)); border: 1px solid var(--rule); border-radius: 12px; padding: 1.5rem; background: var(--bg); color: var(--ink); }
.report-dialog::backdrop { background: rgb(10 14 19 / 0.55); }
.report-dialog h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.report-dialog form { display: grid; gap: 0.4rem; }
.report-dialog label { font-weight: 600; font-size: 0.9rem; margin-top: 0.5rem; }
.report-dialog input, .report-dialog select, .report-dialog textarea { font: inherit; width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--bg); color: var(--ink); }
.report-dialog textarea { resize: vertical; }
.report-dialog p { margin: 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-status { min-height: 1.25rem; font-size: 0.9rem; }
.form-status[data-state="error"] { color: var(--danger); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.75rem; }

/* ------------------------- Term, search, archive, author ------------------------- */

.term-header { padding-bottom: 1.25rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--rule); }
.term-kind { margin: 2rem 0 0; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.term-header .page-title { margin-top: 0.2rem; }
.term-description { font-family: var(--serif); font-size: 1.12rem; line-height: 1.55; max-width: 44em; margin: 0 0 0.6rem; }
.term-count { color: var(--muted); margin: 0 0 0.75rem; font-size: 0.92rem; }

.search-form { display: flex; gap: 0.5rem; margin: 0 0 1.5rem; }
.search-form input { flex: 1; min-width: 0; font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--soft); border: 1px solid var(--rule); border-radius: 999px; padding: 0.7rem 1rem; }
.search-form input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.search-summary { color: var(--muted); }
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding-block: 1.25rem; border-bottom: 1px solid var(--rule); }
.result-snippet { font-family: var(--serif); line-height: 1.55; margin: 0; color: var(--muted); }

.archive-year h2 { font-size: 1.1rem; margin: 2rem 0 0.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--rule); }
.archive-year ol { list-style: none; margin: 0; padding: 0; }
.archive-year li { display: grid; grid-template-columns: 7rem 1fr; gap: 1rem; padding-block: 0.45rem; }
.archive-year time { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; padding-top: 0.1rem; }
.archive-year a { color: var(--ink); font-weight: 600; text-decoration: none; }
.archive-year a:hover { color: var(--link); text-decoration: underline; }

.author-header { display: grid; gap: 1.25rem; align-items: center; padding-block: 2rem 1.5rem; border-bottom: 1px solid var(--rule); margin-bottom: 1rem; }
.author-header.has-avatar { grid-template-columns: 6.5rem 1fr; }
.author-header .page-title { margin: 0 0 0.2rem; }
.author-photo img { width: 6.5rem; height: 6.5rem; border-radius: 50%; object-fit: cover; display: block; }
.author-role { margin: 0; color: var(--muted); font-size: 1.05rem; }
.author-headline { font-family: var(--serif); font-size: 1.15rem; margin: 0.4rem 0 0; }
.author-bio { margin-bottom: 1.5rem; }
@media (max-width: 520px) { .author-header.has-avatar { grid-template-columns: 1fr; } }

.error-page { padding-top: 1rem; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--rule); margin: 2rem 0 0; line-height: 1; }

.preview-banner { font-size: 0.9rem; padding: 0.6rem 1rem; text-align: center; background: #fff1cc; color: #4d3800; border-bottom: 1px solid #e9d494; }
.preview-banner a { margin-left: 0.75rem; color: inherit; font-weight: 600; }

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

@media print {
  .site-header, .site-footer, .post-aside, .related, .actions-bar, .read-progress, .toc-inline, .code-copy, .skip-link, .sidebar { display: none !important; }
  body { background: #fff; color: #000; }
  .post-grid, .layout-2col { grid-template-columns: 1fr; }
  .prose a::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
}

/* ------------------------------ Q&A and discussion ------------------------------ */

.faq { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.faq h2 { font-size: 1.3rem; margin: 0 0 1rem; }
.faq-item { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.faq-item:last-child { border-bottom: 0; }
.faq-item h3 { font-size: 1.05rem; line-height: 1.4; margin: 0 0 0.4rem; }
.faq-answer { font-family: var(--serif); font-size: 1.05rem; line-height: 1.65; }
.faq-answer p { margin: 0 0 0.6rem; }
.faq-answer p:last-child { margin: 0; }

.comments { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.comments > h2 { font-size: 1.3rem; margin: 0 0 1rem; }
.comment-list, .comment-replies { list-style: none; margin: 0; padding: 0; }
.comment-list > li { padding-block: 1.1rem; border-bottom: 1px solid var(--rule); }
.comment-replies { margin: 0.75rem 0 0 1.4rem; padding-left: 1rem; border-left: 2px solid var(--rule); display: grid; gap: 0.9rem; }
.comment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.92rem; }
.comment-avatar { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--soft); color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.comment-name { font-weight: 700; }
.author-badge { font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: color-mix(in srgb, var(--accent) 15%, var(--bg)); color: var(--accent); }
.comment-date { color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.comment-date:hover { text-decoration: underline; }
.is-author .comment-avatar { background: color-mix(in srgb, var(--accent) 18%, var(--bg)); color: var(--accent); }
.comment-body { margin: 0.4rem 0 0 2.5rem; font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
.comment-body p { margin: 0 0 0.6rem; }
.comment-body p:last-child { margin: 0; }
.comment-body pre { background: var(--code-bg); color: var(--code-ink); padding: 0.75rem 0.9rem; border-radius: 6px; overflow-x: auto; font-size: 0.85rem; }
.comment-body code { font-family: var(--mono); font-size: 0.88em; }
.comment-body :not(pre) > code { background: var(--soft); padding: 0.05em 0.3em; border-radius: 4px; }
.comment-actions { display: flex; gap: 1rem; margin: 0.35rem 0 0 2.5rem; }
.link-btn { border: 0; background: none; padding: 0; color: var(--link); font-size: 0.875rem; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.quiet { color: var(--muted); }
@media (max-width: 560px) { .comment-body, .comment-actions { margin-left: 0; } .comment-replies { margin-left: 0.5rem; } }

.comment-form { display: grid; gap: 0.4rem; margin-top: 1.5rem; padding: 1.25rem; background: var(--soft); border-radius: var(--radius); }
.comment-form h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.comment-form label { font-weight: 600; font-size: 0.9rem; margin-top: 0.4rem; }
.comment-form input, .comment-form textarea { font: inherit; width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--bg); color: var(--ink); }
.comment-form textarea { resize: vertical; }
.comment-form .btn { justify-self: start; margin-top: 0.5rem; }
.comment-form p { margin: 0; }
.comment-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.comment-fields > div { display: grid; gap: 0.3rem; }
@media (max-width: 560px) { .comment-fields { grid-template-columns: 1fr; } }
.replying { font-size: 0.9rem; }

/* Tables in articles */
.prose .table-scroll { overflow-x: auto; margin-block: 1.4em; border: 1px solid var(--rule); border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.95rem; line-height: 1.5; }
.prose th, .prose td { padding: 0.6rem 0.8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.prose th + th, .prose td + td { border-left: 1px solid var(--rule); }
.prose thead th { background: var(--soft); font-weight: 700; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td p, .prose th p { margin: 0; }
.prose td p + p, .prose th p + p { margin-top: 0.5em; }
.prose td code { white-space: nowrap; }

/* External links in articles: a small arrow signals that they open in a new tab. */
.prose a[target="_blank"]::after, .references a[target="_blank"]::after, .comment-body a[target="_blank"]::after {
  content: "\2197"; display: inline-block; margin-left: 0.15em; font-size: 0.75em; text-decoration: none; color: var(--muted);
}

/* Mobile menu panel */
.nav-mobile[open] > summary .icon { color: var(--accent); }
.nav-mobile > nav { z-index: 49; box-shadow: 0 12px 24px rgb(15 23 42 / 0.08); }
.nav-mobile li a:hover, .m-group > summary:hover { color: var(--link); }

/* --------------------------------- Glossary --------------------------------- */

.glossary-tools { position: sticky; top: var(--header-h); z-index: 20; background: var(--bg); padding: 0.75rem 0; border-bottom: 1px solid var(--rule); display: grid; gap: 0.6rem; }
.glossary-tools input { font: inherit; width: 100%; max-width: 28rem; padding: 0.6rem 0.9rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--soft); color: var(--ink); }
.letter-nav { display: flex; flex-wrap: wrap; gap: 0.2rem; }
.letter-nav a, .letter-nav span { display: inline-grid; place-items: center; min-width: 1.9rem; height: 1.9rem; border-radius: 6px; font-weight: 700; font-size: 0.9rem; text-decoration: none; }
.letter-nav a { color: var(--ink); background: var(--soft); }
.letter-nav a:hover { background: color-mix(in srgb, var(--accent) 16%, var(--soft)); color: var(--link); }
.letter-nav span { color: var(--rule); }
.glossary-letter { scroll-margin-top: calc(var(--header-h) + 7rem); }
.glossary-letter h2 { font-size: 1.6rem; margin: 2rem 0 0.5rem; color: var(--accent); }
.glossary-list { margin: 0; display: grid; }
.glossary-entry { padding: 0.8rem 0; border-bottom: 1px solid var(--rule); }
.glossary-entry dt { font-weight: 700; font-size: 1.05rem; }
.glossary-entry dt a { color: var(--ink); text-decoration: none; }
.glossary-entry dt a:hover { color: var(--link); text-decoration: underline; }
.glossary-entry dd { margin: 0.25rem 0 0; color: var(--muted); font-family: var(--serif); line-height: 1.5; }
.glossary-list.compact .glossary-entry { padding: 0.6rem 0; }
.aka { font-weight: 400; color: var(--muted); font-size: 0.92rem; }
.aka-line { color: var(--muted); margin: -0.25rem 0 1rem; }

.glossary-term .page-title { margin-top: 0.5rem; }
.definition { border-left: 4px solid var(--accent); background: var(--soft); padding: 1rem 1.25rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 0 0 1.75rem; }
.definition p { margin: 0; font-family: var(--serif); font-size: 1.2rem; line-height: 1.55; }
.glossary-related, .glossary-mentions { margin-top: 2.5rem; }
.glossary-related h2, .glossary-mentions h2 { font-size: 1.15rem; margin: 0 0 0.5rem; }
.mention-list li { display: grid; gap: 0.15rem; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.mention-list a { font-weight: 700; color: var(--ink); text-decoration: none; }
.mention-list a:hover { color: var(--link); text-decoration: underline; }
.mention-list .muted { font-size: 0.92rem; }
.term-updated { margin-top: 2rem; }

/* Glossary links inside articles: dotted underline; definition tooltip on hover or keyboard focus.
   Pure CSS (no script). On touch screens there is no hover, so a tap opens the definition page. */
.prose a.gloss { color: inherit; text-decoration: underline dotted; text-decoration-color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1.5px; }
.prose a.gloss:hover { color: var(--link); }
@media (hover: hover) and (pointer: fine) {
  .prose a.gloss { position: relative; }
  .prose a.gloss:hover::after, .prose a.gloss:focus-visible::after {
    content: attr(data-definition);
    position: absolute; left: 50%; bottom: calc(100% + 0.55rem); transform: translateX(-50%);
    width: max-content; max-width: min(20rem, 80vw); z-index: 40; pointer-events: none;
    padding: 0.6rem 0.75rem; border-radius: 6px; background: var(--ink); color: var(--bg);
    font: 400 0.875rem/1.45 var(--sans); text-align: left; white-space: normal; text-decoration: none;
    box-shadow: 0 8px 24px rgb(15 23 42 / 0.2);
  }
  .prose a.gloss:hover::before, .prose a.gloss:focus-visible::before {
    content: ""; position: absolute; left: 50%; bottom: calc(100% + 0.2rem); transform: translateX(-50%);
    border: 0.35rem solid transparent; border-top-color: var(--ink); z-index: 40; pointer-events: none;
  }
}
.related-plain { margin-top: 0.75rem; }
.definition-q { font-size: 0.95rem; font-weight: 700; margin: 0 0 0.35rem; color: var(--accent); font-family: var(--sans); }

/* ================================================================== */
/* Homepage: a personal profile in the blog's design language          */
/* ================================================================== */

.home { padding-bottom: 1rem; }
.home-hero { display: grid; gap: 2rem; align-items: center; padding-block: clamp(2.5rem, 7vw, 4.5rem) 2rem; }
.home-hero.has-photo { grid-template-columns: minmax(0, 1fr) auto; }
.home-kicker { margin: 0 0 0.6rem; color: var(--accent); font-weight: 700; font-size: 0.95rem; }
.home-name { font-size: clamp(2.1rem, 5.4vw, 3.5rem); line-height: 1.06; letter-spacing: -0.03em; font-weight: 800; margin: 0; text-wrap: balance; }
.home-tagline { font-family: var(--serif); font-size: clamp(1.15rem, 2.4vw, 1.45rem); line-height: 1.5; color: var(--muted); margin: 1rem 0 0; max-width: 34em; }
.home-ctas { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.75rem; }
.home-ctas .btn, .home-ctas .btn-secondary { text-decoration: none; }
.home-ctas .btn-secondary { color: var(--ink); }
.home-ctas .btn-secondary:hover { border-color: var(--ink); }
.home-photo img { display: block; width: clamp(9rem, 22vw, 15rem); height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 50%; border: 4px solid var(--bg); box-shadow: 0 0 0 1px var(--rule), 0 18px 40px rgb(15 23 42 / 0.12); }
@media (max-width: 700px) {
  .home-hero.has-photo { grid-template-columns: 1fr; }
  .home-photo { order: -1; }
  .home-photo img { width: 7.5rem; }
}

.home-stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.home-stats li { display: grid; gap: 0.1rem; align-content: start; padding: 1.1rem 1.25rem; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0 -1px -1px 0; }
.home-stats strong { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.home-stat-label { font-weight: 600; }
.home-stat-note { color: var(--muted); font-size: 0.88rem; }

.home-section { padding-top: clamp(2.5rem, 6vw, 3.75rem); }
.home-h2 { font-size: clamp(1.5rem, 3vw, 1.9rem); letter-spacing: -0.02em; font-weight: 800; margin: 0 0 1.1rem; }
.home-section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; }
.home-more { font-weight: 600; }

.home-about { display: grid; grid-template-columns: minmax(0, var(--measure)) minmax(min(100%, 16rem), 1fr); gap: 2.5rem; align-items: start; }
@media (max-width: 960px) { .home-about { grid-template-columns: 1fr; gap: 1.5rem; } }
.home-prose { font-size: 1.12rem; }
.home-facts { background: var(--soft); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.home-facts h3 { font-size: 0.95rem; margin: 0 0 0.75rem; }
.home-facts dl { margin: 0; display: grid; gap: 0.75rem; }
.home-facts dt { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.home-facts dd { margin: 0.1rem 0 0; font-size: 0.95rem; }

.home-latest { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 0 2rem; border-top: 1px solid var(--rule); }
.home-latest .card.has-image { grid-template-columns: minmax(0, 1fr) 6rem; }

.home-exp-heading { color: var(--muted); margin: -0.4rem 0 1.5rem; font-weight: 600; }
.home-timeline { list-style: none; margin: 0; padding: 0; }
.home-timeline > li { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.25rem 2rem; padding-block: 1.25rem; border-top: 1px solid var(--rule); }
.home-period { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.home-timeline h3 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.home-timeline ul { margin: 0; padding-left: 1.15rem; display: grid; gap: 0.35rem; font-family: var(--serif); font-size: 1.04rem; line-height: 1.55; }
@media (max-width: 640px) { .home-timeline > li { grid-template-columns: 1fr; } }

.home-skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1.5rem 2rem; }
.home-skill-group h3 { font-size: 0.98rem; margin: 0 0 0.6rem; }

.home-certs { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 0.75rem; }
.home-certs li { display: grid; gap: 0.15rem; padding: 1rem 1.1rem; border: 1px solid var(--rule); border-radius: var(--radius); }
.home-certs strong { color: var(--accent); font-size: 1.05rem; }
.home-certs span { font-size: 0.95rem; }
.home-cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1.5rem 2rem; }
.home-cred-grid h3 { font-size: 0.98rem; margin: 0 0 0.5rem; }
.home-cred-grid li { line-height: 1.5; }

.home-contact { padding-bottom: 1rem; }
.home-contact-intro { font-family: var(--serif); font-size: 1.15rem; max-width: 36em; margin: 0 0 1.25rem; }
.home-contact-list { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 0.75rem; }
.home-contact-list div { padding: 1rem 1.1rem; background: var(--soft); border-radius: var(--radius); }
.home-contact-list dt { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.home-contact-list dd { margin: 0.15rem 0 0; font-weight: 600; overflow-wrap: anywhere; }

/* Glossary topic filter */
.topic-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.25rem 0 0.75rem; }
.topic-filter a { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.8rem; border-radius: 999px; background: var(--soft); color: var(--ink); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.topic-filter a span { color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.topic-filter a:hover { color: var(--link); }
.topic-filter a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.topic-filter a[aria-current="page"] span { color: inherit; opacity: 0.75; }

/* Consent banner: non-blocking, both choices equally prominent */
.consent { position: fixed; z-index: 80; left: 1rem; right: 1rem; bottom: 1rem; max-width: 34rem; margin-left: auto; padding: 1rem 1.15rem; background: var(--bg); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: 0 16px 40px rgb(15 23 42 / 0.18); font-size: 0.95rem; }
.consent-title { font-size: 1rem; margin: 0 0 0.35rem; }
.consent p { margin: 0 0 0.85rem; line-height: 1.5; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.consent-actions button { flex: 1 1 9rem; }
.footer-privacy { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem) 1.5rem; font-size: 0.85rem; color: var(--muted); display: flex; gap: 1rem; }
.footer-privacy a, .footer-privacy .link-btn { color: var(--muted); }

/* Share menu: quick actions, then networks in two columns */
.share-menu { min-width: min(22rem, calc(100vw - 2rem)); padding: 0.5rem; display: grid; gap: 0.4rem; }
.share-quick { display: grid; gap: 2px; padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule); }
.share-networks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.share-menu a, .share-menu button { display: block; width: 100%; text-align: left; padding: 0.45rem 0.6rem; border-radius: 6px; border: 0; background: none; color: var(--ink); text-decoration: none; font: inherit; font-size: 0.92rem; cursor: pointer; }
.share-menu a:hover, .share-menu button:hover { background: var(--soft); }
.share-hint { margin: 0; padding: 0.4rem 0.6rem 0.2rem; font-size: 0.78rem; color: var(--muted); border-top: 1px solid var(--rule); line-height: 1.4; }
@media (max-width: 600px) {
  /* On phones the share menu becomes a bottom sheet, so it never runs off the screen. */
  .share-menu, .actions-bottom .share-menu { position: fixed; left: 0.75rem; right: 0.75rem; top: auto; bottom: 0.75rem; min-width: 0; max-height: 75vh; overflow-y: auto; z-index: 70; box-shadow: 0 -8px 40px rgb(15 23 42 / 0.25); }
}
