html {
  scroll-behavior: smooth;
}

:root {
  --nav-initial-gap: -0.15em;
  /* horizontal gap between initial and next letter */
  --nav-initial-nudge: -0.02em;
  /* vertical nudge for the initial (positive moves down) */
}

body {
  margin: 0px;
  padding: 0px;
  background: white;
  font-family: 'Raleway', sans-serif;
  font-size: 13pt;
  font-weight: 400;
  color: #363636;
}


h1,
h3 {
  margin: 0;
  padding: 0;
}

h2 {
  margin-bottom: 1em
}

html {
  scroll-behavior: smooth;
}

:root {
  --accent: #16a085;
  --accent-strong: #0f7d68;
  --accent-soft: rgba(22, 160, 133, 0.12);
  --accent-border: rgba(22, 160, 133, 0.3);
  --page-bg: #f5f7f7;
  --card-bg: #ffffff;
  --text-color: #2f3437;
  --muted-text: #69707a;
  --divider: rgba(15, 23, 42, 0.08);
  --nav-height: 64px;
  --nav-initial-gap: -0.12em;
  --nav-initial-nudge: -0.02em;
  --hero-overlay: linear-gradient(200deg, rgba(10, 38, 32, 0.08) 0%, rgba(10, 38, 32, 0.32) 75%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  font-family: 'Raleway', sans-serif;
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.75;
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: inherit;
}

p,
ul,
ol {
  margin: 0 0 1.35rem;
}

li {
  margin: 0 0 0.9rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.18s ease;
}

a:hover,
a:focus {
  color: var(--accent-strong);
}

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

.page {
  padding: 0 1.5rem 6rem;
}

.block {
  --block-pad-block: clamp(2.4rem, 3.5vw, 3rem);
  --block-pad-inline: clamp(2rem, 3.5vw, 3.2rem);
  max-width: 900px;
  margin: 0 auto 3rem;
  padding: var(--block-pad-block) var(--block-pad-inline);
  background: var(--card-bg);
  border: 1px solid var(--divider);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
}

@media (max-width: 1024px) {
  .block {
    --block-pad-block: 2.6rem;
    --block-pad-inline: 2.4rem;
    padding: var(--block-pad-block) var(--block-pad-inline);
  }
}

@media (max-width: 720px) {
  body {
    font-size: 1rem;
  }

  .page {
    padding: 0 1.1rem 5rem;
  }

  .block {
    margin-top: 0;
    --block-pad-block: 2rem;
    --block-pad-inline: 1.6rem;
    padding: var(--block-pad-block) var(--block-pad-inline);
  }
}

.title {
  margin-bottom: 2rem;
  text-transform: none;
}

.title h3 {
  text-align: center;
  font-size: clamp(1.5rem, 2.5vw, 1.9rem);
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-color);
  margin-bottom: 1.4rem;
}

.title h2 {
  display: inline-block;
  position: relative;
  font-size: clamp(1.25rem, 2.2vw, 1.5rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-color);
  margin-bottom: 1rem;
  padding-bottom: 0.25rem;
}

.title h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.6;
}

.title h2.hidden-spacer {
  display: none;
}

#Heading {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: end;
  margin: calc(-1 * var(--block-pad-block)) auto clamp(1.2rem, 3vw, 2rem);
  padding: clamp(0.8rem, 2vw, 1.2rem);
  max-width: min(800px, 100%);
  border-radius: 4px;
  overflow: hidden;
  isolation: isolate;
  background: rgba(30, 41, 59, 0.25);
  backdrop-filter: blur(4px);
}

#Heading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--hero-overlay);
  z-index: 1;
}

#Heading h3 {
  position: relative;
  z-index: 2;
  justify-self: stretch;
  color: #ffffff;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  margin: 0;
  padding: clamp(0.6rem, 2vw, 1rem) clamp(1rem, 2.5vw, 1.4rem);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#Heading p {
  position: relative;
  z-index: 0;
  margin: clamp(0.3rem, 1.2vw, 0.6rem) 0 0;
  display: flex;
  justify-content: center;
  width: 100%;
}

#Heading img {
  width: min(100%, 700px);
  height: auto;
  display: block;
  filter: saturate(1) contrast(1);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.block p {
  text-align: justify;
  text-justify: inter-word;
}

.block p+p {
  margin-top: 1.4rem;
}

.block ul,
.block ol {
  padding-left: 1.1rem;
}

.block ul li {
  padding-bottom: 0.95rem;
  border-bottom: 1px dashed var(--divider);
}

.block ul li:last-child {
  border-bottom: none;
}

/* Grid layout for ul items (teaching, software) */
.block ul {
  width: 100%;
  padding-left: 0;
  list-style: none;
}

.block ul li.grid-item {
  display: grid;
  /* Use different width for software section to fit "Repository" (approx 145px) */
  grid-template-columns: 145px 1fr auto;
  /* Fixed width for links column */
  grid-template-areas:
    "links title toggle"
    ". abstract .";
  gap: 0.4rem 0.8rem;
  align-items: start;
}

.block ul li.grid-item .item-links {
  grid-area: links;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.block ul li.grid-item .item-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 500;
  border: 1px solid var(--accent-border);
  background: transparent;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.block ul li.grid-item .item-links a:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.block ul li.grid-item .item-title {
  grid-area: title;
  font-size: 0.9rem;
  line-height: 1.45;
}

.block ul li.grid-item .item-toggle {
  grid-area: toggle;
  align-self: start;
}

.block ul li.grid-item .toggle-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 500;
  border: 1px solid var(--accent-border);
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  white-space: nowrap;
}

.block ul li.grid-item .toggle-summary.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.block ul li.grid-item .item-abstract {
  grid-area: abstract;
  margin-top: 0.3rem;
  padding: 0.7rem 0.9rem;
  background: rgba(22, 160, 133, 0.04);
  border-left: 2px solid var(--accent-border);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  text-align: justify;
  display: none;
}

.block ul li.grid-item.abstract-open .item-abstract {
  display: block;
}

/* arXiv logo styling */
/* arXiv logo styling */
.arxiv-logo {
  height: 1.25em;
  width: auto;
  margin: 0 auto;
  /* Center horizontally */
  display: block;
  /* Allows margin auto to work */
  border-radius: 0;
}

/* Ensure arXiv button content is centered */
/* This assumes there is a specific way to target the arXiv link if it is just a logo */
.block ol li .item-links a:has(.arxiv-logo) {
  justify-content: center;
  padding: 0.15rem 0.35rem;
  /* Ensure consistent padding */
}

/* Research items - 3 column grid layout */
.block ol {
  counter-reset: research-counter 10;
  /* Start at 9, decrement to 1 for PhD */
  list-style: none;
  padding-left: 0;
  width: 100%;
}

.block ol li {
  counter-increment: research-counter -1;
  /* Decrement */
  display: grid;
  /* Adjust width to be just enough for "Journal" button (approx 85px) */
  grid-template-columns: 85px 1fr auto;
  /* Fixed width for links column */
  grid-template-areas:
    "links title toggle"
    ". abstract .";
  gap: 0.4rem 0.8rem;
  align-items: start;
  padding-bottom: 0.95rem;
  border-bottom: 1px dashed var(--divider);
}

.block ol li:last-child {
  border-bottom: none;
}

/* Number shown in the title area */
.block ol li .item-title::before {
  content: counter(research-counter) ". ";
  font-weight: 600;
}

/* Left column: stacked buttons */
.block ol li .item-links {
  grid-area: links;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.block ol li .item-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 500;
  border: 1px solid var(--accent-border);
  background: transparent;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.block ol li .item-links a:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.block ol li .item-links a i {
  font-size: 0.8em;
}

/* Center column: title text */
.block ol li .item-title {
  grid-area: title;
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Right column: abstract toggle button only */
.block ol li .item-toggle {
  grid-area: toggle;
  align-self: start;
}

.block ol li .item-toggle .toggle-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 500;
  border: 1px solid var(--accent-border);
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

.block ol li .item-toggle .toggle-summary::-webkit-details-marker {
  display: none;
}

.block ol li .item-toggle .toggle-details[open] .toggle-summary {
  background: var(--accent-soft);
  color: var(--accent);
}

.block ol li .item-toggle .toggle-summary.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Abstract content appears below title in center column */
.block ol li .item-abstract {
  grid-area: abstract;
  margin-top: 0.3rem;
  padding: 0.7rem 0.9rem;
  background: rgba(22, 160, 133, 0.04);
  border-left: 2px solid var(--accent-border);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  text-align: justify;
  display: none;
}

.block ol li .item-toggle .toggle-details[open]~.item-abstract,
.block ol li.abstract-open .item-abstract {
  display: block;
}

#navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(245, 247, 247, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--divider);
}

#spblock {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.8rem;
  max-width: 960px;
  margin: 0 auto;
}

#navbar a {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.55rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--muted-text);
  text-transform: uppercase;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-initial {
  font-size: 1.3em;
  line-height: 1;
  font-weight: 600;
  margin-right: var(--nav-initial-gap);
  transform: translateY(var(--nav-initial-nudge));
}

#navbar a:hover,
#navbar a:focus {
  background: var(--accent-soft);
  color: var(--accent);
}

#navbar a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.toggle-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  margin-bottom: 0.3rem;
}

/* Link buttons on the left (arXiv, Journal, Repository etc.) */
.toggle-group .link-btn,
.toggle-group>a {
  order: -1;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid var(--accent-border);
  background: transparent;
  color: var(--accent);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.toggle-group>a i {
  font-size: 0.85em;
  opacity: 0.85;
}

/* Abstract/Syllabus toggle on the right */
.toggle-details {
  order: 1;
  margin-left: auto;
}

.toggle-summary i {
  font-size: 0.85em;
  opacity: 0.85;
}

.toggle-details {
  display: inline-block;
}

.toggle-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.6rem;
  border-radius: 3px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--accent-border);
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  list-style: none;
}

.toggle-summary::-webkit-details-marker {
  display: none;
}

.toggle-summary::after {
  content: '\25BE';
  font-size: 0.75rem;
  transform: translateY(-1px);
  transition: transform 0.2s ease;
}

.toggle-summary:focus-visible {
  outline: 3px solid rgba(22, 160, 133, 0.25);
  outline-offset: 2px;
}

.toggle-details[open] .toggle-summary,
.toggle-details.is-open .toggle-summary {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.toggle-details[open] .toggle-summary::after,
.toggle-details.is-open .toggle-summary::after {
  transform: rotate(180deg) translateY(1px);
}

.toggle-group a,
.block a[href$=".pdf"] {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.6rem;
  border-radius: 3px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--accent-border);
  background: transparent;
  color: var(--accent);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.toggle-group a:hover,
.toggle-group a:focus,
.block a[href$=".pdf"]:hover,
.block a[href$=".pdf"]:focus {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.toggle-content {
  margin-top: 0.6rem;
  padding: 0.8rem 1rem 0.8rem 1.1rem;
  background: rgba(61, 90, 128, 0.04);
  border-left: 2px solid var(--accent-border);
  border-radius: 0 4px 4px 0;
  color: inherit;
  font-size: 0.95rem;
}

.toggle-details:not([open]):not(.is-open) .toggle-content {
  display: none;
}

.toggle-details.is-open .toggle-content {
  display: block;
}

#contact-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  background: #ffffff;
  border-top: 1px solid var(--divider);
  color: var(--muted-text);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.4rem 1rem;
  text-align: center;
}

@media (max-width: 720px) {
  #navbar a {
    padding: 0.55rem 0.9rem;
    font-size: 0.92rem;
  }

  #Heading img {
    width: min(100%, 520px);
  }

  #contact-footer {
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

#block ul li {

  padding-bottom: 10px;

  border-bottom: 1px dashed rgba(0, 0, 0, 0.12);

}

/* App Card Styles */
.app-card {
  margin: 1.2rem 0 2rem;
}

.app-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 4px;
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  background: var(--card-bg);
  border: 1px solid var(--divider);
}

.app-card-link:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--accent-border);
}

.app-card-content {
  display: flex;
  align-items: flex-start;
  gap: 1.2rem;
  padding: 1.2rem;
}

.app-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
  background: white;
  padding: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.app-info {
  flex: 1;
}

.app-info h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 0.4rem;
}

.app-info p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted-text);
  margin-bottom: 0.7rem;
  text-align: left;
}

.app-cta {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  padding: 0.3rem 0.6rem;
  border-radius: 3px;
  background: var(--accent-soft);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.app-card-link:hover .app-cta {
  background: var(--accent);
  color: white;
}

@media (max-width: 600px) {
  .app-card-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .app-info p {
    text-align: center;
  }

  .app-logo {
    width: 80px;
    height: 80px;
  }
}

/* Responsive layout for mobile/tablets */
@media (max-width: 768px) {

  .block ol li,
  .block ul li.grid-item {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "title title"
      "links toggle"
      "abstract abstract";
    gap: 0.6rem 0.5rem;
  }

  .block ol li .item-links,
  .block ul li.grid-item .item-links {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .block ol li .item-title,
  .block ul li.grid-item .item-title {
    font-size: 1rem;
    /* Slightly larger title for readability on mobile? Or keep same. */
  }
}