/* ===========================================================================
 * custom.css — site styling on top of Pico.css.
 * Pico handles the semantic-HTML reset; this file layers the typography,
 * colour palette, navbar, publication thumbnails, and card layouts on top.
 * ========================================================================= */

/* ---- Theme palette (override Pico variables) ---- */
:root {
  --pico-font-family: "Roboto", sans-serif;
  --pico-primary: #2962ff;
  --pico-primary-hover: #1e4dd6;
  --pico-background-color: #ffffff;
  --pico-color: #181818;
  --pico-muted-color: #6c757d;
  --pico-card-background-color: #ffffff;
  --pico-card-border-color: rgba(0, 0, 0, 0.1);
  --pico-card-sectioning-background-color: #fafafa;

  /* site-specific palette */
  --af-theme: #2962ff;
  --af-bg: #ffffff;
  --af-text: #181818;
  --af-muted: #6c757d;
  --af-card-bg: #ffffff;
  --af-divider: rgba(0, 0, 0, 0.1);
  --af-navbar-bg: rgba(255, 255, 255, 0.85);
  --af-navbar-text: #343a40;
}

[data-theme="dark"] {
  --pico-primary: #2962ff;
  --pico-primary-hover: #1e4dd6;
  --pico-background-color: #131416;
  --pico-color: #c9c9c9;
  --pico-muted-color: #8a8a8a;
  --pico-card-background-color: #1a1a1d;
  --pico-card-border-color: rgba(255, 255, 255, 0.1);
  --pico-card-sectioning-background-color: #1e1e21;

  --af-theme: #6c97ff;   /* lighter blue: 6.6:1 on #131416, passes AA */
  --af-bg: #131416;
  --af-text: #c9c9c9;
  --af-muted: #8a8a8a;
  --af-card-bg: #1a1a1d;
  --af-divider: rgba(255, 255, 255, 0.1);
  --af-navbar-bg: rgba(19, 20, 22, 0.85);
  --af-navbar-text: #c9c9c9;
}

/* ---- Base typography ---- */
body {
  font-family: "Roboto", sans-serif;
  font-weight: 300;
  color: var(--af-text);
  background-color: var(--af-bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  text-align: justify;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Roboto Slab", serif;
  font-weight: 400;
  color: var(--af-text);
}

/* Neutralize Pico's <article>-as-card styling: this site is flat, not a card.
   Also neutralize the article>header gray band. */
article {
  margin: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
article > header {
  margin: 0;
  padding: 0;
  background: transparent;
}

/* Reset the oversized top margin on the first heading inside main/article. */
article > :first-child,
.post > :first-child,
article > header > :first-child,
.about header h1:first-child {
  margin-top: 0;
}

a {
  color: var(--af-theme);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---- Layout container ---- */
main.container {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1000px;
  margin-right: auto;
  margin-left: auto;
  padding-right: var(--pico-spacing, 1rem);
  padding-left: var(--pico-spacing, 1rem);
  padding-top: 5rem;   /* clear the fixed navbar */
  padding-bottom: 3rem;
}

/* ---- Navbar (fixed, translucent, lowercase) ---- */
header > nav[aria-label="Primary"] {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  background-color: var(--af-navbar-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--af-divider);
  color: var(--af-navbar-text);
}
nav[aria-label="Primary"] .brand {
  font-family: "Roboto Slab", serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--af-navbar-text);
  text-decoration: none;
}
nav[aria-label="Primary"] .brand:hover { text-decoration: none; }
nav[aria-label="Primary"] ul {
  display: flex;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
nav[aria-label="Primary"] li a {
  text-transform: lowercase;
  font-size: 0.95rem;
  padding: 0.2rem 0.5rem;
  color: var(--af-navbar-text);
}
#theme-toggle {
  padding: 0.15rem 0.45rem;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  background: transparent;
}

/* ---- Footer ---- */
footer {
  flex-shrink: 0;
  border-top: 1px solid var(--af-divider);
  padding: 1.5rem 0;
  color: var(--af-muted);
  text-align: center;
}
footer .container { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
footer a { color: var(--af-muted); }

/* ---- Socials (icon row: circular muted buttons) ---- */
ul.socials {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  padding: 0;
  margin: 0;
  font-size: 1.1rem;
}
ul.socials li { list-style: none; }
ul.socials li a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  overflow: hidden;
  color: var(--af-muted);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}
ul.socials li a i {
  font-size: 1.5rem;
  line-height: 1;
  width: 1.25em;
  text-align: center;
}
/* Inline SVG icons (Scholar/ORCID/ResearchGate) sized to match FA glyphs. */
ul.socials li a svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: currentColor;
}
ul.socials li a:hover {
  color: var(--af-theme);
  text-decoration: none;
}

/* ---- About / profile (floated, text wraps around) ---- */
.about .profile {
  float: right;
  width: 300px;
  height: auto;
  margin: 0 0 1rem 1.5rem;
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.about .profile.left {
  float: left;
  margin: 0 1.5rem 1rem 0;
}
.about h1 { margin-top: 0; margin-bottom: 0.3rem; }
.about .lead { color: var(--af-muted); font-size: 1.05rem; }
/* Clear the float before the section blocks (Selected Pubs, News, etc.). */
.about section { clear: both; }

/* ---- News list ---- */
ul.news-list {
  list-style: none;
  padding: 0;
}
ul.news-list li {
  list-style: none;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--af-divider);
}

ul.news-list time {
  display: inline-block;
  min-width: 6rem;
  color: var(--af-muted);
  font-size: 0.85rem;
  font-weight: 400;
}
.news-inline {
  display: inline;
}
.news-inline p { display: inline; margin: 0; }

/* ---- Projects grid ---- */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.projects-grid-3 {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.project-card {
  border: 1px solid var(--af-divider);
  border-radius: 4px;
  overflow: hidden;
  background: var(--af-card-bg);
  transition: box-shadow 0.2s ease;
}
.project-card:hover { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); }
.project-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.project-card .project-body,
.project-card h3,
.project-card p {
  padding: 0 0.8rem;
  margin: 0.5rem 0;
}
.project-card h3 { font-size: 1.1rem; }
.project-card a { text-decoration: none; }

/* ---- Bibliography (publications) ---- */
.bib-entry {
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--af-divider);
  align-items: flex-start;
}
.bib-preview {
  flex-shrink: 0;
  width: 120px;
  overflow: hidden;
  border-radius: 4px;
}
.bib-preview img {
  width: 100%;
  height: auto;   /* natural ratio — no cropping, no distortion */
  display: block;
}
.bib-thumb {
  border: none;
  background: none;
  padding: 0;
  cursor: zoom-in;
  width: 100%;
  display: block;
}
.bib-thumb:focus-visible {
  outline: 2px solid var(--af-theme);
  outline-offset: 2px;
  border-radius: 4px;
}
.bib-content {
  flex: 1;
  min-width: 0;
}
.bib-reference {
  display: block;
  font-size: 0.95rem;
  line-height: 1.5;
}
.bib-links {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.bib-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--af-divider);
  border-radius: 3px;
  color: var(--af-muted);
  text-decoration: none;
}
.bib-link:hover {
  color: var(--af-theme);
  border-color: var(--af-theme);
  text-decoration: none;
}
/* Scholar citation button — slightly emphasized. */
.bib-link[title="Google Scholar"] {
  color: var(--af-theme);
  border-color: var(--af-theme);
  font-weight: 700;
}

/* ---- Lightbox (click thumbnail to view full image) ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.lightbox.open {
  opacity: 1;
  visibility: visible;
  background: rgba(0, 0, 0, 0.9);
  transition: opacity 0.25s ease, visibility 0s linear 0s;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transform: scale(0.85);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.lightbox.open img {
  transform: scale(1);
  opacity: 1;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2001;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }
.lightbox-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Year group headers produced by jekyll-scholar (group_by: year) */
h2.bibliography {
  font-size: 1.4rem;
  margin-top: 2rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--af-divider);
}
/* jekyll-scholar renders each year group as <ol class="bibliography">.
   Strip the numbering — entries are self-documenting. */
ol.bibliography {
  list-style: none;
  margin: 0;
  padding: 0;
}
ol.bibliography li { list-style: none; }

/* ---- Blog post list ---- */
.post-list {
  list-style: none;
  padding: 0;
}
.post-list li {
  list-style: none;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--af-divider);
}
.post-list h3 { margin-bottom: 0.2rem; font-size: 1.1rem; }
.post-meta {
  font-size: 0.85rem;
  color: var(--af-muted);
}
.header-bar {
  text-align: center;
  margin-bottom: 2rem;
}
.header-bar h2 { color: var(--af-muted); font-weight: 300; }

/* ---- Bootstrap-grid approximation (project content pages use .row/.col-sm) ---- */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
}
[class*="col-sm"] {
  flex: 1 1 0;
  min-width: 0;
}
.row.justify-content-sm-center { justify-content: center; }
.caption {
  font-size: 0.85rem;
  color: var(--af-muted);
  text-align: center;
  margin: 0.5rem 0 1.5rem;
}
img.img-fluid {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* ---- Code blocks / highlight ---- */
.highlight {
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ---- Responsive breakpoints ---- */
@media (max-width: 600px) {
  /* Smaller floated profile beside the name, not full-width on top. */
  .about .profile {
    float: right;
    width: 120px;
    margin: 0 0 0.5rem 1rem;
  }
  /* Clear extra top padding for the taller wrapped navbar. */
  main.container { padding-top: 7rem; }
  /* Bibliography thumbnails smaller, stack nicely. */
  .bib-preview { width: 100px; }
  /* Project grid collapses to single column. */
  .projects-grid-3 { grid-template-columns: 1fr; }
}
