/* -------- Base -------- */
html, body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  font-size: 1.05em;
  color: #fff;
  background-color: #000;
}

:root {
  --nav-h: 56px;  /* tweak if you want a taller/shorter bar */
}

/* -------- Layout (pure flex) -------- */
.container {
  display: flex;           /* two real flex children: sidebar + content */
  margin: 0 auto;
  /* no overflow here; sticky needs ancestors without overflow hidden/auto */
  padding-top: var(--nav-h);      /* new */
}

/* Sidebar: fixed 250px, sticky, independent scroll */
#sidebar-container {
  flex: 0 0 300px;         /* fixed column width */
  box-sizing: border-box;  /* padding included in 250px */
  background-color: #1a1a1a;
  padding: 0px 20px 20px 20px;
  font-size: 0.9em;

  position: sticky;        /* stay in view on scroll */
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));           /* fill viewport height */
  overflow-y: auto;        /* only scrolls when hovered/needed */
  -webkit-overflow-scrolling: touch;
}

/* Main content: fills remaining space, no horizontal overflow */
.content {
  flex: 1;
  min-width: 0;            /* critical to prevent flex overflow */
  padding: 20px;
  overflow-wrap: anywhere; /* break long tokens/URLs if necessary */
}

/* -------- Sticky Navbar -------- */
#top-navbar {
  position: fixed;     /* was: sticky */
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111;
  color: #fff;
  padding: 10px 20px;
  border-bottom: 1px solid #2a2a2a;
  height: var(--nav-h);           /* lock its height */
  box-sizing: border-box;
}

#scroll-progress {
  position: absolute;
  left: 0;
  right: 0;          /* let width be driven by scale for perf, but keep hitbox full */
  bottom: 0;
  height: 2px;       /* requested height */
  transform-origin: left center;
  transform: scaleX(0);     /* start empty */
  background: #0A84FF;      /* blue (dark theme) */
  will-change: transform;
  pointer-events: none;
  z-index: 1000;   /* <— add this */
}

/* Right cluster: links + icon sit together on the right */
#top-navbar .navbar-right{
  display: flex;
  align-items: center;
  gap: 16px;          /* space between the link group and the search icon */
  margin-left: auto;
}

/* Space between individual links (no margins needed) */
#top-navbar .navbar-right .nav-links{
  display: flex;
  gap: 16px;
}

/* Base link styling (no spacing here) */
#top-navbar .navbar-right a{
  color: #fff;
  text-decoration: none;
  font-size: 0.95em;
}

#top-navbar .navbar-right a:hover{
  text-decoration: underline;
}

/* Light theme links */
body.light #top-navbar .navbar-right a{
  color: #0D0D0D;
}


/* -------- Sidebar links -------- */
#sidebar-container a {
  display: block;
  color: #fff;
  padding: 5px 0 5px 10px;
  text-decoration: none;
  transition: color 0.2s;
}

#sidebar-container strong {
    font-weight: 700;
    display: inline-block;
    margin-top: 1em;
}

#sidebar-container a:hover {
  text-decoration: underline;
}
#sidebar-container a.active {
  color: #fff;
  font-weight: bold;
  background-color: #0055FF;
  border-radius: 4px;
}

.group-link { color: inherit; text-decoration: none; }
.subgroup { padding-left: 14px; display: block; }
.subgroup a { display: block;}
[data-group] { margin-bottom: 10px; }

/* A11y utility */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Sticky filter area */
#sidebar-container .sidebar-filter {
  position: sticky; top: 0; z-index: 2;
  padding-bottom: 12px; margin-bottom: 12px;
  padding-top: 20px;
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
}

/* Wrap to position icons inside the input */
#sidebar-container .sidebar-filter .filter-wrap { position: relative; }

/* Input pill */
#sidebar-container .sidebar-filter input[type="search"] {
  width: 100%;
  padding: 10px 44px 10px 44px;   /* space for left icon + right clear */
  border-radius: 14px;
  border: 1px solid #2a2a2a;
  background: #111;
  color: #fff;
  font-size: 0.95em;
}
#sidebar-container .sidebar-filter input[type="search"]:focus {
  outline: 2px solid #0A84FF; outline-offset: 2px;
}

/* Left “filter” glyph drawn with 3 bars (CSS, no SVG) */
#sidebar-container .sidebar-filter .icon-left {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: #8a8a8a; pointer-events: none;
  background:
    linear-gradient(currentColor 2px, transparent 0) 0 3px / 18px 2px no-repeat,
    linear-gradient(currentColor 2px, transparent 0) 3px 8px / 12px 2px no-repeat,
    linear-gradient(currentColor 2px, transparent 0) 6px 13px / 6px 2px no-repeat;
  opacity: .9;
}

/* Right clear (×) button INSIDE the input */
#sidebar-container .sidebar-filter .clear-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: none;                  /* shown only when there is text */
  width: 24px; height: 24px;
  border: 0; background: transparent; color: #8a8a8a;
  padding: 0; cursor: pointer; border-radius: 50%;
  font-size: 16px; line-height: 1;
}
#sidebar-container .sidebar-filter .clear-btn:hover { color: #fff; }

/* -------- Typography -------- */
p {
    margin-block-start: 0.5em;
    margin-block-end: 0.5em;
    font-weight: 400;
}

h1 {
  font-size: 2em;
  color: #fff;
  margin: 0 0 0.5em 0;
  font-weight: 400;
}

h1::after {
  content: "";
  display: block;
  width: 100%; /* length of line */
  height: 1px; /* thickness */
  background: #ccc; /* subtle color */
  margin-top: 0.5em;
}

h2 {
  font-size: 1.5em;
  color: #fff;
  font-weight: 400;
  
  margin-block-start: 1.5em;
  margin-block-end: 0.5em;
}
h3 {
  font-size: 1.2em;
  color: #fff;
  font-weight: 400;

  margin-block-start: 1em;
  margin-block-end: 0.5em;
}
a {
  color: #0055FF;
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: #0033CC;
  text-decoration: underline;
}
ul, ol {
  margin: 1em 0;
  padding-left: 2em;
  color: #fff;
}
strong { color: #fff; }

/* -------- Code blocks -------- */
pre {
  background-color: rgb(22, 22, 22);
  border: 1px solid #575757;
  padding: 0 15px;
  border-radius: 4px;
  overflow-x: auto;
  font-family: "SF Mono", "Courier New", Courier, monospace;
  margin: 0 0;
  transition: box-shadow 0.2s;
}
pre:hover { box-shadow: 0 0 5px rgba(0,0,0,0.3); }
code { color: #D4D4D4; }
.keyword { color: #C586C0; }
.string { color: #CE9178; }
.comment { color: #6A9955; }
.number { color: #B5CEA8; }
.operator { color: #D4D4D4; }
.type { color: #4EC9B0; }
.function { color: #DCDCAA; }
.variable { color: #9CDCFE; }
.preprocessor { color: #C586C0; }
.url { color: #9CDCFE; }
.heading { color: #DCDCAA; }
.attribute { color: #9CDCFE; }
.note { font-style: italic; color: #555; margin: 1em 0; }

.highlight {
  background-color: #2d2d2d;   /* dark background */
  color: #f5f5f5;              /* light text */
  border-left: 5px solid #888; /* subtle left border */
  padding: 16px;
  margin: 20px 0;
  border-radius: 4px;
  line-height: 1.5;
}

.highlight strong {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #fff;
}

.upscale {
  background-color: #2d2d2d;  /* dark background */
  color: #f8f8f2;            /* light text */
  padding: 2px 6px;          /* small padding around text */
  border-radius: 4px;        /* rounded corners */
  font-size: 0.9em;
}

/* --- Article pager (prev/next under H1 and all Content) --- */
.article-pager {
  margin-top: 0.75rem;   /* a touch of space under the H1 + its ::after line */
  padding-top: 0.25rem;
}
.article-pager .pager-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.article-pager .spacer { flex: 1; }

.pager-link {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.95em;

  border-color: #ccc;
  color: #fff;
}
.pager-link:hover { text-decoration: none; border-color: #555; }

/* Top instance sits under H1; bottom instance adds a separator */
.article-pager--bottom {
  margin-top: 2rem;
  padding-top: 0.75rem;
  border-top: 1px solid #2a2a2a;
}

/* Light theme adjustments */
body.light .pager-link { border-color: #ccc; color: #0D0D0D; }
body.light .article-pager--bottom { border-top: 1px solid #ccc; }

body.light .pager-link {
  border-color: #ccc;
  color: #0D0D0D;
}


/* -------- Responsive (stack on phones) -------- */
@media (max-width: 850px) {
  .container {
    flex-direction: column;    /* stack */
  }
  #sidebar-container {
    position: static;          /* no sticky on tiny screens */
    height: auto;
    top: 0;
    flex: none;
    width: 100%;
  }
  .content {
    padding: 10px;
  }
  h1 { font-size: 1.5em; }
  h2 { font-size: 1.2em; }
}

/* -------- Footer Design -------- */

/* Footer layout */
#site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid #2a2a2a;
  background: #1a1a1a;       /* default dark */
  color: #ccc;
  font-size: 0.9em;
}

#site-footer a {
  color: #4ea3ff;
  text-decoration: none;
}
#site-footer a:hover {
  text-decoration: underline;
}

/* Theme toggle buttons */
#site-footer .footer-right button {
  border: 1px solid #666;
  background: transparent;
  color: #ccc;
  padding: 6px 12px;
  margin-left: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
}

#site-footer .footer-right button.active {
  background: #0070f3;
  border-color: #0070f3;
  color: #fff;
}

#site-footer .footer-right button:hover:not(.active) {
  border-color: #999;
  color: #fff;
}

#site-footer .footer-right button:focus-visible {
  outline: 2px solid #0A84FF;
  outline-offset: 2px;
  border-radius: 6px;
}

/* Small "NEW" tag beside sidebar links */
.tag-new {
  display: inline-block;
  margin-left: 3px;
  padding: 2px 5px;
  background: #0A84FF;      /* bright red */
  color: #fff;
  font-size: 0.5em;
  font-weight: bold;
  border-radius: 10px;
  text-transform: uppercase;
  vertical-align: middle;
}

/* --- Search form: compact pill overlaid inside the fixed header (right-aligned) --- */
#searchForm{
  display:none;
  position:absolute;                /* relative to #top-navbar (fixed) */
  right:12px;
  top:50%;
  transform: translateY(-50%);
  align-items:center;
  gap:8px;
  width:min(360px, 60vw);           /* compact, like the sidebar filter */
  z-index:1001;                     /* above progress line */
}

/* Input styling (dark) — extra right padding for the close button inside */
#searchInput{
  flex:1;
  height:36px;
  padding:8px 40px 8px 12px;        /* room for the X on the right */
  border:1px solid #2a2a2a;
  background:#111;
  color:#fff;
  border-radius:14px;
  outline:none;
  font-size:15px;
}
#searchInput::placeholder{
  font-size:15px;
  color:#9aa0a6;
}
#searchInput:focus{
  outline:2px solid #0A84FF;
  outline-offset:2px;
}

/* In-field close button (bigger, clearer) */
.search-close{
  position:absolute;
  right:8px;
  top:50%;
  transform:translateY(-50%);
  width:28px; height:28px;
  border:0; background:transparent; color:#9aa0a6;
  display:grid; place-items:center;
  border-radius:8px; cursor:pointer;
}
.search-close svg{ width:16px; height:16px; }
.search-close:hover{ background:rgba(255,255,255,0.06); color:#cfd8dc; }

/* Toggle logic (checkbox drives visibility) */
#searchToggleChk:checked ~ .navbar-right .nav-links{ display:none; }  /* hide links */
#searchToggleChk:checked ~ .navbar-right .search-open{ display:none; }/* hide icon  */
#searchToggleChk:checked ~ #searchForm{ display:flex; }               /* show form   */

/* Icon uses SVG, inherits currentColor */
.search-open { background:transparent; border:0; cursor:pointer; line-height:1; padding:6px; }
.search-open .ico { display:block; }

/* Light theme */
body.light #searchInput{
  background:#fff;
  border-color:#ccc;
  color:#0d0d0d;
}
body.light #searchInput::placeholder{ color:#6b7280; }
body.light .search-close:hover{ background:rgba(0,0,0,0.06); color:#374151; }

/* visible focus for Tab users on the search icon and the close button. */
.search-open:focus-visible,
.search-close:focus-visible {
  outline: 2px solid #0A84FF;
  outline-offset: 2px;
  border-radius: 8px;
}

/* keep the pill comfy on phones; slightly narrower and readable text. */
@media (max-width: 480px){
  #searchForm { right: 8px; width: min(280px, 90vw); }
  #searchInput { font-size: 14px; }
}

/* ---------- SEARCH PAGE ---------- */

/* results wrapper sizing */
.results { max-width: 900px; margin: 24px auto; padding: 0 16px; }

/* results page title */
.results h1 { font-size: 2rem; font-weight: 700; margin: 0 0 8px 0; }

/* muted helper line under H1 */
.results .muted { color: #9aa0a6; font-size: 0.95rem; margin: 0 0 16px 0; }

/* each result block spacing */
.results .result { padding: 14px 0 18px; }

/* clickable title (inherits text color, looks native) */
.results .result-title a { color: inherit; font-weight: 700; text-decoration: none; }
.results .result-title a:hover { text-decoration: underline; }

/* snippet (2-line clamp) */
.results .result-snippet {
  color: #6b7280;
  font-size: 0.98rem;
  margin: 4px 0 6px;
  display: -webkit-box;          /* legacy Safari/Chromium */
  -webkit-line-clamp: 2;         /* legacy property */
  line-clamp: 2;                 /* standard property */
  -webkit-box-orient: vertical;  /* legacy Safari */
  overflow: hidden;              /* hide extra lines */
}

/* url line (blue link) */
.results .result-url { color: #8ab4f8; font-size: 0.95rem; text-decoration: none; }
.results .result-url:hover { text-decoration: underline; }

/* ---------------- LIGHT THEME ---------------- */

body.light {
  background: #fff;
  color: #0D0D0D;
}

/* Sidebar (light) */
body.light #sidebar-container {
  background: #fafafa;
  color: #0D0D0D;
  border-right: 1px solid #ddd;
}
body.light #sidebar-container a { color: #0D0D0D; }
body.light #sidebar-container strong { color: #0D0D0D; }
body.light #sidebar-container a.active { background-color: #0070f3; color: #fff; }

/* Filter (light) */
body.light #sidebar-container .sidebar-filter { background: #fafafa; border-bottom: 1px solid #ddd; }
body.light #sidebar-container .sidebar-filter input[type="search"] { background: #fff; border: 1px solid #ccc; color: #0D0D0D; }
body.light #sidebar-container .sidebar-filter .icon-left,
body.light #sidebar-container .sidebar-filter .clear-btn { color: #666; }

/* Content text (light) — ensure headings + body copy flip */
body.light main, body.light article,
body.light, body.light p, body.light li, body.light li strong,
body.light blockquote, body.light table, body.light th, body.light td {
  color: #0D0D0D;
}
body.light h1, body.light h2, body.light h3, body.light h4, body.light h5, body.light h6 {
  color: #0D0D0D;
}

body.light .upscale, body.light .highlight, body.light .highlight strong {
    color: #0D0D0D;  /* dark background */
    background-color: #ECECEC;   
}

body.light #site-footer .footer-right button:not(.active) {
  color: #0D0D0D;
}
/* Lists (light) — force “normal” bullets + spacing */
body.light ul, body.light ol {
  color: #0D0D0D;               /* text color */
  list-style-position: outside;
  padding-left: 1.5rem;      /* override any UA/WebKit default (40px) */
  margin: 1em 0;
}
body.light li { display: list-item; text-align: left; }
body.light li p { margin: 0; }      /* avoid paragraph margins pushing text */
body.light ul { list-style-type: disc; }
body.light ol { list-style-type: decimal; }

/* Footer (light) */
body.light #site-footer { background: #f5f5f5; border-top: 1px solid #ddd; color: #333; }
body.light #site-footer a { color: #0070f3; }

body.light .tag-new {
  background: #0A84FF;
}

/* header: light theme overrides (ensure this is last) */
body.light #top-navbar { background:#fafafa; color:#0D0D0D; border-bottom:1px solid #ddd; }  /* bar bg + base text */
body.light #top-navbar .site-title { color:#0D0D0D; }                                      /* brand text */
body.light #top-navbar .navbar-right a { color:#0D0D0D; }                                   /* nav links */
body.light #top-navbar .icon-btn { color:#0D0D0D; }                                         /* search icon (SVG uses currentColor) */
