@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;600&display=swap');

:root {
  --bg: #f8f5f2;
  --sidebar-bg: #fffaf6;
  --accent: #e8ded2;
  --border: #e2cfc3;
  --text: #3e2c18;
  --heading: #5c4327;
  --link: #a67c52;
  --link-hover: #7c5c36;
  --highlight: #d6bfa7;
  --toggle-bg: #b6a48a;
}

body.dark-mode {
  --bg: #23201b;
  --sidebar-bg: #2d261c;
  --accent: #3a2f23;
  --border: #4a3b2a;
  --text: #f5eee6;
  --heading: #ffe7b3;
  --link: #e8c28d;
  --link-hover: #ffe7b3;
  --highlight: #6b5436;
  --toggle-bg: #3a2f23;
  background: var(--bg);
  color: var(--text);
}

.dark-mode-toggle {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  background: var(--toggle-bg);
  color: var(--text);
  border: none;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(100, 80, 60, 0.10);
  transition: background 0.3s, color 0.3s;
  z-index: 2000;
}
.dark-mode-toggle:hover,
.dark-mode-toggle:focus {
  background: var(--highlight);
  color: var(--heading);
  outline: 2px solid var(--highlight);
}

body.dark-mode .dark-mode-toggle,
body.dark-mode #back-to-top {
  background: #5a4632; /* lighter brown for dark mode */
  color: var(--heading);
}

body.dark-mode .dark-mode-toggle:hover,
body.dark-mode .dark-mode-toggle:focus,
body.dark-mode #back-to-top:hover,
body.dark-mode #back-to-top:focus {
  background: #7c6243; /* even lighter brown on hover/focus */
  color: var(--bg);
  outline: 2px solid var(--highlight);
}

body {
  font-family: 'Barlow', 'Inter', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.main-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  width: 280px;
  min-width: 220px;
  max-width: 320px;
  padding: 2.5rem 1.5rem 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 2px 0 8px rgba(100, 80, 60, 0.04);
  border-right: 1px solid var(--border);
}

.profile-pic-large {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 220px;
  height: 160px;
  border-radius: 12px;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 12px rgba(100, 80, 60, 0.06);
  margin-bottom: 1.2rem;
  margin-top: 0;
  background: var(--sidebar-bg);
}

.sidebar h1 {
  font-size: 1.7rem;
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--heading);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: 100%;
  margin-top: 1rem;
  align-items: center;
}

.side-nav a {
  color: var(--text);
  background: none;
  text-decoration: none;
  font-size: 1.08rem;
  font-weight: 500;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  transition: background 0.4s cubic-bezier(0.4,0,0.2,1), color 0.2s, box-shadow 0.2s;
  width: 100%;
  text-align: center;
  box-shadow: none;
  border: none;
}

.side-nav a:hover,
.side-nav a:focus,
.side-nav a.active {
  color: var(--link-hover);
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(100, 80, 60, 0.03);
}

.sidebar .news-section {
  background: var(--accent);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(100, 80, 60, 0.03);
  padding: 1rem 1rem 0.5rem 1rem;
  margin-top: 2rem;
  width: 100%;
}

.sidebar .news-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.7rem;
  color: var(--heading);
  font-weight: 600;
}

.sidebar .news-list {
  font-size: 0.98rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar .news-list li {
  margin-bottom: 0.75rem;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.5;
}

.content-sections {
  flex: 1;
  padding: 3rem 2rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  max-width: 900px;
  margin: 0 auto;
}

.about-section,
.publications-section,
.contact-section {
  background: var(--sidebar-bg);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(100, 80, 60, 0.04);
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  width: 100%;
  border-left: 4px solid var(--accent);
  color: var(--text);
  font-size: 1.15rem;
}

.about-section {
  margin-bottom: 0.5rem;
}

.about-section h2,
.publications-section h2,
.contact-section h2 {
  font-size: 1.3rem;
  color: var(--heading);
  margin-bottom: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.publications-list,
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.publications-list li,
.contact-list li {
  margin-bottom: 0.75rem;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

.publications-list a,
.contact-list a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s;
  font-weight: 500;
}

.publications-list a:hover,
.contact-list a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  background: var(--accent);
  color: var(--text);
  padding: 0.5em 1em;
  z-index: 1000;
  border-radius: 4px;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  outline: 2px solid var(--highlight);
}

a:focus, button:focus, input:focus {
  outline: 2px solid var(--highlight);
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
  }
  .sidebar {
    flex-direction: row;
    width: 100%;
    max-width: unset;
    min-width: unset;
    box-shadow: none;
    border-bottom: 1px solid var(--accent);
    border-right: none;
    padding: 1rem 0.5rem;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 1rem;
  }
  .sidebar header {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 0;
    gap: 1rem;
  }
  .profile-pic-large {
    width: 70px;
    height: 70px;
    min-width: 50px;
    min-height: 50px;
    margin: 0;
    border-width: 2px;
  }
  .sidebar h1 {
    font-size: 1.1rem;
    margin: 0;
    text-align: left;
  }
  .side-nav {
    flex-direction: row;
    gap: 0.5rem;
    margin-top: 0;
    width: auto;
    align-items: center;
  }
  .side-nav a {
    font-size: 0.98rem;
    padding: 0.25rem 0.6rem;
    width: auto;
  }
  .sidebar .news-section {
    margin-top: 0;
    padding: 0.7rem 0.5rem 0.5rem 0.5rem;
    box-shadow: none;
    background: none;
    flex: 1 1 100%;
    min-width: 0;
  }
  .sidebar .news-section h2 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .sidebar-trademark {
  margin-top: auto;
  padding-top: 1.5rem;
  font-size: 0.95rem;
  color: var(--link);
  text-align: center;
  opacity: 0.7;
  letter-spacing: 0.01em;
}

  .content-sections {
    padding: 1rem 0.5rem;
    gap: 1rem;
  }
  .about-section,
  .publications-section,
  .contact-section {
    padding: 1rem 0.5rem 0.7rem 0.7rem;
    font-size: 1.05rem;
  }
}

@media (max-width: 600px) {
  .sidebar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem 0.2rem;
  }
  .sidebar header {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
  .profile-pic-large {
    width: 100%;
    height: auto;
    max-width: 120px;
    margin: 0 auto 0.5rem auto;
    display: block;
    border-width: 2px;
  }
  .sidebar h1 {
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
    text-align: center;
  }
  .side-nav {
    flex-direction: column;
    gap: 0.3rem;
    width: 100%;
    align-items: stretch;
  }
  .side-nav a {
    width: 100%;
    font-size: 0.95rem;
    padding: 0.25rem 0.2rem;
  }
  .sidebar .news-section {
    margin-top: 0.5rem;
    padding: 0.5rem 0.2rem 0.3rem 0.2rem;
    background: var(--accent);
    border-radius: 6px;
    font-size: 0.95rem;
  }
  .sidebar .news-section h2 {
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
  }
  .content-sections {
    padding: 0.5rem 0.1rem;
    gap: 0.7rem;
  }
  .about-section,
  .publications-section,
  .contact-section {
    padding: 0.7rem 0.3rem 0.5rem 0.5rem;
    font-size: 0.98rem;
  }
}

.news-list a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s;
  font-weight: 500;
}

.news-list a:hover,
.news-list a:focus {
  color: var(--link-hover);
  text-decoration: underline;
}

.about-section a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s;
  font-weight: 500;
}

.about-section a:hover,
.about-section a:focus {
  color: var(--link-hover);
  text-decoration: underline;
}

#back-to-top {
  display: none;
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--toggle-bg);
  color: var(--text);
  border: none;
  box-shadow: 0 2px 8px rgba(100,80,60,0.15);
  font-size: 1.5rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3000;
  transition: background 0.3s, color 0.3s, opacity 0.2s;
}
#back-to-top:hover,
#back-to-top:focus {
  background: var(--highlight);
  color: var(--heading);
  outline: 2px solid var(--highlight);
}

@media (max-width: 600px) {
  #back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.2rem;
    /* Ensure it's not hidden on mobile */
    /* display: flex;  <-- DO NOT set this here, JS controls display */
  }
}
