/* J2 website. Typeset, content-first, no frameworks. */

:root {
  --paper: #f7f5f0;
  --paper-deep: #efece4;
  --ink: #1d1b16;
  --muted: #6e6a5e;
  --faint: #96917f;
  --accent: #1f5738;
  --accent-soft: #eaf0e9;
  --rule: #d9d4c6;
  --rule-soft: #e6e2d6;
  --code-bg: #f1eee6;
  --code-border: #e2ddd0;

  --syn-comment: #8b8676;
  --syn-keyword: #1f5738;
  --syn-string: #8a4a2c;
  --syn-number: #2f5273;
  --syn-type: #7a5427;
  --syn-func: #3d5a78;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, Georgia, serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 44rem;
  --page: 72rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: "liga", "kern";
}

::selection { background: #dce6d9; }

a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(31, 87, 56, 0.35); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--accent); }

/* ---------- loading overlay ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
}
.loader.skip { display: none; }
.loader.done { opacity: 0; transition: opacity 0.45s ease; pointer-events: none; }

.loader-inner { text-align: center; }

.loader-mark {
  font-family: var(--serif);
  font-size: 4.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  line-height: 1;
  opacity: 0;
  transform: translateY(0.35rem);
  animation: loader-rise 0.7s ease-out 0.15s forwards;
}

.loader-rule {
  width: 9rem;
  height: 1px;
  background: var(--ink);
  margin: 1.1rem auto 0.9rem;
  transform: scaleX(0);
  animation: loader-draw 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.7s forwards;
}

.loader-sub {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--muted);
  opacity: 0;
  animation: loader-rise 0.6s ease-out 1.15s forwards;
}

@keyframes loader-rise {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes loader-draw {
  to { transform: scaleX(1); }
}

/* Exit: the rule and subtitle fade, the mark shrinks and travels to the
   header wordmark's spot, then the sheet fades to reveal the real page.
   The travel transform itself is computed and set inline by site.js. */
.loader.exit .loader-mark {
  animation: none;
  opacity: 1;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.loader.exit .loader-rule {
  animation: none;
  transform: scaleX(1);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.loader.exit .loader-sub {
  animation: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  .loader { display: none; }
}

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

.site-header {
  border-bottom: 1px solid var(--rule);
}
.site-header .bar {
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.1rem 2rem;
  display: flex;
  align-items: baseline;
  gap: 2rem;
}
.wordmark {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover { text-decoration: none; }
.site-header nav {
  margin-left: auto;
  display: flex;
  gap: 1.6rem;
}
.site-header nav a {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 0.2rem;
}
.site-header nav a:hover { color: var(--ink); }
.site-header nav a.active { color: var(--ink); }

/* ---------- home ---------- */

.home main { max-width: var(--page); margin: 0 auto; padding: 0 2rem; }

.hero {
  max-width: var(--measure);
  margin: 5.5rem auto 4.5rem;
  text-align: center;
}
.hero h1 {
  font-size: 3.2rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 1.2rem;
}
.hero .kicker {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin: 0 0 1.6rem;
}
.hero p.sub {
  font-size: 1.18rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 auto 2.2rem;
  max-width: 36rem;
}
.hero .actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block;
  font-family: var(--serif);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 0.75rem 1.6rem;
  border: 1px solid var(--ink);
  border-radius: 2px;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }

/* home sections */

.home section.band {
  border-top: 1px solid var(--rule);
  padding: 3.5rem 0;
}
.home .band-inner {
  max-width: var(--measure);
  margin: 0 auto;
}
.home .band-inner.wide { max-width: 58rem; }

.home h2 {
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}
.home .band .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.26em;
  color: var(--accent);
  margin: 0 0 0.8rem;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 3rem;
  align-items: start;
  max-width: 62rem;
  margin: 0 auto;
}
.split .prose { max-width: 30rem; }

.traits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.traits li {
  border-top: 1px solid var(--rule-soft);
  padding: 1.1rem 0 1.3rem;
}
.traits h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.35rem; }
.traits p { margin: 0; color: var(--muted); font-size: 0.97rem; line-height: 1.6; }

/* ---------- docs layout ---------- */

.layout {
  max-width: var(--page);
  margin: 0 auto;
  display: flex;
  min-height: calc(100vh - 8rem);
}

.sidebar {
  width: 15.5rem;
  flex: 0 0 15.5rem;
  border-right: 1px solid var(--rule);
  padding: 2.2rem 1.8rem 2.2rem 2rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y: auto;
}
.sidebar h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--faint);
  font-weight: 600;
  margin: 1.8rem 0 0.55rem;
}
.sidebar h3:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 0; }
.sidebar a {
  display: block;
  padding: 0.22rem 0 0.22rem 0.75rem;
  margin-left: -0.75rem;
  border-left: 1px solid transparent;
  color: var(--ink);
  font-size: 0.95rem;
  text-decoration: none;
}
.sidebar a:hover { color: var(--accent); }
.sidebar a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.content { flex: 1 1 auto; min-width: 0; padding: 2.8rem 2rem 3rem 3rem; }
.content .inner { max-width: var(--measure); }

/* ---------- article typography ---------- */

h1 { font-size: 2.1rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 0.9rem; }
h2 { font-size: 1.45rem; font-weight: 600; margin: 2.6rem 0 0.8rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--rule-soft); }
h3 { font-size: 1.1rem; font-weight: 700; margin: 1.9rem 0 0.5rem; }
p { margin: 0.8rem 0; }
ul, ol { padding-left: 1.5rem; }
li { margin: 0.3rem 0; }

.lead {
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 1.8rem;
}

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

.anchor {
  color: var(--rule);
  margin-left: 0.45rem;
  font-weight: 400;
  opacity: 0;
  text-decoration: none;
}
.anchor:hover { color: var(--accent); }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

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

code, pre, kbd, .mono { font-family: var(--mono); }
code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.08em 0.32em;
  border-radius: 3px;
  font-size: 0.82em;
}
pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 3px;
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  line-height: 1.55;
  font-size: 0.83rem;
  margin: 1.1rem 0;
}
pre code { background: none; border: none; padding: 0; font-size: inherit; border-radius: 0; }

pre .copy {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  font-family: var(--serif);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 2px;
  padding: 0.18rem 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}
pre:hover .copy { opacity: 1; }
pre .copy:hover { color: var(--ink); border-color: var(--faint); }

kbd {
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0.05em 0.4em;
  font-size: 0.8em;
}

.tok-comment { color: var(--syn-comment); font-style: italic; }
.tok-keyword { color: var(--syn-keyword); font-weight: 600; }
.tok-string  { color: var(--syn-string); }
.tok-number  { color: var(--syn-number); }
.tok-type    { color: var(--syn-type); }
.tok-func    { color: var(--syn-func); }

/* ---------- tables ---------- */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.1rem 0;
  font-size: 0.92rem;
}
th, td {
  border-bottom: 1px solid var(--rule-soft);
  padding: 0.5rem 0.9rem 0.5rem 0;
  text-align: left;
  vertical-align: top;
}
th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
}
td code { white-space: nowrap; }

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

.note {
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  padding: 0.7rem 1.1rem;
  margin: 1.3rem 0;
}
.note p:first-child { margin-top: 0; }
.note p:last-child { margin-bottom: 0; }
.note .note-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 600;
  display: block;
  margin-bottom: 0.2rem;
}

/* ---------- download page ---------- */

.dl-asset {
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1.3rem 1.5rem;
  margin: 1.2rem 0;
  background: rgba(255, 255, 255, 0.35);
}
.dl-asset h3 { margin: 0 0 0.3rem; }
.dl-asset .meta { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.9rem; }
.dl-asset .meta .sep { margin: 0 0.5rem; color: var(--rule); }

.checksum { font-size: 0.78rem; word-break: break-all; white-space: normal; }

/* ---------- page chrome ---------- */

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}
.page-nav .dir {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--faint);
  margin-bottom: 0.15rem;
}
.page-nav a { text-decoration: none; }
.page-nav a:hover { text-decoration: underline; }
.page-nav .next { text-align: right; margin-left: auto; }

.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 4rem;
}
.site-footer .bar {
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.6rem 2rem 2.2rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }

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

@media (max-width: 860px) {
  .site-header .bar { padding: 1rem 1.25rem; flex-wrap: wrap; gap: 0.8rem 1.4rem; }
  .site-header nav { margin-left: 0; gap: 1.2rem; flex-wrap: wrap; }

  .hero { margin: 3rem auto 2.5rem; }
  .hero h1 { font-size: 2.4rem; }

  .split { grid-template-columns: 1fr; gap: 1.5rem; }
  .traits { grid-template-columns: 1fr; }

  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-basis: auto;
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding: 1.4rem 1.25rem;
  }
  .content { padding: 1.8rem 1.25rem 2.5rem; }

  .home main { padding: 0 1.25rem; }
}
