/* BTH Legal — shared design system */

:root {
  color-scheme: light;
  --paper: #faf8f4;
  --panel: #ffffff;
  --ink: #211f1b;
  --ink-soft: #55514a;
  --muted: #8a8478;
  --line: #e7e1d6;
  --line-soft: #efeae1;
  --accent: #a14e24;
  --accent-deep: #7d3a18;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: "Geist", ui-sans-serif, system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: "Geist Mono", ui-monospace, "SF Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- header ---------- */

.site-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1.25rem, 5vw, 4rem);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand .tag {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.site-top nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.site-top nav a:hover { color: var(--ink); }

/* ---------- shared type ---------- */

h1, h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 560;
  color: var(--ink);
  letter-spacing: -0.015em;
}

a { color: var(--accent-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
a:active { transform: translateY(1px); }

strong { color: var(--ink); font-weight: 600; }

code {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--line-soft);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.eyebrow {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
}

/* ---------- index ---------- */

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: clamp(3rem, 8vw, 8rem);
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(3.5rem, 9vh, 7rem) clamp(1.25rem, 5vw, 4rem) 4rem;
  align-items: start;
}

.hero-left { position: sticky; top: 7rem; }

.hero-left h1 {
  font-size: clamp(2.4rem, 5.2vw, 3.9rem);
  line-height: 1.04;
  margin: 0 0 1.4rem;
}

.hero-left .lede {
  max-width: 42ch;
  margin: 0;
  color: var(--ink-soft);
}

.doc-list {
  border-top: 1px solid var(--line);
  margin-top: 0.4rem;
}

.doc-row {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 1rem;
  padding: 1.6rem 0.25rem;
  border-bottom: 1px solid var(--line);
  transition: background 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-row:hover { background: color-mix(in srgb, var(--panel) 65%, transparent); }

.doc-row .num {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--accent);
}

.doc-row .app {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 560;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.doc-row .links {
  display: flex;
  gap: 1.4rem;
  white-space: nowrap;
}

.doc-row .links a {
  position: relative;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--ink-soft);
  transition: color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-row .links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-row .links a:hover { color: var(--accent-deep); }
.doc-row .links a:hover::after { transform: scaleX(1); }

/* ---------- document pages ---------- */

.doc-grid {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 68ch);
  gap: clamp(2.5rem, 7vw, 6.5rem);
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(2.5rem, 7vh, 5rem) clamp(1.25rem, 5vw, 4rem) 5rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: 6.5rem;
  padding-top: 0.4rem;
}

.toc .toc-title {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}

.toc li a {
  display: block;
  padding: 0.32rem 0 0.32rem 1rem;
  margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toc li a:hover { color: var(--ink); }

.toc li a.active {
  color: var(--accent-deep);
  border-left-color: var(--accent);
}

.toc .related {
  margin-top: 2.2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.84rem;
}

.toc .related a { text-decoration: none; }
.toc .related a:hover { text-decoration: underline; }

article { counter-reset: sec; min-width: 0; }

article .doc-head { margin-bottom: 3rem; }

article h1 {
  font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  line-height: 1.06;
  margin: 0 0 1.1rem;
}

article .meta {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

article h2 {
  counter-increment: sec;
  font-size: 1.45rem;
  line-height: 1.3;
  margin: 3.2rem 0 0.9rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line-soft);
}

article h2::before {
  content: counter(sec, decimal-leading-zero);
  display: block;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.45rem;
}

article p, article li { max-width: 65ch; }

article ul { padding-left: 1.3rem; }
article li { margin-bottom: 0.5rem; }
article li::marker { color: var(--accent); }

/* ---------- footer ---------- */

.site-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem clamp(1.25rem, 5vw, 4rem) 3.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
  color: var(--muted);
}

.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--accent-deep); }

/* ---------- motion ---------- */

.rise {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--i, 0) * 80ms);
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rise { animation: none; opacity: 1; transform: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- mobile collapse ---------- */

@media (max-width: 860px) {
  .hero-grid, .doc-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .hero-left { position: static; }

  .toc { position: static; top: auto; order: 2; }

  .doc-row {
    grid-template-columns: 3rem minmax(0, 1fr);
    row-gap: 0.4rem;
  }

  .doc-row .links { grid-column: 2; }
}
