/* Alkanes protocol documentation
   Visual language: structural chemistry. Lab-white base, deep petrol dark mode,
   bond-line diagrams, one restrained chemical-green accent. */

:root {
  color-scheme: light dark;

  --bg: #fbfcfb;
  --bg-tint: #f2f5f4;
  --surface: #ffffff;
  --surface-2: #f6f8f8;
  --ink: #0e1519;
  --ink-2: #3d4a52;
  --muted: #55636c;
  --line: #d3dcde;
  --line-strong: #828c8f;
  --accent: #0d7a45;
  --accent-ink: #0a5e35;
  --accent-wash: #e6f4ec;
  --warn: #97350f;
  --warn-wash: #fbeee7;
  --warn-line: #e4c3b1;
  --ok: #0d7a45;
  --bond: #2b3a42;
  --atom: #ffffff;

  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --maxw: 1180px;
  --rail: 236px;
  --r: 4px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #04161c;
    --bg-tint: #072028;
    --surface: #08202a;
    --surface-2: #0b2833;
    --ink: #e8f2f2;
    --ink-2: #b6c9cd;
    --muted: #9ab0b6;
    --line: #17414f;
    --line-strong: #3d8095;
    --accent: #47ce8b;
    --accent-ink: #6fe0a6;
    --accent-wash: #0a2f26;
    --warn: #ffb083;
    --warn-wash: #2c1a10;
    --warn-line: #6b3d22;
    --ok: #47ce8b;
    --bond: #9fc0c8;
    --atom: #08202a;
  }
}

:root[data-theme="dark"] {
  --bg: #04161c;
  --bg-tint: #072028;
  --surface: #08202a;
  --surface-2: #0b2833;
  --ink: #e8f2f2;
  --ink-2: #b6c9cd;
  --muted: #9ab0b6;
  --line: #17414f;
  --line-strong: #3d8095;
  --accent: #47ce8b;
  --accent-ink: #6fe0a6;
  --accent-wash: #0a2f26;
  --warn: #ffb083;
  --warn-wash: #2c1a10;
  --warn-line: #6b3d22;
  --ok: #47ce8b;
  --bond: #9fc0c8;
  --atom: #08202a;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  overflow-wrap: break-word;
}

/* ---------- skip link ---------- */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--accent); color: #fff; padding: .6rem 1rem;
  font-weight: 600; border-radius: 0 0 var(--r) 0;
}
.skip:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- masthead ---------- */
.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 40;
}
.masthead-in {
  max-width: var(--maxw); margin: 0 auto; padding: .55rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.wordmark {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 650; letter-spacing: .01em; color: var(--ink);
  text-decoration: none; font-size: 1.02rem; flex: none;
}
.wordmark svg { display: block; }
.wordmark small {
  font-family: var(--mono); font-size: .68rem; font-weight: 500;
  color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
}
.masthead nav { display: flex; gap: .1rem; flex-wrap: wrap; flex: 1 1 auto; }
.masthead nav a {
  color: var(--ink-2); text-decoration: none; font-size: .875rem;
  padding: .35rem .55rem; border-radius: var(--r); white-space: nowrap;
}
.masthead nav a:hover { color: var(--accent-ink); background: var(--accent-wash); }
.masthead nav a[aria-current="page"] {
  color: var(--ink); font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.mast-tools { display: flex; gap: .5rem; align-items: center; flex: none; }

button.ghost {
  font: inherit; font-size: .8rem; cursor: pointer;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: .3rem .6rem; line-height: 1.4;
}
button.ghost:hover { border-color: var(--line-strong); color: var(--ink); }

/* ---------- search ---------- */
.search-wrap { position: relative; flex: none; width: min(260px, 42vw); }
.search-wrap input {
  width: 100%; font: inherit; font-size: .84rem;
  padding: .34rem .55rem .34rem 1.9rem;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); color: var(--ink);
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap .slash {
  position: absolute; left: .5rem; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: .78rem; color: var(--muted); pointer-events: none;
}
#search-results {
  position: absolute; z-index: 50; top: calc(100% + 6px); right: 0;
  width: min(460px, 92vw); max-height: 68vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); box-shadow: 0 12px 34px rgba(0, 0, 0, .16);
  padding: .3rem; margin: 0; list-style: none;
}
#search-results:empty { display: none; }
#search-results li { margin: 0; }
#search-results a {
  display: block; padding: .5rem .6rem; border-radius: var(--r);
  text-decoration: none; color: var(--ink);
}
#search-results a:hover, #search-results a:focus { background: var(--accent-wash); }
#search-results .sr-page {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--accent-ink); display: block;
}
#search-results .sr-title { font-weight: 600; font-size: .92rem; display: block; }
#search-results .sr-snip { font-size: .82rem; color: var(--muted); display: block; }
#search-results .sr-none { padding: .7rem .6rem; font-size: .88rem; color: var(--muted); }
#search-results mark { background: var(--accent-wash); color: var(--accent-ink); padding: 0 1px; }

/* ---------- layout ---------- */
.page { max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }
.with-rail { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); gap: 2.4rem; align-items: start; }
@media (max-width: 900px) { .with-rail { grid-template-columns: minmax(0, 1fr); gap: 1.2rem; } }

/* left rail rendered as a bond chain */
.rail { position: sticky; top: 68px; padding: 1.8rem 0; font-size: .875rem; }
@media (max-width: 900px) {
  .rail { position: static; padding: 1rem 0 0; border-bottom: 1px solid var(--line); }
}
.rail h2 {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); font-family: var(--mono); font-weight: 600; margin: 0 0 .6rem;
}
.rail ol { list-style: none; margin: 0 0 1.6rem; padding: 0 0 0 .9rem; border-left: 1px solid var(--line); }
.rail li { position: relative; margin: 0; }
.rail li::before {
  content: ""; position: absolute; left: -1.16rem; top: .72rem;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--atom); border: 1.5px solid var(--line-strong);
}
.rail li.here::before { background: var(--accent); border-color: var(--accent); }
.rail a { display: block; padding: .2rem 0; color: var(--ink-2); text-decoration: none; }
.rail a:hover { color: var(--accent-ink); }
.rail li.here > a { color: var(--ink); font-weight: 600; }

main { padding: 1.8rem 0 3rem; min-width: 0; }

/* ---------- headings & text ---------- */
h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5rem; font-weight: 660; letter-spacing: -.012em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem); margin-bottom: .7rem; }
h2 { font-size: clamp(1.25rem, 1.05rem + .9vw, 1.6rem); margin-top: 2.6rem; padding-top: .9rem; border-top: 1px solid var(--line); }
h3 { font-size: 1.06rem; margin-top: 1.8rem; }
h4 { font-size: .95rem; margin-top: 1.3rem; color: var(--ink-2); }
p, ul, ol, dl { margin: 0 0 1rem; }
main ul, main ol { padding-left: 1.25rem; }
main li { margin: .25rem 0; }
a { color: var(--accent-ink); text-underline-offset: .16em; }
a:hover { color: var(--accent); }
strong { font-weight: 650; }

.lede { font-size: 1.09rem; color: var(--ink-2); max-width: 62ch; }
.eyebrow {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .13em;
  text-transform: uppercase; color: var(--accent-ink); margin: 0 0 .5rem; font-weight: 600;
}
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.anchor {
  color: var(--line-strong); text-decoration: none; font-weight: 400;
  margin-left: .4rem; font-size: .8em; opacity: 0;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

/* ---------- code ---------- */
code, kbd, samp { font-family: var(--mono); font-size: .875em; }
:not(pre) > code {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 3px; padding: .06em .3em; color: var(--ink);
}
pre {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: .85rem 1rem; overflow-x: auto;
  margin: 0 0 1rem; font-size: .84rem; line-height: 1.65;
}
pre code { background: none; border: 0; padding: 0; font-size: 1em; }
.hexblock { word-break: break-all; white-space: pre-wrap; }
.hexblock .hl { color: var(--accent-ink); font-weight: 700; }
.hexblock .hl2 { color: var(--warn); font-weight: 700; }
kbd {
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 3px; padding: .05em .35em; font-size: .8em;
}

/* ---------- callouts ---------- */
.note, .danger, .fact {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: 0 var(--r) var(--r) 0;
  padding: .85rem 1rem; margin: 0 0 1.2rem;
}
.note > :last-child, .danger > :last-child, .fact > :last-child { margin-bottom: 0; }
.danger { border-left-color: var(--warn); background: var(--warn-wash); border-color: var(--warn-line); }
.fact { background: var(--accent-wash); border-color: var(--line); }
.note .t, .danger .t, .fact .t {
  display: block; font-family: var(--mono); font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; font-weight: 700; margin-bottom: .35rem; color: var(--accent-ink);
}
.danger .t { color: var(--warn); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; margin: 0 0 1.2rem; border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: .875rem; min-width: 30rem; }
.tablewrap.narrow table { min-width: 20rem; }
caption { text-align: left; font-size: .82rem; color: var(--muted); padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

.yes { color: var(--ok); font-weight: 650; }
.no { color: var(--warn); font-weight: 650; }

/* ---------- numbered normative rules ---------- */
.rules { list-style: none; padding: 0; margin: 0 0 1.4rem; counter-reset: none; }
.rules > li {
  display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); gap: .9rem;
  padding: .7rem 0; border-bottom: 1px solid var(--line); margin: 0;
}
.rules > li:last-child { border-bottom: 0; }
.rules .rid {
  font-family: var(--mono); font-size: .78rem; font-weight: 700;
  color: var(--accent-ink); padding-top: .1rem; letter-spacing: .02em;
}
.rules .rbody > :last-child { margin-bottom: 0; }
@media (max-width: 520px) {
  .rules > li { grid-template-columns: minmax(0, 1fr); gap: .2rem; }
}

/* ---------- cards ---------- */
.grid { display: grid; gap: 1rem; margin: 0 0 1.4rem; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); padding: 1rem 1.1rem;
}
.card > :last-child { margin-bottom: 0; }
.card h3 { margin-top: 0; font-size: .98rem; }
.card .k {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); display: block; margin-bottom: .2rem;
}

/* key/value facts strip */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin: 0 0 1.6rem; }
.facts div { background: var(--surface); padding: .7rem .85rem; }
.facts dt { font-family: var(--mono); font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: .1rem 0 0; font-size: .93rem; font-weight: 600; }

/* ---------- figures / diagrams ---------- */
figure { margin: 0 0 1.5rem; }
figure svg { display: block; width: 100%; height: auto; }
.figframe {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); padding: 1rem;
}
figcaption { font-size: .84rem; color: var(--muted); margin-top: .55rem; }
.svg-bond { stroke: var(--bond); }
.svg-accent { stroke: var(--accent); }

/* ---------- hero ---------- */
.hero { padding: 2.4rem 0 1.6rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 2.2rem; align-items: center; }
@media (max-width: 820px) { .hero-grid { grid-template-columns: minmax(0, 1fr); } }
.btnrow { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.2rem; }
.btn {
  display: inline-block; text-decoration: none; font-size: .9rem; font-weight: 600;
  padding: .5rem .95rem; border-radius: var(--r);
  border: 1px solid var(--accent); color: var(--accent-ink); background: var(--surface);
}
.btn:hover { background: var(--accent-wash); }
.btn.solid { background: var(--accent); border-color: var(--accent); color: #ffffff; }
:root[data-theme="dark"] .btn.solid { color: #04161c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.solid { color: #04161c; } }
.btn.solid:hover { filter: brightness(1.07); }

/* ---------- tool ---------- */
.tool { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 1.1rem; margin: 0 0 1.4rem; }
.tool label { display: block; font-size: .82rem; font-weight: 600; margin: 0 0 .25rem; }
.tool .hint { font-size: .78rem; color: var(--muted); margin: -.15rem 0 .35rem; }
.tool input[type="text"], .tool textarea, .tool select {
  width: 100%; font-family: var(--mono); font-size: .84rem;
  padding: .45rem .55rem; border: 1px solid var(--line-strong);
  border-radius: var(--r); background: var(--bg); color: var(--ink);
}
.tool textarea { min-height: 5.5rem; resize: vertical; line-height: 1.55; }
.field { margin-bottom: .8rem; }
.fieldrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; }
.tool button.run {
  font: inherit; font-weight: 650; font-size: .88rem; cursor: pointer;
  background: var(--accent); color: #ffffff; border: 1px solid var(--accent);
  border-radius: var(--r); padding: .48rem 1.1rem;
}
:root[data-theme="dark"] .tool button.run { color: #04161c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tool button.run { color: #04161c; } }
.tool button.run:hover { filter: brightness(1.07); }
.tabs { display: flex; gap: .35rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button {
  font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer;
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: .45rem .7rem; color: var(--muted); margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.out { margin-top: 1rem; }
.out:empty { display: none; }
.noscript { border: 1px dashed var(--line-strong); border-radius: var(--r); padding: .9rem 1rem; color: var(--muted); font-size: .9rem; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .15rem .9rem; font-size: .86rem; margin: 0 0 1rem; }
.kv dt { font-family: var(--mono); color: var(--muted); font-size: .8rem; }
.kv dd { margin: 0; }

/* ---------- footer ---------- */
.sitefoot {
  border-top: 1px solid var(--line); background: var(--bg-tint);
  margin-top: 2rem; padding: 1.6rem 0 2.4rem; font-size: .84rem; color: var(--muted);
}
.sitefoot .page > :last-child { margin-bottom: 0; }
.sitefoot dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .7rem 1.4rem; margin: 0 0 1.1rem; }
.sitefoot dt { font-family: var(--mono); font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.sitefoot dd { margin: 0; color: var(--ink-2); }
.sitefoot a { color: var(--accent-ink); }
.footlinks { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; }

hr.bond { border: 0; height: 1px; background: var(--line); margin: 2rem 0; }
