/*
 * SPDX-FileCopyrightText: 2025-2026 CodeNib Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --subtle: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-line: #bfdbfe;
  --green: #16a34a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 18px 48px rgba(15, 23, 42, 0.07);
  --r-box: 18px;
  --r-ui: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: clip;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "Geist", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

code,
pre,
.mono {
  font-family: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

.wrap {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding-inline: 32px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
}

.skip-link:focus {
  transform: none;
}

/* Header */
.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.nav {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  margin-right: auto;
}

.brand img {
  width: auto;
  height: 32px;
}

.nav-link {
  color: var(--ink-2);
  font-size: 14.5px;
  transition: color 150ms ease;
}

.nav-link:hover,
.nav-link[aria-current="page"] {
  color: var(--ink);
}

.nav-link[aria-current="page"] {
  font-weight: 590;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-ui);
  padding: 9px 17px;
  background: var(--accent);
  color: #fff;
  font-size: 14.5px;
  font-weight: 570;
  line-height: 1.4;
  white-space: nowrap;
  transition: background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.btn:hover {
  background: var(--accent-dark);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--line-strong);
  background: #fff;
  box-shadow: none;
}

/* Blog index */
.index-hero {
  padding: 92px 0 58px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  color: var(--accent);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.index-hero h1 {
  max-width: 13ch;
  font-size: clamp(2.65rem, 6vw, 4.9rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.01;
}

.index-hero .lede {
  max-width: 55ch;
  margin-top: 22px;
  color: var(--ink-2);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
}

.posts {
  padding: 14px 0 112px;
}

.section-label {
  margin-bottom: 22px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.featured-post {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 180ms ease, transform 180ms ease;
}

.featured-post:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.post-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(30px, 5vw, 58px);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  color: var(--ink-2);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 3px 9px;
  font-weight: 620;
}

.featured-post h3 {
  margin-top: 19px;
  font-size: clamp(1.7rem, 3vw, 2.65rem);
  font-weight: 640;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.featured-post .summary {
  max-width: 46ch;
  margin-top: 17px;
  color: var(--ink-2);
  font-size: 16px;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 27px;
  color: var(--accent);
  font-size: 14.5px;
  font-weight: 620;
}

.read-more span {
  transition: transform 150ms ease;
}

.featured-post:hover .read-more span {
  transform: translateX(3px);
}

.post-art {
  display: flex;
  align-items: center;
  min-height: 460px;
  border-left: 1px solid var(--line);
  background: var(--subtle);
  padding: 26px;
}

.post-art img {
  width: 100%;
  border: 1px solid #dbe5f1;
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.1);
}

/* Article */
.article-head {
  padding: 78px 0 46px;
  text-align: center;
}

.article-head .back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 34px;
  color: var(--ink-2);
  font-size: 14px;
}

.article-head .back:hover {
  color: var(--ink);
}

.article-head .post-meta {
  justify-content: center;
}

.article-head h1 {
  max-width: 960px;
  margin: 24px auto 0;
  font-size: clamp(2.55rem, 6.2vw, 5rem);
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1.01;
}

.article-head h1.technical-title {
  max-width: 1080px;
  font-size: clamp(2.4rem, 5.2vw, 4.2rem);
  line-height: 1.04;
}

.article-head .deck {
  max-width: 750px;
  margin: 24px auto 0;
  color: var(--ink-2);
  font-size: clamp(1.08rem, 2.2vw, 1.32rem);
  line-height: 1.55;
}

.hero-figure {
  width: min(100%, 1240px);
  margin: 0 auto 72px;
  padding-inline: 32px;
}

.hero-figure img {
  width: 100%;
  border: 1px solid #dbe5f1;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero-figure figcaption {
  max-width: 820px;
  margin: 14px auto 0;
  color: var(--ink-2);
  font-size: 13px;
  text-align: center;
}

.diagram-open {
  display: flex;
  width: max-content;
  align-items: center;
  gap: 5px;
  margin: 9px auto 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 590;
  text-decoration: underline;
  text-decoration-color: #93c5fd;
  text-underline-offset: 3px;
}

.diagram-open:hover {
  text-decoration-color: var(--accent-dark);
}

.article-body {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 0 28px 112px;
  color: #1e293b;
  font-size: 17.5px;
  line-height: 1.76;
}

.article-body.article-lead {
  padding-bottom: 58px;
}

.article-body > p:first-child {
  color: var(--ink);
  font-size: 21px;
  line-height: 1.62;
}

.article-body h2 {
  margin: 62px 0 20px;
  color: var(--ink);
  font-size: clamp(1.75rem, 3.8vw, 2.4rem);
  font-weight: 640;
  letter-spacing: -0.035em;
  line-height: 1.14;
}

.article-body h3 {
  margin: 35px 0 12px;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 640;
}

.article-body p + p,
.article-body p + ul,
.article-body ul + p,
.article-body pre + p,
.article-body .tool-table + p {
  margin-top: 21px;
}

.article-body a:not(.btn) {
  color: var(--accent-dark);
  text-decoration: underline;
  text-decoration-color: #93c5fd;
  text-underline-offset: 3px;
}

.article-body a:not(.btn):hover {
  text-decoration-color: var(--accent-dark);
}

.article-body strong {
  color: var(--ink);
  font-weight: 640;
}

.article-body ul,
.article-body ol {
  padding-left: 1.35em;
}

.article-body li {
  margin: 9px 0;
  padding-left: 0.25em;
}

.article-body :not(pre) > code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--subtle);
  color: #1e3a8a;
  padding: 0.12em 0.34em;
  font-size: 0.87em;
  overflow-wrap: anywhere;
}

.article-body pre {
  position: relative;
  overflow-x: auto;
  margin: 25px 0;
  border: 1px solid #1e293b;
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 22px 24px;
  font-size: 14px;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}

.article-body .prompt {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #1e3a8a;
  white-space: pre-wrap;
}

.turn-demo {
  overflow: hidden;
  margin: 38px 0 0;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--subtle);
}

.turn-demo-head {
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 21px 22px 19px;
}

.turn-demo-head .turn-demo-kicker {
  color: var(--accent);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.turn-demo-head h3 {
  margin: 7px 0 6px;
  font-size: 18px;
  line-height: 1.35;
}

.turn-demo-head > p:last-child {
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.55;
}

.turn-question {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  align-items: start;
  margin: 18px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--accent-soft);
  padding: 15px 16px;
}

.turn-role {
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 2px 7px;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 680;
  letter-spacing: 0.06em;
  line-height: 1.65;
  text-transform: uppercase;
}

.turn-question p {
  color: #1e3a8a;
  font-size: 14.5px;
  line-height: 1.55;
}

.turn-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
  gap: 12px;
  margin: 0 18px 18px;
}

.turn-tools,
.turn-answer {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.turn-tools {
  align-self: start;
}

.turn-tool {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 15px;
}

.turn-tool + .turn-tool {
  border-top: 1px solid var(--line);
}

.turn-step {
  color: var(--ink-2);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 650;
}

.turn-tool code {
  color: var(--accent-dark);
  font-size: 11.5px;
  font-weight: 650;
}

.turn-tool p {
  margin-top: 5px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.5;
}

.turn-tool-result {
  display: block;
  margin-top: 7px;
  color: #166534;
  font-size: 10.5px;
  line-height: 1.45;
}

.turn-tool-result code {
  color: #166534;
  font-size: 10.5px;
}

.turn-answer {
  padding: 15px;
}

.turn-answer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.turn-verified {
  color: #166534;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 9.5px;
  font-weight: 620;
  text-transform: uppercase;
}

.turn-verified span {
  margin-right: 4px;
  color: var(--green);
}

.turn-answer > p {
  color: var(--ink-2);
  font-size: 12.75px;
  line-height: 1.55;
}

.turn-answer > p + p {
  margin-top: 10px;
}

.turn-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
  padding: 0 !important;
  list-style: none;
}

.turn-sources li {
  display: block;
  margin: 0;
  padding: 0;
}

.turn-sources a {
  display: inline-flex;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  background: var(--accent-soft);
  padding: 3px 6px;
  line-height: 1.35;
}

.turn-sources code {
  font-size: 10.5px;
}

.callout {
  margin: 30px 0;
  border: 1px solid var(--accent-line);
  border-radius: 14px;
  background: var(--accent-soft);
  padding: 20px 22px;
}

.callout-label {
  margin-bottom: 5px;
  color: var(--accent-dark);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.callout p {
  color: #1e3a8a;
  font-size: 15.5px;
  line-height: 1.6;
}

.contract-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 25px 0 5px;
}

.contract {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--subtle);
  padding: 20px;
}

.contract .number {
  color: var(--accent);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 650;
}

.contract h3 {
  margin: 7px 0 5px;
  font-size: 16px;
}

.contract p {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.52;
}

.tool-table {
  overflow: hidden;
  margin: 26px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.tool-row {
  display: grid;
  grid-template-columns: minmax(175px, 0.7fr) minmax(0, 1.3fr);
  gap: 20px;
  padding: 17px 19px;
}

.tool-row + .tool-row {
  border-top: 1px solid var(--line);
}

.tool-row code {
  align-self: start;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 620;
}

.tool-row p {
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.5;
}

.data-table {
  overflow-x: auto;
  margin: 26px 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.data-table:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.data-table table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.data-table.compact table {
  min-width: 560px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  text-align: right;
  white-space: nowrap;
}

.data-table thead th {
  background: var(--subtle);
  color: var(--ink-2);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table tbody th {
  color: var(--ink);
  font-size: 14px;
  font-weight: 610;
}

.data-table tbody td {
  color: var(--ink-2);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 13px;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.scope-note {
  color: #64748b;
  font-size: 14px;
  line-height: 1.62;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
}

.footer-row {
  min-height: 78px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  color: var(--ink-2);
  font-size: 14px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  color: var(--ink);
  font-weight: 590;
}

.footer-brand img {
  width: 16px;
  height: 20px;
  object-fit: contain;
}

.site-footer a:hover {
  color: var(--ink);
}

@media (max-width: 820px) {
  .featured-post {
    grid-template-columns: 1fr;
  }

  .post-art {
    min-height: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .article-head {
    padding-top: 58px;
  }
}

@media (max-width: 620px) {
  .wrap,
  .hero-figure {
    padding-inline: 18px;
  }

  .nav {
    gap: 13px;
  }

  .brand img {
    height: 28px;
    max-width: 122px;
  }

  .nav-docs,
  .nav-github {
    display: none;
  }

  .nav .btn {
    padding-inline: 12px;
  }

  .index-hero {
    padding: 64px 0 40px;
  }

  .posts {
    padding-bottom: 76px;
  }

  .post-copy {
    padding: 28px 24px 30px;
  }

  .post-art {
    padding: 14px;
  }

  .article-head h1 {
    font-size: clamp(2.4rem, 12vw, 3.4rem);
  }

  .article-head h1.technical-title {
    font-size: clamp(2.2rem, 9.8vw, 2.9rem);
  }

  .hero-figure {
    margin-bottom: 50px;
  }

  .hero-figure img {
    border-radius: 14px;
  }

  .article-body {
    padding-inline: 20px;
    font-size: 17px;
  }

  .article-body > p:first-child {
    font-size: 19px;
  }

  .turn-demo-head {
    padding-inline: 18px;
  }

  .turn-question {
    margin: 14px;
  }

  .turn-grid {
    grid-template-columns: 1fr;
    margin: 0 14px 14px;
  }

  .contract-grid {
    grid-template-columns: 1fr;
  }

  .tool-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .footer-row {
    padding-block: 22px;
  }

  .footer-brand {
    flex-basis: 100%;
  }
}

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