/*
 * docs.subnethistory.com
 *
 * Translated from design/Docs.html. Same brand tokens as the app: paper
 * background, ink text, indigo accent, Bricolage for display, Instrument for
 * body, JetBrains for code. The design carried its styling inline with
 * per-element hover attributes; here it is classes and media queries so twenty
 * pages share one sheet.
 *
 * Breakpoints, from the design's JS: <900px the nav becomes a drawer, <1180px
 * the "On this page" rail goes, <480px the wordmark and long CTA label go.
 */

:root {
  --paper: #faf9f7;
  --ink: #191631;
  --body: #5c5875;
  --muted: #8a86a0;
  --acc: #4f46e5;
  --acc-deep: #4338ca;
  --line: #eceaf4;
  --line-2: #e7e4ef;
  --line-hover: #c9c4dc;
  --wash: #f4f2f9;
  --card: #ffffff;
  --code-bg: #0d0a1f;
  --code-ink: #e9e6f7;
  --top-h: 57px;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--top-h) + 16px); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--acc-deep); text-decoration: underline; }

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.86em;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---------------------------------------------------------------- top bar */

.top {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(250, 249, 247, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.top-in {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
}

.burger {
  display: none;
  flex: none;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 9px 8px;
}
.burger:hover { border-color: var(--line-hover); }
.burger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}
.burger span + span { margin-top: 4px; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  flex: none;
}
.brand:hover { color: var(--ink); text-decoration: none; }

/* The mark, matching .brand-mark in styles.css: three strokes of the CIDR
   slash, stepping back in time. Same fractions of the tile as the brand book
   (20 degrees from vertical, 58% tall, opacity 100 / 45 / 18, past fades
   left), so the docs header and the app header cannot drift apart. */
.mark {
  --tile: 26px;
  width: var(--tile);
  height: var(--tile);
  border-radius: calc(var(--tile) * 0.28);
  background: var(--acc);
  position: relative;
  overflow: hidden;
  flex: none;
}
.mark span {
  position: absolute;
  top: calc(var(--tile) * 0.20833);
  width: calc(var(--tile) * 0.125);
  height: calc(var(--tile) * 0.58333);
  border-radius: calc(var(--tile) * 0.0625);
  background: #ffffff;
  transform: rotate(20deg);
}
.mark span:nth-child(1) { left: calc(var(--tile) * 0.21875); opacity: 0.18; }
.mark span:nth-child(2) { left: calc(var(--tile) * 0.38542); opacity: 0.45; }
.mark span:nth-child(3) { left: calc(var(--tile) * 0.55208); }

.wordmark {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.wm-docs { color: var(--muted); font-weight: 500; }

.search-wrap { flex: 1; display: flex; justify-content: center; min-width: 0; }

.search-trigger {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 8px 14px;
  width: 100%;
  max-width: 420px;
  color: var(--muted);
  font-family: inherit;
  font-size: 13.5px;
}
.search-trigger:hover { border-color: var(--line-hover); }

.s-ico { width: 13px; height: 13px; border: 1.8px solid var(--muted); border-radius: 50%; position: relative; flex: none; }
.s-ico::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 1.8px;
  background: var(--muted);
  transform: rotate(45deg);
  left: 10px;
  top: 11px;
}

.s-ph { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; }

.kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 1px 6px;
  flex: none;
}

.cta {
  flex: none;
  background: var(--acc);
  color: #ffffff;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
}
.cta:hover { background: var(--acc-deep); color: #ffffff; text-decoration: none; }
.cta-short { display: none; }

/* ------------------------------------------------------------ search modal */

.sm { position: fixed; inset: 0; z-index: 100; }
.sm-back { position: absolute; inset: 0; background: rgba(25, 22, 49, 0.4); backdrop-filter: blur(3px); }
.sm-panel { position: relative; max-width: 560px; margin: clamp(24px, 12vh, 120px) auto 0; padding: 0 16px; }
.sm-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(25, 22, 49, 0.25);
  overflow: hidden;
}
.sm-head { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--wash); }
.sm-head .s-ico { width: 14px; height: 14px; }
.sm-head .s-ico::after { left: 11px; top: 12px; }
.sm-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: transparent;
  min-width: 0;
}
.sm-esc {
  cursor: pointer;
  border: 1px solid var(--line-2);
  background: var(--card);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
}
.sm-esc:hover { color: var(--ink); border-color: var(--line-hover); }

.sm-results { display: flex; flex-direction: column; padding: 8px; max-height: min(420px, 55vh); overflow-y: auto; }
.sm-hit { display: block; padding: 10px 12px; border-radius: 10px; }
.sm-hit:hover, .sm-hit.sel { background: var(--wash); text-decoration: none; }
.sm-hit-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sm-hit-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.sm-hit-sec { font-size: 11px; color: var(--muted); }
.sm-hit-snip { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.sm-none { padding: 36px 20px; text-align: center; }
.sm-none-t { font-weight: 700; font-size: 14.5px; }
.sm-none-s { color: var(--muted); font-size: 13px; margin-top: 6px; max-width: 36ch; margin-left: auto; margin-right: auto; }

.sm-foot {
  display: flex;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--wash);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ shell */

.shell { max-width: 1360px; margin: 0 auto; display: flex; align-items: flex-start; }

.nav-backdrop { position: fixed; inset: 0; top: var(--top-h); z-index: 65; background: rgba(25, 22, 49, 0.35); }

.side {
  position: sticky;
  top: var(--top-h);
  flex: none;
  width: 250px;
  height: calc(100vh - var(--top-h));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px 22px 48px;
}

.nav-group + .nav-group { margin-top: 0; }
.nav-label {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}
.nav-links { display: flex; flex-direction: column; }
.nav-links a {
  display: block;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--body);
}
.nav-links a:hover { color: var(--ink); background: var(--wash); text-decoration: none; }
.nav-links a.on {
  font-weight: 700;
  color: var(--acc);
  background: var(--card);
  border: 1px solid var(--line);
}

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

.main { flex: 1; min-width: 0; padding: 36px clamp(20px, 4vw, 56px) 80px; }
.article { max-width: 720px; }

.crumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.crumb-here { color: var(--ink); font-weight: 600; }

.article h1 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: clamp(30px, 4.5vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin: 14px 0 0;
}

.lede { color: var(--body); font-size: 16px; margin: 14px 0 0; max-width: 58ch; }

.article h2 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 44px 0 10px;
}
.article h3 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 32px 0 10px;
}

.article p { color: var(--body); margin: 0 0 14px; }
.article ul, .article ol { color: var(--body); margin: 0 0 14px; padding-left: 22px; }
.article li { margin: 5px 0; }
.article li strong, .article p strong { color: var(--ink); }

/* Next-step cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 28px 0 0; }
.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  color: var(--ink);
}
.card:hover { border-color: var(--line-hover); text-decoration: none; color: var(--ink); }
.card-t { font-weight: 700; font-size: 14px; }
.card-s { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* Callouts. Info is the default; warn and success reuse the status palette. */
.callout {
  border: 1px solid #d9d4ee;
  background: #f4f2fb;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 20px 0;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  font-size: 14px;
}
.callout p { margin: 0; color: #3f3a5c; }
.callout-i {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--acc);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 800;
  font-style: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.callout.warn { border-color: #ecdcbc; background: #fbf6ec; }
.callout.warn p { color: #5c4a2f; }
.callout.warn .callout-i { background: #e0913a; }
.callout.success { border-color: #cfe8db; background: #ecf8f1; }
.callout.success p { color: #2f5c47; }
.callout.success .callout-i { background: #1e8a58; }

/* Code blocks: dark card with a header row and a copy button. */
.code { background: var(--code-bg); border-radius: 14px; overflow: hidden; margin: 20px 0; }
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.code-head span { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: rgba(255, 255, 255, 0.5); }
.copy {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}
.copy:hover { color: #ffffff; }
.copy.did { color: #9ee8bf; }
.code pre {
  margin: 0;
  padding: 16px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--code-ink);
  overflow-x: auto;
}

/* Tables: white card, uppercase header row. */
.tbl { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); margin: 20px 0; }
.tbl-scroll { overflow-x: auto; }
.tbl table { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  background: var(--wash);
  padding: 10px 16px;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.tbl td {
  padding: 11px 16px;
  border-top: 1px solid var(--wash);
  font-size: 13.5px;
  color: var(--body);
  vertical-align: top;
}
.tbl td:first-child { white-space: nowrap; }
.tbl td code { background: none; border: none; padding: 0; font-size: 12.5px; color: var(--ink); }

/* Mermaid-less flow line: a simple boxes row used on the freshness page. */
.flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 20px 0; font-size: 13px; }
.flow .fbox { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--ink); }
.flow .farr { color: var(--muted); font-family: 'JetBrains Mono', monospace; }

/* Prev/next */
.pager { display: flex; gap: 12px; margin-top: 48px; flex-wrap: wrap; }
.pg {
  flex: 1;
  min-width: 200px;
  display: block;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 14px 18px;
}
.pg:hover { border-color: var(--line-hover); text-decoration: none; }
.pg-next { text-align: right; }
.pg-k { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.pg-t { color: var(--ink); font-weight: 600; font-size: 14px; margin-top: 3px; }

.foot {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}
.foot a { color: var(--muted); }
.foot a:hover { color: var(--ink); }

/* ------------------------------------------------------------------- toc */

.toc { position: sticky; top: calc(var(--top-h) + 24px); flex: none; width: 200px; padding: 24px 20px 24px 0; }
.toc-label {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}
.toc-links { display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); }
.toc-links a { padding: 4px 0 4px 14px; font-size: 12.5px; color: var(--muted); }
.toc-links a:hover { color: var(--ink); text-decoration: none; }
.toc-links a.on {
  color: var(--acc);
  font-weight: 600;
  border-left: 2px solid var(--acc);
  margin-left: -1.5px;
  padding-left: 12.5px;
}

/* ------------------------------------------------------------ breakpoints */

@media (max-width: 1180px) {
  .toc { display: none; }
}

@media (max-width: 900px) {
  .burger { display: block; }
  .kbd { display: none; }
  .side {
    display: none;
    position: fixed;
    z-index: 70;
    top: var(--top-h);
    left: 0;
    bottom: 0;
    height: auto;
    width: min(300px, 84vw);
    background: var(--paper);
    box-shadow: 0 18px 48px rgba(25, 22, 49, 0.18);
  }
  body.nav-open .side { display: flex; }
}

@media (max-width: 480px) {
  .wordmark { display: none; }
  .cta { padding: 8px 12px; }
  .cta-long { display: none; }
  .cta-short { display: inline; }
}
