/* ==========================================================================
   Terahertz Engineering Laboratory — design system
   Dark, minimal, academic. No gradients, no shadow-cards, no rounded chrome.
   ========================================================================== */

:root {
  --bg: #0b0c0e;
  --bg-raised: #121316;
  --line: #26282c;
  --line-soft: #1b1c1f;
  --text: #e7e5e0;
  --text-dim: #a3a19b;
  --text-faint: #6f6d68;
  --accent: #5c8ad1;
  --accent-dim: #3a537d;
  --link: #8fb3e6;
  --gold: #d9a94a;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --measure: 780px;
  --measure-wide: 1040px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(231, 229, 224, 0.35);
}
a:hover { color: var(--link); border-bottom-color: var(--link); }
a.plain { border-bottom: none; }

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.5em;
  color: var(--text);
}
h1 { font-family: var(--sans); font-size: 2.1rem; font-weight: 600; }
h2 { font-family: var(--sans); font-size: 1.4rem; font-weight: 600; }
h3 { font-family: var(--sans); font-size: 1.1rem; font-weight: 600; }
h4 { font-family: var(--sans); font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.small { font-size: 0.875rem; color: var(--text-dim); }
.mono { font-family: var(--mono); }

/* ---------- layout ---------- */

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 24px;
}
.wrap-wide {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 0 24px;
}

main { display: block; padding-bottom: 96px; }

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

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header-inner {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: none;
}
.brand-mark {
  display: block;
  height: 34px;
  width: auto;
  transition: filter 0.2s ease;
}
.brand-name {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text);
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}
.brand:hover .brand-mark {
  filter: drop-shadow(0 0 6px var(--accent)) drop-shadow(0 0 16px var(--accent)) drop-shadow(0 0 28px var(--accent));
}
.brand:hover .brand-name {
  text-shadow: 0 0 10px var(--accent), 0 0 22px var(--accent), 0 0 36px var(--accent);
}

nav.primary-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
nav.primary-nav ul {
  list-style: none;
  display: flex;
  margin: 0;
  padding: 0;
  gap: 4px;
}
nav.primary-nav > ul > li { position: relative; }
nav.primary-nav a,
nav.primary-nav button.nav-parent {
  display: block;
  padding: 8px 12px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--text-dim);
  border-bottom: none;
  white-space: nowrap;
  background: none;
  border: none;
  font-family: var(--sans);
  cursor: pointer;
  margin: 0;
  vertical-align: top;
}
nav.primary-nav a:hover,
nav.primary-nav button.nav-parent:hover,
nav.primary-nav a[aria-current="page"] { color: var(--text); }
nav.primary-nav button.nav-parent::after {
  content: "";
  display: inline-block;
  margin-left: 5px;
  border: 3px solid transparent;
  border-top-color: var(--text-faint);
  border-bottom: none;
  transform: translateY(-2px);
}

.submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  padding: 6px;
  margin-top: 4px;
}
li.has-children.open .submenu { display: block; }
.submenu a {
  padding: 7px 10px;
  font-size: 0.88rem;
  color: var(--text-dim);
}
.submenu a:hover { color: var(--text); background: var(--line-soft); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  color: var(--text);
  width: 38px;
  height: 34px;
  padding: 0;
  cursor: pointer;
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  display: block;
  width: 16px;
  height: 1px;
  background: var(--text);
  margin: 0 auto;
  position: relative;
}
.nav-toggle span::before { top: -5px; }
.nav-toggle span::after { top: 4px; }

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

.hero {
  padding: 88px 0 64px;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(180deg, rgba(8,14,26,0.08) 0%, rgba(8,12,18,0.55) 80%, var(--bg) 100%), url("/assets/img/brand/header-bg.jpg?v=20260921g");
  background-size: cover;
  background-position: center;
}
.hero-inner {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 0 24px;
}
.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}
.hero h1 {
  font-size: clamp(1.7rem, 3.4vw, 2.7rem);
  white-space: nowrap;
  margin-bottom: 0.35em;
}
@media (max-width: 640px) {
  .hero h1 { white-space: normal; }
}
.hero p.lead {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 62ch;
}

.page-hero {
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(180deg, rgba(8,14,26,0.1) 0%, rgba(8,12,18,0.6) 84%, var(--bg) 100%), url("/assets/img/brand/header-bg.jpg?v=20260921g");
  background-size: cover;
  background-position: center;
}
.page-hero .hero-eyebrow { margin-bottom: 10px; }
.page-hero h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); }
.page-hero p.lead { color: var(--text-dim); max-width: 68ch; }

/* ---------- sections ---------- */

section.block {
  padding: 56px 0;
  border-bottom: 1px solid var(--line-soft);
}
section.block:last-of-type { border-bottom: none; }
section.block > .wrap,
section.block > .wrap-wide { }
section.block h2 {
  margin-bottom: 0.6em;
}
section.block .section-num {
  font-family: var(--mono);
  color: var(--text-faint);
  font-size: 0.8rem;
  margin-bottom: 0.4em;
  display: block;
}
.prose { max-width: 68ch; color: var(--text-dim); }
.prose strong, .prose b { color: var(--text); font-weight: 600; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 28px;
  max-width: 68ch;
}
.stat { display: block; border: 1px solid var(--line); padding: 12px 8px; text-align: center; transition: border-color 0.15s ease; }
a.stat:hover { border-color: var(--accent); }
a.stat:hover .stat-num { color: var(--link); }
.stat-num {
  display: block;
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.1;
}
.stat-label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }
.stat-sub { display: block; font-size: 0.72rem; color: var(--gold); margin-top: 3px; }

/* ---------- grids / cards (flat, no shadows) ---------- */

.card {
  border: 1px solid var(--line);
  padding: 24px;
}
.card h3 { margin-bottom: 0.4em; }
.card .small { margin-top: 0.6em; }

/* ---------- lists (publications, people) ---------- */

.entry-list { list-style: none; margin: 0; padding: 0; }
.entry {
  padding: 20px 0;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 20px;
}
.entry:first-child { padding-top: 0; }
.entry:last-child { border-bottom: none; }
.entry-year {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.9rem;
  padding-top: 2px;
}
.entry-title { color: var(--text); margin: 0 0 4px; font-weight: 500; }
.entry-meta { color: var(--text-dim); font-size: 0.92rem; }
.entry-links { margin-top: 6px; display: flex; gap: 14px; font-size: 0.85rem; }
.entry-links a { border-bottom: 1px dotted rgba(143,179,230,0.4); }

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--line);
  padding: 5px;
  margin: 2px 0 16px;
  cursor: pointer;
}
.copy-btn:hover { border-color: var(--text-faint); color: var(--text); }
.copy-btn:disabled { color: var(--accent); border-color: var(--accent-dim); cursor: default; }
.copy-btn-sm {
  border: none;
  padding: 2px;
  margin: 0 0 0 2px;
  vertical-align: middle;
  color: var(--text-faint);
}
.copy-btn-sm:hover { border-color: transparent; color: var(--text); }

.year-heading {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 500;
  margin: 72px 0 8px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent-dim);
}
.year-heading:first-child { margin-top: 0; }

/* year-heading sits first inside its own .year-block wrapper (for the year
   filter), so :first-child above always zeroes its margin -- space between
   years comes from the block gap instead */
.year-block + .year-block { margin-top: 72px; }

.pub-list { list-style: none; margin: 0; padding: 0; }
.pub-entry {
  padding: 20px 0;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.pub-entry:first-child { padding-top: 0; }
.pub-entry:last-child { border-bottom: none; }
.pub-entry[hidden] { display: none; }
.pub-entry .pub-thumb {
  flex: 0 0 120px;
  width: 120px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--bg-raised);
}
.pub-entry .pub-thumb-empty {
  flex: 0 0 120px;
  width: 120px;
  aspect-ratio: 4 / 3;
  background: var(--bg-raised);
  border: 1px dashed var(--line);
}
.pub-entry .entry-body { flex: 1; min-width: 0; }
.pub-entry .entry-title { color: var(--text); margin: 0; font-weight: 400; font-size: 0.92rem; line-height: 1.55; }
.pub-entry .entry-title a { color: var(--text); border-bottom: 1px solid rgba(143, 179, 230, 0.35); }
.pub-entry .entry-title a:hover { border-bottom-color: var(--link); }
.pub-entry .entry-meta { color: var(--text-dim); font-size: 0.85rem; margin: 6px 0 0; }
.pub-entry .entry-meta a { word-break: break-all; }


/* people */
.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.person {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 440px;
}
.people-grid-compact .person { min-height: 300px; }
.person-photo {
  width: 100%;
  aspect-ratio: 5 / 6;
  object-fit: cover;
  margin-bottom: 14px;
  filter: grayscale(0.3);
}
.person-name { font-weight: 600; color: var(--text); }
.person-role { font-size: 0.85rem; color: var(--accent); margin: 2px 0 8px; }
.person-meta { font-size: 0.85rem; color: var(--text-dim); margin: 0 0 4px; }
.person-meta:last-of-type { margin-bottom: 8px; }
.person-links { font-size: 0.82rem; display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }

/* simple data table (codes, theses, etc.) */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 10px 14px 10px 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
table.data th {
  font-family: var(--mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* fixed, matching column widths across a stack of same-shape tables (coursework students) */
table.data.cols-4 { table-layout: fixed; }
table.data.cols-4 col.c1 { width: 20%; }
table.data.cols-4 col.c2 { width: 12%; }
table.data.cols-4 col.c3 { width: 20%; }
table.data.cols-4 col.c4 { width: 48%; }

/* logos row */
.photo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 24px 0 10px;
}
.photo-row img {
  flex: 1 1 260px;
  min-width: 0;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 1px solid var(--line);
}

.team-photo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
}
.team-photo-row figure {
  flex: 1 1 260px;
  min-width: 0;
  margin: 0;
}
a.lightbox-link {
  display: block;
  border-bottom: none;
  cursor: zoom-in;
}
.team-photo-row img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 1px solid var(--line);
}
.team-photo-row figcaption {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 8px;
}

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

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 8, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 100;
  cursor: zoom-out;
}
.lightbox-overlay[hidden] { display: none; }
.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--line);
}
.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 101;
  background: none;
  border: 1px solid var(--line);
  color: var(--text);
  width: 38px;
  height: 38px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.logo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 14px;
  margin-top: 20px;
  max-width: 68ch;
}
.logo-row a, .logo-row span {
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.88;
  transition: opacity 0.15s ease;
}
.logo-row a:hover, .logo-row span:hover { opacity: 1; }
.logo-row img {
  max-height: 84px;
  max-width: 220px;
  width: auto;
  height: auto;
  transition: filter 0.2s ease;
}
.logo-row a:hover img, .logo-row span:hover img {
  filter: drop-shadow(0 0 6px var(--accent)) drop-shadow(0 0 16px var(--accent));
}

/* tags / pillboxes */
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tag-row-inline { display: inline-flex; vertical-align: middle; margin: 0 0 0 4px; gap: 6px; }
.tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.6;
}
.tag-award {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--bg);
  background: var(--gold);
  border: 1px solid var(--gold);
  padding: 1px 7px;
  border-radius: 999px;
  white-space: normal;
  line-height: 1.3;
}
.tag-award a { color: inherit; border-bottom: 1px dotted currentColor; }
.tag-note {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--gold);
  white-space: normal;
  line-height: 1.4;
}
.tag-note a { color: inherit; border-bottom: 1px dotted currentColor; }
.note-sep { color: var(--text-faint); margin: 0 8px; }

.year-filter-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}
.year-filter {
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  padding: 6px 10px;
  cursor: pointer;
}
.year-filter:hover { border-color: var(--text-faint); }

.topic-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-filter-btn {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.4;
}
.topic-filter-btn:hover { border-color: var(--text-faint); color: var(--text); }
.topic-filter-btn[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

/* research / topic cards */
.cluster-group { margin-bottom: 44px; }
.cluster-group:last-child { margin-bottom: 0; }
.cluster-group > h2 { margin-bottom: 20px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}
.card-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card-grid .card {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.card-grid .card p { font-size: 0.88rem; }
.card p { color: var(--text-dim); font-size: 0.92rem; }
.card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  margin-bottom: 14px;
}
/* the plain (non-compact) card-grid is only used by wider, 2-column
   layouts (e.g. Codes) -- a fixed 160px height crops far more aggressively
   there than in the narrower auto-fill compact grid, so scale with width */
.card-grid:not(.card-grid-compact) .card img {
  height: auto;
  aspect-ratio: 16 / 9;
}

/* buttons */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--accent-dim);
  color: var(--text);
  font-size: 0.9rem;
  border-bottom-width: 1px;
}
.btn:hover { border-color: var(--accent); color: var(--link); }

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

.site-footer {
  border-top: 1px solid var(--line);
  padding: 40px 0 60px;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.site-footer .wrap-wide {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.site-footer a { color: var(--text-dim); }
.acknowledgement {
  max-width: 42.9rem;
  margin: 0;
  color: var(--text-faint);
  font-size: 0.85rem;
}

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

@media (max-width: 980px) {
  nav.primary-nav { display: none; }
  .nav-toggle { display: block; }
  .site-header.open nav.primary-nav {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .site-header.open nav.primary-nav ul {
    flex-direction: column;
    gap: 0;
    padding: 8px 24px 16px;
  }
  .site-header.open li.has-children .submenu {
    position: static;
    border: none;
    padding: 0 0 0 12px;
    margin-top: 0;
    background: none;
  }
}
@media (max-width: 860px) {
  .entry { grid-template-columns: 1fr; gap: 4px; }
  .card-grid { grid-template-columns: 1fr; }
  .pub-entry .pub-thumb, .pub-entry .pub-thumb-empty { width: 96px; flex: 0 0 96px; }
}
