/* BuddhiKernel — buddhikernel.com
   Hand-written, no build step, no JavaScript, no external assets. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-soft: #f6f6f3;
  --fg: #16181c;
  --fg-muted: #55595f;
  --rule: #dbdbd4;
  --link: #0a4fa3;
  --link-hover: #06336c;
  --code-bg: #f3f3ef;
  --code-fg: #1f2227;
  --focus: #0a4fa3;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --bg-soft: #171a1f;
    --fg: #e7e9ec;
    --fg-muted: #a6acb5;
    --rule: #3a4150;
    --link: #8ab6f5;
    --link-hover: #bcd6ff;
    --code-bg: #191d24;
    --code-fg: #dfe3e8;
    --focus: #8ab6f5;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- links and focus ---------- */

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { color: var(--link-hover); }

a:focus-visible,
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg);
  color: var(--fg);
  padding: 0.6rem 1rem;
  border: 1px solid var(--rule);
  z-index: 10;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: transform 0.22s ease;
  will-change: transform;
}
/* Toggled by site.js on scroll direction. Without JS the class is never
   added and the masthead simply stays visible, which is a fine fallback. */
.masthead.is-hidden { transform: translateY(-100%); }

.masthead-in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.mark { flex: none; }

.masthead nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}
.masthead nav a { color: var(--fg-muted); text-decoration: none; }
.masthead nav a:hover { color: var(--link-hover); text-decoration: underline; }

/* ---------- headings and sections ---------- */

main { padding-bottom: 1rem; }

section {
  padding: 2.25rem 0;
  border-top: 1px solid var(--rule);
  /* Clears the sticky masthead, so jumping to #cite does not land the heading
     underneath the bar. Must stay at or above the masthead's height. */
  scroll-margin-top: 5.5rem;
}
section.hero { border-top: 0; padding-top: 2.5rem; }

h1 {
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.35rem;
}

h2 {
  font-size: 1.3rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 0.9rem;
}

h3 {
  font-size: 1.02rem;
  line-height: 1.35;
  margin: 1.6rem 0 0.4rem;
}

p { margin: 0 0 0.9rem; max-width: 46rem; }
p:last-child { margin-bottom: 0; }

b, strong { font-weight: 650; }

/* ---------- hero ---------- */

.tagline {
  font-size: 1.05rem;
  color: var(--fg-muted);
  margin-bottom: 1.5rem;
}

.lede {
  font-size: 1.2rem;
  line-height: 1.45;
  font-weight: 600;
  letter-spacing: -0.008em;
  margin-bottom: 1rem;
}

.status {
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--fg-muted);
  border-radius: 3px;
  font-size: 0.94rem;
  color: var(--fg);
  max-width: 46rem;
}

/* ---------- definition lists ---------- */

.modes { margin: 0 0 0.9rem; max-width: 46rem; }
.modes dt {
  font-weight: 650;
  margin-top: 0.85rem;
}
.modes dd {
  margin: 0.1rem 0 0;
  color: var(--fg-muted);
}

/* ---------- code ---------- */

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.1em 0.32em;
  border-radius: 3px;
  /* long identifiers such as test_module.py::TestCase::test_name must
     wrap rather than widen the page on a 320px screen */
  overflow-wrap: anywhere;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.8rem 0.9rem;
  margin: 0 0 0.9rem;
  overflow-x: auto;
  max-width: min(46rem, 100%);
}
pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre;
}

/* ---------- project cards ---------- */

.cards {
  display: grid;
  /* minmax(0, 1fr): without it a grid track sizes to its widest
     non-wrapping child and the <pre> blocks push the page sideways. */
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  margin: 1.25rem 0 0.5rem;
}

@media (min-width: 56rem) {
  .cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; }
  .cards pre, .cards p { max-width: none; }
}

.card {
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1.1rem 1.2rem 1.2rem;
  background: var(--bg-soft);
}
.card h3 {
  margin-top: 0;
  font-family: var(--mono);
  font-size: 1.05rem;
}
.card pre { background: var(--bg); }

.meta {
  font-size: 0.86rem;
  color: var(--fg-muted);
  margin-bottom: 0.9rem;
}

/* ---------- lists ---------- */

ul.docs, ul.links {
  margin: 0.2rem 0 0.9rem;
  padding-left: 1.15rem;
  max-width: 46rem;
}
ul.docs li, ul.links li { margin-bottom: 0.35rem; }
ul.links { list-style: none; padding-left: 0; }

/* ---------- quotes, small print ---------- */

.quote {
  border-left: 3px solid var(--rule);
  padding-left: 0.95rem;
  color: var(--fg-muted);
  font-style: italic;
}

.more { font-size: 0.92rem; }
.fine { font-size: 0.88rem; color: var(--fg-muted); }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
  padding-bottom: 2.5rem;
  margin-top: 1rem;
  font-size: 0.88rem;
  color: var(--fg-muted);
}
footer p { max-width: none; }

/* ---------- narrow screens ---------- */

@media (max-width: 30rem) {
  .wrap { padding: 0 1rem; }
  h1 { font-size: 1.7rem; }
  .lede { font-size: 1.1rem; }
  .card { padding: 0.9rem 0.9rem 1rem; }
  pre code { font-size: 0.8rem; }

  /* The citation is the one block a reader is most likely to copy on a
     phone, and it is also the widest. Let prose-like blocks wrap rather
     than sit in a nested horizontal scroller. */
  pre.wrap-narrow code { white-space: pre-wrap; overflow-wrap: anywhere; }

  /* Shell blocks wrap too, but with `pre-wrap` rather than `pre`, which keeps
     every real newline intact — a soft-wrapped long command still reads as one
     command. Without this, the install block is a nested horizontal scroller. */
  pre code { white-space: pre-wrap; overflow-wrap: break-word; }
}

/* ---------- mobile layout ----------

   Two problems this fixes, both measured at 375px: the seven-item section nav
   wrapped onto a second row and ate 86px of a phone screen before any content,
   and the page ran to roughly 11,800px of scroll. The nav becomes one swipeable
   row and the vertical rhythm tightens. No JavaScript, no breakpoint framework. */

@media (max-width: 48rem) {
  .masthead-in { padding-top: 0.55rem; padding-bottom: 0.55rem; }

  .masthead nav {
    /* Bleed to the screen edges so the row can scroll fully. */
    margin: 0 -1rem;
    max-width: 100vw;
  }
  .masthead nav ul {
    flex-wrap: nowrap;
    overflow-x: auto;
    /* Required. Setting only overflow-x to `auto` makes the *other* axis
       compute to `auto` as well, which is why the strip could be dragged
       up and down as well as sideways. Pinning overflow-y to hidden
       constrains it to one axis. */
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 0 1rem;
    gap: 0 1rem;
    -webkit-overflow-scrolling: touch;
  }
  .masthead nav ul::-webkit-scrollbar { display: none; }
  .masthead nav li { flex: 0 0 auto; }
  .masthead nav a { padding: 0.3rem 0; }

  section { padding: 1.6rem 0; }
  h2 { margin-top: 0; }
}

/* ---------- diagram ---------- */

.diagram { margin: 1.5rem 0; }
.diagram img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 46rem;
  /* The wide and tall variants have different shapes, so a single width/height
     pair on the <img> would reserve the wrong box for one of them and the page
     would jump as the image loads. Declaring the ratio per breakpoint reserves
     the right space for whichever <source> the browser picks. The 767px here
     must stay in step with the media queries on the <source> elements. */
  aspect-ratio: 1000 / 636;
}
@media (max-width: 767px) {
  .diagram img { aspect-ratio: 350 / 1062; }
}
.diagram figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
  max-width: 46rem;
}

/* The masthead mark is a raster logo; keep it crisp and never let it stretch. */
img.mark {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex: 0 0 auto;
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- print ---------- */

@media print {
  .masthead nav, .skip { display: none; }
  body { color: #000; background: #fff; }
  a { color: #000; }
  section { border-top: 1px solid #ccc; }
}
