/* =========================================================
   kamilbisbis.dev — blog
   A reading surface: article column, sticky contents, callouts,
   code, footnotes. Every color comes from the theme blocks in
   style.css, so all four times of day are handled at once.
   ========================================================= */

body.blog-page .viewport-border {
  scroll-padding-top: 96px;
}

/* the current section of the site, marked without JS */
.nav-link[aria-current="page"] {
  color: var(--paper);
  background: var(--ink);
}

/* ---------------- reading progress ---------------- */

.read-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
}
.read-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(var(--read, 0));
  transform-origin: 0 50%;
  transition: transform 90ms linear, background-color 500ms ease;
}

/* ---------------- blog index ---------------- */

.blog-shell {
  padding: clamp(2rem, 5vw, 4.5rem) clamp(1rem, 3vw, 2.5rem);
}
.blog-shell .panel {
  max-width: 1040px;
}

.index-head {
  margin-bottom: 1.5rem;
}
.index-title {
  font-family: "Bricolage Grotesque", "Inter", sans-serif;
  font-size: clamp(30px, 4.4vw, 46px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.05;
}

.post-list {
  list-style: none;
  border-top: 1px solid var(--border);
}
.post-item + .post-item {
  border-top: 1px solid var(--border);
}
.post-link {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 0 1.5rem;
  padding: 1.35rem 0.6rem;
  margin: 0 -0.6rem;
  border-radius: 12px;
  text-decoration: none;
  transition: background-color 200ms ease;
}
.post-link:hover {
  background: var(--accent-soft);
}
.post-item-date {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--meta);
  padding-top: 0.28rem;
  white-space: nowrap;
}
.post-item-title {
  display: block;
  font-family: "Bricolage Grotesque", "Inter", sans-serif;
  font-size: clamp(17px, 1.7vw, 20px);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.3;
}
.post-link:hover .post-item-title {
  color: var(--accent);
}
.post-item-excerpt {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--prose);
  max-width: 62ch;
}
.post-item-tags {
  display: block;
  margin-top: 0.65rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.post-item-out {
  font-size: 0.8em;
  color: var(--meta);
}

/* ---------------- post layout ---------------- */

.post-shell {
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 2.5rem)
    clamp(3rem, 6vw, 5rem);
  display: grid;
  /* Empty gutter, article, contents. The two outer tracks are flexible and
     the middle one is capped, so the measure fills out first and the
     gutters take whatever is left — which lands the article on the page's
     centerline with the contents out in the right margin. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 820px) minmax(236px, 1fr);
  column-gap: clamp(1.5rem, 3vw, 3.25rem);
  row-gap: 0;
  align-items: start;
}

.post-head,
.post {
  grid-column: 2;
  width: 100%;
  min-width: 0;
}
.toc {
  grid-column: 3;
  grid-row: 1 / span 2;
  justify-self: start;
  max-width: 260px;
}

.post-back {
  display: inline-block;
  margin-bottom: 1.4rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--meta);
  text-decoration: none;
  transition: color 200ms ease;
}
.post-back:hover {
  color: var(--accent);
}

.post-title {
  font-family: "Bricolage Grotesque", "Inter", sans-serif;
  font-optical-sizing: auto;
  font-size: clamp(29px, 4.2vw, 44px);
  font-weight: 700;
  letter-spacing: -0.032em;
  line-height: 1.08;
  color: var(--ink);
}
.post-deck {
  margin-top: 0.85rem;
  font-size: clamp(15px, 1.35vw, 18.5px);
  line-height: 1.55;
  color: var(--prose);
  max-width: 52ch;
}
.post-date {
  margin-top: 0.7rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--meta);
}
.post-head {
  margin-bottom: 1.9rem;
}

/* ---------------- prose ---------------- */

.post-body {
  color: var(--prose);
  font-size: clamp(15.5px, 1.15vw, 17px);
  line-height: 1.85;
}
.post-body > p {
  margin: 0 0 1.2rem;
}

.post-body h2,
.post-body h3 {
  font-family: "Bricolage Grotesque", "Inter", sans-serif;
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--ink);
  line-height: 1.2;
}
.post-body h2 {
  font-size: clamp(21px, 2.4vw, 27px);
  margin: 2.6rem 0 1rem;
}
.post-body h3 {
  font-size: clamp(17px, 1.8vw, 20px);
  margin: 2rem 0 0.85rem;
}
.post-body > h2:first-child,
.post-body > h3:first-child {
  margin-top: 0;
}

.post-body a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: color 180ms ease, text-decoration-color 180ms ease;
}
.post-body a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.post-body strong {
  color: var(--ink);
  font-weight: 600;
}
.post-body em {
  font-style: italic;
}

.post-body ol,
.post-body ul {
  margin: 0 0 1.2rem;
  padding-left: 1.5rem;
}
.post-body li {
  margin-bottom: 0.5rem;
  padding-left: 0.2rem;
}
.post-body li::marker {
  color: var(--accent);
}
.post-body li > ol,
.post-body li > ul {
  margin: 0.5rem 0 0;
}

.post-body blockquote {
  margin: 0 0 1.35rem;
  padding: 0.75rem 1.15rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--accent) 9%, var(--code-bg));
  color: var(--prose);
  line-height: 1.8;
}
.post-body blockquote p {
  margin: 0 0 0.7rem;
}
.post-body blockquote p:last-child {
  margin-bottom: 0;
}

.post-body hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 2.2rem 0;
}

/* inline code */
.post-body code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86em;
  padding: 0.12em 0.38em;
  border-radius: 5px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink);
  word-break: break-word;
}

/* ---------------- figures ---------------- */

.post-body figure {
  margin: 0 0 1.6rem;
}
.post-body figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.post-body figcaption {
  margin-top: 0.55rem;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--meta);
}

/* stand-in for artwork that has not been dropped in yet */
.figure-placeholder {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 170px;
  padding: 1.6rem 1.2rem;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  color: var(--meta);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.7;
  letter-spacing: 0.02em;
}


/* a code block used as a figure keeps the caption tight against it */
.post-body figure > .code-block {
  margin-bottom: 0;
}

/* ---------------- repo chip + summary ----------------
   The elevator pitch, sat at the very top of a post: a recruiter should be
   able to read this box alone and know what was built and how. The tab is
   pulled outside the box's top-right corner, so it reads as a label on the
   card rather than a heading inside it. */

.repo-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1rem;
  padding: 0.62rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  text-decoration: none;
  transition: border-color 200ms ease, background-color 200ms ease;
}
.repo-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.repo-chip svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}
.repo-chip-out {
  margin-left: auto;
  color: var(--meta);
}
.repo-chip-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.summary {
  position: relative;
  margin: 0 0 1.9rem;
  padding: 1.2rem 1.35rem 1.3rem;
  border-radius: 14px;
  background: var(--summary-bg);
  color: var(--summary-ink);
  transition: background-color 500ms ease, color 500ms ease;
}
.summary-tab {
  position: absolute;
  top: -13px;
  right: -9px;
  padding: 6px 15px;
  border-radius: 999px;
  background: var(--summary-tab);
  color: var(--summary-tab-ink);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.summary-title {
  margin: 0 0 0.9rem;
  font-family: "Bricolage Grotesque", "Inter", sans-serif;
  font-size: clamp(17px, 1.7vw, 19px);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--summary-ink);
}
.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}
.summary-list li {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  font-size: 0.9rem;
  line-height: 1.65;
  margin: 0;
  padding: 0;
}
.summary-list li::before {
  content: "\2192";
  color: var(--summary-arrow);
  line-height: 1.65;
}
.summary strong {
  color: var(--summary-ink);
  font-weight: 600;
}
.summary a {
  color: var(--summary-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--summary-arrow);
}
.summary a:hover {
  color: var(--summary-arrow);
  text-decoration-color: var(--summary-arrow);
}

/* ---------------- callouts ---------------- */

.callout {
  --tone: var(--note);
  margin: 0 0 1.35rem;
  padding: 0.85rem 1.1rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 11%, var(--code-bg));
  transition: background-color 500ms ease, border-color 500ms ease;
}
.callout-tip {
  --tone: var(--tip);
}
.callout-caution {
  --tone: var(--caution);
}
.callout-update {
  --tone: var(--update);
}

.callout-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--tone);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.callout-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.callout-body {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  line-height: 1.72;
  color: var(--prose);
}
.callout-body p {
  margin: 0 0 0.6rem;
}
.callout-body p:last-child {
  margin-bottom: 0;
}
.callout-body code {
  font-size: 0.88em;
}

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

.code-block {
  position: relative;
  margin: 0 0 1.35rem;
  border: 1px solid var(--code-border);
  border-radius: 12px;
  background: var(--code-bg);
  transition: background-color 500ms ease, border-color 500ms ease;
}
.code-block pre {
  margin: 0;
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.code-block code {
  display: block;
  padding: 0;
  background: none;
  border-radius: 0;
  white-space: pre;
  word-break: normal;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.795rem;
  line-height: 1.72;
  color: var(--code-ink);
}
.code-block pre::-webkit-scrollbar {
  height: 8px;
}
.code-block pre::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
}
.code-block pre::-webkit-scrollbar-track {
  background: transparent;
}

.code-copy {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: color-mix(in srgb, var(--code-bg) 88%, var(--ink));
  color: var(--meta);
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms ease, color 160ms ease, border-color 160ms ease;
}
.code-block:hover .code-copy,
.code-copy:focus-visible {
  opacity: 1;
}
.code-copy:hover {
  color: var(--ink);
  border-color: var(--border-strong);
}
.code-copy svg {
  width: 14px;
  height: 14px;
  display: block;
}
.code-copy .icon-done {
  display: none;
}
.code-copy.copied {
  color: var(--tip);
  opacity: 1;
}
.code-copy.copied .icon-copy {
  display: none;
}
.code-copy.copied .icon-done {
  display: block;
}

/* Arabic inside an otherwise left-to-right code block: isolate each string
   so the surrounding tokens keep their source order. */
.code-block .tok-str,
.code-block .tok-com {
  unicode-bidi: isolate;
}

/* syntax tokens */
.tok-key {
  color: var(--tok-key);
}
.tok-str {
  color: var(--tok-str);
}
.tok-num {
  color: var(--tok-num);
}
.tok-com {
  color: var(--tok-com);
  font-style: italic;
}
.tok-fn {
  color: var(--tok-fn);
}
.tok-bul {
  color: var(--tok-bul);
}

/* ---------------- footnotes ---------------- */

.fn-ref {
  font-size: 0.68em;
  line-height: 0;
  vertical-align: super;
}
.fn-ref a {
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0 0.05em;
}
:target.fn-item,
:target.fn-ref {
  background: var(--accent-soft);
  border-radius: 4px;
}

.footnotes {
  margin-top: 3rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border);
}
.footnotes h2 {
  font-family: "Bricolage Grotesque", "Inter", sans-serif;
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 1rem;
}
.footnotes ol {
  padding-left: 1.4rem;
}
.footnotes li {
  margin-bottom: 0.7rem;
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--prose);
}
.footnotes a {
  color: inherit;
}
.fn-back {
  margin-left: 0.3rem;
  text-decoration: none;
  color: var(--meta);
}
.fn-back:hover {
  color: var(--accent);
}

/* ---------------- contents ---------------- */

.toc {
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  scrollbar-width: none;
}
.toc::-webkit-scrollbar {
  display: none;
}
.toc-summary {
  display: none;
}
.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.toc-link {
  display: block;
  font-size: 0.83rem;
  line-height: 1.4;
  color: var(--meta);
  text-decoration: none;
  transition: color 220ms ease;
}
.toc-link:hover {
  color: var(--accent);
}
.toc-link.active {
  color: var(--ink);
  font-weight: 600;
}
.toc-item-sub {
  padding-left: 0.95rem;
}
.toc-item-sub .toc-link {
  font-size: 0.79rem;
}

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

.post-end {
  margin-top: 2.8rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.post-end-note {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: var(--meta);
}

/* ---------------- responsive ---------------- */

@media (max-width: 1020px) {
  .post-shell {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 1.6rem;
  }
  .post-head,
  .post,
  .toc {
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
  }
  /* title, then contents, then the piece itself */
  .post-head {
    grid-column: 1;
    grid-row: auto;
    order: 1;
    margin-bottom: 0;
  }
  .post {
    grid-column: 1;
    order: 3;
  }
  .toc {
    grid-column: 1;
    grid-row: auto;
    order: 2;
    position: static;
    justify-self: stretch;
    max-height: none;
    width: 100%;
    padding: 0.8rem 1.05rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--code-bg);
  }
  .toc-summary {
    display: block;
    cursor: pointer;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--meta);
    list-style: none;
  }
  .toc-summary::-webkit-details-marker {
    display: none;
  }
  .toc-summary::after {
    content: "+";
    float: right;
    color: var(--meta);
  }
  .toc[open] .toc-summary::after {
    content: "–";
  }
  .toc[open] .toc-list {
    margin-top: 0.85rem;
  }
}

@media (max-width: 620px) {
  .post-link {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.45rem;
  }
  .post-item-date {
    padding-top: 0;
  }
  .code-block code {
    font-size: 0.74rem;
  }
  .code-copy {
    opacity: 1;
  }
}
