/* ================================================================
   AIP Protocol Documentation Site — Stylesheet
   Brand: Warm orange/amber (#f77f00)
   ================================================================ */

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

:root {
  --aip-orange: #f77f00;
  --aip-amber: #e36414;
  --aip-dark-orange: #c45a10;
  --aip-light-orange: #fff3e0;
  --aip-gold: #fcbf49;

  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-dark: #1a1a2e;
  --bg-darker: #16162a;
  --bg-code: #f5f5f5;

  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted: #8888a0;
  --text-on-dark: #e8e8f0;
  --text-on-orange: #ffffff;

  --border-color: #e0e0e8;
  --border-light: #f0f0f5;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

  --max-width: 1200px;
  --content-width: 800px;
  --nav-height: 64px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 40px rgba(247,127,0,0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--aip-orange); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--aip-amber); }

img { max-width: 100%; height: auto; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 700;
  color: var(--text-primary);
}

h1 { font-size: 2.8rem; letter-spacing: -0.03em; }
h2 { font-size: 2rem; letter-spacing: -0.02em; margin-top: 3rem; margin-bottom: 1rem; }
h3 { font-size: 1.4rem; margin-top: 2rem; margin-bottom: 0.75rem; }
h4 { font-size: 1.15rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

p { margin-bottom: 1rem; }

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  transition: box-shadow 0.3s;
}

.nav.scrolled { box-shadow: var(--shadow-sm); }

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.nav-logo img { width: 32px; height: 32px; }

.nav-logo span { color: var(--aip-orange); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-links a:hover {
  color: var(--aip-orange);
  background: var(--aip-light-orange);
}

.nav-links a.active {
  color: var(--aip-orange);
  background: var(--aip-light-orange);
}

.nav-links a.nav-cta {
  background: var(--aip-orange);
  color: white;
  padding: 0.5rem 1.25rem;
  border-radius: 99px;
  margin-left: 0.5rem;
}

.nav-links a.nav-cta:hover {
  background: var(--aip-amber);
  color: white;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  margin: 5px 0;
  transition: 0.3s;
}

/* --- Hero Section --- */
.hero {
  padding: calc(var(--nav-height) + 5rem) 2rem 5rem;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--aip-light-orange) 100%);
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  padding: 0.35rem 1rem;
  background: var(--aip-light-orange);
  color: var(--aip-orange);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 99px;
  border: 1px solid rgba(247,127,0,0.2);
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: 3.5rem;
  max-width: 800px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--aip-amber) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto 2.5rem;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 4rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 99px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--aip-orange);
  color: white;
  box-shadow: 0 4px 15px rgba(247,127,0,0.3);
}

.btn-primary:hover {
  background: var(--aip-amber);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(247,127,0,0.4);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--aip-orange);
  color: var(--aip-orange);
  transform: translateY(-1px);
}

/* --- Layer Stack Diagram --- */
.layer-stack {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.layer-row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

.layer-label {
  width: 140px;
  text-align: right;
  padding-right: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.layer-bar {
  flex: 1;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  text-align: center;
  position: relative;
}

.layer-payment { background: #6c63ff; }
.layer-commerce { background: #7c4dff; }
.layer-intake { background: var(--aip-orange); box-shadow: var(--shadow-glow); transform: scale(1.03); z-index: 1; }
.layer-comms { background: #26a69a; }
.layer-tool { background: #42a5f5; }
.layer-identity { background: #78909c; }

.layer-intake::after {
  content: 'THIS';
  position: absolute;
  right: -3rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--aip-orange);
  letter-spacing: 0.1em;
}

/* --- Content Sections --- */
.section {
  padding: 5rem 2rem;
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-dark {
  background: var(--bg-dark);
  color: var(--text-on-dark);
  max-width: 100%;
  padding: 5rem 2rem;
}

.section-dark h2,
.section-dark h3 { color: #ffffff; }

.section-dark p { color: var(--text-on-dark); }

.section-dark .section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-alt {
  background: var(--bg-secondary);
  max-width: 100%;
  padding: 5rem 2rem;
}

.section-alt .section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}

.section-header p {
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0.5rem auto 0;
  font-size: 1.1rem;
}

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem;
  transition: all 0.2s;
}

.card:hover {
  border-color: var(--aip-orange);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--aip-light-orange);
  color: var(--aip-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.card h3 { margin-top: 0; font-size: 1.15rem; }

.card p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 0; }

/* --- Code Blocks --- */
pre {
  background: var(--bg-dark);
  color: #e8e8f0;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 1.5rem 0;
  position: relative;
}

pre code {
  font-family: var(--font-mono);
  background: none;
  padding: 0;
  font-size: inherit;
}

code {
  font-family: var(--font-mono);
  background: var(--bg-code);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--aip-amber);
}

.code-block {
  position: relative;
  margin: 1.5rem 0;
}

.code-block .copy-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-on-dark);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.2s;
  z-index: 10;
}

.code-block .copy-btn:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.3);
}

.code-block .copy-btn.copied {
  background: rgba(38,166,154,0.3);
  border-color: rgba(38,166,154,0.5);
  color: #80cbc4;
}

/* --- Lifecycle Diagram --- */
.lifecycle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.lifecycle-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.lifecycle-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--aip-orange);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.lifecycle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.lifecycle-arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
  margin-top: -1.5rem;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

tr:hover td { background: var(--bg-secondary); }

/* --- Prose (white paper, spec) --- */
.prose {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: calc(var(--nav-height) + 3rem) 2rem 5rem;
}

.prose h1 { margin-bottom: 1.5rem; font-size: 2.5rem; }
.prose h2 { padding-top: 1rem; border-top: 1px solid var(--border-light); }
.prose h2:first-of-type { border-top: none; }

.prose ul, .prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.prose li { margin-bottom: 0.35rem; }

.prose blockquote {
  border-left: 4px solid var(--aip-orange);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--aip-light-orange);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.prose blockquote p { margin-bottom: 0; }

/* --- Sidebar TOC (for long pages) --- */
.page-with-toc {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 3rem;
  max-width: calc(var(--content-width) + 300px);
  margin: 0 auto;
  padding: calc(var(--nav-height) + 3rem) 2rem 5rem;
}

.page-with-toc .prose {
  padding: 0;
  max-width: none;
}

.toc {
  position: sticky;
  top: calc(var(--nav-height) + 2rem);
  align-self: start;
  max-height: calc(100vh - var(--nav-height) - 4rem);
  overflow-y: auto;
}

.toc-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.toc a {
  display: block;
  padding: 0.3rem 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  padding-left: 1rem;
  line-height: 1.4;
}

.toc a:hover { color: var(--aip-orange); border-left-color: var(--aip-orange); }
.toc a.active { color: var(--aip-orange); border-left-color: var(--aip-orange); font-weight: 600; }

.toc a.toc-sub { padding-left: 2rem; font-size: 0.82rem; }

/* --- Footer --- */
.footer {
  background: var(--bg-dark);
  color: var(--text-on-dark);
  padding: 3rem 2rem;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer-left img { width: 24px; height: 24px; opacity: 0.7; }

.footer-text { font-size: 0.85rem; color: var(--text-muted); }

.footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--aip-orange); }

/* --- Utilities --- */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-orange { color: var(--aip-orange); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 99px;
}

.badge-orange { background: var(--aip-light-orange); color: var(--aip-orange); }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-blue { background: #e3f2fd; color: #1565c0; }

/* --- Comparison Matrix --- */
.matrix {
  overflow-x: auto;
  margin: 2rem 0;
}

.matrix table { min-width: 700px; }

.matrix th {
  position: sticky;
  top: 0;
  background: var(--bg-primary);
}

.check { color: #2e7d32; font-weight: 700; }
.cross { color: #c62828; }
.partial { color: var(--aip-orange); }

/* --- Responsive --- */
@media (max-width: 768px) {
  .hero h1 { font-size: 2.2rem; }
  .hero-subtitle { font-size: 1.05rem; }
  .hero-actions { flex-direction: column; align-items: center; }

  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
  }
  .nav-toggle { display: block; }

  .layer-stack { padding: 0 1rem; }
  .layer-label { width: 100px; font-size: 0.75rem; }
  .layer-bar { font-size: 0.8rem; padding: 0.6rem 0.75rem; }
  .layer-intake::after { display: none; }

  .lifecycle { gap: 0.25rem; }
  .lifecycle-circle { width: 45px; height: 45px; font-size: 0.65rem; }
  .lifecycle-arrow { font-size: 1rem; }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.6rem; }

  .page-with-toc {
    grid-template-columns: 1fr;
  }
  .toc { display: none; }

  .card-grid { grid-template-columns: 1fr; }

  .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
  .hero { padding: calc(var(--nav-height) + 3rem) 1rem 3rem; }
  .hero h1 { font-size: 1.8rem; }
  .section { padding: 3rem 1rem; }
  .prose { padding: calc(var(--nav-height) + 2rem) 1rem 3rem; }
}
