/* Blog index responsive styles (mobile-first) */

/* Global */
html, body {
  max-width: 100%;
  height: 100%;
}

body {
  margin: 0;
  color: var(--fg, #111);
  font-family: var(--sans, var(--font-sans, -apple-system, Inter, Roboto, Arial, sans-serif));
  -webkit-text-size-adjust: 100%;
  background: var(--bg, #fff);
  overflow-x: hidden; /* remove horizontal scroll on small screens */
  min-height: 100vh;
  font-size: var(--step-0);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

pre,
code,
kbd,
samp {
  font-family: var(--mono, ui-monospace, Menlo, Consolas, monospace);
}

pre {
  background: #f7f7f7;
  border: 1px solid var(--line, #e5e5e5);
  padding: 12px;
  border-radius: 6px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  word-wrap: normal;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
}

th,
td {
  padding: 10px;
  border: 1px solid var(--line, #e5e5e5);
  text-align: left;
}

/* Wrappers */
.wrap,
.container {
  max-width: 840px;
  margin: 0 auto;
  padding: 20px;
}

/* Header / brand */
.site-header h1 {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 0;
}
.brand__link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand__logo {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: contain;
}

/* Toolbar */
.toolbar,
[data-toolbar] {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}
.control,
.field {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--fg);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg);
}
.control input,
.control select,
.field input,
.field select,
.toolbar input,
.toolbar select {
  width: 100%;
  font-size: 16px; /* prevent iOS zoom */
  border: 0;
  outline: 0;
  background: transparent;
}

/* Grid (auto-fit columns) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
@media (max-width: 480px) { .grid { gap: 12px; } }

/* Post lists */
.post-list article {
  margin: 0 0 20px;
}
.post-grid,
[data-listing] {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Tags */
.tag {
  border: 1px solid var(--fg);
  padding: 6px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  cursor: pointer;
  user-select: none;
  background: transparent;
  transition: background .2s, color .2s, border-color .2s;
}
.tag:hover,
.tag:focus {
  background: var(--fg);
  color: #fff;
  outline: 2px solid transparent;
  outline-offset: 2px;
}
.tag.active {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}

/* Cards */
article.card {
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  line-height: 1.5;
}
.thumb-wrap {
  position: relative;
  border: 1px solid var(--fg);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
  background: var(--bg);
}
.thumb-wrap::after { content: ""; display: block; aspect-ratio: 16/9; }
.thumb-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
@media (prefers-reduced-data: reduce) { .thumb-wrap img { object-fit: contain; } }

.excerpt { line-height: 1.6; margin: 0 0 8px; padding: 0 2px; }

/* Pager */
.pager,
[data-pager] {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 22px 0;
}
.pager .btn,
[data-pager] button {
  border: 2px solid var(--fg);
  background: transparent;
  border-radius: 12px;
  padding: 8px 12px;
  font-family: var(--mono);
  cursor: pointer;
}
.pager .btn[disabled],
[data-pager] button[disabled] { opacity: .35; cursor: not-allowed; }

/* Footer badges */
.badges-wrap {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  list-style: none;
  padding: 0;
  margin-top: 14px;
}

/* Fade-in for results */
#results { opacity: 0; transition: opacity .3s; }

/* Mobile breakpoint */
@media (max-width: 600px) {
  .site-header h1 { font-size: 1.4rem; line-height: 1.2; }
  .toolbar, [data-toolbar] { flex-direction: column; gap: 8px; }
  .toolbar select, .toolbar input, [data-toolbar] select, [data-toolbar] input { width: 100%; }
  .post-list article { margin: 0 0 16px; }
  .badges-wrap { flex-wrap: wrap; justify-content: center; }
  h1 { font-size: 1.5rem; line-height: 1.2; }
  h2 { font-size: 1.25rem; }
  p { font-size: 1rem; line-height: 1.5; }
}

@media (max-width: 400px) {
  .site-header .brand span {
    font-size: 14px;
  }

  .badge {
    width: 36px;
    height: 36px;
  }

  .badge img,
  .badge .i {
    width: 24px;
    height: 24px;
  }

  .badge--text {
    height: 36px;
    padding: 0 10px;
    font-size: 11.5px;
  }
}

/* Footer badges normalized */
.footer-badges {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.footer-badge { width: 26px; height: 26px; object-fit: contain; }
@media (max-width: 480px) { .footer-badge { width: 22px; height: 22px; } }

/* === Mobile tightening & toolbar alignment === */
@media (max-width: 480px) {
  body { padding: 0 8px; }
  .layout-wrap { padding: 0; }
  .toolbar { padding: 8px; }
  .post-card { padding: 0.85rem; }
}

/* Align toolbar labels & controls on wider screens */
@media (min-width: 640px) {
  .toolbar label.control {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .toolbar label.control span {
    min-width: 70px;
  }
}

/* Tag row layout */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

/* Post card thumbnail */
.post-card__thumb img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}
@media (max-width: 600px) {
  .post-card__thumb img {
    object-fit: contain;
  }
}

/* === Site Tagline === */
.tagline {
  font-family: var(--font-mono, var(--mono));
  font-size: var(--step--1, 0.95rem);
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .tagline {
    font-size: 0.9rem;
    line-height: 1.3;
  }
}

:root {
  color-scheme: light dark;
  --fg: #111;
  --line: #e5e5e5;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, Inter, Roboto, Arial, sans-serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --bg: #fdfdfd;
  --muted: #5b5b5f;
  --border: rgba(10, 10, 10, 0.14);
  --border-strong: rgba(10, 10, 10, 0.24);
  --surface: rgba(255, 255, 255, 0.92);
  --shadow: 0 0.6rem 1.8rem rgba(15, 23, 42, 0.08);
  --accent: #0f62fe;
  --link: rgba(20, 20, 20, 0.76);
  --wrap-width: min(74rem, 100vw - 2.5rem);
  --radius-sm: 0.5rem;
  --radius-md: 0.85rem;
  --radius-lg: 1.4rem;
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1.1rem;
  --space-lg: 1.65rem;
  --space-xl: 2.5rem;
  --step--1: clamp(0.88rem, 0.84rem + 0.2vw, 0.96rem);
  --step-0: clamp(1rem, 0.96rem + 0.3vw, 1.08rem);
  --step-1: clamp(1.2rem, 1.07rem + 0.7vw, 1.38rem);
  --step-2: clamp(1.55rem, 1.35rem + 1.3vw, 1.95rem);
  --step-3: clamp(1.95rem, 1.7rem + 1.8vw, 2.55rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090c;
    --fg: #f6f6f7;
    --line: rgba(255, 255, 255, 0.18);
    --muted: #a6a6b3;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);
    --surface: rgba(14, 14, 20, 0.9);
    --shadow: 0 0.8rem 2.2rem rgba(0, 0, 0, 0.6);
    --link: rgba(255, 255, 255, 0.78);
    --accent: #5c8bff;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--fg);
  font-size: 100%;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--link);
  transition: color 0.2s ease, background-color 0.2s ease;
}

a:focus-visible,
a:hover {
  color: #fff;
  background: var(--accent);
  outline: none;
}

img,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

h1 {
  font-size: clamp(22px, 6vw, 36px);
  margin: 0.75rem 0 0.25rem;
}

h2 {
  font-size: clamp(18px, 4.8vw, 28px);
  margin: 0.75rem 0 0.35rem;
}

p,
li {
  font-size: clamp(15px, 3.8vw, 18px);
  line-height: 1.55;
}

.skip-link {
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  border: 0;
  z-index: 200;
}

.skip-link:focus-visible {
  top: var(--space-sm);
}

.layout-wrap {
  width: var(--wrap-width);
  margin-inline: auto;
  padding: var(--space-md) var(--space-sm);
}

@media (min-width: 48rem) {
  .layout-wrap {
    padding-inline: var(--space-md);
  }
}

@supports (padding: max(0px)) {
  .site-header,
  .wrap,
  .container {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }
}

@media (max-width: 720px) {
  .wrap,
  .container {
    padding: 16px;
  }

  header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .grid,
  .row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sidebar {
    order: 2;
  }

  .content {
    order: 1;
  }

  .hide-mobile {
    display: none !important;
  }
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line, var(--border));
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  backdrop-filter: saturate(130%) blur(12px);
}

@supports not (backdrop-filter: blur(12px)) {
  .site-header {
    background: rgba(255, 255, 255, 0.96);
  }

  @media (prefers-color-scheme: dark) {
    .site-header {
      background: rgba(9, 9, 12, 0.98);
    }
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.site-header .brand img {
  width: 28px;
  height: 28px;
  display: block;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step-1);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.intro {
  margin-block: var(--space-md) var(--space-sm);
}

.intro h2 {
  font-size: var(--step-2);
  line-height: 1.2;
  margin-bottom: var(--space-xs);
}

.intro p {
  color: var(--muted);
  max-width: 60ch;
  margin: 0;
}

.toolbar {
  display: grid;
  gap: var(--space-sm);
  padding-block: var(--space-sm);
  border-top: 1px solid var(--border);
}

@media (min-width: 40rem) {
  .toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }
}

.control {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.control span {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.control input,
.control select {
  border: 0;
  padding: 0;
  background: transparent;
  min-height: 2.25rem;
}

.tag-button {
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  cursor: pointer;
  scroll-snap-align: center;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tag-button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: transparent;
}

.tag-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.post-list {
  margin-block: var(--space-lg);
}

.post-list__fallback {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-md);
}

.post-list__fallback article {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.post-list__fallback h2 {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--step-1);
}

.post-list__fallback .meta {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  margin-bottom: var(--space-xs);
}

.post-list__fallback p {
  margin: 0;
}

.post-grid {
  display: grid;
  gap: var(--space-md);
  margin: 0;
}

.post-grid[data-density="comfortable"] {
  --card-padding: 1.25rem;
  --card-gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
}

.post-grid[data-density="cozy"] {
  --card-padding: 1rem;
  --card-gap: var(--space-sm);
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
}

.post-grid[data-density="compact"] {
  --card-padding: 0.85rem;
  --card-gap: var(--space-sm);
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.post-card,
.card {
  min-width: 0;
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--card-padding, 1.15rem);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover,
.post-card:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.16);
}

.post-card__thumb {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  aspect-ratio: 16 / 9;
}

.post-card h2 {
  margin: 0;
  font-size: var(--step-1);
  line-height: 1.3;
}

.post-card h2 a {
  border: 0;
}

.post-card__meta {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
}

.post-card__summary {
  margin: 0;
  color: inherit;
}

.post-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.post-card__tag {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-block: var(--space-lg);
}

.pager button,
.pager span {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-mono);
  padding: 0.6rem 1rem;
  min-width: 5.5rem;
  text-align: center;
}

.pager button {
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.pager button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: var(--space-lg);
  color: var(--muted);
  font-family: var(--font-mono);
}

.site-footer__links {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.site-footer__copy {
  display: block;
  margin-top: var(--space-sm);
  text-align: center;
  font-size: var(--step--1);
}

/* ========== Badge System ========== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line, #e5e5e5);
  text-decoration: none;
  outline: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.badge img,
.badge .i {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 10px rgba(10, 18, 40, 0.08);
}

.badge:focus-visible {
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35);
}

.badge--text {
  width: auto;
  min-width: 42px;
  padding: 0 12px;
  gap: 8px;
  font: 600 12px/1 var(--sans, -apple-system, Inter, Roboto, Arial, sans-serif);
}

.badge--text span {
  display: inline;
}

.badge.-siena {
  background: #e7f5ed;
  border-color: #cdebdc;
  color: #006341;
}

.badge.-bu {
  background: #ffe9ea;
  border-color: #ffd4d7;
  color: #cc0000;
}

.badge.-orcid {
  background: #eaffe5;
  border-color: #c6efbb;
  color: #2e7d32;
}

.badge.-email {
  background: #f5f3ff;
  border-color: #e4e1ff;
  color: #5b21b6;
}

.blog-prose {
  font-size: var(--step-0);
  line-height: 1.7;
  color: inherit;
}

.blog-prose > * + * {
  margin-top: var(--space-sm);
}

.blog-prose h2 {
  font-size: var(--step-2);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
}

.blog-prose h3 {
  font-size: var(--step-1);
  margin-top: var(--space-md);
  margin-bottom: var(--space-xs);
}

.blog-prose p {
  margin: 0;
}

.blog-prose ul,
.blog-prose ol {
  padding-left: 1.2rem;
  margin: 0;
}

.blog-prose blockquote {
  margin: var(--space-md) 0;
  padding: var(--space-sm) var(--space-md);
  border-left: 4px solid var(--accent);
  background: rgba(15, 98, 254, 0.08);
}

@media (prefers-color-scheme: dark) {
  .blog-prose blockquote {
    background: rgba(92, 139, 255, 0.12);
  }
}

.blog-prose code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  background: rgba(15, 23, 42, 0.08);
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
}

@media (prefers-color-scheme: dark) {
  .blog-prose code {
    background: rgba(255, 255, 255, 0.12);
  }
}

.blog-prose pre {
  font-family: var(--font-mono);
  overflow: auto;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
  .blog-prose pre {
    background: rgba(255, 255, 255, 0.06);
  }
}

.blog-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0;
  font-size: 0.98em;
}

.blog-prose th,
.blog-prose td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
}

.blog-prose thead th {
  background: rgba(15, 23, 42, 0.05);
}

@media (prefers-color-scheme: dark) {
  .blog-prose thead th {
    background: rgba(255, 255, 255, 0.08);
  }
}

.post-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-sm);
}

.post-header .crumbs {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  margin-bottom: var(--space-2xs);
}

.post-header h1 {
  font-size: var(--step-3);
  line-height: 1.15;
  margin: 0;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin-top: var(--space-xs);
}

.post-meta .tag {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

.post-hero {
  margin: var(--space-md) 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.post-hero figcaption {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  padding: var(--space-xs) var(--space-sm);
}

.back-link {
  margin-top: var(--space-lg);
  display: inline-flex;
  font-family: var(--font-mono);
}

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

/* blog.css — responsive styles for blog */
