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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #0a0a14;
    color: #c8ccd4;
    font-family: "Trebuchet MS", Trebuchet, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Navigation === */
nav {
    background-color: #0d0d1a;
    border-bottom: 1px solid #1e1e3a;
    padding: 0.8rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav .logo {
    font-family: "Trebuchet MS", Trebuchet, sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #e2e8f0;
    text-decoration: none;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

nav .logo .nav-logo {
    height: 2.4rem;
    width: auto;
    display: block;
}

nav .logo .dot {
    color: #38bdf8;
    margin-left: -0.35em;
}

.hero-logo {
    display: block;
    width: 320px;
    height: auto;
    margin: 0 auto 1.5rem;
    filter: drop-shadow(0 0 18px rgba(125, 217, 86, 0.25));
}

nav .nav-links {
    display: flex;
    gap: 1.8rem;
    list-style: none;
}

nav .nav-links a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
    position: relative;
}

nav .nav-links a:hover,
nav .nav-links a.active {
    color: #7dd956;
}

nav .nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: #7dd956;
    transition: width 0.2s;
}

nav .nav-links a:hover::after,
nav .nav-links a.active::after {
    width: 100%;
}

/* === Main Content === */
main {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 3rem 2rem;
    flex: 1;
}

/* === Hero Section === */
.hero {
    text-align: center;
    padding: 4rem 0 3rem;
    border-bottom: 1px solid #1e1e3a;
    margin-bottom: 3rem;
}

.hero h1 {
    font-family: "Trebuchet MS", Trebuchet, sans-serif;
    font-size: 3rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.04em;
    margin-bottom: 0.8rem;
}

.hero h1 .dot {
    color: #38bdf8;
}

.hero .tagline {
    font-size: 1.15rem;
    color: #7dd956;
    margin-bottom: 1.5rem;
}

.hero .description {
    font-size: 0.95rem;
    color: #8892a4;
    max-width: 650px;
    margin: 0 auto;
    line-height: 1.8;
}

/* === Section Headings === */
h2 {
    color: #7dd956;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    margin-top: 2.5rem;
}

h3 {
    color: #38bdf8;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    margin-top: 1.5rem;
}

/* === Text & Links === */
p {
    margin-bottom: 1rem;
    color: #c8ccd4;
}

a {
    color: #38bdf8;
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #7dd3fc;
    text-decoration: underline;
}

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

.card {
    background: #0f0f1e;
    border: 1px solid #1e1e3a;
    border-radius: 8px;
    padding: 1.8rem;
    transition: border-color 0.2s, transform 0.2s;
    text-decoration: none;
    display: block;
}

.card:hover {
    border-color: #7dd956;
    transform: translateY(-2px);
    text-decoration: none;
}

.card h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.card p {
    color: #8892a4;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.card .arrow {
    color: #7dd956;
    font-size: 0.85rem;
    margin-top: 1rem;
    display: block;
}

/* === Feature List === */
.features {
    list-style: none;
    margin-top: 1rem;
}

.features li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #1a1a2e;
    color: #c8ccd4;
    font-size: 0.95rem;
}

.features li::before {
    content: "→ ";
    color: #7dd956;
    font-weight: bold;
}

/* === Code Block === */
.code-block {
    background: #0d0d1a;
    border: 1px solid #1e1e3a;
    border-radius: 6px;
    padding: 1.2rem 1.5rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.88rem;
    line-height: 1.6;
}

.code-block code {
    color: #c8ccd4;
    white-space: pre-wrap;
}

.code-block .comment {
    color: #5c6370;
}

.code-block .keyword {
    color: #c678dd;
}

.code-block .string {
    color: #98c379;
}

/* === Footer === */
footer {
    border-top: 1px solid #1e1e3a;
    padding: 1.5rem 2rem;
    text-align: center;
    font-size: 0.82rem;
    color: #5c6370;
}

footer a {
    color: #7dd956;
}

/* === Documentation Page === */
.doc-placeholder {
    text-align: center;
    padding: 5rem 2rem;
}

.doc-placeholder .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.doc-placeholder h2 {
    color: #f1f5f9;
    margin-top: 0;
}

.doc-placeholder p {
    color: #5c6370;
    font-size: 0.95rem;
}

/* === Inline Code === */
code {
    font-family: "Trebuchet MS", Trebuchet, sans-serif;
    font-size: 0.88em;
}

p code, li code, td code {
    background: #151525;
    border: 1px solid #1e1e3a;
    border-radius: 4px;
    padding: 0.15em 0.4em;
    color: #e5c07b;
    font-size: 0.85em;
}

/* === Table of Contents === */
.toc {
    background: #0d0d1a;
    border: 1px solid #1e1e3a;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    margin: 2rem 0 3rem;
}

.toc h3 {
    color: #e2e8f0;
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.toc ol {
    counter-reset: toc-counter;
    list-style: none;
    padding-left: 0;
}

.toc > ol > li {
    counter-increment: toc-counter;
    margin-bottom: 0.4rem;
}

.toc > ol > li > a {
    color: #7dd956;
    font-weight: 600;
    font-size: 0.92rem;
}

.toc ol ol {
    padding-left: 1.5rem;
    margin-top: 0.3rem;
    margin-bottom: 0.6rem;
}

.toc ol ol li {
    margin-bottom: 0.2rem;
}

.toc ol ol a {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 400;
}

.toc a:hover {
    color: #7dd3fc;
}

/* === Callout Boxes === */
.callout {
    background: #0f1525;
    border-left: 4px solid #38bdf8;
    border-radius: 0 6px 6px 0;
    padding: 1rem 1.3rem;
    margin: 1.2rem 0;
    font-size: 0.92rem;
    line-height: 1.7;
}

.callout strong {
    color: #38bdf8;
}

.callout-key {
    background: #0f1a12;
    border-left-color: #7dd956;
}

.callout-key strong {
    color: #7dd956;
}

.callout-warning {
    background: #1a1510;
    border-left-color: #f59e0b;
}

.callout-warning strong {
    color: #f59e0b;
}

/* === Example Boxes === */
.example-box {
    background: #0d0d1a;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    padding: 1.2rem 1.5rem;
    margin: 1.2rem 0;
    position: relative;
}

.example-label {
    display: inline-block;
    background: #7dd956;
    color: #0a0a14;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.6rem;
    border-radius: 3px;
    margin-bottom: 0.7rem;
}

.example-box p:last-child,
.example-box .code-block:last-child {
    margin-bottom: 0;
}

/* === Screenshot Placeholders === */
.screenshot-placeholder {
    background: #0a0a14;
    border: 2px dashed #2a2a4a;
    border-radius: 8px;
    padding: 2rem 1.5rem;
    margin: 1.5rem 0;
    text-align: center;
}

.screenshot-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.screenshot-placeholder p {
    color: #5c6370;
    font-size: 0.85rem;
    font-style: italic;
    margin-bottom: 0;
}

/* === Documentation Tables === */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem;
    font-size: 0.9rem;
}

.doc-table th {
    background: #0f0f1e;
    color: #7dd956;
    font-weight: 600;
    text-align: left;
    padding: 0.7rem 1rem;
    border-bottom: 2px solid #2a2a4a;
}

.doc-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #1e1e3a;
    color: #c8ccd4;
    vertical-align: top;
}

.doc-table tr:hover td {
    background: #0d0d1a;
}

.doc-table td strong {
    color: #e2e8f0;
}

/* === H4 Heading === */
h4 {
    color: #e5c07b;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
}

/* === Chapter Book Styles === */
.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.chapter-card {
    display: flex;
    align-items: flex-start;
    gap: 1.2rem;
    background: rgba(30, 30, 58, 0.4);
    border: 1px solid #1e1e3a;
    border-radius: 8px;
    padding: 1.2rem 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, background 0.2s;
}

.chapter-card:hover {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.05);
}

.chapter-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #38bdf8;
    min-width: 2.5rem;
    line-height: 1.3;
}

.chapter-content h3 {
    color: #e2e8f0;
    font-size: 1.05rem;
    margin-bottom: 0.3rem;
}

.chapter-content p {
    color: #8b8fa3;
    font-size: 0.9rem;
    margin: 0;
}

.chapter-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.3rem;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #1e1e3a;
    gap: 1rem;
}

.chapter-nav a {
    color: #38bdf8;
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border: 1px solid #1e1e3a;
    border-radius: 6px;
    transition: border-color 0.2s, background 0.2s;
}

.chapter-nav a:hover {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
}

.chapter-nav-prev {
    margin-right: auto;
}

.chapter-nav-next {
    margin-left: auto;
}

/* === Illustration Images === */
.illustration {
    display: block;
    width: 100%;
    margin: 1.5rem auto;
    border-radius: 10px;
    border: 1px solid #1e1e3a;
}

.illustration.img-agent-loop {
    max-width: 360px;
}

.illustration.img-pipeline {
    max-width: 440px;
}

.illustration.img-version0 {
    max-width: 520px;
}

/* Excalidraw diagram screenshots */
.illustration.img-ch1-simple-workflow {
    max-width: 750px;
}

.illustration.img-ch2-template-prompts {
    max-width: 560px;
}

.illustration.img-ch2-tool-assignment {
    max-width: 750px;
}

.illustration.img-react-loop {
    max-width: 600px;
}

.illustration.img-ch2-full-llm-config {
    max-width: 600px;
}

.illustration.img-ch3-pipeline {
    max-width: 750px;
}

.illustration.img-single-agent {
    max-width: 400px;
}

.illustration.img-ch3-fanout {
    max-width: 550px;
}

.illustration.img-ch3-hierarchy {
    max-width: 550px;
}

.illustration.img-ch3-cyclic {
    max-width: 500px;
}

.illustration.img-ch4-static {
    max-width: 400px;
}

.illustration.img-ch4-conditional {
    max-width: 450px;
}

.illustration.img-ch4-tool-driven {
    max-width: 500px;
}

.illustration.img-ch4-iterative {
    max-width: 500px;
}

.illustration.img-ch7-ctf {
    max-width: 650px;
}

.illustration.img-ch1-pipeline {
    max-width: 700px;
}

.illustration.img-ch6-pipeline,
.illustration.img-ch6-router,
.illustration.img-ch6-worker,
.illustration.img-ch6-loop {
    max-width: 550px;
}

.illustration.img-ch3-router {
    max-width: 680px;
}

.illustration.img-ch3-combined-topology {
    max-width: 800px;
}

/* === FAQ === */
.faq {
    margin-top: 1rem;
}

.faq-item {
    background: #0f0f1e;
    border: 1px solid #1e1e3a;
    border-radius: 8px;
    margin-bottom: 0.6rem;
    overflow: hidden;
}

.faq-item:hover {
    border-color: #2a2a4a;
}

.faq-item[open] {
    border-color: #38bdf8;
}

.faq-item summary {
    padding: 1rem 1.3rem;
    cursor: pointer;
    font-weight: 600;
    color: #e2e8f0;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: "+";
    font-size: 1.2rem;
    color: #38bdf8;
    flex-shrink: 0;
}

.faq-item[open] summary::after {
    content: "−";
}

.faq-item p {
    padding: 0 1.3rem 1.2rem;
    margin: 0;
    color: #8892a4;
    font-size: 0.95rem;
    line-height: 1.7;
}

.faq-item p a {
    color: #38bdf8;
}

/* === Responsive === */
@media (max-width: 600px) {
    nav {
        flex-direction: column;
        gap: 0.8rem;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero .tagline {
        font-size: 1rem;
    }

    main {
        padding: 2rem 1rem;
    }

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