/* Aegis Commons — minimal, typography-forward */

:root {
  --bg: #fafafa;
  --surface: #fff;
  --text: #1a1a1a;
  --text-muted: #555;
  --border: #e0e0e0;
  --accent: #2c5282;
  --focus-ring: #2c5282;
  --max-width: 860px;
  --line-height: 1.65;
  --space: 1.5rem;
  --radius: 4px;
  --nav-height: 3.5rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #252525;
  --text: #e8e8e8;
  --text-muted: #aaa;
  --border: #404040;
  --accent: #7eb8e8;
  --focus-ring: #7eb8e8;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: var(--line-height);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space) var(--space) 3rem;
}

/* Header & nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--nav-height);
  gap: var(--space);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
}

.logo:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.logo-icon {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
}

.logo-icon svg {
  width: 100%;
  height: 100%;
}

.nav-toggle,
.theme-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text);
  border-radius: var(--radius);
}

.nav-toggle:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.nav-toggle {
  flex-direction: column;
  gap: 5px;
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.theme-toggle-icon::before {
  content: "☀";
  font-size: 1.2rem;
}

[data-theme="dark"] .theme-toggle-icon::before {
  content: "☾";
}

.main-nav {
  display: flex;
  align-items: center;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.25rem;
}

.nav-list a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
}

.nav-list a:hover,
.nav-list a[aria-current="page"] {
  color: var(--text);
  background: var(--bg);
}

.nav-list a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .nav-toggle,
  .theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
  }

  .main-nav.is-open {
    max-height: 280px;
  }

  .nav-list {
    flex-direction: column;
    padding: var(--space);
    gap: 0;
  }

  .nav-list a {
    padding: 0.75rem;
  }
}

/* Typography */
h1, h2, h3 {
  line-height: 1.25;
  margin-top: 0;
  margin-bottom: 0.75em;
  font-weight: 600;
}

h1 { font-size: 1.75rem; margin-bottom: 0.5em; }
h2 { font-size: 1.35rem; margin-top: 1.5em; }
h3 { font-size: 1.15rem; margin-top: 1.25em; }

p {
  margin-top: 0;
  margin-bottom: 1em;
}

ul, ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.35em;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.section + .section {
  margin-top: 2rem;
}

/* Page hero */
.page-hero {
  margin-bottom: 2.5rem;
}

.page-hero h1 {
  margin-bottom: 0.25em;
}

/* TOC (whitepaper) */
.toc-layout {
  display: grid;
  gap: 2rem;
}

@media (min-width: 900px) {
  .toc-layout {
    grid-template-columns: 200px 1fr;
  }

  .toc-wrap {
    position: sticky;
    top: calc(var(--nav-height) + 1rem);
    align-self: start;
  }
}

.toc-toggle {
  display: none;
  width: 100%;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.toc-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (max-width: 899px) {
  .toc-toggle {
    display: block;
  }

  .toc-nav {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  .toc-wrap.is-open .toc-nav {
    max-height: 500px;
  }
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
}

.toc-list li {
  margin: 0;
  border-left: 2px solid var(--border);
  padding-left: 0.75rem;
  margin-bottom: 0.35em;
}

.toc-list a {
  color: var(--text-muted);
  display: block;
  padding: 0.2em 0;
}

.toc-list a:hover {
  color: var(--accent);
}

/* FAQ */
.faq-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
}

.faq-item:first-child {
  padding-top: 0;
}

.faq-q {
  font-weight: 600;
  margin-bottom: 0.5em;
}

.faq-a {
  margin: 0;
  color: var(--text-muted);
}

/* Contact */
.contact-form {
  max-width: 32rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.35em;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.form-group textarea {
  min-height: 8rem;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 0;
}

.contact-email {
  margin-bottom: 1.5rem;
}

.contact-email a {
  font-weight: 500;
}

.contact-fallback {
  color: var(--text-muted);
}

.form-actions {
  margin-top: 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  font: inherit;
  font-size: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn:hover {
  opacity: 0.9;
}

.btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Footer */
.site-footer {
  margin-top: auto;
  padding: var(--space);
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-tagline {
  margin: 0 0 0.25em;
}

.footer-copy {
  margin: 0;
}

/* Utility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
