/* ---------------------------------------------------------------------------
   Theme tokens — light is the default, dark is applied via [data-theme="dark"]
   or the OS preference when no explicit choice has been made.
   --------------------------------------------------------------------------- */
:root {
  --background: #f9fafb;
  --foreground: #111827;
  --accent: #3b82f6;
  --muted: #6b7280;
  --border: #e5e7eb;
  --surface: #f3f4f6;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #241f1c;
    --foreground: #e6dfd3;
    --accent: #d97757;
    --muted: #8a7d71;
    --border: #3d342d;
    --surface: #2d2723;
  }
}

:root[data-theme="dark"] {
  --background: #241f1c;
  --foreground: #e6dfd3;
  --accent: #d97757;
  --muted: #8a7d71;
  --border: #3d342d;
  --surface: #2d2723;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------------------------
   Layout: sticky sidebar + main column
   --------------------------------------------------------------------------- */
.layout {
  display: flex;
  width: 100%;
  max-width: 72rem;
  min-height: 100vh;
  margin: 0 auto;
}

.sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 1.5rem;
  width: 280px;
  height: 100vh;
  padding: 4rem 1.5rem 1.5rem;
  position: sticky;
  top: 0;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.sidebar-avatar {
  width: 160px;
  height: 160px;
  border: 2px solid var(--border);
  border-radius: 50%;
  object-fit: cover;
  transition: border-color 0.3s;
}

.sidebar-avatar:hover {
  border-color: var(--accent);
}

/* Monogram stand-in used until a photo is dropped in at assets/avatar.jpg */
.sidebar-avatar--monogram {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--accent);
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  user-select: none;
}

.sidebar-name {
  margin: 1rem 0 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.sidebar-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  opacity: 0.7;
}

.sidebar-bio {
  margin: 0.75rem 0 0;
  padding: 0 0.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.8;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 0.75rem;
}

.social-link {
  display: inline-flex;
  padding: 0.25rem;
  opacity: 0.75;
  transition: opacity 0.3s, transform 0.3s, color 0.3s;
}

.social-link svg {
  width: 28px;
  height: 28px;
}

.social-link:hover {
  opacity: 1;
  color: var(--accent);
  transform: rotate(6deg);
}

.main-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--border);
}

/* ---------------------------------------------------------------------------
   Navigation
   --------------------------------------------------------------------------- */
.nav {
  padding: 2rem 2rem 1rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  position: relative;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s;
}

.nav-link.inactive {
  opacity: 0.75;
}

.nav-link.active {
  color: var(--accent);
}

.nav-link-line {
  position: absolute;
  bottom: -0.5rem;
  left: 0;
  width: 0;
  height: 4px;
  background-color: var(--accent);
  transition: width 0.3s;
}

.nav-link:hover .nav-link-line,
.nav-link.active .nav-link-line {
  width: 100%;
}

/* ---------------------------------------------------------------------------
   Page body
   --------------------------------------------------------------------------- */
.main-body {
  flex: 1;
  padding: 1.5rem 2rem 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  opacity: 0.75;
}

.section {
  margin-bottom: 2rem;
}

.section-title {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.prose {
  font-size: 1rem;
  line-height: 1.7;
}

.prose p {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose ul li::marker,
.prose ol li::marker {
  color: var(--accent);
  font-weight: 800;
}

.prose a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.2s;
}

.prose a:hover {
  color: var(--accent);
}

.prose blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 4px solid var(--accent);
  font-style: italic;
  opacity: 0.85;
}

.divider {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 2rem 0;
}

/* ---------------------------------------------------------------------------
   Publication cards
   --------------------------------------------------------------------------- */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.card {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  padding: 1rem 0;
}

.card-content {
  flex: 1;
  min-width: 0;
}

.card-title {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: color 0.2s;
}

.card-title:hover {
  color: var(--accent);
  text-decoration: underline;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.75;
}

.card-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.card-desc {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.8;
}

.card-actions {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Emphasised chips used for the research-interest list on the about page */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.chip {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
}

.icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.body-xs {
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.75;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-icon:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--background);
  transform: translateY(-2px);
}

/* Only one of the two toggle glyphs is visible at a time. */
.icon-moon {
  display: none;
}

:root[data-theme="dark"] .icon-moon {
  display: block;
}

:root[data-theme="dark"] .icon-sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon {
    display: block;
  }
  :root:not([data-theme="light"]) .icon-sun {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem;
  }

  .sidebar-inner {
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
    text-align: left;
  }

  .sidebar-avatar {
    width: 112px;
    height: 112px;
    font-size: 2.5rem;
  }

  .sidebar-name {
    margin-top: 0;
  }

  .sidebar-bio {
    padding: 0;
  }

  .sidebar-info,
  .social-links {
    justify-content: flex-start;
  }

  .main-content {
    width: 100%;
    flex: none;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .nav,
  .main-body,
  .footer {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (max-width: 768px) {
  .sidebar {
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .sidebar-inner {
    gap: 1rem;
  }

  .sidebar-avatar {
    width: 80px;
    height: 80px;
    font-size: 1.75rem;
  }

  .sidebar-name {
    font-size: 1.25rem;
  }

  .sidebar-bio {
    display: none;
  }

  .nav,
  .main-body,
  .footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .nav-links {
    gap: 1rem;
  }

  .nav-link {
    font-size: 0.85rem;
  }

  .card {
    flex-direction: column;
    gap: 0.75rem;
  }
}
