/* ============================================================
   baselashraf.com/sensortap/docs/
   Read-mode surface. Inherits sensortap's broadcast palette from the
   landing page, but this is documentation: comprehension outranks
   expression. Prose is set in IBM Plex Sans, the same family as the
   landing page's mono, so the two read as kin without making a
   reference doc a wall of monospace. Mono is reserved for code,
   identifiers, and measured values.
   ============================================================ */

:root {
  --black: #000000;
  --page: #0b0b0b;
  --panel: #121212;
  --panel-2: #171717;
  --line: #262626;
  --line-2: #333333;
  --white: #f2f2f2;
  --grey: #b4b4b4;
  --grey-dim: #8f8f8f;
  --yellow: #ffe15a;
  --cyan: #5adfdf;
  --green: #5ad46a;
  --red: #ff5a5a;
  --blue: #7d9bff;

  /* Callout grounds and the ink that sits on them, tokenised together so a
     theme change (including print) moves both and can never leave dark text
     on a dark ground. */
  --note-warn-bg: #17120a;
  --note-ok-bg: #0c1510;
  --on-accent: #000000;
  /* Translucent so content scrolling under the sticky bar is felt rather
     than hidden. Tokenised so it flips with the theme instead of staying
     dark over a light ground. */
  --bar-bg: rgba(11, 11, 11, 0.92);
  --row-hover: rgba(242, 242, 242, 0.025);

  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;

  --sidebar: 17rem;
  --toc: 15rem;
  --content: 48rem;
  --bar-h: 3.5rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--bar-h) + 1.5rem);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--page);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--yellow); color: var(--on-accent); }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

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

.skip {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -130%);
  z-index: 200;
  background: var(--yellow);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  font-weight: 700;
}
.skip:focus { transform: translate(-50%, 0); }

/* --- Top bar ------------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--bar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.bar__brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
}
.bar__brand:hover { text-decoration: none; color: var(--white); }
.bar__brand b { font-weight: 700; }
.bar__tag {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-accent);
  background: var(--cyan);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}

.bar__spacer { flex: 1; }

.bar__links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.bar__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.88rem;
  color: var(--grey);
  border: 1px solid transparent;
  border-radius: 3px;
  white-space: nowrap;
}
.bar__link:hover { color: var(--white); border-color: var(--line-2); text-decoration: none; }

.icon { width: 1em; height: 1em; flex: none; }

/* --- Search -------------------------------------------------------------- */

.search {
  position: relative;
  width: min(22rem, 40vw);
}
.search__input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--white);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0.45rem 2.6rem 0.45rem 0.7rem;
}
.search__input::placeholder { color: var(--grey-dim); }
.search__input:focus {
  outline: none;
  border-color: var(--cyan);
}
.search__kbd {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--grey-dim);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  pointer-events: none;
}

.search__results {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0.3rem;
  z-index: 120;
}
.search__results[hidden] { display: none; }
.search__hit {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 3px;
  color: var(--white);
}
.search__hit:hover, .search__hit[aria-selected="true"] {
  background: var(--panel-2);
  text-decoration: none;
}
.search__hit-title { display: block; font-size: 0.9rem; font-weight: 600; }
.search__hit-sec { display: block; font-size: 0.76rem; color: var(--grey-dim); margin-top: 0.05rem; }
.search__empty { padding: 0.7rem 0.6rem; font-size: 0.86rem; color: var(--grey-dim); }

/* --- Layout -------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc);
  gap: 0;
  align-items: start;
  max-width: 96rem;
  margin: 0 auto;
}

@media (max-width: 78rem) {
  .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 56rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { display: none; }
}

/* --- Sidebar nav --------------------------------------------------------- */

.nav {
  position: sticky;
  top: var(--bar-h);
  max-height: calc(100vh - var(--bar-h));
  overflow-y: auto;
  padding: 1.75rem 1rem 3rem 1.25rem;
  border-right: 1px solid var(--line);
  font-size: 0.9rem;
}

.nav__group { margin-bottom: 1.5rem; }
.nav__title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-dim);
  margin: 0 0 0.5rem 0.55rem;
}
.nav__list { list-style: none; margin: 0; padding: 0; }
.nav__link {
  display: block;
  padding: 0.32rem 0.55rem;
  border-left: 2px solid transparent;
  color: var(--grey);
  border-radius: 0 3px 3px 0;
}
.nav__link:hover { color: var(--white); background: var(--panel); text-decoration: none; }
.nav__link[aria-current="true"] {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: var(--panel);
  font-weight: 600;
}

/* Mobile nav drawer */
.navdrawer {
  display: none;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 56rem) {
  .navdrawer { display: block; }
}
.navdrawer summary {
  cursor: pointer;
  list-style: none;
  padding: 0.7rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navdrawer summary::-webkit-details-marker { display: none; }
.navdrawer__body { padding: 0 1.25rem 1rem; }
.navdrawer[open] summary { border-bottom: 1px solid var(--line); }

/* --- Content ------------------------------------------------------------- */

.doc {
  min-width: 0;
  padding: 2.25rem clamp(1.25rem, 3vw, 3rem) 6rem;
}
.doc__inner { max-width: var(--content); }

.doc__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cyan);
  margin: 0 0 0.4rem;
}

.doc h1 {
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0 0 0.75rem;
}

.doc__lede {
  font-size: 1.08rem;
  color: var(--grey);
  margin: 0 0 1.5rem;
}

.doc h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 3.5rem 0 1rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}
.doc h2:first-of-type { margin-top: 2.5rem; }

.doc h3 {
  font-size: 1.14rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 2.25rem 0 0.65rem;
}

.doc h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.6rem 0 0.5rem;
  color: var(--white);
}

.doc p { margin: 0 0 1rem; color: var(--grey); }
.doc p strong, .doc li strong { color: var(--white); font-weight: 600; }

.doc ul, .doc ol { margin: 0 0 1rem; padding-left: 1.4rem; color: var(--grey); }
.doc li { margin: 0.3rem 0; }
.doc li::marker { color: var(--grey-dim); }

/* Anchor links on headings */
.anchor {
  color: var(--grey-dim);
  font-weight: 400;
  margin-left: 0.4rem;
  opacity: 0;
  font-size: 0.85em;
}
.doc h2:hover .anchor,
.doc h3:hover .anchor,
.doc h4:hover .anchor,
.anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--cyan); text-decoration: none; }

/* --- Inline code and code blocks ---------------------------------------- */

.doc :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--yellow);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.08em 0.32em;
  white-space: nowrap;
}

.code {
  position: relative;
  margin: 0 0 1.25rem;
}
.code pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: var(--black);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--white);
}
.code pre code { font-family: inherit; }
.code--sh pre { padding-right: 4.5rem; }

.code__copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--grey);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s linear;
}
.code:hover .code__copy, .code__copy:focus-visible { opacity: 1; }
.code__copy:hover { color: var(--white); border-color: var(--grey); }
.code__copy--done { color: var(--on-accent); background: var(--green); border-color: var(--green); opacity: 1; }

.tok-c { color: var(--grey-dim); }
.tok-k { color: var(--blue); }
.tok-s { color: var(--green); }
.tok-p { color: var(--cyan); }

/* --- Tables -------------------------------------------------------------- */

.tablewrap {
  margin: 0 0 1.5rem;
  overflow-x: auto;
  border: 1px solid var(--line-2);
  border-radius: 4px;
}
.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.doc thead th {
  text-align: left;
  font-weight: 600;
  color: var(--white);
  background: var(--panel-2);
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.doc tbody td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line);
  color: var(--grey);
  vertical-align: top;
}
.doc tbody tr:last-child td { border-bottom: none; }
.doc tbody tr:hover td { background: var(--row-hover); }
.doc td code, .doc th code { white-space: nowrap; }

/* --- Callouts ------------------------------------------------------------ */

.note {
  margin: 0 0 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 4px;
}
.note > :last-child { margin-bottom: 0; }
.note__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}
.note--warn { border-color: #6b4a1f; background: var(--note-warn-bg); }
.note--warn .note__label { color: var(--yellow); }
.note--info .note__label { color: var(--cyan); }
.note--ok { border-color: #24512c; background: var(--note-ok-bg); }
.note--ok .note__label { color: var(--green); }

/* --- Status pills -------------------------------------------------------- */

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.05rem 0.4rem;
  border-radius: 2px;
  white-space: nowrap;
}
.pill--req { color: var(--on-accent); background: var(--yellow); }
.pill--opt { color: var(--grey); border: 1px solid var(--line-2); }

/* --- On this page -------------------------------------------------------- */

.toc {
  position: sticky;
  top: var(--bar-h);
  max-height: calc(100vh - var(--bar-h));
  overflow-y: auto;
  padding: 1.75rem 1.25rem 3rem 0.5rem;
  font-size: 0.85rem;
}
.toc__title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-dim);
  margin: 0 0 0.6rem 0.7rem;
}
.toc__list { list-style: none; margin: 0; padding: 0; }
.toc__link {
  display: block;
  padding: 0.22rem 0.7rem;
  border-left: 2px solid var(--line);
  color: var(--grey-dim);
  line-height: 1.45;
}
.toc__link:hover { color: var(--white); text-decoration: none; }
.toc__link--h3 { padding-left: 1.5rem; font-size: 0.82rem; }
.toc__link[aria-current="true"] { color: var(--cyan); border-left-color: var(--cyan); }

/* --- Copy-for-AI panel --------------------------------------------------- */

.ai {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 2rem;
  padding: 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 4px;
}
.ai__text { flex: 1 1 14rem; font-size: 0.88rem; color: var(--grey); margin: 0; }
.ai__text b { color: var(--white); font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  border-radius: 3px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--white);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--grey); text-decoration: none; }
.btn--primary { background: var(--cyan); color: var(--on-accent); border-color: var(--cyan); }
.btn--primary:hover { background: var(--white); color: var(--page); border-color: var(--white); }
.btn[disabled] { opacity: 0.6; cursor: default; }
.btn--done { background: var(--green); color: var(--on-accent); border-color: var(--green); }

/* --- Footer -------------------------------------------------------------- */

.foot {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding-top: 1.75rem;
  font-size: 0.86rem;
  color: var(--grey-dim);
}
.foot a { color: var(--grey); }
.foot p { margin: 0 0 0.4rem; }

/* --- Print --------------------------------------------------------------- */

/* Re-point the tokens themselves rather than patching individual rules, so
   every foreground/background pair stays internally consistent on paper
   instead of mixing a print text colour onto a screen panel colour. */
@media print {
  :root {
    --page: #ffffff;
    --panel: #f4f4f4;
    --panel-2: #ececec;
    --line: #d4d4d4;
    --line-2: #b4b4b4;
    --white: #111111;
    --grey: #333333;
    --grey-dim: #555555;
    --cyan: #0b5c8a;
    --yellow: #7a5400;
    --green: #1c5b28;
    --blue: #21409a;
    --note-warn-bg: #fdf6e6;
    --note-ok-bg: #edf7ee;
    /* Accent grounds go dark on paper, so their ink must go light. */
    --on-accent: #ffffff;
    --bar-bg: #ffffff;
    --row-hover: transparent;
  }
  .bar, .nav, .toc, .navdrawer, .ai, .code__copy, .skip { display: none; }
  .shell { grid-template-columns: 1fr; max-width: none; }
  .doc { padding: 0; }
  .doc__inner { max-width: none; }
  .code pre, .tablewrap { break-inside: avoid; }
  .doc h2, .doc h3 { break-after: avoid; }
  a { text-decoration: underline; }
}
