/* ==========================================================================
   Borax — design tokens
   Palette drawn from raw borax mineral: chalky white crust, the
   blue-grey cast of the crystal in low light, and the faint violet
   flame-test glow borates give off when burned.
   ========================================================================== */

:root {
  --ink: #14181c;
  --ink-soft: #4b545c;
  --paper: #efeee7;
  --paper-raised: #f8f7f2;
  --line: #d8d5c9;
  --line-strong: #b9b6a8;
  --crystal: #3f7f93;
  --crystal-deep: #2b5c6c;
  --violet: #8a7bc4;
  --violet-deep: #6a5aa3;
  --amber: #c98a3f;

  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --max: 1120px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

::selection {
  background: var(--violet);
  color: var(--paper-raised);
}

/* Custom scrollbar — matches the paper/ink palette instead of the
   browser default dark-grey track. */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) var(--paper);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--paper);
}

::-webkit-scrollbar-thumb {
  background-color: var(--line-strong);
  border-radius: 8px;
  border: 3px solid var(--paper);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--crystal-deep);
}

::-webkit-scrollbar-corner {
  background: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--crystal-deep);
  outline-offset: 3px;
}

/* Background lattice — faint hex grid, the crystal motif, everywhere */
.lattice-bg {
  background-image: radial-gradient(circle at 1px 1px, rgba(20, 24, 28, 0.07) 1px, transparent 0);
  background-size: 28px 28px;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 1em;
  color: var(--ink-soft);
  max-width: 62ch;
}

code,
pre {
  font-family: var(--font-mono);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--crystal-deep);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.9em;
}

.eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--violet);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(239, 238, 231, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 22px;
  height: 22px;
  flex: none;
}

.brand-mark polygon {
  fill: var(--crystal);
}

.brand-mark polygon.b {
  fill: var(--violet);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 6px;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.nav-links a:hover {
  color: var(--ink);
  background: rgba(20, 24, 28, 0.06);
}

.nav-links a.active {
  color: var(--ink);
  background: rgba(63, 127, 147, 0.14);
}

.nav-cta {
  margin-left: 8px;
  font-family: var(--font-mono) !important;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  position: relative;
  transition: transform 180ms var(--ease-out);
}

.nav-toggle span::before {
  position: absolute;
  top: -6px;
}

.nav-toggle span::after {
  position: absolute;
  top: 6px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background 140ms var(--ease-out), border-color 140ms var(--ease-out);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--ink);
  color: var(--paper-raised);
}

.btn-primary:hover {
  background: var(--crystal-deep);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--ink);
  background: rgba(20, 24, 28, 0.05);
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.8rem;
}

/* ---------- hero ---------- */

.hero {
  padding: 88px 0 64px;
  position: relative;
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 48px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(2.4rem, 4.4vw, 3.6rem);
  margin-bottom: 0.35em;
}

.hero h1 em {
  font-style: normal;
  color: var(--crystal-deep);
  position: relative;
}

.hero-lede {
  font-size: 1.08rem;
  max-width: 46ch;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.hero-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 18px;
}

/* the crystal — signature element: source text condensing into a
   hex-bytecode lattice, built from stacked layers that fade/scale in */
.crystal-panel {
  position: relative;
  aspect-ratio: 1 / 1;
  max-width: 420px;
  margin: 0 auto;
}

.crystal-panel svg {
  width: 100%;
  height: 100%;
}

.hex {
  fill: var(--paper-raised);
  stroke: var(--line-strong);
  stroke-width: 1;
  opacity: 0;
  transform-origin: center;
  animation: hexIn 640ms var(--ease-out) forwards;
}

.hex.lit {
  fill: rgba(63, 127, 147, 0.16);
  stroke: var(--crystal);
}

.hex.lit-violet {
  fill: rgba(138, 123, 196, 0.18);
  stroke: var(--violet);
}

@keyframes hexIn {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.crystal-core {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--ink-soft);
}

/* ---------- pipeline ---------- */

.pipeline {
  padding: 56px 0 72px;
  border-top: 1px solid var(--line);
}

.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-top: 40px;
  position: relative;
}

.pipeline-steps::before {
  content: "";
  position: absolute;
  top: 22px;
  left: 6%;
  right: 6%;
  height: 1px;
  background: repeating-linear-gradient(to right, var(--line-strong) 0 6px, transparent 6px 12px);
  z-index: 0;
}

.pipeline-step {
  position: relative;
  z-index: 1;
  padding: 0 14px;
  text-align: left;
}

.pipeline-num {
  width: 44px;
  height: 44px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-bottom: 14px;
  color: var(--crystal-deep);
}

.pipeline-step h3 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.pipeline-step p {
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* ---------- code sample ---------- */

.sample {
  padding: 56px 0 72px;
  border-top: 1px solid var(--line);
}

.sample-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 36px;
}

.code-card {
  background: var(--ink);
  color: #e8e6de;
  border-radius: 10px;
  overflow: hidden;
}

.code-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: rgba(232, 230, 222, 0.55);
}

.code-card-dots {
  display: flex;
  gap: 6px;
}

.code-card-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.code-card pre {
  margin: 0;
  padding: 18px 16px 22px;
  font-size: 0.84rem;
  line-height: 1.65;
  overflow-x: auto;
}

.code-card .tok-kw {
  color: #8fb8c9;
}
.code-card .tok-str {
  color: #c7a76c;
}
.code-card .tok-com {
  color: #6f7a80;
}
.code-card .tok-fn {
  color: #b4a6e0;
}

/* ---------- feature grid ---------- */

.features {
  padding: 56px 0 72px;
  border-top: 1px solid var(--line);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: 36px;
}

.feature {
  background: var(--paper-raised);
  padding: 26px 24px;
}

.feature-icon {
  width: 30px;
  height: 30px;
  margin-bottom: 16px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--crystal);
}

.feature:nth-child(3n + 2) .feature-icon {
  background: var(--violet);
}

.feature:nth-child(3n) .feature-icon {
  background: var(--amber);
}

.feature h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.feature p {
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* ---------- comparison ---------- */

.comparison {
  padding: 56px 0 72px;
  border-top: 1px solid var(--line);
}

.compare-table-wrap {
  margin-top: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper-raised);
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.compare-table th,
.compare-table td {
  text-align: left;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.compare-table thead th {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: rgba(20, 24, 28, 0.03);
}

.compare-table tbody th {
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink);
}

.compare-table tbody tr:last-child th,
.compare-table tbody tr:last-child td {
  border-bottom: none;
}

.compare-table td.col-borax,
.compare-table th.col-borax {
  background: rgba(63, 127, 147, 0.08);
  position: relative;
}

.compare-table thead th.col-borax {
  color: var(--crystal-deep);
}

.compare-table thead th.col-borax::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(to right, var(--crystal), var(--violet));
}

.compare-table td code {
  font-size: 0.82rem;
}

.compare-foot {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin-top: 14px;
}

@media (max-width: 700px) {
  .compare-table-wrap {
    overflow-x: auto;
  }
  .compare-table {
    min-width: 640px;
  }
}

/* ---------- requirements ---------- */

.requirements {
  padding: 56px 0 80px;
  border-top: 1px solid var(--line);
}

.req-panel {
  margin-top: 36px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.req-item {
  padding: 22px 24px;
  border-right: 1px solid var(--line);
}

.req-item:last-child {
  border-right: none;
}

.req-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.req-value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
}

.req-sub {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* ---------- cta band ---------- */

.cta-band {
  padding: 64px 0;
  border-top: 1px solid var(--line);
  text-align: center;
}

.cta-band h2 {
  font-size: 1.9rem;
}

.cta-band .hero-actions {
  justify-content: center;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 32px 0;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-row p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.footer-links {
  display: flex;
  gap: 18px;
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--ink-soft);
}

.footer-links a:hover {
  color: var(--ink);
}

/* ---------- page header (releases / changelog) ---------- */

.page-header {
  padding: 64px 0 40px;
  border-bottom: 1px solid var(--line);
}

.page-header h1 {
  font-size: clamp(2rem, 3.6vw, 2.8rem);
}

.page-header p {
  font-size: 1.02rem;
}

/* ---------- releases ---------- */

.releases {
  padding: 48px 0 80px;
}

.release-latest {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 32px;
  margin-bottom: 48px;
  position: relative;
}

.release-latest::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  right: 24px;
  height: 3px;
  background: linear-gradient(to right, var(--crystal), var(--violet));
  border-radius: 0 0 3px 3px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(63, 127, 147, 0.14);
  color: var(--crystal-deep);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.release-latest h2 {
  font-size: 1.9rem;
  margin-bottom: 6px;
}

.release-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 18px;
}

.release-notes {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  font-size: 0.92rem;
}

.release-notes li {
  padding-left: 20px;
  position: relative;
  margin-bottom: 8px;
  color: var(--ink-soft);
}

.release-notes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  background: var(--violet);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.download-panel {
  background: var(--ink);
  color: var(--paper-raised);
  border-radius: 10px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.download-panel .file-name {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: rgba(232, 230, 222, 0.7);
  word-break: break-all;
}

.download-panel .btn-primary {
  background: var(--paper-raised);
  color: var(--ink);
  justify-content: center;
}

.download-panel .btn-primary:hover {
  background: #fff;
}

.download-facts {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: rgba(232, 230, 222, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 14px;
}

.release-list {
  display: flex;
  flex-direction: column;
}

.release-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 20px;
  align-items: start;
  padding: 22px 4px;
  border-top: 1px solid var(--line);
}

.release-row:last-child {
  border-bottom: 1px solid var(--line);
}

.release-version {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
}

.release-version-date {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

.release-summary p {
  margin: 0;
  font-size: 0.9rem;
}

.release-row .btn-ghost {
  align-self: center;
}

/* ---------- changelog ---------- */

.changelog {
  padding: 48px 0 80px;
}

.changelog-entry {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 32px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
}

.changelog-entry:last-child {
  border-bottom: 1px solid var(--line);
}

.changelog-when {
  position: relative;
}

.changelog-when .v {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
}

.changelog-when .d {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  margin: 10px 8px 0 0;
}

.tag-added {
  background: rgba(63, 127, 147, 0.14);
  color: var(--crystal-deep);
}

.tag-fixed {
  background: rgba(201, 138, 63, 0.16);
  color: #93611f;
}

.tag-changed {
  background: rgba(138, 123, 196, 0.16);
  color: var(--violet-deep);
}

.changelog-body h3 {
  font-size: 1.02rem;
  margin-bottom: 12px;
}

.changelog-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.changelog-list li {
  padding-left: 22px;
  position: relative;
  margin-bottom: 10px;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.changelog-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.changelog-list li strong {
  color: var(--ink);
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .crystal-panel {
    max-width: 280px;
  }

  .pipeline-steps {
    grid-template-columns: 1fr 1fr;
    row-gap: 32px;
  }

  .pipeline-steps::before {
    display: none;
  }

  .sample-grid {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }

  .req-panel {
    grid-template-columns: 1fr;
  }

  .req-item {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .req-item:last-child {
    border-bottom: none;
  }

  .release-latest {
    grid-template-columns: 1fr;
  }

  .release-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .changelog-entry {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (max-width: 640px) {
  .nav-links {
    position: fixed;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--paper-raised);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    display: none;
    gap: 2px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 12px 14px;
  }

  .nav-toggle {
    display: flex;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}