/* Base */
:root {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #3b82f6;
  --accent-2: #1e40af;
  --border: #e2e8f0;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html:focus-within {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  z-index: 999;
  background: #fff;
  color: #000;
  padding: .5rem .75rem;
  border-radius: .25rem;
  box-shadow: var(--shadow);
}

:focus {
  outline: none;
}

*:focus,
*:focus-visible,
a:focus,
button:focus,
[role="button"]:focus,
input:focus,
select:focus,
textarea:focus,
iframe:focus {
  outline: none !important;
}

a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.icon-btn:focus-visible,
.resource:focus-visible,
.back-to-top:focus-visible,
.modal__close:focus-visible,
.top-nav a:focus-visible {
  outline: none;
}

a:-moz-focusring {
  outline: none !important;
}

main:focus,
section:focus,
article:focus,
.card:focus {
  outline: none !important;
}

main:focus-visible,
section:focus-visible,
article:focus-visible,
.card:focus-visible {
  outline: none !important;
}

[id]:target {
  outline: none !important;
}

[tabindex="-1"]:focus {
  outline: none !important;
}

::selection {
  background: #cfe0ff;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250,250,250,.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.top-nav {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
}

.top-nav .brand {
  font-weight: 700;
  color: var(--text);
  font-size: 1.8rem;
}

.top-nav ul {
  list-style: none;
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
}

.top-nav a {
  padding: .25rem .5rem;
  border-radius: .25rem;
}

.top-nav a[aria-current="true"],
.top-nav a.is-active {
  background: rgba(26,95,209,.1);
}

/* Layout */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  padding: 1.25rem;
}

.sidebar {
  position: static;
  top: auto;
  height: auto;
  overflow: visible;
  align-self: start;
}

.sidebar h1 {
  font-size: 2.25rem;
  line-height: 1.2;
  margin: .25rem 0;
}

.tagline {
  color: var(--muted);
  margin-top: .25rem;
}

.avatar {
  margin: 1rem 0;
  border-radius: .75rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.avatar img {
  width: 100%;
  height: auto;
}

.social {
  display: flex;
  gap: .5rem;
  justify-content: center;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--accent-2);
}

/* Affiliations - Fixed Layout */
.affiliations ul {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  align-items: center;
}

.affiliations li {
  width: auto;
}

.affiliations .row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.affiliations a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.affiliations img {
  max-width: 90%;
  max-height: 90%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Main */
main {
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .75rem;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  padding-top: 2rem;
}

.card h2 {
  font-size: 1.6rem;
  margin: .25rem 0 1rem;
}

.entry {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

.entry:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.entry-title {
  font-size: 1.25rem;
  margin: .25rem 0;
}

.entry-meta {
  color: var(--muted);
  margin: .25rem 0 .5rem;
}

.media-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, max-content));
  gap: 1rem;
  margin: .75rem 0;
  justify-items: center;
  justify-content: center;
}

.media-row figure {
  text-align: center;
}

figure {
  margin: 0;
}

figcaption {
  color: var(--muted);
  font-size: .9rem;
  margin-top: .25rem;
}

.resources {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .5rem;
}

.resource {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #f4f7ff;
  border: 1px solid #d9e3ff;
  color: #123;
  box-shadow: var(--shadow);
  padding: .45rem .6rem;
  border-radius: .5rem;
}

.resource svg {
  width: 18px;
  height: 18px;
  fill: var(--accent);
}

/* Chips */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 1rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--card);
  padding: .35rem .6rem;
  border-radius: 999px;
  cursor: pointer;
}

.chip.is-active {
  background: #eaf1ff;
  border-color: #cfe0ff;
}

/* Back to top */
.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}

.back-to-top.is-visible {
  opacity: 1;
  transform: none;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
}

.modal.is-open {
  display: block;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
}

.modal__dialog {
  position: relative;
  max-width: min(1000px, 92vw);
  margin: 5vh auto;
  background: var(--card);
  border-radius: .75rem;
  box-shadow: var(--shadow);
  padding: 0;
}

.modal__content {
  padding: 0;
  max-height: 80vh;
  overflow: auto;
}

.modal__close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  border: 0;
  background: #fff;
  border-radius: .4rem;
  width: 36px;
  height: 36px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* Footer */
.site-footer {
  color: var(--muted);
  text-align: center;
  padding: 1.5rem 0;
}

/* Typography scale */
h1 {
  font-size: 2.25rem;
}

h2 {
  font-size: 1.7rem;
}

h3 {
  font-size: 1.25rem;
}

p, li {
  font-size: 1rem;
}

/* Section scroll offset for navigation */
.card h2 {
  scroll-margin-top: 120px;
}

.card {
  scroll-margin-top: 80px;
}

/* Enhanced color scheme improvements */
.card {
  transition: box-shadow .2s ease, border-color .2s ease;
}

#about.card {
  padding-top: 1.25rem;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
}

.entry {
  border-top: 1px solid var(--border);
  transition: border-color .2s ease;
}

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

.resource {
  transition: all .2s ease;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
}

.resource:hover {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,.15);
}

.icon-btn {
  transition: all .2s ease;
}

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

.icon-btn:hover svg {
  fill: #ffffff;
}

.back-to-top {
  transition: all .2s ease;
}

.back-to-top:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-elev: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #60a5fa;
    --accent-2: #3b82f6;
    --border: #334155;
    --card: #1e293b;
    --shadow: none;
  }
  
  .site-header {
    background: rgba(15,23,42,.85);
    border-bottom: 1px solid var(--border);
  }
  
  .resource {
    background: #1e293b;
    border-color: #475569;
  }
}

/* Motion reduce */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Responsive */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 1rem;
    grid-template-areas: "sidebar" "main";
  }
  
  .sidebar {
    position: relative;
    grid-area: sidebar;
  }
  
  main {
    grid-area: main;
  }
  
  .top-nav {
    flex-wrap: wrap;
    gap: .5rem;
  }
  
  .top-nav ul {
    flex-wrap: wrap;
  }
}

/* Print */
@media print {
  html, body {
    background: #fff;
    color: #000;
  }
  
  a {
    color: #000;
    text-decoration: underline;
  }
  
  .site-header,
  .filters,
  .media-row,
  .resources,
  .back-to-top,
  .modal,
  .affiliations {
    display: none !important;
  }
  
  .layout {
    grid-template-columns: 1fr;
    padding: 0;
  }
  
  .card {
    box-shadow: none;
    border: 0;
    padding: 0;
    margin: 0 0 1rem;
  }
  
  .entry {
    break-inside: avoid;
  }
  
  h1 {
    font-size: 28pt;
  }
  
  h2 {
    font-size: 18pt;
  }
  
  h3 {
    font-size: 13pt;
  }
  
  p, li {
    font-size: 11pt;
    line-height: 1.4;
  }
}