/* Bitcoin payments research: one stylesheet, light and dark. */

:root {
  --bg: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.86);
  --bg-card: #f5f5f7;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --accent: #0066cc;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  --header-height: 52px;
  --sidebar-width: 280px;
  --toc-width: 240px;
  --column: 700px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-header: rgba(0, 0, 0, 0.8);
    --bg-card: #1c1c1e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #86868b;
    --border: #424245;
    --border-light: #2c2c2e;
    --accent: #2997ff;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.53;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

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

/* Header */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 32px;
  background: var(--bg-header);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-light);
}

.header-title {
  color: var(--text);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.header-title:hover { text-decoration: none; }

.header-links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14px;
}
.header-links a { color: var(--text); }
.header-links a:hover { color: var(--accent); text-decoration: none; }

.menu-button { display: none; }

/* Layout */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
  max-width: 1440px;
  margin: 0 auto;
}

/* Sidebar */

.sidebar {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 40px 24px 48px 32px;
  font-size: 15px;
  line-height: 1.35;
}

.nav-top,
.nav-heading {
  display: block;
  padding: 7px 0;
  color: var(--text-secondary);
  font-weight: 400;
}
.nav-top:hover { color: var(--text); text-decoration: none; }
.nav-top[aria-current="page"],
.nav-heading.is-current { color: var(--text); font-weight: 600; }

.nav-group { margin: 0; }

.nav-heading {
  position: relative;
  padding-left: 18px;
  cursor: pointer;
  list-style: none;
  -webkit-user-select: none;
  user-select: none;
}
.nav-heading::-webkit-details-marker { display: none; }
.nav-heading::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-50%) rotate(-45deg);
  transition: transform 0.15s ease;
}
.nav-group[open] > .nav-heading::before { transform: translateY(-75%) rotate(45deg); }
.nav-group + .nav-top { margin-top: 2px; }

.sidebar ul { list-style: none; margin: 2px 0 8px; padding: 0 0 0 18px; }

.sidebar li a {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  color: var(--text-secondary);
}
.sidebar li a:hover { color: var(--text); text-decoration: none; }
.sidebar li a[aria-current="page"] { color: var(--text); font-weight: 600; }

.num {
  flex: 0 0 24px;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}
.num:empty { display: none; }

/* Content */

.content {
  width: 100%;
  max-width: calc(var(--column) + 80px);
  padding: 72px 40px 120px;
}

.content h1 {
  margin: 0 0 20px;
  font-size: 48px;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* Status line: the italic paragraph directly under the title. */
.content h1 + p:has(> em:only-child) {
  display: inline-block;
  margin: 0 0 32px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}
.content h1 + p:has(> em:only-child) em { font-style: normal; }

/* Lead paragraph: the first paragraph after the status line. */
.content h1 + p:has(> em:only-child) + p {
  margin-bottom: 40px;
  font-size: 24px;
  line-height: 1.38;
  letter-spacing: -0.015em;
}

.content h2 {
  margin: 64px 0 16px;
  font-size: 32px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.content h3 {
  margin: 40px 0 10px;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.content h4 { margin: 28px 0 8px; font-size: 17px; font-weight: 600; }

.content p, .content ul, .content ol { margin: 0 0 18px; }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin: 6px 0; }
.content li > ul, .content li > ol { margin: 6px 0 0; }

/* Task lists (TODO.md) */
.content .task-list-item { list-style: none; }
.content .task-list-item input { margin: 0 0.55em 0 -1.4em; vertical-align: middle; }

.content blockquote {
  margin: 0 0 18px;
  padding: 0 0 0 20px;
  border-left: 3px solid var(--border-light);
  color: var(--text-secondary);
}

.content code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-card);
  font-family: var(--mono);
  font-size: 0.85em;
  letter-spacing: 0;
}
.content pre {
  overflow-x: auto;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--bg-card);
  font-size: 14px;
  line-height: 1.5;
}
.content pre code { padding: 0; background: none; }

.content hr { margin: 56px 0; border: 0; border-top: 1px solid var(--border-light); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 24px 0 32px; }
.content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.45;
}
.table-wrap table { margin: 0; }
.content th, .content td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
}
.content th {
  padding-top: 0;
  border-bottom: 1.5px solid var(--text);
  color: var(--text);
  font-weight: 600;
}
.content td {
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.content td strong { color: var(--text); }

.footer {
  margin-top: 96px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  color: var(--text-tertiary);
  font-size: 13px;
}

/* On this page */

.toc {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 200px 32px 48px 8px;
  font-size: 14px;
  line-height: 1.35;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}
.toc li { margin: 0; }
.toc a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 16px;
  border-left: 1px solid transparent;
  color: var(--text-secondary);
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.is-current { border-left-color: var(--text); color: var(--text); }

/* Medium screens: drop "On this page" */

@media (max-width: 1200px) {
  .layout { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .toc { display: none; }
}

/* Small screens: sidebar behind a menu button */

@media (max-width: 860px) {
  body { font-size: 17px; }

  .header { padding: 0 16px; }
  .header-title { font-size: 17px; }
  .header-links { gap: 18px; }
  .menu-button {
    display: block;
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
  }

  .layout { display: block; }

  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    max-height: none;
    padding: calc(var(--header-height) + 16px) 16px 48px;
    background: var(--bg);
    font-size: 17px;
  }
  .sidebar li a, .nav-top, .nav-heading { padding-top: 9px; padding-bottom: 9px; }
  .menu-open .sidebar { display: block; }
  .menu-open { overflow: hidden; }

  .content { padding: 40px 16px 80px; }
  .content h1 { font-size: 34px; }
  .content h2 { font-size: 26px; margin-top: 48px; }
  .content h1 + p:has(> em:only-child) + p { font-size: 21px; }
}
