/* ── TOKENS ── */
:root {
  --font-size-h1: 32px;
  --font-size-h2: 25px;
  --font-size-h3: 22px;
  --font-size-body: 18px;
  --font-size-small: 0.8rem;

  --color-bg: #0d1117;
  --color-surface: #141a22;
  --color-surface-alpha: rgba(20, 26, 34, 0.99);
  --color-text: #f2eee8;
  --color-link: #7987dd;
  --color-border: #2a313c;
  --color-border-light: #313943;

  --transition-theme: background-color 0.3s ease, color 0.3s ease;
  --radius-sm: 4px;
  --radius-md: 8px;
}

html.light-mode {
  --color-bg: #f2eee8;
  --color-surface: #ebe5dd;
  --color-surface-alpha: rgba(235, 229, 221, 0.95);
  --color-text: #0d1117;
  --color-link: #4a56b0;
}

/* ── RESET ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── BASE ── */
@font-face {
  font-family: "JetBrainsMono";
  src: url("../fonts/JetBrains_Mono/static/JetBrainsMono-Medium.ttf")
    format("truetype");
  font-weight: 400;
  font-style: normal;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: "JetBrainsMono";
  font-size: var(--font-size-body);
  transition: var(--transition-theme);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body a {
  cursor: pointer;
}

body h1 {
  font-size: var(--font-size-h1);
}

body h2 {
  font-size: var(--font-size-h2);
}

body h3 {
  font-size: var(--font-size-h3);
}

/* ── NAVBAR ── */
.nav-container {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1000;
  background-color: var(--color-surface-alpha);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background-color 0.3s ease;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 60px;
  max-width: 1400px;
  margin: 0 auto;
}

.navbar__brand {
  text-decoration: none;
  color: var(--color-text);
  font-size: var(--font-size-h2);
  font-weight: bold;
  white-space: nowrap;
}

.navbar__links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.navbar__links a {
  text-decoration: none;
  color: var(--color-link);
  transition: opacity 0.2s ease;
}

.navbar__links a:hover {
  opacity: 0.75;
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-text);
  color: var(--color-text);
  width: 65px;
  height: 30px;
  font-family: inherit;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.theme-toggle:hover {
  background-color: var(--color-link);
  color: var(--color-bg);
}

/* Hamburger (mobile) */
.navbar__hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.navbar__hamburger span {
  display: block;
  height: 2px;
  background-color: var(--color-text);
  border-radius: 2px;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

/* Icons */

.icon {
  fill: var(--color-text) !important;
  width: 32px;
  height: 32px;
}

/* Search input */

/* ── Search Container ── */
#search-container {
  position: relative;
}

/* ── Search Input ── */
#search {
  height: 30px;
  width: 300px;
  background-color: var(--color-bg);
  color: var(--color-text);
  border-radius: 5px;
  border: 1px solid var(--color-text);
  text-indent: 15px;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

#search::placeholder {
  color: var(--color-text);
  opacity: 0.6;
}

#search:focus {
  border-color: var(--color-text);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-text) 15%, transparent);
}

/* ── Dropdown Results ── */
#search-result {
  position: absolute; /* detaches from flow, anchors to #search-container */
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  min-width: 300px;

  display: flex;
  flex-direction: column;
  gap: 0;

  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);

  z-index: 9999; /* float above all page content */
  overflow: hidden;

  /* hidden by default — toggle with JS */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease,
    visibility 0.15s;
}

/* Show state — add this class via JS when results exist */
#search-result.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ── Individual result links ── */
#search-result a {
  display: block;
  padding: 9px 14px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-bottom: 1px solid
    color-mix(in srgb, var(--color-border) 60%, transparent);
  transition: background-color 0.1s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

#search-result a:hover,
#search-result a:focus {
  background-color: color-mix(in srgb, var(--color-text) 8%, transparent);
}

/* ── LAYOUT ── */
.layout {
  flex: 1;
  display: flex;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 80px;
  justify-content: right;
  gap: 4rem;
}

/* ── SIDEBAR ── */
.sidebar {
  display: flex;
  align-items: left;
  justify-content: start;
  flex-direction: column;
  width: 160px;
  height: 88vh;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  padding-left: 2%;
  align-self: flex-start;
}

.sidebar-label {
  font-size: var(--font-size-body);
  text-transform: uppercase;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar nav li {
  list-style: none;
  margin-bottom: 15px;
}

.sidebar nav a {
  font-size: var(--font-size-small);
  text-decoration: none;
  padding: 0 0.2rem 0;
  color: var(--color-link);
  transition: opacity 0.2s ease;
}

.sidebar nav a:hover {
  opacity: 0.75;
}

/* ── INDEX CONTENT ── */
.content {
  flex: 1;
  max-width: 800px;
  text-align: justify;
}

/* Month block */
.month-block {
  margin-bottom: 3rem;
}

.month-block + .month-block {
  padding-top: 1rem;
}

.month-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  margin-bottom: 1rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border-light);
}

.month-header h1 {
  font-size: var(--font-size-h1);
  line-height: 1.3;
  flex: 1;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.month-header:hover .toggle-btn {
  border-color: var(--color-link);
  background: rgba(121, 135, 221, 0.08);
}

.toggle-btn svg {
  transition: transform 0.3s ease;
}

.month-block.collapsed .toggle-btn svg {
  transform: rotate(-90deg);
}

/* Articles list */
.articles {
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
  transition:
    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease;
}

.month-block.collapsed .articles {
  max-height: 0;
  opacity: 0;
}

.articles h2 a {
  display: flex;
  align-items: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-link);
  font-size: var(--font-size-h2);
  text-decoration: none;
  cursor: pointer;
  transition:
    color 0.15s,
    padding-left 0.15s;
}

.articles h2:hover a {
  padding-left: 0.5rem;
}

/* ── ARTICLE / TEXT CONTENT ── */
.text-content {
  flex: 1;
  max-width: 800px;
  text-align: justify;
}

.text-content article,
.text-content > * {
  line-height: 1.75;
}

/* Headings */
.text-content h1 {
  font-size: var(--font-size-h1);
  text-align: start;
  margin: 2.5rem 0 1.2rem 0;
  line-height: 1.3;
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: 0.6rem;
}

.text-content h2 {
  font-size: var(--font-size-h2);
  margin: 2rem 0 1rem 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--color-border);
}

.text-content h3 {
  font-size: 18px;
  margin: 1.6rem 0 0.8rem 0;
}

.text-content h4 {
  margin: 1.4rem 0 0.6rem 0;
}

/* Paragraphs & links */
.text-content p {
  margin: 1rem 0;
}

.text-content a {
  color: var(--color-link);
  text-decoration: underline;
}

.text-content a:hover {
  opacity: 0.8;
}

/* Lists */
.text-content ul,
.text-content ol {
  margin: 1rem 0 1rem 1.5rem;
  padding-left: 1rem;
}

.text-content li {
  margin: 0.4rem 0;
}

/* Blockquote */
.text-content blockquote {
  margin: 1.5rem 0;
  padding: 0.1rem 1.2rem;
  border-left: 4px solid var(--color-link);
  background-color: var(--color-surface);
  opacity: 0.9;
  font-style: italic;
  overflow-wrap:break-word;
}


/* Code */
.text-content code {
  background-color: var(--color-surface);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.text-content pre {
  background-color: var(--color-surface);
  padding: 1.2rem;
  text-align: left;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--color-border);
}

.text-content pre code {
  background: none;
  padding: 0;
  font-size: var(--font-size-body);
}

/* Misc */
.text-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 3rem 0;
}

.text-content img {
  max-width: 100%;
  border-radius: 6px;
  margin: 1.5rem 0;
}

/* Tables */
.text-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.text-content th,
.text-content td {
  border: 1px solid var(--color-border);
  padding: 0.6rem 0.8rem;
  text-align: left;
}

.text-content th {
  background-color: var(--color-surface);
}

#footer {
  border-top: solid 1px var(--TEXTCOLOR);
  text-align: center;
  margin-top: auto;
  padding: 20px;
  bottom: 0;
  width: 100%;
  position: relative;
  background-color: var(--color-surface);
}

.display-block{
  display: block !important;
}

#back-to-top{
  display: none;
  font-size: 15px;
  margin-top: auto;
}

#back-to-top svg{
  display: none!important;
}