/* ============================================================
   Google Fonts — EB Garamond for headings
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --blue:         #003d73;
  --blue-dark:    #002a50;
  --gold:         #c8a951;
  --bg:           #ffffff;
  --text:         #1a1a1a;
  --muted:        #5a6475;
  --border:       #dde3ea;
  --bg-subtle:    #f4f7fb;
  --border-light: #ebebeb;
  --max-width:    1100px;
  --radius:       6px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 14px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg:    0 8px 28px rgba(0,0,0,0.13), 0 4px 8px rgba(0,0,0,0.06);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

h1, h2, h3, h4 {
  font-family: 'EB Garamond', Georgia, "Times New Roman", serif;
  color: var(--blue);
  line-height: 1.25;
}

h1 { font-size: 2.25rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.55rem; margin-bottom: 0.65rem; }
h3 { font-size: 1.18rem; margin-bottom: 0.4rem; }

p  { margin-bottom: 1rem; }
a  { color: var(--blue); text-decoration: none; transition: color 0.15s; }
a:hover { text-decoration: underline; color: var(--gold); }

ul, ol { padding-left: 1.25rem; margin-bottom: 1rem; }
li { margin-bottom: 0.25rem; }

/* ============================================================
   Layout
   ============================================================ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

main.container { padding-top: 2.75rem; padding-bottom: 3.5rem; }

/* ============================================================
   Navigation
   ============================================================ */
header {
  background: var(--blue);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.28);
}

.navbar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-brand {
  color: #fff;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.nav-brand:hover { text-decoration: none; color: var(--gold); }

.nav-links {
  list-style: none;
  display: flex;
  gap: 0.15rem;
}

.nav-links a {
  color: rgba(255,255,255,0.82);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-links a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}
.nav-links a.active {
  color: #fff;
  background: rgba(255,255,255,0.12);
}
.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}

.nav-links a:focus-visible,
.nav-brand:focus-visible,
.nav-toggle:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

/* ============================================================
   Email reveal button
   ============================================================ */
.email-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--blue);
  cursor: pointer;
  font-size: 0.83em;
  font-family: inherit;
  padding: 0.1em 0.5em;
  line-height: 1.6;
  vertical-align: baseline;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.email-btn:hover {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
footer .email-btn {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.22);
  color: var(--gold);
}
footer .email-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}

/* ============================================================
   Section headings — gold accent rule
   ============================================================ */
main h2:not(.no-rule) {
  padding-bottom: 0.35rem;
  position: relative;
}
main h2:not(.no-rule)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: linear-gradient(to right, var(--gold) 0%, var(--gold) 40%, transparent 100%);
  border-radius: 2px;
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  background: var(--blue-dark);
  color: rgba(255,255,255,0.75);
  padding: 2.25rem 0;
  margin-top: 4rem;
  font-size: 0.875rem;
  line-height: 1.85;
  border-top: 3px solid var(--gold);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  flex-wrap: wrap;
}

footer a { color: var(--gold); transition: color 0.15s; }
footer a:hover { color: #fff; text-decoration: none; }
footer strong { color: #fff; }

/* ============================================================
   Home page — two-column layout
   ============================================================ */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 3rem;
  align-items: start;
  padding-top: 2.5rem;
}

.highlights {
  background: var(--bg-subtle);
  border-left: 4px solid var(--gold);
  padding: 1.35rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-top: 2rem;
  box-shadow: var(--shadow-sm);
}

.highlights h3 { color: var(--blue); margin-bottom: 0.65rem; font-size: 1.05rem; }

.contact-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 4px solid var(--blue);
  padding: 1.6rem;
  border-radius: var(--radius);
  font-size: 0.92rem;
  line-height: 1.9;
  box-shadow: var(--shadow-md);
}

.contact-card h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.85rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 600;
}

/* ============================================================
   Research page
   ============================================================ */
.research-section {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.research-section:last-child { border-bottom: none; }

.research-section .key-publications {
  background: var(--bg-subtle);
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  margin-top: 0.85rem;
}
.research-section .key-publications li { margin-bottom: 0.15rem; }

/* ============================================================
   Members page
   ============================================================ */
.members-group { margin-bottom: 3rem; }
.members-group h2 { margin-bottom: 1.1rem; }

.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.35rem;
}

.member-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.member-card h3 { font-size: 1.05rem; margin-bottom: 0.2rem; color: var(--blue); }
.member-card .role { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.55rem; font-style: italic; }
.member-card .details { font-size: 0.88rem; line-height: 1.7; }
.member-card .details a { word-break: break-all; }

.member-card.leader {
  border-top: 4px solid var(--blue);
}

/* ============================================================
   Publications page
   ============================================================ */
.pub-year { margin-bottom: 2.5rem; }
.pub-year h2 { font-size: 1.3rem; margin-bottom: 1rem; }

.pub-list {
  list-style: none;
}

.pub-list li {
  margin-bottom: 0.9rem;
}

.pub-list li:last-child { border-bottom: none; }

.pub-title { font-style: italic; }
.pub-doi { font-size: 0.82rem; margin-left: 0.25rem; }

/* ============================================================
   Software page
   ============================================================ */
.software-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.software-card {
  border: 1px solid var(--border);
  border-top: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 1.6rem;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.software-card h3 { font-size: 1.18rem; margin-bottom: 0.5rem; }
.software-card .meta { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.75rem; }
.software-card p { font-size: 0.92rem; }
.software-card .links { margin-top: 1rem; font-size: 0.88rem; }
.software-card .links a { margin-right: 1rem; }
.software-card .reference {
  font-size: 0.82rem;
  margin-top: 0.75rem;
  color: var(--muted);
}

/* ============================================================
   Links & Teaching — simple
   ============================================================ */
.link-group { margin-bottom: 2rem; }
.link-group h3 { margin-bottom: 0.5rem; }
.placeholder-note {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 2rem;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

/* ============================================================
   Teaching — YouTube channel card
   ============================================================ */
.youtube-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.15rem 1.5rem;
  border: 1px solid #f5c6c6;
  border-left: 4px solid #ff0000;
  border-radius: var(--radius);
  background: #fff9f9;
  margin: 1.75rem 0 0;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.18s ease;
}
.youtube-card:hover {
  box-shadow: 0 6px 20px rgba(255,0,0,0.12);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}
.youtube-logo {
  flex-shrink: 0;
  width: 46px;
  height: 32px;
  background: #ff0000;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
}
.youtube-info { flex: 1; }
.youtube-info strong { display: block; color: var(--text); font-size: 0.95rem; }
.youtube-info span { font-size: 0.83rem; color: var(--muted); }
.youtube-cta {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
}

/* ============================================================
   Teaching — course sections
   ============================================================ */
.course-section { margin-top: 3rem; }

.course-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--gold);
}
.course-header h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
  font-size: 1.4rem;
}
.course-header h2::after { display: none !important; }

.course-badge {
  flex-shrink: 0;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.course-desc {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.45rem 0 0;
}

/* ============================================================
   Teaching — interactive app cards
   ============================================================ */
.app-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.1rem;
}

.app-card {
  display: flex;
  flex-direction: row;
  overflow: hidden;
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.2s ease;
}
.app-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.app-card-thumb {
  flex: 0 0 200px;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.app-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
  display: block;
  transition: transform 0.35s ease, opacity 0.18s;
}
.app-card:hover .app-card-thumb img {
  transform: scale(1.04);
  opacity: 0.88;
}

.app-card-body {
  flex: 1;
  padding: 1.15rem 1.5rem;
  display: flex;
  flex-direction: column;
}
.app-card-body h3 { font-size: 1.08rem; margin-bottom: 0.3rem; }
.app-card-body .meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.6rem; }
.app-card-body p { font-size: 0.88rem; line-height: 1.6; margin-bottom: 0; flex: 1; }
.app-card-body .links { margin-top: 0.9rem; font-size: 0.88rem; }
.app-card-body .links a { font-weight: 600; margin-right: 1rem; }

.app-card--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  border-top-color: var(--border);
  box-shadow: none;
  background: var(--bg-subtle);
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}
.app-card--empty p { margin: 0; }

/* ============================================================
   Page header strip
   ============================================================ */
.page-header {
  border-bottom: 2px solid var(--border);
  margin-bottom: 2.25rem;
  padding-bottom: 1.1rem;
}
.page-header h1 { margin-bottom: 0.3rem; font-size: 2rem; }
.page-header p { color: var(--muted); margin: 0; font-size: 0.95rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .nav-toggle { display: block; }

  .nav-links {
    display: none;
    flex-direction: column;
    gap: 0;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--blue);
    padding: 0.5rem 0;
    box-shadow: 0 6px 12px rgba(0,0,0,0.25);
  }

  .nav-links.open { display: flex; }

  .nav-links a {
    padding: 0.7rem 1.5rem;
    border-radius: 0;
    display: block;
  }

  .nav-links a.active::after { display: none; }

  .home-grid { grid-template-columns: 1fr; padding-top: 1.5rem; }

  .member-grid { grid-template-columns: 1fr; }

  .software-cards { grid-template-columns: 1fr; }

  .app-card { flex-direction: column; }
  .app-card-thumb { flex: none; height: 148px; border-right: none; border-bottom: 1px solid var(--border); }
  .youtube-card { flex-wrap: wrap; gap: 0.75rem; }
  .youtube-cta { width: 100%; }

  .footer-inner { flex-direction: column; }
}

/* ============================================================
   Publications — dynamic accordion
   ============================================================ */

/* Spinner */
.pub-spinner {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pub-spinner::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.pub-spinner--global {
  font-size: 1rem;
  padding: 2rem 0;
  justify-content: center;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Year accordion */
.pub-year-details {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.pub-year-details:last-child { border-bottom: none; }

.pub-year-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 0;
  user-select: none;
}
.pub-year-summary::-webkit-details-marker { display: none; }
.pub-year-summary::before {
  content: '▶';
  font-size: 0.65rem;
  color: var(--blue);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.pub-year-details[open] > .pub-year-summary::before {
  transform: rotate(90deg);
}
.pub-year-label {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.3rem;
  color: var(--blue);
  font-weight: 600;
}
.pub-count {
  font-size: 0.82rem;
  color: var(--muted);
}
.pub-year-summary:hover .pub-year-label { color: var(--gold); }

/* Publication list inside accordion */
.pub-year-details .pub-list {
  list-style: none;
  padding: 0 0 1.1rem 1.25rem;
  margin: 0;
}

/* Each entry */
.pub-entry {
  padding: 0.75rem 0;
  padding-left: 0;
  text-indent: 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.92rem;
  line-height: 1.6;
  list-style: none;
}
.pub-entry:last-child { border-bottom: none; }

/* Inner flex row */
.pub-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.85rem;
}

.pub-toc-wrap {
  flex: 0 0 180px;
  width: 180px;
  overflow: hidden;
}
.pub-toc {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f9f9f9;
}

.pub-body { flex: 1; min-width: 0; }
.pub-title { font-style: italic; }
.pub-doi   { font-size: 0.82rem; margin-left: 0.25rem; }
.small-caps { font-variant: small-caps; }
.pub-error { color: #c0392b; padding: 1rem 0; }

/* ============================================================
   Hero section (index.html)
   ============================================================ */
.hero {
  position: relative;
  background: var(--blue);
  color: #fff;
  padding: 5.5rem 1.5rem 4.5rem;
  text-align: center;
  overflow: hidden;
  margin-bottom: 0;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,61,115,0.82) 0%, rgba(0,42,80,0.92) 100%);
  z-index: 1;
}
.hero-bg {
  position: absolute;
  inset: 0;
  object-fit: cover;
  object-position: center top;
  width: 100%;
  height: 100%;
  opacity: 0.38;
  z-index: 0;
}
.hero-content {
  position: relative;
  z-index: 2;
  max-width: var(--max-width);
  margin: 0 auto;
}
.hero h1 {
  color: #fff;
  font-size: 2.65rem;
  margin-bottom: 0.6rem;
  border: none;
  text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.hero h1::after { display: none; }
.hero p {
  color: rgba(255,255,255,0.82);
  font-size: 1.1rem;
  max-width: 620px;
  margin: 0 auto 1.75rem;
}
.hero-cta {
  display: inline-block;
  background: var(--gold);
  color: var(--blue-dark);
  padding: 0.7rem 1.75rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.hero-cta:hover {
  background: #d4b35a;
  color: var(--blue-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  text-decoration: none;
}
main.container.has-hero { padding-top: 0; }

/* ============================================================
   Card hover lift (member cards, software cards)
   ============================================================ */
.member-card,
.software-card {
  transition: transform 0.18s ease, box-shadow 0.2s ease;
}
.member-card:hover,
.software-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Member portrait photo
   ============================================================ */
.member-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.75rem;
  border: 3px solid var(--border);
  display: block;
}
.member-photo-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--border);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ============================================================
   Group photos gallery
   ============================================================ */
.group-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.group-gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  aspect-ratio: 3/2;
  background: var(--border);
  box-shadow: var(--shadow-sm);
}
.group-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  display: block;
}
.group-gallery-item:hover img { transform: scale(1.04); }
.group-gallery-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  padding: 1rem;
}

/* ============================================================
   Section dividers / visual accents
   ============================================================ */
.section-divider {
  border: none;
  height: 2px;
  background: linear-gradient(to right, var(--blue), var(--gold) 40%, transparent);
  margin: 2.75rem 0;
  border-radius: 2px;
  opacity: 0.7;
}

/* Fade-in animation on page load */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeInUp 0.45s ease both;
}
.fade-in-delay-1 { animation-delay: 0.1s; }
.fade-in-delay-2 { animation-delay: 0.2s; }
.fade-in-delay-3 { animation-delay: 0.3s; }

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .fade-in,
  .fade-in-delay-1,
  .fade-in-delay-2,
  .fade-in-delay-3 {
    animation: none;
  }
}

/* ============================================================
   Responsive additions
   ============================================================ */
@media (max-width: 768px) {
  .hero h1  { font-size: 1.9rem; }
  .hero p   { font-size: 1rem; }
  .pub-toc-wrap { flex: 0 0 120px; width: 120px; }
  .group-gallery { grid-template-columns: 1fr; }
  main.container { padding-top: 2rem; padding-bottom: 2.5rem; }
}
