/* adhikasp.id: site stylesheet.
   Replaces the ink-free theme CSS entirely (main.css, dark.css, normalize.css are no longer loaded).
   Tokens first, light by default, dark via prefers-color-scheme or the header toggle ([data-theme]). */

:root {
  --bg: #fdfdfc;
  --surface: #f5f5f3;
  --surface-2: #ececea;
  --text: #1f2328;
  --text-2: #4b5260;
  --muted: #6b7280;
  --line: #e6e6e2;
  --line-strong: #d4d4cf;
  --accent: #4338ca;
  --accent-hover: #312e81;
  --accent-soft: #eef0ff;
  --chart-bg: #fcfcfb;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 42rem;
  --gutter: 1.25rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #20242c;
    --text: #e7e9ee;
    --text-2: #b4bac6;
    --muted: #8a92a3;
    --line: #242831;
    --line-strong: #343947;
    --accent: #a5b4fc;
    --accent-hover: #c7d2fe;
    --accent-soft: #1b1f33;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #20242c;
  --text: #e7e9ee;
  --text-2: #b4bac6;
  --muted: #8a92a3;
  --line: #242831;
  --line-strong: #343947;
  --accent: #a5b4fc;
  --accent-hover: #c7d2fe;
  --accent-soft: #1b1f33;
  color-scheme: dark;
}

/* ---------- Reset & base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

::selection { background: var(--accent); color: var(--bg); }

img, svg, video { max-width: 100%; height: auto; }
img { display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}
a:hover { color: var(--accent-hover); }

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

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  background: var(--text);
  color: var(--bg);
  padding: .5rem .9rem;
  border-radius: 6px;
  font-size: .9rem;
}
.skip-link:focus { top: .75rem; color: var(--bg); }

/* ---------- Layout ---------- */

.wrapper, .site-footer .inner, .site-header .inner {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main.wrapper { padding-block: 2.5rem 3rem; }

/* ---------- Site header ---------- */

.site-header { border-bottom: 1px solid var(--line); }

.site-header .inner {
  padding-block: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--text);
  min-width: 0;
}
.brand:hover { color: var(--text); }
.brand img { width: 36px; height: 36px; flex: none; margin: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 650; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-tag { color: var(--muted); font-size: .8125rem; margin-top: 2px; }

.site-nav { display: flex; align-items: center; gap: .25rem; }
.site-nav ul { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 .75rem;
  border-radius: 8px;
  color: var(--text-2);
  font-size: .9375rem;
  font-weight: 500;
}
.site-nav a:hover { background: var(--surface); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface); }

.theme-toggle {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: .25rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface); color: var(--text); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media (max-width: 560px) {
  .site-header .inner { padding-block: 1rem .5rem; }
  .site-nav { width: calc(100% + .75rem); margin-left: -.75rem; justify-content: space-between; }
  .site-nav ul { flex: 1; overflow-x: auto; scrollbar-width: none; }
  .site-nav ul::-webkit-scrollbar { display: none; }
  .site-nav a { white-space: nowrap; }
}

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

.site-footer { border-top: 1px solid var(--line); margin-top: 1rem; }
.site-footer .inner {
  padding-block: 1.75rem 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .875rem;
}
.social { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.social a {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--text-2);
}
.social a:hover { background: var(--surface); color: var(--accent); }
.social .icon { width: 18px; height: 18px; }

/* ---------- Headings & prose ---------- */

h1, h2, h3, h4, h5, h6 {
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -.015em;
  margin: 2.25rem 0 .75rem;
  text-wrap: balance;
}
h1 { font-size: 2.25rem; letter-spacing: -.025em; line-height: 1.15; }
h2 { font-size: 1.5rem; margin-top: 2.75rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
h5, h6 { font-size: 1rem; }

.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose pre, .prose figure, .prose table, .prose blockquote, .prose details, .prose .highlight { margin: 0 0 1.25rem; }

.prose a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.prose a:hover { text-decoration-color: currentColor; }

.prose ul, .prose ol { padding-left: 1.35rem; list-style-position: outside; }
.prose ul { list-style-type: disc; }
.prose li { margin: .35rem 0; padding-left: .2rem; }
.prose li::marker { color: var(--muted); }
.prose li > p { margin: 0 0 .5rem; }
.prose li > ul, .prose li > ol { margin: .35rem 0 0; }

.prose strong { font-weight: 650; }

blockquote {
  margin: 0 0 1.25rem;
  padding: .1rem 0 .1rem 1.1rem;
  border-left: 3px solid var(--line-strong);
  color: var(--text-2);
}
blockquote p:last-child { margin-bottom: 0; }
blockquote cite { font-size: .85em; color: var(--muted); }

.footnotes { font-size: .9rem; color: var(--text-2); }
.footnotes hr { margin: 2rem 0 1rem; }
sup { line-height: 0; }

/* ---------- Code ---------- */

code, kbd, samp, pre { font-family: var(--font-mono); }

:not(pre) > code {
  font-size: .86em;
  padding: .12em .38em;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  overflow-wrap: anywhere;
}

pre {
  font-size: .85rem;
  line-height: 1.6;
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  tab-size: 4;
}

.highlight {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.prose .highlight pre, .highlight .chroma, .highlight pre { background: transparent; color: var(--text); margin: 0; }
.highlight pre code { font-size: inherit; background: none; padding: 0; }
.chroma .line { display: inline; }
.chroma .lnt, .chroma .ln { color: var(--muted); }

.prose > pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

@media (max-width: 640px) {
  .prose .highlight, .prose > pre {
    margin-inline: calc(-1 * var(--gutter));
    border-radius: 0;
    border-inline: 0;
  }
  pre { font-size: .8rem; padding: .9rem var(--gutter); }
}

/* ---------- Tables ---------- */

.prose table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  font-size: .9rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.prose th, .prose td {
  padding: .55rem .8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}
.prose th { font-weight: 600; background: var(--surface); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.prose td[align="right"], .prose th[align="right"] { text-align: right; }

/* ---------- Media ---------- */

.prose img { margin: 1.5rem auto; border-radius: 8px; }
/* SVG diagrams are vector: let them fill the measure instead of sitting at
   their authored pixel width, and keep them as a card in dark mode. */
.prose img.svg,
.prose img[src$=".svg"] {
  width: 100%;
  height: auto;
  background: var(--chart-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .5rem;
}
/* Inlined vectors: no card, they draw on the page and follow the theme. */
.svg-inline { margin: 1.75rem 0; }
.svg-inline > svg { display: block; width: 100%; height: auto; }
@media (max-width: 640px) {
  .prose img.svg,
  .prose img[src$=".svg"] { padding: .25rem; border-radius: 8px; }
}

figure { margin: 1.75rem 0; text-align: center; }
figure img { margin-inline: auto; }
figcaption { font-size: .875rem; color: var(--muted); margin-top: .5rem; line-height: 1.5; }
figcaption p { margin: 0; }

iframe, video { border: 0; border-radius: 8px; }
.prose iframe { display: block; max-width: 100%; margin: 0 0 1.5rem; }
.prose iframe[src*="youtube"] { width: 100%; height: auto; aspect-ratio: 16 / 9; }

/* ---------- Post list ---------- */

.page-title { margin: 0 0 .5rem; font-size: 2rem; }
.page-lede { color: var(--text-2); margin: 0 0 2rem; }

.post-list { list-style: none; margin: 0; padding: 0; }

.post-item {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: .25rem 1.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}
.post-list > .post-item:first-child { border-top: 0; padding-top: .25rem; }

.post-item time {
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  padding-top: .35rem;
  white-space: nowrap;
}
.post-item h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 0;
  padding: 0;
  border: 0;
  text-wrap: pretty;
}
.post-item h2 a { color: var(--text); }
.post-item h2 a:hover { color: var(--accent); }
.post-item .summary { margin: .4rem 0 0; color: var(--text-2); font-size: .975rem; line-height: 1.6; }
.post-item .meta-line { margin-top: .6rem; }

.post-item { grid-template-columns: 10rem minmax(0, 1fr); }
.post-main { grid-column: 2; grid-row: 1 / span 2; min-width: 0; }
.post-item time { grid-column: 1; grid-row: 1; }
.post-thumb { grid-column: 1; grid-row: 2; align-self: start; margin-top: .4rem; }
.post-thumb img {
  display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover;
  border: 1px solid var(--line); border-radius: 6px; background: var(--chart-bg);
}
.post-thumb:hover img { border-color: var(--accent); }

.draft-label {
  display: inline-block;
  margin-left: .5rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  vertical-align: middle;
  color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 640px) {
  .post-item { grid-template-columns: 1fr; padding: 1.25rem 0; }
  .post-item time { padding-top: 0; margin-bottom: .1rem; }
  .post-item h2 { font-size: 1.15rem; }
  .post-main, .post-item time, .post-thumb { grid-column: 1; grid-row: auto; }
  .post-thumb { margin: .4rem 0 .5rem; }
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .6rem;
  color: var(--muted);
  font-size: .875rem;
  margin: 0;
}

.tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; margin: 0; padding: 0; }
.tags li { margin: 0; padding: 0; }
.tags a {
  display: inline-block;
  padding: .1rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: .78rem;
  line-height: 1.6;
  text-decoration: none;
}
.tags a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- Single page ---------- */

.post-head { margin-bottom: 2rem; }
.post-head h1 { margin: 0 0 .9rem; }
.post-head .lede { margin: 0 0 1rem; font-size: 1.15rem; line-height: 1.55; color: var(--text-2); }
.post-head .tags { margin-top: .9rem; }

.toc {
  margin: 0 0 2rem;
  padding: .25rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: .925rem;
}
.toc summary {
  cursor: pointer;
  padding: .6rem 0;
  font-weight: 600;
  color: var(--text-2);
}
.toc nav { padding-bottom: .5rem; }
.toc ul { margin: 0; padding-left: 1.1rem; list-style: none; }
.toc nav > ul { padding-left: 0; }
.toc li { margin: .3rem 0; line-height: 1.45; }
.toc a { color: var(--text-2); text-decoration: none; }
.toc a:hover { color: var(--accent); }

.link-source {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 1.75rem;
  padding: .75rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: .85rem;
  word-break: break-all;
}
.link-source .icon { flex: none; }

.post-foot { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.post-foot .tags { margin-bottom: 1.5rem; }

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin: 0 0 1.5rem;
}
.post-nav a {
  display: block;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  line-height: 1.35;
  font-weight: 500;
  font-size: .95rem;
}
.post-nav a:hover { border-color: var(--accent); background: var(--accent-soft); }
.post-nav small { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; margin-bottom: .15rem; }
.post-nav .prev { grid-column: 1; }
.post-nav .next { grid-column: 2; text-align: right; }
@media (max-width: 560px) {
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .prev, .post-nav .next { grid-column: 1; text-align: left; }
}

.back { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .9rem; }
.back:hover { color: var(--accent); }
.back .icon { width: 16px; height: 16px; }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  list-style: none;
  margin: 2rem 0 0;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--line);
}
.pagination li { margin: 0; }
.pagination a { display: inline-block; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 8px; font-weight: 500; font-size: .95rem; }
.pagination a:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Tag cloud ---------- */

.tag-cloud { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: 1.5rem 0 0; padding: 0; }
.tag-cloud a {
  display: inline-block;
  padding: .25rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: .95rem;
}
.tag-cloud a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tag-cloud .count { color: var(--muted); margin-left: .35rem; font-variant-numeric: tabular-nums; }

/* ---------- Notebooks (ipynb shortcode) ---------- */

.ipynb-button {
  cursor: pointer;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: .4rem .9rem;
  border-radius: 8px;
  font-size: .875rem;
  display: inline-block;
  margin-bottom: .75rem;
}
.ipynb-button:hover { border-color: var(--accent); color: var(--accent); }
details > summary { cursor: pointer; }

.cell-output { margin: -.25rem 0 1.5rem; overflow-x: auto; }
.cell-output-text {
  padding: .8rem 1rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  font-size: .82rem;
  color: var(--text-2);
  margin: 0 0 1rem;
}
.cell-output table { display: block; overflow-x: auto; font-size: .8rem; width: max-content; max-width: 100%; border-collapse: collapse; }
.cell-output th, .cell-output td { padding: .4rem .7rem; border-bottom: 1px solid var(--line); text-align: right; }
.cell-output th { background: var(--surface); }
.cell-output img { background: #fff; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- 404 ---------- */

.not-found { text-align: center; padding-block: 4rem; }
.not-found .code { font-size: 4rem; font-weight: 700; letter-spacing: -.04em; color: var(--accent); line-height: 1; margin: 0 0 .5rem; }

/* ---------- Misc ---------- */

mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; padding: 0 .15em; border-radius: 3px; }

@media (max-width: 640px) {
  :root { --gutter: 1.1rem; }
  body { font-size: 1.03rem; line-height: 1.68; }
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.35rem; margin-top: 2.25rem; }
  h3 { font-size: 1.12rem; }
  main.wrapper { padding-block: 1.75rem 2.5rem; }
  .page-title { font-size: 1.6rem; }
  .post-head .lede { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .site-header, .site-footer, .post-nav, .theme-toggle, .skip-link { display: none; }
  body { background: #fff; color: #000; }
  a { color: inherit; text-decoration: underline; }
}
