/* ===========================================================================
   Recoil docs — visual system
   "Machine & human": a monospace voice (Iosevka) for everything the compiler
   touches — headings, nav, labels, code — and a humanist sans (IBM Plex Sans)
   for prose. Warm forge ink + a single ember accent. The `!` type sigil is the
   recurring section marker.
   Note: original CSS variable *names* are preserved (HTML inline styles depend
   on them); only their values changed, plus a few additions.
   =========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

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

:root {
    /* Forge ink surfaces (warm near-black, not cool GitHub black) */
    --bg-primary: #14110d;
    --bg-secondary: #1c1813;
    --bg-tertiary: #241e17;
    --border: #352c22;

    /* Warm type */
    --text-primary: #f4eee3;
    --text-secondary: #cfc3b0;
    --text-muted: #968673;

    /* Accents — names kept; values are the new forge set.
       --accent-red carries the ember (it drives code keywords/operators). */
    --accent-blue: #76b6c4;   /* steel — links, subheads, types */
    --accent-green: #5ca86b;  /* success */
    --accent-purple: #cBa4d6; /* mauve — functions, h4 */
    --accent-orange: #ffc857; /* spark — numbers */
    --accent-red: #ff6a3d;    /* ember — keywords / operators */
    --accent-teal: #9dc27a;   /* sage — strings */

    /* The signature accent, used deliberately and sparingly */
    --ember: #ff6a3d;
    --ember-soft: #ff8a5c;
    --ember-glow: rgba(255, 106, 61, 0.14);

    --mono: 'Iosevka', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
    --sans: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

html { scroll-behavior: smooth; }

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

/* ---- Header ---------------------------------------------------------------- */

header {
    background:
        radial-gradient(ellipse 70% 120% at 50% -10%, var(--ember-glow) 0%, transparent 60%),
        var(--bg-primary);
    padding: 56px 20px 36px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

/* hairline "anvil" rule the wordmark sits on */
header::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 120px;
    height: 2px;
    transform: translateX(-50%);
    background: var(--ember);
}

.header-content { position: relative; z-index: 1; }

h1 {
    font-family: var(--mono);
    font-size: clamp(2.6rem, 7vw, 4.2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text-primary);
    margin-bottom: 14px;
    line-height: 1;
}

/* the type sigil as a brand mark on the wordmark */
.sigil { color: var(--ember); }

.tagline {
    font-family: var(--sans);
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 640px;
    margin: 0 auto 22px;
    line-height: 1.6;
}

.eyebrow {
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ember);
    margin-bottom: 18px;
}
.eyebrow::before { content: '// '; color: var(--text-muted); }

.badge {
    display: inline-block;
    background: transparent;
    color: var(--ember);
    padding: 5px 14px;
    border: 1px solid var(--ember);
    border-radius: 2px;
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.repo-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--mono);
    font-size: 0.85rem;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 2px;
    transition: all 0.2s ease;
}
.repo-link:hover { color: var(--text-primary); border-color: var(--ember); background: var(--ember-glow); }
.repo-link svg { width: 18px; height: 18px; }

.logo { width: 200px; height: 200px; vertical-align: middle; }

/* ---- Forge hero (source -> C) --------------------------------------------- */

.forge {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    align-items: stretch;
    max-width: 920px;
    margin: 36px auto 0;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-secondary);
}
.forge-pane { padding: 18px 20px; min-width: 0; }
.forge-pane + .forge-pane { border-left: 1px solid var(--border); }
.forge-label {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.forge-label .dot { color: var(--ember); }
.forge pre { margin: 0; background: none; border: 0; padding: 0; }
.forge pre code { font-size: 0.82rem; }
.forge-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    color: var(--ember);
    font-family: var(--mono);
    font-size: 1.3rem;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

@media (max-width: 760px) {
    .forge { grid-template-columns: 1fr; }
    .forge-pane + .forge-pane { border-left: 0; border-top: 1px solid var(--border); }
    .forge-arrow { border: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 8px; transform: rotate(90deg); }
}

/* ---- Layout w/ TOC -------------------------------------------------------- */

.content-wrapper {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 48px;
    align-items: start;
    max-width: 1500px;
    margin: 0 auto;
    padding: 30px;
}

.toc {
    position: sticky;
    top: 84px;
    background: transparent;
    padding: 4px 0 4px 16px;
    border-left: 1px solid var(--border);
    max-height: calc(100vh - 120px);
    overflow: auto;
}
.toc h4 {
    font-family: var(--mono);
    color: var(--text-muted);
    margin: 0 0 12px;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.toc a {
    display: block;
    font-family: var(--mono);
    color: var(--text-muted);
    text-decoration: none;
    padding: 5px 0 5px 12px;
    border-left: 2px solid transparent;
    margin-left: -16px;
    font-size: 0.85rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.toc a:hover, .toc a.active { color: var(--ember); border-left-color: var(--ember); background: none; }
.toc .toc-sub { padding-left: 22px; font-size: 0.85rem; color: var(--text-secondary); }

@media (max-width: 1100px) {
    .content-wrapper { grid-template-columns: 1fr; padding: 0 20px; }
    .toc { position: relative; top: auto; max-height: none; margin-bottom: 18px; border-left: 0; padding-left: 0; }
    .toc a { margin-left: 0; }
    main { max-width: 100%; }
}
@media (min-width: 1500px) {
    .content-wrapper { max-width: 1700px; }
    main { max-width: 1180px; }
}

/* ---- Nav ------------------------------------------------------------------ */

nav {
    background: rgba(20, 17, 13, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}
nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    max-width: 1280px;
    margin: 0 auto;
}
nav a {
    font-family: var(--mono);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.82rem;
    padding: 7px 12px;
    border-radius: 2px;
    transition: all 0.15s ease;
}
nav a:hover { color: var(--text-primary); }
nav a.active { color: var(--ember); }
nav a.active::before { content: '!'; color: var(--ember); margin-right: 3px; font-weight: 700; }

/* ---- Main / sections ------------------------------------------------------ */

main { max-width: 1080px; margin: 0 auto; padding: 44px 20px 90px; }

section {
    margin-bottom: 64px;
    opacity: 0;
    transform: translateY(16px);
    animation: fadeInUp 0.5s ease forwards;
}
@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }
section:nth-child(1) { animation-delay: 0.05s; }
section:nth-child(2) { animation-delay: 0.10s; }
section:nth-child(3) { animation-delay: 0.15s; }
section:nth-child(4) { animation-delay: 0.20s; }
section:nth-child(5) { animation-delay: 0.25s; }
section:nth-child(6) { animation-delay: 0.30s; }
section:nth-child(7) { animation-delay: 0.35s; }
section:nth-child(8) { animation-delay: 0.40s; }
section:nth-child(n+9) { animation-delay: 0.45s; }

/* Headings — mono "machine" voice. The `!` sigil marks each section. */
h2 {
    font-family: var(--mono);
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 22px;
    padding-top: 26px;
    border-top: 1px solid var(--border);
    line-height: 1.15;
}
.content > section:first-child h2,
main > section:first-child h2 { border-top: 0; padding-top: 0; }
h2::before {
    content: '!';
    color: var(--ember);
    font-weight: 800;
    margin-right: 10px;
}

h3 {
    font-family: var(--mono);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-blue);
    margin: 32px 0 14px;
    letter-spacing: -0.01em;
}
h4 {
    font-family: var(--mono);
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--accent-purple);
    margin: 24px 0 10px;
}

p { color: var(--text-secondary); margin-bottom: 15px; }
ul, ol { margin: 15px 0; padding-left: 24px; }
li { margin-bottom: 8px; color: var(--text-secondary); }
li::marker { color: var(--ember); }

/* ---- Code ----------------------------------------------------------------- */

code {
    font-family: var(--mono);
    background: var(--bg-secondary);
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.88em;
    color: var(--accent-blue);
    border: 1px solid var(--border);
}

pre {
    background: var(--bg-secondary);
    padding: 20px 22px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid var(--border);
    position: relative;
}
pre code {
    background: none;
    padding: 0;
    border: 0;
    color: var(--text-secondary);
    display: block;
    line-height: 1.65;
    font-size: 0.88rem;
}

.comment  { color: var(--text-muted); font-style: italic; }
.keyword  { color: var(--accent-red); }
.type     { color: var(--accent-blue); }
.function { color: var(--accent-purple); }
.string   { color: var(--accent-teal); }
.number   { color: var(--accent-orange); }
.operator { color: var(--accent-red); }

/* ---- Pipeline diagram ----------------------------------------------------- */

.pipeline-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 30px 0;
    padding: 22px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.pipeline-stage {
    font-family: var(--mono);
    background: var(--bg-tertiary);
    padding: 10px 16px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.pipeline-arrow { color: var(--ember); font-size: 1.1rem; font-weight: bold; }

/* ---- Tables --------------------------------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th {
    font-family: var(--mono);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
td { color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--ember-glow); }

.copy-type   { color: var(--accent-teal); font-weight: 600; }
.move-type   { color: var(--ember); font-weight: 600; }
.borrow-type { color: var(--accent-purple); font-weight: 600; }

/* ---- Callout boxes -------------------------------------------------------- */

.example-box, .warning-box, .error-box, .success-box {
    background: var(--bg-secondary);
    padding: 18px 20px;
    margin: 20px 0;
    border-radius: 0 4px 4px 0;
    border-left: 3px solid var(--border);
}
.example-box { border-left-color: var(--accent-blue); }
.warning-box { border-left-color: #d29922; }
.error-box   { border-left-color: #f85149; }
.success-box { border-left-color: var(--accent-green); }

/* ---- Cards ---------------------------------------------------------------- */

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    margin: 30px 0;
}
.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 22px;
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.feature-card:hover { transform: translateY(-3px); border-color: var(--ember); }
.feature-card h4 { font-family: var(--mono); color: var(--text-primary); margin: 0 0 9px; font-size: 1.02rem; }
.feature-card p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0; }

/* ---- Links ---------------------------------------------------------------- */

main a, footer a, .feature-card a, .example-box a, .toc a {
    color: var(--accent-blue);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}
main a:hover, footer a:hover, .feature-card a:hover, .example-box a:hover {
    color: var(--ember);
    border-bottom-color: var(--ember);
}
.feature-card a, .toc a { border-bottom: 0; }

.nav-anchor { scroll-margin-top: 76px; }
h2[id], h3[id] { scroll-margin-top: 76px; }

/* ---- Back to top ---------------------------------------------------------- */

.back-to-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 44px;
    height: 44px;
    background: var(--ember);
    color: var(--bg-primary);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    text-decoration: none;
}
.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { background: var(--ember-soft); transform: translateY(-2px); }

/* ---- Footer --------------------------------------------------------------- */

footer {
    text-align: center;
    padding: 44px 20px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}
footer p { color: var(--text-muted); font-size: 0.88rem; font-family: var(--mono); }

/* ---- Multi-page additions ------------------------------------------------- */

.page-header { padding: 30px 20px 24px; }
.page-header .logo { width: 64px; height: 64px; }
.page-header h1 { font-size: clamp(1.8rem, 4vw, 2.3rem); margin-bottom: 4px; }
.page-header .tagline {
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ember);
    margin-bottom: 0;
}
.page-header .tagline::before { content: '// '; color: var(--text-muted); }

.cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.cta {
    display: inline-block;
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 12px 24px;
    border-radius: 3px;
    text-decoration: none;
    border: 1px solid var(--border);
    transition: all 0.18s ease;
}
.cta-primary { background: var(--ember); color: #14110d; border-color: var(--ember); }
.cta-primary:hover { background: var(--ember-soft); border-color: var(--ember-soft); }
.cta-secondary { background: transparent; color: var(--text-primary); }
.cta-secondary:hover { border-color: var(--ember); color: var(--ember); }

.lead { font-size: 1.12rem; color: var(--text-secondary); max-width: 760px; }

.spotlight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: 20px;
    margin: 30px 0;
}
.spotlight-card {
    display: block;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--ember);
    border-radius: 0 4px 4px 0;
    padding: 24px;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.spotlight-card:hover { transform: translateY(-3px); box-shadow: 0 10px 40px -20px var(--ember); text-decoration: none; }
.spotlight-card h3 { margin-top: 0; color: var(--text-primary); }
.spotlight-card p { color: var(--text-muted); }
.spotlight-card pre { margin-bottom: 0; }

/* ---- Accessibility floor -------------------------------------------------- */

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--ember);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0s !important; transition-duration: 0.001ms !important; }
    section { opacity: 1; transform: none; }
}

/* ---- Mobile --------------------------------------------------------------- */

@media (max-width: 768px) {
    h1 { font-size: 2.4rem; }
    .tagline { font-size: 1rem; }
    nav ul { gap: 2px; }
    nav a { padding: 6px 9px; font-size: 0.78rem; }
    section { margin-bottom: 48px; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.1rem; }
    pre { padding: 15px; font-size: 0.85rem; }
    th, td { padding: 10px 12px; font-size: 0.85rem; }
    .feature-grid { grid-template-columns: 1fr; }
    .logo { width: 120px; height: 120px; }
}
