@import url('https://fonts.googleapis.com/css2?family=EB+Garamond&family=Figtree:wght@400;600&family=Jost:wght@400;600&family=Alegreya+SC:wght@700&display=swap');

/* Shared layout and structure */
body {
  line-height: 1.6;
  margin: 0 auto;
  padding: 2rem;
  max-width: 800px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  text-decoration: underline;
  transition: color 0.2s ease;
}
a:hover {
  text-decoration: none;
}

code, pre {
  font-family: "Fira Code", monospace;
  padding: 0.2em 0.4em;
  border-radius: 4px;
}
pre {
  padding: 1em;
  overflow: auto;
  margin-bottom: 1.5em;
}

blockquote {
  border-left: 4px solid;
  margin: 1em 0;
  padding-left: 1em;
}

hr {
  border: none;
  border-top: 1px solid;
  margin: 2rem 0;
}

.byline {
  font-style: italic;
  margin-bottom: 1.5em;
}

/* Link previews */
p a[href^="http"]:after {
  content: " ↗";
  font-size: 0.8em;
  opacity: 0.6;
}

/* Navbar */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}
nav .home-button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  font-weight: bold;
  text-decoration: none;
}
nav .theme-toggle-button {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 5px;
  border: none;
}

/* Headings */
h1 {
  font-family: 'Alegreya SC', serif;
  font-size: 2.2rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid;
  padding-bottom: 0.3rem;
}

h2, h3, h4 {
  font-weight: 600;
  font-family: inherit;
  margin-top: 2rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid;
  padding-bottom: 0.3rem;
}

h2 { font-size: 1.8rem; }
h3 { font-size: 1.5rem; }

/* Light Theme */
.theme-light {
  background-color: #fdfdfb;
  color: #1a1a1a;
  font-family: 'Figtree', 'Jost', 'Segoe UI', sans-serif;
}
.theme-light a {
  color: #1e6091;
}
.theme-light a:hover {
  color: #168aad;
}
.theme-light p {
  color: #2b2b2b;
  text-align: justify;
}
.theme-light em {
  color: #ca6702;
  font-style: italic;
}
.theme-light strong {
  color: #007f5f;
  font-weight: bold;
}
.theme-light h1 {
  color: #0a9396;
  border-color: #94d2bd;
}
.theme-light h2 {
  color: #005f73;
  border-color: #cce3dc;
  font-family: 'EB Garamond', serif;
}
.theme-light h3 {
  color: #3d5a80;
  border-color: #e0fbfc;
  font-family: 'EB Garamond', serif;
}
.theme-light code, .theme-light pre {
  background: #f1f1f1;
  color: #007f5f;
}
.theme-light blockquote {
  border-left-color: #a9d6e5;
  background-color: #edf6f9;
  color: #33415c;
}
.theme-light hr {
  border-top-color: #ccc;
}
.theme-light .byline {
  color: #6c757d;
}
.theme-light .home-button {
  background-color: #0a9396;
  color: #ffffff;
}
.theme-light .home-button:hover {
  background-color: #007f5f;
}
.theme-light .theme-toggle-button {
  background-color: #cce3dc;
  color: #1a1a1a;
}

/* Dark Theme */
.theme-dark {
  background-color: #2e3440;
  color: #e5e9f0;
  font-family: 'Figtree', 'Jost', 'Segoe UI', sans-serif;
}
.theme-dark a {
  color: #88c0d0;
}
.theme-dark a:hover {
  color: #8fbcbb;
}
.theme-dark p {
  color: #eceff4;
  text-align: justify;
}
.theme-dark em {
  color: #ebcb8b;
  font-style: italic;
}
.theme-dark strong {
  color: #a3be8c;
  font-weight: bold;
}
.theme-dark h1 {
  color: #88c0d0;
  border-color: #434c5e;
}
.theme-dark h2 {
  color: #81a1c1;
  border-color: #4c566a;
  font-family: 'EB Garamond', serif;
}
.theme-dark h3 {
  color: #5e81ac;
  border-color: #434c5e;
  font-family: 'EB Garamond', serif;
}
.theme-dark code, .theme-dark pre {
  background: #3b4252;
  color: #88c0d0;
}
.theme-dark blockquote {
  border-left-color: #81a1c1;
  background-color: #434c5e;
  color: #d8dee9;
}
.theme-dark hr {
  border-top-color: #4c566a;
}
.theme-dark .byline {
  color: #a3be8c;
}
.theme-dark .home-button {
  background-color: #81a1c1;
  color: #2e3440;
}
.theme-dark .home-button:hover {
  background-color: #5e81ac;
}
.theme-dark .theme-toggle-button {
  background-color: #4c566a;
  color: #eceff4;
}

/* Sidebar styles */
.sidebar {
  position: fixed;
  top: 0;
  left: -250px;
  width: 250px;
  height: 100%;
  background-color: var(--sidebar-bg, #fff);
  box-shadow: 2px 0 5px rgba(0,0,0,0.3);
  padding: 1rem;
  transition: left 0.3s ease;
  z-index: 1001;
  display: flex;
  flex-direction: column;
}

.theme-light .sidebar {
  --sidebar-bg: #fdfdfb;
  color: #1a1a1a;
}
.theme-dark .sidebar {
  --sidebar-bg: #3b4252;
  color: #eceff4;
}

.sidebar.open {
  left: 0;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  margin-top: 2rem;
  gap: 1rem;
}

.sidebar nav a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 0.25rem;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background-color: #81a1c1;
  color: #2e3440;
}

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  align-self: flex-end;
  cursor: pointer;
  color: inherit;
}

/* Overlay */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  display: none;
  z-index: 1000;
}

/* Hamburger button */
.hamburger {
  position: fixed;
  top: 1rem;
  left: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1100;
  color: inherit;
}

/* Hide hamburger on desktop */
@media (min-width: 768px) {
  .hamburger {
    display: none;
  }
  .sidebar {
    left: 0;
    position: relative;
    height: auto;
    box-shadow: none;
    flex-direction: row;
    background: transparent;
    padding: 0;
  }
  .sidebar nav {
    flex-direction: row;
    margin-top: 0;
    gap: 2rem;
  }
  .sidebar nav a {
    background: transparent !important;
    color: inherit !important;
    padding: 0;
    font-weight: normal;
  }
  .close-btn {
    display: none;
  }
  #overlay {
    display: none !important;
  }
}

/* Dark toggle button in sidebar */
.dark-toggle {
  margin-top: auto;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 5px;
  border: none;
  background-color: #81a1c1;
  color: #2e3440;
  font-weight: 600;
}
.dark-toggle:hover {
  background-color: #5e81ac;
}

/* Dark mode toggle button fixed top-right */
.dark-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1200;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 5px;
  border: none;
  background-color: #81a1c1;
  color: #2e3440;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.dark-toggle:hover {
  background-color: #5e81ac;
}

/* Hide dark-toggle inside sidebar if present */
.sidebar .dark-toggle {
  display: none;
}
