/* ==========================================================================
   Flexoki-ish base stylesheet — extracted from sagnikc395.github.io
   Drop-in, no build step, no framework. Link it and write plain HTML.

   Design rules this file encodes:
     - One column, max 44rem. Text is the layout.
     - No border-radius, no shadows (except transient popups), no cards.
     - Hairline rules (1px --rule) do all the separating.
     - Weight and color carry hierarchy, not size. Only 4 type sizes.
     - System font stack. Monospace only for code.
     - Light/dark via Flexoki palette; respects OS, overridable by [data-theme].
   ========================================================================== */

/* --- reset ---------------------------------------------------------------- */
*, :before, :after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, pre { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img, picture, video, svg { display: block; max-width: 100%; height: auto; }

/* --- tokens: light (Flexoki paper) ---------------------------------------- */
:root {
  --bg:      #fffcf0;  /* paper          */
  --fg:      #100f0f;  /* ink            */
  --muted:   #6f6e69;  /* secondary text */
  --faint:   #878580;  /* tertiary text  */
  --rule:    #dad8ce;  /* hairlines      */
  --link:    #bc5215;  /* orange-600     */
  --mark:    #f6e2a0;  /* highlight      */
  --code-bg: #f2f0e5;

  --measure: 44rem;                      /* the only layout constant */
  --gutter:  clamp(1rem, 4vw, 2rem);
  color-scheme: light;
}

/* --- tokens: dark --------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100f0f; --fg: #cecdc3; --muted: #878580; --faint: #6f6e69;
    --rule: #343331; --link: #8b7ec8; --mark: #3a2d04; --code-bg: #1c1b1a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #100f0f; --fg: #cecdc3; --muted: #878580; --faint: #6f6e69;
  --rule: #343331; --link: #8b7ec8; --mark: #3a2d04; --code-bg: #1c1b1a;
  color-scheme: dark;
}

/* --- base ----------------------------------------------------------------- */
html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
}
@media (min-width: 40rem) { html { font-size: 15px; } }   /* denser on desktop */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body { background: var(--bg); color: var(--fg); line-height: 1.5; margin: 0; padding: 2rem 0 4rem; }

h1 { font-size: 1.6rem;  line-height: 1.25; margin: 0 0 .6rem;     font-weight: 700; }
h2 { font-size: 1.2rem;  line-height: 1.3;  margin: 1.8rem 0 .4rem; font-weight: 700; }
h3 { font-size: 1.05rem;                    margin: 1.4rem 0 .35rem; font-weight: 700; }
p  { margin: .5rem 0; }
ul, ol { margin: .4rem 0 .7rem; padding-left: 1.4rem; }
li { margin-bottom: .35rem; }
a  { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5rem 0; }
::selection { background: var(--mark); color: var(--fg); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--rule); padding: .15rem .3rem; }

/* --- layout + text utilities ---------------------------------------------- */
.wrap  { max-width: var(--measure); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.small { font-size: .87rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* --- header / nav: inline links separated by a pipe ------------------------ */
.site-header { margin-bottom: 1.6rem; }
.site-header h1 a { color: var(--fg); text-decoration: none; }
.site-header h1 a:hover { text-decoration: underline; }
.site-nav { margin-top: .7rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .55rem; }
.site-nav a[aria-current="page"] { color: var(--fg); font-weight: 700; }
.site-nav .sep { color: var(--rule); user-select: none; }

/* --- theme toggle --------------------------------------------------------- */
.theme-picker { position: relative; display: inline-block; }
.theme-toggle { background: none; border: 0; padding: 0; font: inherit; line-height: 1; cursor: pointer; }
.theme-menu {
  position: absolute; top: calc(100% + .4rem); right: 0; z-index: 10;
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--rule);
}
.theme-menu button { background: none; border: 0; padding: .3rem .7rem; font: inherit; color: var(--fg); text-align: left; white-space: nowrap; cursor: pointer; }
.theme-menu button:hover { background: var(--code-bg); }
.theme-menu button[aria-checked="true"] { font-weight: 700; }

/* --- intro block with floated portrait ------------------------------------ */
.intro:after { content: ""; display: block; clear: both; }
.intro-photo { width: 130px; margin: 0 0 .8rem; }
@media (min-width: 34rem) { .intro-photo { float: right; margin: 0 0 .8rem 1.5rem; } }

/* --- entry lists (posts, projects) ---------------------------------------- */
.entries { list-style: none; margin: .6rem 0 0; padding: 0; }
.entries > li { margin-bottom: .9rem; }
.entry-title { font-weight: 700; }
.entry-meta  { color: var(--muted); }
.entry-note  { color: var(--muted); margin: .15rem 0 0; }

/* --- inline key/value pairs ----------------------------------------------- */
.kv { display: flex; flex-wrap: wrap; gap: 0 .5rem; }
.kv dt { font-weight: 700; }
.kv dd { margin: 0; }

/* --- long-form article body ----------------------------------------------- */
.md-output { line-height: 1.6; content-visibility: auto; contain-intrinsic-size: auto 1000px; }
.md-output p  { margin: .8rem 0; }
.md-output h2 { margin-top: 2rem; }
.md-output li { margin-bottom: .3rem; }
.md-output img, .md-output picture { margin: 1.2rem 0; }
.md-output img[width] { width: auto; }
.md-output figure { margin: 1.4rem 0; }
.md-output figcaption { font-size: .87rem; color: var(--muted); margin-top: .4rem; }
.md-output blockquote { margin: .9rem 0; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--muted); }
.md-output table { display: block; overflow-x: auto; width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: .93rem; }
.md-output th, .md-output td { padding: .35rem .6rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.md-output th { white-space: nowrap; }
.md-output :not(pre) > code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--code-bg); padding: .1em .3em; }
.md-output pre {
  background: var(--code-bg); border: 1px solid var(--rule);
  padding: .8rem 1rem; overflow-x: auto; margin: 1.2rem 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .88rem; line-height: 1.55;
}
.md-output pre code { background: none; padding: 0; font-size: inherit; }
mark { background: var(--mark); color: inherit; }

/* --- footer --------------------------------------------------------------- */
.site-footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: .93rem; }
.site-footer p { margin: .25rem 0; }

/* --- back-link under an article ------------------------------------------- */
.note-back { border-top: 1px solid var(--rule); margin-top: 2rem; padding-top: .6rem; }

/* --- search: ⌘K overlay ---------------------------------------------------- */
.search-picker { display: inline-block; }
.search-trigger {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.search-kbd { white-space: nowrap; }
.search-overlay {
  position: fixed; inset: 0; z-index: 30;
  background: #00000047;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 0 var(--gutter);
}
.search-dialog {
  width: 100%; max-width: 34rem;
  margin-top: min(12vh, 6rem);
  max-height: min(70vh, 34rem);
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--rule);
  box-shadow: 0 2px 10px #00000029;
}
.search-input {
  width: 100%; background: none; border: 0;
  border-bottom: 1px solid var(--rule);
  padding: .7rem .85rem; font-size: 1rem;
}
.search-input:focus { outline: none; }
.search-input::placeholder { color: var(--faint); }
.search-results { list-style: none; margin: 0; padding: .25rem 0; overflow-y: auto; overscroll-behavior: contain; }
.search-hit { display: block; margin: 0; padding: .4rem .85rem; cursor: pointer; }
.search-hit.is-active { background: var(--code-bg); }
.search-hit-title { display: block; font-weight: 700; }
.search-hit-external { color: var(--faint); font-weight: 400; }
.search-hit-meta, .search-hit-snippet { display: block; }
.search-hit-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-hit mark { background: var(--mark); color: inherit; }
.search-empty { margin: 0; padding: .7rem .85rem; }
.search-hint {
  display: flex; gap: 0 .9rem; flex-wrap: wrap;
  margin: 0; padding: .45rem .85rem; border-top: 1px solid var(--rule);
}

/* --- link previews: hover/tap popup over annotated links ------------------- */
.link-popup {
  position: fixed; z-index: 20;
  background: var(--bg); border: 1px solid var(--rule);
  padding: .6rem .8rem .7rem;
  font-size: .9rem; line-height: 1.45;
  box-shadow: 0 1px 6px #0000001f;
  overscroll-behavior: contain;
}
.link-popup-title { font-weight: 700; display: block; }
.link-popup-meta { margin: .15rem 0 0; }
.link-popup-body { margin: .45rem 0 0; max-height: 11rem; overflow-y: auto; }
.link-popup-url { margin: .4rem 0 0; overflow-wrap: anywhere; }
.link-popup-close {
  margin-top: .6rem; background: none; border: 1px solid var(--rule);
  padding: .2rem .7rem; color: var(--muted); cursor: pointer;
}
/* Narrow screens: dock the popup to the bottom edge instead of floating. */
.link-popup--pinned {
  inset: auto 0 0; max-width: none; max-height: 60vh; overflow-y: auto;
  border-width: 1px 0 0; padding: .8rem var(--gutter) 1rem;
  box-shadow: 0 -1px 8px #00000024;
}
.md-output a[data-preview], .references a[data-preview] { text-decoration-style: dotted; }
@media (prefers-reduced-motion: no-preference) {
  .link-popup { animation: link-popup-in 90ms ease-out; }
  @keyframes link-popup-in { from { opacity: 0; } }
}

/* --- reading list ---------------------------------------------------------- */
.reading-section { border-bottom: 1px solid var(--rule); margin: 1.8rem 0 .2rem; padding-bottom: .2rem; }
.reading-month > summary { cursor: pointer; font-weight: 700; margin: 1.1rem 0 .2rem; }
.reading-item { display: flex; gap: .55rem; align-items: flex-start; }
.reading-item.is-done .entry-link { text-decoration-line: underline line-through; }

/* --- source line under a note --------------------------------------------- */
.note-source { color: var(--muted); margin: .1rem 0 1.2rem; }
.note-source dd { margin-right: .9rem; }

/* --- visually hidden (labels for screen readers only) ---------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
