/* ============================================================
   LAYOUT & COMPONENTS — colours and fonts come exclusively
   from the variables in theme.css.
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: min(72rem, 100% - 3rem);
  margin-inline: auto;
}

a { color: var(--text); text-decoration-color: var(--grey-400); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }

section { padding-block: 3.5rem; }

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

/* ---------- header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 0 1.5rem;
  min-height: 3.75rem;
  flex-wrap: wrap;
}

/* The brand absorbs all free space, anchoring nav + toggle to the
   right edge — their position stays put even when the brand is
   empty (as on the About page). */
.brand {
  font-weight: 700;
  text-decoration: none;
  font-size: 1.05rem;
  margin-right: auto;
}

nav.site-nav { order: 1; }
.header-actions { order: 2; }

.nav-toggle { display: none; }

.nav-toggle-label {
  display: none;
  cursor: pointer;
  padding: 0.5rem;
  font-size: 1.4rem;
  line-height: 1;
  user-select: none;
}

nav.site-nav ul {
  display: flex;
  gap: 1.75rem;
  list-style: none;
}

nav.site-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.95rem;
}

nav.site-nav a:hover { color: var(--text); }

nav.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.theme-toggle {
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.45rem 0.55rem;
  transition: border-color 0.15s ease;
}

.theme-toggle:hover { border-color: var(--border); }

/* ---------- hero ---------- */

.hero { padding-block: 5.5rem 3rem; }

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 700;
}

.hero .tagline {
  margin-top: 1rem;
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  color: var(--text-muted);
  max-width: 38em;
}

.hero .actions { margin-top: 2rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ---------- buttons & chips ---------- */

.btn {
  display: inline-block;
  padding: 0.6rem 1.3rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-solid { background: var(--accent); color: var(--accent-text); }
.btn-solid:hover { background: transparent; color: var(--text); }

.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--accent); color: var(--accent-text); }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.chip {
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--surface);
}

/* ---------- prose ---------- */

.prose { max-width: 46em; }
.prose p + p { margin-top: 1.1em; }
.prose .lede { font-size: 1.15rem; }

/* ---------- card grids ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

a.card { text-decoration: none; }

a.card:hover { border-color: var(--grey-400); transform: translateY(-2px); }

.card h3 { font-size: 1.08rem; }

.card .desc { color: var(--text-muted); font-size: 0.93rem; flex: 1; }

.card .meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
}

.status-tag {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--border);
}

/* ---------- publications ---------- */

.pub-list { display: flex; flex-direction: column; gap: 1.25rem; max-width: 52em; }

.pub {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0.5rem;
  padding: 1.5rem 1.75rem;
}

.pub h3 { font-size: 1.15rem; margin-bottom: 0.4rem; }
.pub .authors { font-size: 0.95rem; }
.pub .venue { font-size: 0.9rem; color: var(--text-muted); font-style: italic; margin-top: 0.2rem; }
.pub .summary { font-size: 0.93rem; color: var(--text-muted); margin-top: 0.8rem; }
.pub .links { margin-top: 0.9rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.pub .links a {
  font-size: 0.82rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  color: var(--text-muted);
}
.pub .links a:hover { border-color: var(--text); color: var(--text); }

/* ---------- socials ---------- */

.social-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  max-width: 46em;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.social-link:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

/* brand logo, tinted with the current text colour via mask */
.social-icon {
  width: 1em;
  height: 1em;
  flex: none;
  background-color: currentColor;
  -webkit-mask: var(--icon) no-repeat center / contain;
  mask: var(--icon) no-repeat center / contain;
}

.social-link .social-icon { width: 1.2rem; height: 1.2rem; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding-block: 2.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-footer nav { display: flex; gap: 1.1rem; flex-wrap: wrap; align-items: center; }
.site-footer a, .site-footer button.social-link-inline {
  display: inline-flex;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease;
}
.site-footer a:hover, .site-footer button.social-link-inline:hover { color: var(--text); }
.site-footer .social-icon { width: 1.05rem; height: 1.05rem; }

/* ---------- gallery ---------- */

.gallery-group + .gallery-group { margin-top: 3rem; }

.gallery-group .section-title { margin-bottom: 1rem; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(var(--gallery-columns), 1fr);
  gap: 0rem;
}

.gallery-tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--surface);
}

.gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.gallery-tile:hover img { transform: scale(1.04); filter: brightness(1.06); }

.gallery-empty { color: var(--text-muted); max-width: 46em; }

@media (max-width: 40rem) {
  .gallery-grid { grid-template-columns: repeat(var(--gallery-columns-mobile), 1fr); gap: 0.15rem; }
}

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
}

.lightbox img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 0.25rem;
}

.lightbox button {
  position: absolute;
  background: none;
  border: none;
  color: var(--grey-200);
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  padding: 0.75rem;
  transition: color 0.15s ease;
}

.lightbox button:hover { color: #ffffff; }

.lightbox .lb-close { top: 0.75rem; right: 1rem; }
.lightbox .lb-prev  { left: 0.5rem; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next  { right: 0.5rem; top: 50%; transform: translateY(-50%); }

.lightbox .lb-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.9rem 4rem 1rem;
  text-align: center;
}

.lightbox .lb-caption {
  color: var(--grey-100);
  font-size: 0.95rem;
  max-width: 60em;
}

.lightbox .lb-count {
  color: var(--grey-400);
  font-size: 0.8rem;
}

/* ---------- toast (clipboard feedback) ---------- */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive nav ---------- */

@media (max-width: 40rem) {
  .nav-toggle-label { display: block; }

  nav.site-nav {
    order: 3;            /* drop below brand + toggle row when open */
    flex-basis: 100%;
    display: none;
    padding-bottom: 1rem;
  }

  .nav-toggle:checked ~ nav.site-nav { display: block; }

  nav.site-nav ul { flex-direction: column; gap: 0.75rem; }

  .hero { padding-block: 3.5rem 2rem; }
  section { padding-block: 2.5rem; }
}
