/* =========================================================
   Design tokens (shadcn-style semantic tokens, plain CSS)
   ========================================================= */
:root {
  --background: #ffffff;
  --foreground: #111111;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #6b7280;
  --accent: #f4f4f5;
  --border: #e4e4e7;
  --primary: #0e76a8;
  --primary-foreground: #ffffff;
  --ring: rgba(14, 118, 168, 0.35);
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.10);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --background: #14161a;
  --foreground: #e4e6ea;
  --card: #1b1e24;
  --muted: #1e2127;
  --muted-foreground: #9aa0a8;
  --accent: #262a31;
  --border: #2f343c;
  --primary: #6da4eb;
  --primary-foreground: #14161a;
  --ring: rgba(109, 164, 235, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.55);
}

/* =========================================================
   Theme switch: shadcn "outline" icon button
   ========================================================= */
.theme-switch {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.theme-switch:hover { background: var(--accent); }
.theme-switch:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }
.theme-switch svg {
  position: absolute;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(.3, 1.4, .5, 1), opacity 0.25s ease;
}
/* light mode shows the sun, dark mode shows the snowflake */
.theme-switch .icon-sun       { transform: rotate(0) scale(1);        opacity: 1; }
.theme-switch .icon-snowflake { transform: rotate(-90deg) scale(0);   opacity: 0; }
html[data-theme="dark"] .theme-switch .icon-sun       { transform: rotate(90deg) scale(0); opacity: 0; }
html[data-theme="dark"] .theme-switch .icon-snowflake { transform: rotate(0) scale(1);     opacity: 1; }

/* =========================================================
   Page chrome
   ========================================================= */
html[data-theme="dark"] body,
html[data-theme="dark"] .page-content,
html[data-theme="dark"] .slideout-panel,
html[data-theme="dark"] #panel {
  background-color: var(--background);
  color: var(--foreground);
}
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] .page-heading,
html[data-theme="dark"] b,
html[data-theme="dark"] strong { color: #f1f3f5; }
html[data-theme="dark"] a { color: var(--primary); }
html[data-theme="dark"] a:hover { color: #9cc2f4; }

html[data-theme="dark"] .site-header,
html[data-theme="dark"] .site-header .menu-toggle button { background-color: var(--background); color: var(--foreground); }
html[data-theme="dark"] .site-header a,
html[data-theme="dark"] .site-header .desktop-menu ul li a,
html[data-theme="dark"] .site-title a { color: var(--foreground); }
html[data-theme="dark"] .site-header .desktop-menu ul li a:hover { color: var(--muted-foreground); }
/* main.css has :visited rules that out-rank the plain link overrides above */
html[data-theme="dark"] .site-header .site-title a,
html[data-theme="dark"] .site-header .site-title a:visited,
html[data-theme="dark"] .site-header .icon-wrapper a,
html[data-theme="dark"] .site-header .desktop-menu ul li a,
html[data-theme="dark"] .site-header .desktop-menu ul li a:visited { color: var(--foreground); }
html[data-theme="dark"] .site-header .site-title a:hover,
html[data-theme="dark"] .site-header .desktop-menu ul li a:hover { color: var(--muted-foreground); }
html[data-theme="dark"] .menu .page-link:visited { color: var(--foreground); }
html[data-theme="dark"] #menu { background-color: var(--card); }
html[data-theme="dark"] .menu ul,
html[data-theme="dark"] .menu .page-link,
html[data-theme="dark"] .menu-section-title { color: var(--foreground); }
html[data-theme="dark"] .menu .page-link:hover { background-color: var(--accent); }

html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .site-footer a,
html[data-theme="dark"] .site-footer .site-description a { color: var(--muted-foreground) !important; }
html[data-theme="dark"] .site-footer { border-top-color: var(--border) !important; }
html[data-theme="dark"] .divider,
html[data-theme="dark"] .invisible-divider { border-top-color: var(--border); }
html[data-theme="dark"] hr { border-top-color: var(--border) !important; }
html[data-theme="dark"] code,
html[data-theme="dark"] pre { background-color: var(--muted); color: var(--foreground); }
html[data-theme="dark"] blockquote { color: var(--muted-foreground); }

/* inline-styled elements (need !important to beat style="...") */
html[data-theme="dark"] i[style*="211F1F"] { color: var(--foreground) !important; }
html[data-theme="dark"] blockquote[style] {
  background: var(--card) !important;
  border-color: var(--border) !important;
  border-left-color: #0e76a8 !important;
  color: var(--foreground) !important;
}
html[data-theme="dark"] .bib-toggle { color: var(--foreground) !important; }
html[data-theme="dark"] .bib-block { background-color: var(--card) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .bib-block pre { color: var(--foreground); background: transparent; }

/* figures are mostly drawn on white: soften and round them */
.publication img { border-radius: 6px; }
html[data-theme="dark"] .publication img,
html[data-theme="dark"] .highlight-card img { filter: brightness(0.92); }

/* =========================================================
   Shared primitives: Badge + outline Button
   ========================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}
.badge-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground) !important;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none !important;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-outline:hover { background: var(--accent); border-color: var(--primary); }
.btn-outline:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* =========================================================
   Homepage highlight cards (shadcn Card composition)
   ========================================================= */
.highlights-scroll {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding: 0.5rem 0.25rem 1.25rem;
  margin: 0 0 1rem 0;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.highlight-card {
  flex: 0 0 320px;
  max-width: 320px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.highlight-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.highlight-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  margin: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}
.highlight-card .card-body {
  padding: 1rem 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
.highlight-card .card-title { font-weight: 700; line-height: 1.3; font-size: 1rem; }
.highlight-card .card-venue { margin: 0.5rem 0 0.6rem; align-self: flex-start; }
.highlight-card .card-desc { font-size: 0.9rem; color: var(--muted-foreground); margin: 0; }
.highlight-card .card-links { margin-top: auto; padding-top: 0.9rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.highlight-card .card-links a {
  display: inline-flex; align-items: center; height: 2rem; padding: 0 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--background); color: var(--foreground);
  font-size: 0.82rem; font-weight: 500; text-decoration: none; box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease; margin: 0;
}
.highlight-card .card-links a:hover { background: var(--accent); border-color: var(--primary); color: var(--foreground); }

/* =========================================================
   Blog
   ========================================================= */
.blog-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
.blog-list li { margin: 0; }
.blog-card {
  display: block;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
  text-decoration: none !important;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.blog-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--primary); }
.blog-card .post-title { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.3; color: var(--foreground); }
.blog-card .post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.45rem 0 0.6rem; color: var(--muted-foreground); font-size: 0.85rem; }
.blog-card .post-excerpt { margin: 0; color: var(--muted-foreground); font-size: 0.95rem; }
.blog-card .post-more { display: inline-block; margin-top: 0.75rem; color: var(--primary); font-size: 0.85rem; font-weight: 500; }
.blog-empty {
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border);
  border-radius: calc(var(--radius) + 4px);
  text-align: center;
  color: var(--muted-foreground);
}

.blog-post { max-width: 42rem; margin: 0 auto; }
.blog-post .post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; color: var(--muted-foreground); font-size: 0.9rem; margin: 0 0 1.25rem; }
.blog-post .post-body { font-size: 1.05rem; line-height: 1.75; }
.blog-post .post-body h2,
.blog-post .post-body h3 { margin: 2rem 0 0.75rem; line-height: 1.3; }
.blog-post .post-body img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.blog-post .post-body blockquote { border-left: 3px solid var(--primary); padding: 0.1rem 1rem; margin: 1.25rem 0; font-style: italic; }
.blog-post .post-body pre { padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.blog-post .post-body :not(pre) > code { padding: 0.1rem 0.35rem; border-radius: 4px; }
.blog-post .post-nav { display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
html[data-theme="dark"] .blog-card .post-title { color: var(--foreground); }

/* =========================================================
   Smooth theme changes
   ========================================================= */
html, body, .page-content, .site-header { transition: background-color 0.3s ease, color 0.3s ease; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
