@import "syntax-light.css" (prefers-color-scheme: light);
@import "syntax-dark.css" (prefers-color-scheme: dark);

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/BricolageGrotesque-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/BricolageGrotesque-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Monaspace Neon Regular";
  src: url("/fonts/MonaspaceNeon-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --width: 720px;
  --font-main: "Bricolage Grotesque", sans-serif;
  --font-secondary: "Bricolage Grotesque", sans-serif;
  --font-code: "Monaspace Neon Regular";
  --font-scale: 1em;

  --background-color: hsl(0, 0%, 100%);
  --heading-color: hsl(0, 0%, 0%);
  --text-color: hsl(0, 0%, 20%);
  --link-color: hsl(230, 88%, 58%);
  --active-link-color: hsl(0, 0%, 0%);
  --inactive-link-color: hsl(218, 12%, 47%);
  --blockquote-color: hsl(0, 0%, 0%);
  --text-inactive-color: hsl(0, 0%, 27%);

  --search-bg: hsl(0, 0%, 100%);
  --search-border: hsl(0, 0%, 96%);
  --search-text: hsl(0, 0%, 42%);
  --search-inactive-text: hsl(0, 0%, 40%);
  --search-inactive-bg: hsl(0, 0%, 97%);

  --inline-code-bg: hsl(0, 0%, 93%);
  --inline-code-text: hsl(0, 0%, 7%);

  --code-block-title-bg: hsl(0, 0%, 93%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background-color: hsl(0, 0%, 8%);
    --heading-color: hsl(0, 0%, 95%);
    --text-color: hsl(0, 0%, 90%);
    --link-color: hsl(75, 99%, 55%);
    --active-link-color: hsl(0, 0%, 100%);
    --inactive-link-color: hsl(218, 12%, 47%);
    --blockquote-color: hsl(0, 0%, 80%);
    --text-inactive-color: hsl(0, 0%, 67%);
    --search-bg: hsl(0, 0%, 10%);
    --search-border: hsl(0, 0%, 20%);
    --search-text: hsl(0, 0%, 57%);
    --search-inactive-text: hsl(0, 0%, 40%);
    --search-inactive-bg: hsl(0, 0%, 13%);
    --inline-code-bg: hsl(0, 0%, 27%);
    --inline-code-text: hsl(0, 0%, 100%);
    --code-block-title-bg: hsl(240, 7%, 14%);
  }
}

::selection {
  background: var(--link-color);
  color: var(--background-color);
}
::-moz-selection {
  background: var(--link-color);
  color: var(--background-color);
}

body {
  font-family: var(--font-secondary);
  font-size: var(--font-scale);
  margin: auto;
  padding: 20px;
  max-width: var(--width);
  text-align: left;
  background-color: var(--background-color);
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
  color: var(--text-color);
}

h1 {
  font-size: 2.5em;
  line-height: 1.2;
  color: var(--heading-color);
}

h2 {
  font-size: 1.8em;
  color: var(--heading-color);
}

h3,
h4,
h5,
h6 {
  font-family: var(--font-main);
  color: var(--heading-color);
}

a {
  color: var(--link-color);
  cursor: pointer;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.heading-link {
  color: var(--heading-color);
}

nav {
  padding-top: 20px;
}

nav a {
  margin-right: 8px;
  color: var(--inactive-link-color);
}

nav a.active {
  color: var(--active-link-color);
  font-weight: 500;
}

strong,
b {
  color: var(--heading-color);
}

button {
  margin: 0;
  cursor: pointer;
}

time {
  /* font-family: monospace; */
  font-style: normal;
  font-size: 15px;
  color: var(--text-inactive-color);
}

main {
  line-height: 1.6;
}

table {
  width: 100%;
}

hr {
  border: 0;
  border-top: 1px dashed;
}

img {
  max-width: 100%;
}

blockquote {
  border-left: 1px solid var(--inactive-link-color);
  color: var(--blockquote-color);
  padding-left: 20px;
  font-style: italic;
}

footer {
  padding: 25px 0;
  text-align: center;
}

.title:hover {
  text-decoration: none;
}

.title h1 {
  font-size: 1.5em;
}

.inline {
  width: auto !important;
}

.highlight,
.code {
  border-radius: 3px;
  margin-block-start: 1em;
  margin-block-end: 1em;
}

/* blog post list */
ul.blog-posts {
  list-style-type: none;
  padding: unset;
}

ul.blog-posts li {
  display: flex;
}

ul.blog-posts li span {
  flex: 0 0 130px;
  margin-bottom: 10px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background-color);
}

::-webkit-scrollbar-thumb {
  background-color: var(--inactive-link-color);
  border-radius: 4px;
  border: 2px solid var(--background-color); /* padding effect */
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--link-color);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--inactive-link-color) var(--background-color);
}

/* Override scrollbar for search results */
.search-results::-webkit-scrollbar-track {
  background: var(--search-bg);
}

.search-results::-webkit-scrollbar-thumb {
  border: 2px solid var(--search-bg);
}

.search-results {
  scrollbar-color: var(--inactive-link-color) var(--search-bg);
}

/* Search Modal Overlay */
.search-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  backdrop-filter: blur(9px);
}

.search-modal.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

/* Command Palette Style Container */
.search-container {
  background: var(--search-bg);
  border: 1px solid var(--search-border);
  border-radius: 8px;
  width: 90%;
  max-width: 580px;
  max-height: 60vh;
  overflow: hidden;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.2);
  position: relative;
}

/* Search Input */
.search-input {
  width: 100%;
  padding: 16px 20px;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-color);
  border-bottom: 1px solid var(--search-border);
}

.search-input::placeholder {
  color: var(--search-inactive-text);
}

.search-input:focus {
  outline: none;
}

/* Results Container */
.search-results {
  max-height: 400px;
  overflow-y: auto;
}

/* Individual Result */
.search-result {
  padding: 12px 20px;
  border-bottom: 1px solid var(--search-border);
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.search-result:hover {
  background-color: var(--search-inactive-bg);
}

.search-result:last-child {
  border-bottom: none;
}

/* Result Title */
.search-result-title {
  font-weight: 500;
  color: var(--heading-color);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 4px;
  display: block;
}

/* Result Excerpt */
.search-result-excerpt {
  color: var(--search-text);
  font-size: 13px;
  line-height: 1.3;
  margin: 0;
}

/* Empty State */
.search-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--search-text);
  font-size: 14px;
}

/* Keyboard shortcut hint */
.search-hint {
  position: absolute;
  top: 16px;
  right: 20px;
  color: #666;
  font-size: 14px;
  pointer-events: none;
}

/* Hide default Pagefind UI */
.pagefind-ui__form,
.pagefind-ui__search-input,
.pagefind-ui__search-clear,
.pagefind-ui__results {
  display: none !important;
}

/* Navigation adjustments for search trigger */
header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

/* Keep nav links grouped together */
.nav-links {
  display: flex;
  gap: 1rem;
}

/* Search trigger button in navbar */
.search-trigger {
  background: none;
  border: none;
  color: var(--search-text);
  cursor: pointer;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: baseline;
}

.search-trigger:hover {
  color: var(--link-color);
}

.search-trigger svg {
  display: block;
  /* vertical-align: middle; */
}

mark {
  background-color: var(--link-color) !important;
  color: var(--search-bg) !important;
  padding: 0 2px;
  border-radius: 2px;
}

/* Hide search-hint once start typing */
.search-input:not(:placeholder-shown) ~ .search-hint {
  display: none;
}

.search-trigger {
  position: relative;
}

.tooltip {
  position: absolute;
  bottom: 125%; /* place above the icon */
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--search-bg);
  color: var(--text-color);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

/* little arrow */
.tooltip::after {
  content: "";
  position: absolute;
  top: 100%; /* arrow points down */
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: var(--search-bg) transparent transparent transparent;
}

/* show tooltip on hover or focus */
.search-trigger:hover .tooltip,
.search-trigger:focus .tooltip {
  opacity: 1;
}

@media (max-width: 760px) {
  .nav-links {
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .tooltip {
    font-size: 12px;
    white-space: normal;
    max-width: 90vw;
  }
}

figcaption {
  text-align: center;
  font-style: italic;
  font-size: 0.9em;
  color: var(--text-inactive-color);
  margin-top: 0.5em;
}

.toc-container {
  margin: 1.5rem 0;
}

.toc-container summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--text-color);
  margin-bottom: 0;
}

.toc-container ul {
  list-style-type: none;
  padding-left: 0;
  margin: 0;
}

.toc-container li {
  margin: 0.2rem 0;
}

.toc-container li a {
  text-decoration: none;
  color: var(--text-inactive-color);
}

.toc-container li a:hover {
  text-decoration: underline;
  color: var(--link-color);
}

.toc-container ul ul {
  padding-left: 1.25rem;
}

pre code {
  display: block;
  padding: 10px;
  font-size: 0.9rem;
  overflow-x: auto;
  background-color: transparent;
  font-family: var(--font-code);
}

:not(pre) > code {
  background-color: var(--inline-code-bg);
  color: var(--inline-code-text);
  border-radius: 3px;
  font-family: var(--font-code);
  font-size: 1rem;
}

.code-title {
  background-color: var(--code-block-title-bg);
  color: var(--inline-code-text);
  font-family: var(--font-code);
  font-size: 0.85rem;
  padding: 4px 8px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  border-bottom: none;
}

.code-wrapper pre {
  border-top: none;
  border-radius: 0 0 4px 4px;
  margin: 0;
}

.code-wrapper {
  margin-bottom: 2em;
  max-width: var(--width);
}
