:root {
  --app-bg: #fbfbf8;
  --app-ink: #101112;
  --app-muted: rgba(16, 17, 18, 0.62);
  --app-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --app-max: 1060px;
  --app-gutter: 22px;
  --app-serif: "Fraunces", ui-serif, Georgia, serif;
  --app-sans: "Source Sans 3", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --app-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/Fraunces-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("../fonts/SourceSans3-Variable.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

body {
  font-family: var(--app-sans);
  background: radial-gradient(900px 420px at 12% 10%, rgba(148, 91, 33, 0.08), transparent 55%),
    radial-gradient(900px 420px at 84% 12%, rgba(0, 0, 0, 0.06), transparent 60%),
    radial-gradient(900px 560px at 40% 90%, rgba(148, 91, 33, 0.05), transparent 62%),
    var(--app-bg);
}

h1,
h2,
h3,
h4 {
  font-family: var(--app-serif);
  font-variation-settings: "wght" 520, "opsz" 88;
  letter-spacing: -0.015em;
}

.shell {
  width: min(var(--app-max), calc(100% - var(--app-gutter) * 2));
  margin: 0 auto;
}

.navInner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

/* Bridge: style the Beautiful Jekyll navbar to match the app shell. */
.navBar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 0;
  border-bottom: 1px solid rgba(16, 17, 18, 0.08);
  backdrop-filter: blur(10px);
  background: rgba(251, 251, 248, 0.72) !important;
}

.navBar .navbar-collapse {
  justify-content: flex-end;
}

.navBar .navbar-nav {
  gap: 14px;
}

.navbar.navbar-custom {
  font-family: var(--app-sans);
  border-bottom: 1px solid rgba(16, 17, 18, 0.08);
  background: rgba(251, 251, 248, 0.72) !important;
  backdrop-filter: blur(10px);
}

.navbar.navbar-custom .navbar-brand {
  font-family: var(--app-serif);
  font-variation-settings: "wght" 520, "opsz" 88;
  letter-spacing: -0.015em;
  color: var(--app-ink) !important;
}

.navbar.navbar-custom .nav-link {
  position: relative;
  font-family: var(--app-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(16, 17, 18, 0.78) !important;
  font-weight: 500;
  border-radius: 10px;
  transition: background 160ms var(--app-ease), color 160ms var(--app-ease);
  padding: 8px 8px;
}

.navbar.navbar-custom .nav-link:hover {
  background: rgba(16, 17, 18, 0.05);
  color: rgba(16, 17, 18, 0.78) !important;
}

.navbar.navbar-custom .nav-item.active .nav-link,
.navbar.navbar-custom .nav-link.active,
.navbar.navbar-custom .nav-link[aria-current="page"] {
  color: var(--app-ink) !important;
  background: transparent !important;
}

.navbar.navbar-custom .nav-item.active .nav-link::after,
.navbar.navbar-custom .nav-link.active::after,
.navbar.navbar-custom .nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 5px;
  height: 2px;
  background: rgba(148, 91, 33, 0.72);
  border-radius: 99px;
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Topics (tags) page */
.tagsPage {
  padding: 6px 0 42px;
}

.tagsHeader {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.tagsTitle {
  margin: 0;
  font-size: 40px;
}

.tagsChips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 16px;
}

.tagChip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(16, 17, 18, 0.12);
  background: rgba(255, 255, 255, 0.55);
  color: rgba(16, 17, 18, 0.74);
  font-family: var(--app-sans);
  font-size: 15px;
  text-decoration: none;
  transition:
    transform 160ms var(--app-ease),
    background 160ms var(--app-ease),
    border-color 160ms var(--app-ease),
    color 160ms var(--app-ease);
}

.tagChip:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(16, 17, 18, 0.2);
  color: rgba(16, 17, 18, 0.9);
}

.tagChip.isActive {
  background: rgba(148, 91, 33, 0.08);
  border-color: rgba(148, 91, 33, 0.28);
  color: rgba(16, 17, 18, 0.92);
}

.tagChipCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(148, 91, 33, 0.1);
  color: rgba(148, 91, 33, 0.86);
  letter-spacing: 0;
}

.tagsResults {
  display: grid;
  gap: 10px;
  padding-top: 6px;
}

.tagsResultsBar {
  display: flex;
  justify-content: flex-start;
}

.tagsClear {
  appearance: none;
  border: 1px solid rgba(16, 17, 18, 0.12);
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.55);
  color: rgba(16, 17, 18, 0.72);
  font-family: var(--app-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition:
    transform 160ms var(--app-ease),
    background 160ms var(--app-ease),
    border-color 160ms var(--app-ease),
    color 160ms var(--app-ease);
}

.tagsClear:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(16, 17, 18, 0.2);
  color: rgba(16, 17, 18, 0.9);
}

.tagsClear:focus {
  outline: none;
}

.tagsClear:focus-visible {
  border-color: rgba(148, 91, 33, 0.32);
  box-shadow: 0 0 0 4px rgba(148, 91, 33, 0.11);
}

.tagsGroups {
  display: grid;
  gap: 10px;
}

.tagGroup {
  border: 1px solid rgba(16, 17, 18, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  overflow: hidden;
}

.tagGroupSummary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  transition: background 160ms var(--app-ease);
}

.tagGroupSummary::-webkit-details-marker {
  display: none;
}

.tagGroupSummary:hover {
  background: rgba(16, 17, 18, 0.03);
}

.tagGroup[open] .tagGroupSummary {
  background: rgba(148, 91, 33, 0.06);
}

.tagGroupName {
  font-family: var(--app-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(16, 17, 18, 0.8);
}

.tagGroupCount {
  font-family: var(--app-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(16, 17, 18, 0.5);
}

.tagPosts {
  margin: 0;
  padding: 0 12px 12px;
  list-style: none;
  display: grid;
  gap: 8px;
}

.tagPost {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 8px;
  border-radius: 12px;
  transition: background 160ms var(--app-ease);
}

.tagPost:hover {
  background: rgba(16, 17, 18, 0.03);
}

.tagPostLink {
  color: rgba(16, 17, 18, 0.92);
  text-decoration: none;
}

.tagPostLink:hover {
  text-decoration: underline;
  text-decoration-color: rgba(148, 91, 33, 0.6);
  text-underline-offset: 3px;
}

.tagPostDate {
  font-size: 12px;
  color: rgba(16, 17, 18, 0.55);
  white-space: nowrap;
}

@media (max-width: 680px) {
  .tagsTitle {
    font-size: 32px;
  }

  .tagPost {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
}

.blog-post pre.mermaid {
  margin: 1.25rem 0 1.5rem;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

.blog-post pre.mermaid svg {
  display: block;
  width: auto !important;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.blog-post pre,
.blog-post pre code {
  tab-size: 4;
}

.post-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin-block: 1rem;
}

.post-table-scroll:focus-visible {
  outline: 2px solid var(--app-ink);
  outline-offset: 2px;
}

/* Native deep links and refresh must also clear the sticky navigation. */
.blog-post :is(h2, h3, h4)[id] {
  scroll-margin-top: 5.5rem;
}

.blog-post details {
  margin-top: 2.5rem;
}

.blog-post h2 {
  font-size: 2.125rem;
}

.blog-post h3 {
  font-size: 1.75rem;
}

.blog-post h4 {
  font-size: 1.5rem;
}

.blog-post img {
  /* width/height attrs set intrinsic size (no layout shift); derive height
     from the max-width:100% width so the aspect ratio is never stretched */
  height: auto;
}

.blog-post img:not(.no-zoom):not([data-no-zoom]) {
  cursor: zoom-in;
}

.blog-post a img:not(.no-zoom):not([data-no-zoom]) {
  cursor: pointer;
}

.blog-post img[data-image-zoom-ready="true"]:focus-visible {
  outline: 3px solid rgba(122, 76, 194, 0.45);
  outline-offset: 4px;
  border-radius: 4px;
}

html.image-zoom-open,
html.image-zoom-open body {
  overflow: hidden;
}

.image-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  background: rgba(12, 12, 12, 0.84);
  backdrop-filter: blur(8px);
  cursor: zoom-out;
}

.image-zoom-overlay[hidden] {
  display: none;
}

.image-zoom-image {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 1400px);
  max-height: calc(100vh - 96px);
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  cursor: default;
}

.image-zoom-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: var(--app-sans);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.image-zoom-close:hover,
.image-zoom-close:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.anchor-back-button {
  position: fixed;
  left: 50%;
  bottom: 6vh;
  transform: translateX(-50%);
  z-index: 1500;
  padding: 12px 22px;
  border: 1px solid rgba(148, 91, 33, 0.4);
  border-radius: 999px;
  background: rgba(148, 91, 33, 0.94);
  backdrop-filter: blur(6px);
  color: #fff;
  font-family: var(--app-sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  box-shadow:
    0 14px 36px rgba(148, 91, 33, 0.35),
    0 3px 10px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  animation: anchor-back-pop 240ms var(--app-ease);
  transition:
    background 160ms var(--app-ease),
    transform 160ms var(--app-ease);
}

.anchor-back-button:hover,
.anchor-back-button:focus-visible {
  background: rgb(122, 73, 24);
  transform: translateX(-50%) scale(1.04);
}

.anchor-back-button[hidden] {
  display: none;
}

@keyframes anchor-back-pop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .anchor-back-button {
    animation: none;
    transition: none;
  }
}

/* Lists: tighten the gap with the preceding paragraph, add breathing room between items.
   Kramdown renders loose items as <li><p>...</p>...</li> and tight items as <li>...</li>;
   the rules below keep both forms visually consistent. */
.blog-post p + ol,
.blog-post p + ul {
  margin-top: -0.25rem;
}

.blog-post ol > li + li,
.blog-post ul > li + li {
  margin-top: 0.75rem;
}

.blog-post ol > li > p:first-child,
.blog-post ul > li > p:first-child {
  margin-top: 0;
}

.blog-post ol > li > p:last-child,
.blog-post ul > li > p:last-child {
  margin-bottom: 0;
}

.blog-post ol > li > p,
.blog-post ul > li > p {
  margin-bottom: 0.5rem;
}

.blog-post a[href^="#"]:not(.footnote):not(.reversefootnote) {
  color: #7a4cc2;
  font-weight: 500;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(122, 76, 194, 0.45);
  text-underline-offset: 0.18em;
}

.blog-post a[href^="#"]:not(.footnote):not(.reversefootnote):hover,
.blog-post a[href^="#"]:not(.footnote):not(.reversefootnote):focus {
  color: #5f36a6;
  text-decoration-style: solid;
  text-decoration-color: currentColor;
}

.blog-post a.footnote {
  color: #7a4cc2;
  font-family: var(--app-mono);
  font-size: 0.72em;
  font-weight: 650;
  text-decoration: none;
}

.blog-post a.footnote:hover,
.blog-post a.footnote:focus {
  color: #5f36a6;
  outline: none;
}

.blog-post a.footnote:focus-visible {
  outline: 2px solid rgba(122, 76, 194, 0.45);
  outline-offset: 2px;
  border-radius: 3px;
}

.blog-post-footnotes-enhanced .footnotes {
  display: none;
}

.footnote-popover {
  position: fixed;
  z-index: 50;
  width: min(420px, calc(100vw - 24px));
  max-height: min(42vh, 360px);
  overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid rgba(16, 17, 18, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 252, 0.96);
  box-shadow: 0 18px 50px rgba(16, 17, 18, 0.16);
  color: var(--app-ink);
  font-family: var(--app-sans);
  font-size: 14px;
  line-height: 1.45;
}

.footnote-popover[hidden] {
  display: none;
}

.footnote-popover code {
  font-size: 0.88em;
}

.writingTitle {
  margin: 24px 0 0;
  font-size: 24px;
}

.post-preview .post-meta {
  font-family: var(--app-sans);
  font-size: 13px;
  font-style: normal;
  color: var(--app-muted);
}

.post-preview .blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 13px;
}

.post-preview .blog-tags a {
  padding: 0;
  border: 0;
  font-family: var(--app-sans);
  color: var(--app-muted);
  opacity: 1;
  text-decoration: underline;
  text-decoration-color: rgba(148, 91, 33, 0.4);
  text-underline-offset: 3px;
}

.post-preview .blog-tags a:hover {
  color: var(--app-ink);
}

.blog-pager .page-item {
  min-width: 0;
  max-width: 48%;
}

.blog-pager .page-link {
  display: grid;
  gap: 6px;
  white-space: normal;
  font-family: var(--app-sans);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.postPagerDirection {
  font-size: 12px;
  color: var(--app-muted);
}

.articleHeaderBand {
  padding: 38px 0 30px;
  background: #efede5;
  border-bottom: 1px solid #ded9cc;
  margin-bottom: 30px;
}

.articleHeaderInner {
  max-width: 48rem;
  margin: 0 auto;
}

.articleHeaderInner h1 {
  font-size: clamp(2rem, 3.5vw, 2.75rem);
  line-height: 1.15;
  margin: 0 0 16px;
}

.articleHeaderMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 14px;
  color: var(--app-muted);
}

.articleHeaderMeta a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.articleSubtitle {
  margin: 0 0 16px;
}

.blog-post > :first-child {
  margin-top: 0;
}
