/* ── Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@600;700&family=Fraunces:opsz,wght@9..144,600;9..144,700&family=DM+Sans:wght@300;400;500;600&family=Outfit:wght@400;500;600;700&display=swap');

/* ── Custom Properties ─────────────────────────────── */
:root {
  --bg:              #f0f3f8;
  --bg-card:         #ffffff;
  --bg-card-hover:   #f7f9fc;
  --bg-sidebar:      #e8ecf3;
  --bg-input:        #ffffff;

  --border:          rgba(0,0,0,0.08);
  --border-accent:   rgba(0,168,158,0.35);

  --text:            #0e1120;
  --text-muted:      #3d4555;
  --text-dim:        #6b7385;

  --accent:          #00a89e;
  --accent-dim:      rgba(0,168,158,0.55);
  --accent-glow:     rgba(0,168,158,0.07);
  --accent-glow-hi:  rgba(0,168,158,0.16);
  --num-ghost:       rgba(0,168,158,0.04);

  --sidebar-width:   262px;
  --header-h:        64px;

  --mono:    'JetBrains Mono', 'Courier New', monospace;
  --sans:    'DM Sans', system-ui, -apple-system, sans-serif;
  --display: 'Fraunces', Georgia, serif;
  --ui:      'Outfit', system-ui, sans-serif;

  --ease: cubic-bezier(.4,0,.2,1);
  --t:   0.22s;
  --ts:  0.38s;
}


/* ── Reset ─────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.78;
  overflow-x: hidden;
  transition: background var(--ts) var(--ease), color var(--ts) var(--ease);
}

/* Dot-grid backdrop */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ─────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--t) var(--ease);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-chip {
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  padding: 3px 7px;
  letter-spacing: 1.5px;
}

.brand-text {
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  line-height: 1.3;
}

.sidebar-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  padding: 4px 6px;
  display: none;
  transition: color var(--t);
  border-radius: 4px;
}
.sidebar-close:hover { color: var(--accent); }

/* Search */
.search-wrap {
  padding: 12px 12px 8px;
  flex-shrink: 0;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 10px;
  color: var(--text-dim);
  pointer-events: none;
  flex-shrink: 0;
}

#searchInput {
  width: 100%;
  padding: 8px 30px 8px 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--ui);
  font-size: 11.5px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
#searchInput:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
#searchInput::placeholder { color: var(--text-dim); }

#clearSearch {
  position: absolute;
  right: 7px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 3px 5px;
  display: none;
  border-radius: 3px;
  transition: color var(--t);
}
#clearSearch:hover { color: var(--accent); }
#clearSearch.show { display: flex; }

.search-meta {
  font-family: var(--ui);
  font-size: 9.5px;
  color: var(--text-dim);
  padding: 5px 2px 0;
  letter-spacing: 0.5px;
  min-height: 18px;
}

/* TOC */
.toc-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0 40px;
}
.toc-scroll::-webkit-scrollbar { width: 3px; }
.toc-scroll::-webkit-scrollbar-track { background: transparent; }
.toc-scroll::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 2px;
}
.toc-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

.toc-list { list-style: none; }

.toc-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  line-height: 1.3;
  border-left: 2px solid transparent;
  transition: color var(--t), background var(--t), border-color var(--t), padding-left var(--t);
}
.toc-link:hover {
  color: var(--text);
  background: var(--accent-glow);
  padding-left: 18px;
}
.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
  padding-left: 18px;
}

.toc-n {
  font-size: 9px;
  color: var(--text-dim);
  min-width: 16px;
  transition: color var(--t);
}
.toc-link.active .toc-n,
.toc-link:hover .toc-n { color: var(--accent-dim); }

/* ── Main ───────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(240,243,248,0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px 0 22px;
  gap: 16px;
  transition: background var(--ts);
}


.header-l { display: flex; align-items: center; gap: 14px; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
}
.hamburger span {
  display: block;
  width: 21px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
  transition: background var(--t), transform var(--t), opacity var(--t);
}
.hamburger:hover span { background: var(--accent); }

.site-title {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  line-height: 1.2;
  color: var(--text);
}
.site-title em {
  color: var(--accent);
  font-style: normal;
}

.header-r { display: flex; align-items: center; gap: 14px; }

.disclaimer {
  font-family: var(--ui);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.2px;
  max-width: 320px;
}


/* ── Content ─────────────────────────────────────────── */
.content {
  padding: 36px 28px 80px;
  max-width: 860px;
}

/* ── Intro ───────────────────────────────────────────── */
.intro {
  margin-bottom: 32px;
  padding: 32px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
}

.intro-title {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 12px;
}

.intro-blurb {
  font-size: 15.5px;
  color: var(--text-muted);
  line-height: 1.75;
  max-width: 680px;
  margin-bottom: 20px;
}

.intro-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--ui);
  font-size: 13.5px;
}

.intro-stat {
  color: var(--text-muted);
}

.intro-stat strong {
  color: var(--accent);
  font-weight: 700;
}

.intro-divider {
  color: var(--text-dim);
}

@media (max-width: 920px) {
  .intro { padding: 22px 18px; }
  .intro-title { font-size: 21px; }
}

/* ── Protocol Cards ──────────────────────────────────── */
.proto {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 8px;
  padding: 28px 32px;
  margin-bottom: 16px;
  overflow: hidden;
  transition:
    border-color var(--t) var(--ease),
    background var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    transform var(--t) var(--ease);
  animation: rise .4s var(--ease) both;
}
.proto:hover {
  border-left-color: var(--accent);
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 36px var(--accent-glow), inset 0 0 0 1px var(--accent-glow);
  transform: translateY(-1px);
}

/* Ghost number watermark */
.proto::after {
  content: attr(data-n);
  position: absolute;
  top: -8px; right: 20px;
  font-family: var(--ui);
  font-size: 96px;
  font-weight: 700;
  color: var(--num-ghost);
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

/* Staggered entrance */
.proto:nth-child(1)  { animation-delay:.04s }
.proto:nth-child(2)  { animation-delay:.07s }
.proto:nth-child(3)  { animation-delay:.10s }
.proto:nth-child(4)  { animation-delay:.13s }
.proto:nth-child(5)  { animation-delay:.16s }
.proto:nth-child(6)  { animation-delay:.19s }
.proto:nth-child(n+7){ animation-delay:.22s }

@keyframes rise {
  from { opacity:0; transform:translateY(14px); }
  to   { opacity:1; transform:translateY(0); }
}

/* Card header */
.proto-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.proto-num {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-glow-hi);
  border-radius: 3px;
  padding: 2px 7px;
  letter-spacing: 2px;
  flex-shrink: 0;
}

.proto-title {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .2px;
}

/* Card body */
.proto-body { line-height: 1.74; }

.proto-body ul { list-style: none; padding-left: 0; }

.proto-body li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 6px;
  font-size: 15.5px;
  color: var(--text);
}
.proto-body li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent-dim);
  font-weight: 600;
  line-height: 1.74;
}

.proto-body ol { padding-left: 20px; }
.proto-body ol li { padding-left: 6px; font-size: 15.5px; }
.proto-body ol li::before { display: none; }
.proto-body ol li::marker {
  color: var(--accent);
  font-family: var(--ui);
  font-weight: 700;
}

/* Subsection label */
.sub-label {
  display: block;
  font-family: var(--ui);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent-dim);
  margin: 16px 0 7px;
  padding-left: 10px;
  border-left: 2px solid var(--accent-dim);
}
.sub-label:first-child { margin-top: 0; }

.proto-body strong {
  color: var(--text);
  font-weight: 600;
}

/* Note block */
.proto-note {
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 10px;
  padding: 7px 13px;
  background: var(--accent-glow);
  border-left: 2px solid var(--accent-dim);
  border-radius: 0 4px 4px 0;
}

/* Inline pill tag */
.tag {
  display: inline-block;
  font-family: var(--ui);
  font-size: 9.5px;
  font-weight: 600;
  background: var(--accent-glow-hi);
  color: var(--accent);
  border: 1px solid var(--accent-glow-hi);
  border-radius: 20px;
  padding: 1px 9px;
  letter-spacing: .5px;
  white-space: nowrap;
  vertical-align: middle;
}

/* Search highlight */
mark {
  background: var(--accent-glow-hi);
  color: var(--accent);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* Hidden (search filter) */
.proto.hidden { display: none; }

/* ── No results ─────────────────────────────────────── */
#noResults {
  display: none;
  text-align: center;
  padding: 80px 32px;
  font-family: var(--ui);
  color: var(--text-muted);
}
#noResults.show { display: block; }
#noResults .nr-icon {
  font-size: 40px;
  opacity: .25;
  display: block;
  margin-bottom: 14px;
}

/* ── Footer ─────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  padding: 22px 28px;
  border-top: 1px solid var(--border);
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: .3px;
}

/* ── Back to top ────────────────────────────────────── */
#backTop {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 42px; height: 42px;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 50%;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all var(--t) var(--ease);
  box-shadow: 0 4px 18px var(--accent-glow);
}
#backTop.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#backTop:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 6px 28px var(--accent-glow-hi);
  transform: translateY(-2px);
}
#backTop svg { width: 17px; height: 17px; }

/* ── Overlay (mobile) ───────────────────────────────── */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 99;
  opacity: 0;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity var(--t);
  pointer-events: none;
}
#overlay.show { opacity: 1; pointer-events: auto; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 920px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 40px rgba(0,0,0,0.55);
    z-index: 101;
  }
  .sidebar.open { transform: translateX(0); }

  #overlay { display: block; }
  .sidebar-close { display: flex; align-items: center; }

  .main-wrap { margin-left: 0; }
  .hamburger { display: flex; }
  .disclaimer { display: none; }

  .site-header { padding: 0 16px; }
  .content { padding: 20px 14px 60px; }

  .proto { padding: 22px 18px; }
  .proto::after { font-size: 68px; right: 12px; }

  #backTop { bottom: 18px; right: 14px; }
}

@media (max-width: 480px) {
  .site-title { font-size: 11px; letter-spacing: 2px; }
  .proto-title { font-size: 15px; }
  .content { padding: 14px 10px 60px; }
}

/* ── Print ──────────────────────────────────────────── */
@media print {
  .sidebar, .site-header, #backTop { display: none !important; }
  .main-wrap { margin-left: 0; }
  body::before { display: none; }
  .proto { break-inside: avoid; box-shadow: none; animation: none; }
}
