:root {
    --text-color: rgba(255, 255, 255, 0.9);
    --background: rgb(30, 30, 46);
    --link-color: rgb(95, 231, 82);
    --border-color: rgba(255, 255, 255, 0.2);
    --hover-background: rgba(255, 255, 255, 0.05);
}

html, body {
    background-color: var(--background);
    color: var(--text-color);
    margin: 0;
    padding: 0;
}

body {
    font-family: "Iosevka Comfy Duo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    text-align: left;
    font-size: 18px;
    --list-spacing: 0.5em;
    --margin-bottom: 0.5em;
}

nav {
    margin: 2rem 0;
}

a, a:visited, a:active {
    color: var(--link-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    opacity: 1;
    text-decoration: underline;
    color: var(--link-color);
}

nav a {
    font-size: 0.9rem;
}

.navbar a:not(.logo) {
    margin: 0;
}

hr {
    width: 100%;
    margin: 2rem auto;
    border: none;
    border-top: 2px solid var(--border-color);
}

hr.nav-divider {
    margin: 1rem auto;
}

h1 {
    font-size: 2rem;
    margin: 2rem 0;
    color: var(--text-color);
    font-weight: bold;
}

h2, h3, h4, h5, h6 {
    font-size: 1.5rem;
    margin: 1.5rem 0;
    color: var(--text-color);
    font-weight: bold;
}

p, li, code, pre {
    font-size: 1rem;
    margin: var(--margin-bottom) 0;
}

/* List spacing */
ul, ol {
    margin: var(--margin-bottom) 0;
    padding-left: 1.5rem;
}

li {
    margin-bottom: var(--list-spacing);
}

li:last-child {
    margin-bottom: 0;
}

/* Ensure consistent text size in project sections */
.project-section h2 {
    font-size: 1.5rem;
    margin: 0;
    padding: 10px;
}

/* Math styling consistency */
.math-inline, .math-display {
    font-family: "Computer Modern", serif;
    font-style: italic;
    font-size: 1rem;
}

/* Code consistency */
code {
    font-size: 1rem;
}

/* Nav links consistency */
nav a, .nav-links a {
    font-size: 1rem;
}

nav.navbar .logo,
nav.navbar .logo:visited,
nav.navbar .logo:active,
nav.navbar .logo:focus,
nav.navbar .logo:hover {
    color: var(--link-color) !important;
    font-size: 1.2rem;
    font-weight: bold;
    text-decoration: none;
    transition: text-decoration 0.2s ease;
    outline: none;
}
nav.navbar .logo:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    body {
        padding: 1rem;
    }
    
    nav a {
        display: block;
        margin: 0.5rem 0;
    }
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-links {
    display: inline-block;
}

.nav-links a {
    margin: 0 4px;
}

.project-section {
    margin-top: 20px;
    border: 1px solid var(--border-color);
    text-align: left;
    background-color: var(--background);
    display: block;
}

.project-section h2 {
    color: var(--text-color);
    font-weight: normal;
    margin: 0;
    padding: 10px;
    background-color: var(--hover-background);
    border-bottom: 1px solid var(--border-color);
}

.project-section a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--link-color);
    text-decoration: none;
    padding: 10px;
}

.project-section a:last-child {
    border-bottom: none;
}

.project-section a:hover {
    background-color: var(--hover-background);
    text-decoration: none;
}

.social-links {
    text-align: center;
}

.index-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.index-content p {
    margin: 1.5rem auto;
}

.math-display {
    overflow-x: auto;
    margin: 1em 0;
}

pre[class*="language-"] {
    margin: 1.5em 0;
    border-radius: 4px;
}

/* Add these new rules */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em auto;
    /* improve image quality when scaled */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    /* add better hardware acceleration */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Add loading indicator */
md-block:not(:defined) {
    display: block;
    position: relative;
    min-height: 300px;
    background: var(--background);
    visibility: hidden;
}

md-block:not(:defined)::after {
    content: "Loading...";
    visibility: visible;
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-color);
    font-size: 1.2rem;
    opacity: 0.7;
}

/* Show content once defined */
md-block:defined {
    visibility: visible;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Loading state styles */
.loading .content-block {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

main:not(.loading) .content-block {
    opacity: 1;
}

.loading-spinner {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.loading .loading-spinner {
    display: block;
}

/* Optimize md-block rendering */
md-block {
    display: block;
    visibility: visible;
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

md-block:not(:defined) {
    opacity: 0;
}

/* Code block styling */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('media/fonts/JetBrainsMono-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

.code-container {
  position: relative;
  margin: 20px 0;
}

.code-block {
  background-color: #1a1b26;
  color: #c0caf5;
  padding: 16px;
  padding-top: 10px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1;
  display: block;
  position: relative;
  overflow-x: hidden; /* Prevent horizontal scrolling on the container */
}

/* Language indicator for code blocks */
.language-indicator {
  position: static;
  font-size: 12px;
  color: #7aa2f7;
  font-weight: bold;
  text-transform: uppercase;
  opacity: 0.8;
  border: 1px solid #7aa2f7;
  border-radius: 4px;
  padding: 2px 6px;
  z-index: 10;
  background-color: #1a1b26;
  display: inline-block;
}

.code-block > div:last-child {
  overflow-x: auto; /* Enable horizontal scrolling on the content wrapper */
  padding-bottom: 5px;
}

.code-line {
  display: block;
  padding-left: 0;
  margin: 0;
}

.code-line.indented {
  padding-left: 2em;
}

.copy-button {
  position: static;
  background-color: transparent;
  color: #7aa2f7;
  border: 1px solid #7aa2f7;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: bold;
  padding: 2px 6px;
  opacity: 0.8;
  z-index: 10;
  background-color: #1a1b26;
}

.copy-button:hover {
  opacity: 1;
  background-color: rgba(122, 162, 247, 0.1);
}

/* Notification styles */
.clipboard-notification {
  position: fixed;
  top: 20px;
  right: -300px; /* Start off-screen */
  background-color: #1a1b26;
  color: #ffffff;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: right 0.3s ease-in-out;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  visibility: hidden;
}

.clipboard-notification.show {
  right: 20px;
  opacity: 1;
  visibility: visible;
}

.clipboard-notification-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: var(--link-color);
  border-radius: 50%;
  position: relative;
}

.clipboard-notification-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 3px;
  width: 8px;
  height: 5px;
  border-left: 2px solid #1a1b26;
  border-bottom: 2px solid #1a1b26;
  transform: rotate(-45deg);
}

/* Override existing pre and code styles */
pre {
  margin: 0;
  padding: 0;
  background: none;
  border-radius: 0;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: inherit;
  background: none;
  white-space: pre;
  margin: 0;
  padding: 0;
}

/* Syntax highlighting */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #999;
}

.token.punctuation {
    color: #ccc;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol {
    color: #f08d49;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin {
    color: #7ec699;
}

.token.operator,
.token.entity,
.token.url,
.token.variable {
    color: #67cdcc;
}

.token.keyword {
    color: #cc99cd;
}

.token.function {
    color: #f08d49;
}

/* Math styling */
.math-inline, .math-display {
    font-family: "Computer Modern", serif;
    font-style: italic;
    font-size: 1.1em;
}

.math-inline {
    display: inline-block;
    margin: 0 0.2em;
}

.math-display {
    display: block;
    margin: 1em 0;
    text-align: center;
}

/* Basic math symbols */
.math-inline .operator,
.math-display .operator {
    margin: 0 0.2em;
}

.math-inline sup,
.math-display sup {
    vertical-align: super;
    font-size: 0.8em;
}

.math-inline sub,
.math-display sub {
    vertical-align: sub;
    font-size: 0.8em;
}

/* Greek letters */
.math-inline .greek,
.math-display .greek {
    font-family: "Symbol", serif;
}

/* Fractions */
.math-display .fraction {
    display: inline-block;
    vertical-align: middle;
    text-align: center;
}

.math-display .fraction > span {
    display: block;
}

.math-display .fraction .numerator {
    border-bottom: 1px solid var(--text-color);
}

.math-display .fraction .denominator {
    border-top: 1px solid var(--text-color);
}

/* Matrices */
.math-display .matrix {
    display: inline-table;
    vertical-align: middle;
    text-align: center;
}

.math-display .matrix > span {
    display: table-row;
}

.math-display .matrix > span > span {
    display: table-cell;
    padding: 0 0.2em;
}

#scroll-top {
  display: block;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background-color: var(--background);
  color: var(--text-color);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  z-index: 1000;
  padding: 0;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  transform: translateY(0);
  visibility: visible;
  pointer-events: none;
}

#scroll-top:hover {
  background-color: var(--hover-background);
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

#scroll-top:hover::before {
  content: "Scroll to top";
  position: absolute;
  right: 120%;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--background);
  color: var(--text-color);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 14px;
  white-space: nowrap;
  border: 1px solid var(--border-color);
}

/* Show button when page is scrolled */
@media (min-height: 700px) {
  #scroll-top.visible {
    opacity: 0.8;
    pointer-events: auto;
    animation: fadeIn 0.3s ease-in;
  }
}

/* Fade out animation */
#scroll-top.fade-out {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

/* Update keyframe animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 0.8;
    transform: translateY(0);
  }
}

.project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.project-item:last-child {
    border-bottom: none;
}

.project-item a {
    flex-grow: 1;
    padding: 10px 0;
    color: var(--link-color);
    text-decoration: none;
}

.project-item a:hover {
    text-decoration: underline;
    background: none;
}

.last-modified {
    margin-left: 1em;
    white-space: nowrap;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.5);
}
