/* ===========================================================================
   Minimal theme — left sidebar rail
   Everything visual lives here. Tweak the variables below to restyle.
   =========================================================================== */

:root {
  --bg:         #f7f4ec;   /* the reading surface — background of the content card */
  --page-bg:    #e9e2d2;   /* page behind the card; the bg-image shows through here */
  --text:       #22201b;   /* body text (warm near-black) */
  --muted:      #8c8579;   /* dates, taglines, meta (warm grey) */
  --rule:       #e6e0d3;   /* hairline separators (warm) */
  --visited:    #9c9488;   /* visited post links */
  --code-bg:    #efe9dc;   /* inline / block code background (warm) */
  --hover:      #066649;   /* link hover (darker accent) */

  /* Accent — change this one line to recolour the whole site. */
  --accent:      #087f5b;  /* links, tag pills, sidebar mark & hovers */
  --accent-soft: #e3f1ec;  /* tinted backgrounds (tag pills) */

  /* Dark sidebar palette (deep pine to match the ivory content) */
  --side-bg:    #1e2b26;   /* rail background */
  --side-text:  #ece7dd;   /* rail primary text */
  --side-muted: #9a9186;   /* rail secondary text */
  --side-rule:  rgba(255,255,255,0.10);  /* rail divider */

  /* Background picture — off by default, opt in per page. Put a file in
     assets/img/ and add to that page's front matter:
       bg-image: /assets/img/yourfile.jpg
       bg-image-opacity: 0.85   # optional; the opaque card covers the picture,
                                # so anything up to 1 stays perfectly readable
     base.html then sets these variables on <body> for that page only. */
  --bg-image:         none;
  --bg-image-opacity: 0.85;

  --sidebar-w:  228px;     /* width of the dark left rail */
  --main-w:     920px;     /* max width of the content column */
  --read-w:     700px;     /* max text measure inside a post */
  --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:       "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --fs:         15px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Background picture layer. Sits behind everything (z-index: -1) and is fully
   covered by the opaque content card, so it only ever shows in the gutter
   around the card — text contrast is never affected and bg-image-opacity can
   safely go as high as 1. Inert while --bg-image is `none`. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--bg-image-opacity);
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--hover); text-decoration: underline; }

/* --- Overall shell ------------------------------------------------------- */

.layout { display: block; }

/* --- Fixed dark left rail ------------------------------------------------ */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  background: var(--side-bg);
  color: var(--side-text);
  padding: 40px 26px;
  font-size: 13.5px;
  line-height: 1.5;
}
.sidebar .name {
  display: block;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.sidebar .name::before {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 9px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: middle;
}
.sidebar .name:hover { color: var(--accent); text-decoration: none; }
.sidebar .tagline { color: var(--side-muted); font-size: 12.5px; margin-bottom: 26px; padding-left: 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a { color: var(--side-text); }
.sidebar nav a:hover { color: var(--accent); text-decoration: none; }
/* collapsible "materials" toggle */
.sidebar nav details.materials > summary {
  list-style: none; cursor: pointer;
  color: var(--side-text);
  display: flex; align-items: center;
}
.sidebar nav details.materials > summary::-webkit-details-marker { display: none; }
.sidebar nav details.materials > summary::before {
  content: ""; display: inline-block; flex: none;
  border-left: 4px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  margin-right: 8px; opacity: 0.55;
  transition: transform 0.15s ease;
}
.sidebar nav details.materials[open] > summary::before { transform: rotate(90deg); }
.sidebar nav details.materials > summary:hover { color: var(--accent); }

.sidebar nav .subnav {
  display: flex; flex-direction: column; gap: 5px;
  margin: 6px 0 2px 5px; padding-left: 11px;
  border-left: 1px solid var(--side-rule);
}
.sidebar nav .subnav a { font-size: 12.5px; color: var(--side-muted); }
.sidebar nav .subnav a:hover { color: var(--accent); }

.sidebar .rule { height: 1px; background: var(--side-rule); margin: 22px 0; }

/* section headings + generic link lists (projects) */
.sidebar .heading {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--side-muted); margin-bottom: 10px;
}
.sidebar .linklist { display: flex; flex-direction: column; gap: 6px; }
.sidebar .linklist a { color: var(--side-text); }
.sidebar .linklist a:hover { color: var(--accent); text-decoration: none; }
.sidebar .social { display: flex; flex-direction: column; gap: 8px; }
.sidebar .social a { display: flex; align-items: center; gap: 9px; color: var(--side-muted); }
.sidebar .social a:hover { color: #fff; text-decoration: none; }
.sidebar .social .ico { width: 15px; height: 15px; fill: currentColor; flex: none; }

/* --- Main content column (offset past the rail) -------------------------- */

.main {
  margin-left: var(--sidebar-w);
  max-width: var(--main-w);
  padding: 28px clamp(20px, 3vw, 44px) 44px;   /* this padding is the gutter around the card */
  min-width: 0;
}

/* --- Content card -------------------------------------------------------- */
/* Opaque panel holding the header and body of every page. Because it is
   opaque, the page's background picture only shows in the gutter around it,
   so a bold picture never costs text legibility. */

.card {
  position: relative;   /* anchor for the language switcher */
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 40px clamp(22px, 4vw, 56px) 36px;
  box-shadow: 0 1px 3px rgba(34, 32, 27, 0.06);
}

/* --- Language switcher (ENG / ҚАЗ pill, top-right of the column) ---------- */

.langsw {
  position: absolute;   /* top-right inside the card's padding */
  top: 16px;
  right: 16px;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;   /* equal halves, so the thumb is exactly 50% */
  align-items: center;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--code-bg);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  line-height: 1;
  user-select: none;
}

/* the dark pill that slides between the two options */
.langsw .thumb {
  position: absolute;
  top: 2px; bottom: 2px; left: 2px;
  width: calc(50% - 2px);
  border-radius: 999px;
  background: var(--side-bg);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}
.langsw[data-lang="kk"] .thumb { transform: translateX(100%); }

.langsw .opt {
  position: relative;   /* above the thumb */
  padding: 5px 9px;
  text-align: center;
  color: var(--muted);
  transition: color 0.2s ease;
}
/* whichever option the thumb is under gets the light label */
.langsw[data-lang="en"] .opt[data-lang="en"],
.langsw[data-lang="kk"] .opt[data-lang="kk"] {
  color: var(--bg);
  font-weight: 600;
}
.langsw a.opt { cursor: pointer; }
.langsw a.opt:hover { color: var(--text); text-decoration: none; }
/* no translation for this page: visibly dimmed, but still legible */
.langsw .off { color: var(--muted); opacity: 0.45; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .langsw .thumb, .langsw .opt { transition: none; }
}

/* --- Home: post list ----------------------------------------------------- */

.home-intro { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* compact one-line index for the paper-reviews list */
.paper-list { margin: 0; padding: 0; list-style: none; }
.paper-list li {
  display: flex; align-items: baseline; gap: 16px;
  padding: 3px 0; line-height: 1.4;
}
.paper-list .d {
  flex: none; width: 84px;
  color: var(--muted); font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.paper-list li > a {
  flex: 1 1 auto; min-width: 0;
  font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.paper-list li > a:hover { color: var(--accent); }
.paper-list li > a:visited { color: var(--visited); }

.post-list { margin: 0; padding: 0; list-style: none; }
.post-list li { margin: 0 0 22px; }
.post-list .title { font-size: 16px; font-weight: 500; }
.post-list .title a:hover { color: var(--accent); }
.post-list .title a:visited { color: var(--visited); }
.post-list .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.post-list .meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.post-list .meta .date { color: var(--muted); }

/* --- Pager --------------------------------------------------------------- */

.pager { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 13.5px; }
.pager a { margin-right: 20px; color: var(--muted); }
.pager a:hover { color: var(--text); }

/* --- Post / page --------------------------------------------------------- */

.post-header { margin-bottom: 24px; }
.post-header h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; line-height: 1.25; }
.post-header .sub { color: var(--muted); font-weight: 400; font-size: 15px; margin: 0 0 8px; }
.post-header .meta { color: var(--muted); font-size: 13px; }

.post-body { max-width: var(--read-w); font-size: var(--fs); }
.post-body h1 { font-size: 21px; margin: 32px 0 10px; }
.post-body h2 { font-size: 18px; margin: 28px 0 10px; }
.post-body h3 { font-size: 15px; margin: 24px 0 8px; }
.post-body p { margin: 14px 0; }
.post-body ul, .post-body ol { padding-left: 24px; margin: 14px 0; }
.post-body li { margin: 5px 0; }
.post-body img { max-width: 100%; height: auto; border-radius: 3px; }
.post-body blockquote {
  margin: 16px 0;
  padding: 2px 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.post-body hr { border: 0; border-top: 1px solid var(--rule); margin: 32px 0; }
.post-body a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(8,127,91,0.35); text-underline-offset: 2px; }
.post-body a:hover { color: var(--hover); text-decoration-color: currentColor; }

/* math — let long display equations scroll instead of overflowing the column */
mjx-container[jax="CHTML"][display="true"] { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* code */
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
}
pre {
  background: var(--code-bg);
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 5px;
  border: 1px solid var(--rule);
  font-size: 13px;
}
pre code { background: none; padding: 0; font-size: inherit; }

/* tables */
.post-body table { border-collapse: collapse; margin: 16px 0; display: block; overflow-x: auto; }
.post-body th, .post-body td { border: 1px solid var(--rule); padding: 6px 10px; text-align: left; }

/* tag pills — shared by the home list meta and the post footer */
.post-list .meta a,
.tags a {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  line-height: 1.4;
  padding: 1px 8px;
  border-radius: 10px;
  text-decoration: none;
}
.post-list .meta a:hover,
.tags a:hover { background: var(--accent); color: #fff; text-decoration: none; }

/* tags line under a post */
.tags { max-width: var(--read-w); margin-top: 28px; font-size: 12.5px; color: var(--muted); }
.tags a { margin-right: 6px; }

/* --- Tag index ----------------------------------------------------------- */

.tag-cloud { margin-bottom: 24px; }
.tag-cloud a { display: inline-block; margin: 0 12px 8px 0; color: var(--muted); }
.tag-cloud a:hover { color: var(--text); }
.tag-section h2 { font-size: 16px; margin: 24px 0 8px; }
.tag-section .entry { margin: 3px 0; }
.tag-section .entry time { color: var(--muted); font-size: 12px; margin-left: 8px; }

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

.site-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 12.5px;
}

/* --- Standalone .content wrapper (minimal.html layout) ------------------- */
.content { max-width: var(--read-w); margin: 0 auto; padding: 48px 24px; }

/* --- Responsive: dark rail becomes a top bar on narrow screens ----------- */
@media (max-width: 820px) {
  .sidebar {
    position: static;
    width: auto;
    bottom: auto;
    padding: 22px 24px;
  }
  .sidebar .tagline { margin-bottom: 14px; }
  .sidebar nav { flex-flow: row wrap; gap: 6px 18px; align-items: center; }
  .sidebar nav .subnav { flex-flow: row wrap; gap: 6px 12px; margin: 0; padding-left: 0; border-left: none; }
  .sidebar .heading { display: none; }
  .sidebar .side-group { margin-top: 12px; }
  .sidebar .linklist { flex-flow: row wrap; gap: 6px 18px; }
  .sidebar .social { flex-flow: row wrap; gap: 6px 18px; margin-top: 10px; }
  .main { margin-left: 0; padding: 12px 10px 28px; max-width: none; }
  .card { border-radius: 10px; padding: 26px 18px 22px; }
  .langsw { top: 12px; right: 12px; }
  .langsw { top: 12px; right: 24px; }
  .post-header h1 { font-size: 21px; }
}
