/* tltv spec site */

:root {
  --fg:          #111;
  --fg-muted:    #555;
  --fg-faint:    #999;
  --bg:          #fff;
  --rule:        #ddd;
  --code-bg:     #f4f4f4;
  --accent:      #4fc3f7;
  --accent-warm: #ff800d;
  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
  --font-mono:   "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
                 monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg:          #fff;
    --fg-muted:    #999;
    --fg-faint:    #666;
    --bg:          #000;
    --rule:        #333;
    --code-bg:     #111;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Header */
.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 72rem;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-sans);
}

.site-title {
  color: var(--fg);
  text-decoration: none;
  display: flex;
  align-items: center;
}

.site-title:hover {
  opacity: 0.7;
}

.site-lockup {
  height: 24px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-links a:hover {
  color: var(--fg);
}

.nav-sep {
  width: 1px;
  height: 1em;
  background: var(--rule);
}

.nav-spacer {
  flex: 1;
}

/* Main content */
main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem;
}

article h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

article h2 {
  font-size: 1.4rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

article h3 {
  font-size: 1.15rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

article p {
  margin-bottom: 1rem;
}

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

article a:hover {
  text-decoration: underline;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}

th, td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  text-align: left;
}

th {
  background: var(--code-bg);
  font-weight: 600;
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--rule);
  max-width: 100%;
}

pre code {
  background: none;
  padding: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Footer */
footer {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--fg-faint);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-mark {
  height: 16px;
  width: auto;
  opacity: 0.4;
}

.footer-mark:hover {
  opacity: 0.7;
}

.footer-sep {
  width: 1px;
  height: 1em;
  background: var(--rule);
}

.footer-right {
  margin-left: auto;
}

footer a {
  color: var(--fg-faint);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

.footer-brand {
  border-bottom: none;
}

footer a:hover {
  color: var(--fg);
}

/* Lists */
ul, ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.25rem;
}

/* Spec layout — sidebar TOC + content */

.spec-layout {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 3rem;
  align-items: start;
}

.spec-toc {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  font-size: 0.8rem;
  padding-right: 1rem;
  border-right: 1px solid var(--rule);
}

.toc-collapse {
  border: none;
}

.toc-collapse summary {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.toc-collapse summary::-webkit-details-marker {
  display: none;
}

.toc-collapse[open] summary {
  margin-bottom: 0.75rem;
}

.spec-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.spec-toc li {
  margin-bottom: 0.3rem;
}

.spec-toc a {
  color: var(--fg-muted);
  text-decoration: none;
  display: block;
  padding: 0.15rem 0;
  line-height: 1.3;
}

.spec-toc a:hover {
  color: var(--fg);
}

.toc-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.toc-footer a {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.toc-footer a:hover {
  color: var(--fg);
}

.spec-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.spec-header h1 {
  margin-bottom: 0.5rem;
}

.spec-meta {
  color: var(--fg-muted);
  font-size: 0.9rem;
  display: flex;
  gap: 1.5rem;
}

.spec-meta a {
  color: var(--fg-muted);
  text-decoration: none;
}

.spec-meta a:hover {
  color: var(--fg);
}

.spec-body {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  overflow-x: auto;
}

.spec-body h2 {
  font-size: 1.5rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.spec-body h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.spec-body h3 {
  font-size: 1.2rem;
  margin-top: 2rem;
}

.spec-body h4 {
  font-size: 1.05rem;
  margin-top: 1.5rem;
}

/* Blockquotes (notes, warnings in spec) */
blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--fg-muted);
  background: var(--code-bg);
  border-radius: 0 4px 4px 0;
}

/* Definition-like bold terms in spec */
.spec-body dt {
  font-weight: 600;
  margin-top: 0.5rem;
}

.spec-body dd {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

/* License page */
.license-text {
  max-width: 40rem;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.7;
}

/* Responsive */
@media (max-width: 900px) {
  .spec-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .spec-toc {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding: 0 0 1rem;
    margin-bottom: 2rem;
  }

  .toc-collapse summary {
    cursor: pointer;
    list-style: revert;
  }

  .toc-collapse summary::-webkit-details-marker {
    display: revert;
  }

  .toc-collapse:not([open]) + .toc-footer {
    display: none;
  }

  main {
    max-width: 48rem;
  }
}

@media (max-width: 640px) {
  .site-header nav {
    padding: 0.75rem 1rem;
  }

  main {
    padding: 1rem;
  }

  footer {
    padding: 1.5rem 1rem 2.5rem;
  }
}
