/* ===== Case study pages (uses the variables in style.css) ===== */
:root {
    --cs-glow: rgba(245, 245, 245, 0.06);
    --cs-line: rgba(245, 245, 245, 0.14);
}

body.cs-body { background: var(--bg); color: var(--muted); }

/* Undo homepage layout rules that also target <main> */
.cs-body main { max-width: none; margin: 0; padding: 0; }

/* Top bar */
.cs-topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px clamp(20px, 5vw, 48px);
    background: rgba(2, 4, 10, 0.8); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.cs-logo {
    font-family: var(--mono), monospace; font-weight: 700; font-size: 0.85rem;
    color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 3px 8px;
}
.cs-back { font-family: var(--mono), monospace; font-size: 0.8rem; color: var(--muted); }
.cs-back:hover { color: var(--accent); }

/* Hero */
.cs-hero {
    position: relative; overflow: hidden;
    padding: clamp(56px, 9vw, 110px) clamp(20px, 5vw, 48px) 56px;
    border-bottom: 1px solid var(--border);
}
.cs-hero::before {
    content: ""; position: absolute; top: -280px; right: -180px; width: 680px; height: 680px;
    background: radial-gradient(circle, var(--cs-glow), transparent 65%); pointer-events: none;
}
.cs-hero-inner { position: relative; max-width: 1100px; margin: 0 auto; }
.cs-eyebrow { font-family: var(--mono), monospace; font-size: 0.8rem; color: var(--accent); }
.cs-hero h1 {
    color: var(--text); font-size: clamp(2.2rem, 5.2vw, 3.6rem); line-height: 1.08;
    margin: 0.9rem 0 1.25rem; max-width: 20ch;
}
.cs-lede { font-size: clamp(1rem, 2vw, 1.2rem); line-height: 1.6; max-width: 62ch; margin: 0; }
.cs-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.5rem; }
.cs-tags span {
    font-family: var(--mono), monospace; font-size: 0.72rem; color: var(--text);
    border: 1px solid var(--border); background: var(--bg-alt); border-radius: 999px; padding: 0.3rem 0.75rem;
}
.cs-facts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px;
    margin: 2.5rem 0 0; background: var(--border); border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden;
}
.cs-facts div { background: var(--bg-alt); padding: 1.1rem 1.25rem; }
.cs-facts dt {
    font-family: var(--mono), monospace; font-size: 0.68rem; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.35rem;
}
.cs-facts dd { margin: 0; color: var(--text); font-size: 0.95rem; }

/* Layout + sidebar */
.cs-layout {
    max-width: 1100px; margin: 0 auto; padding: 4rem clamp(20px, 5vw, 48px) 2.5rem;
    display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 4rem;
}
.cs-toc { position: sticky; top: 90px; align-self: start; font-family: var(--mono), monospace; font-size: 0.75rem; }
.cs-toc p { text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 0.75rem; }
.cs-toc a {
    display: block; padding: 0.45rem 0 0.45rem 0.9rem; color: var(--muted);
    border-left: 1px solid var(--border); transition: color 0.2s, border-color 0.2s;
}
.cs-toc a:hover, .cs-toc a.active { color: var(--accent); border-left-color: var(--accent); transform: none; }
.cs-body .cs-content { max-width: 700px; }

/* Sections */
.cs-section { margin-bottom: 4.5rem; scroll-margin-top: 90px; }
.cs-num { font-family: var(--mono), monospace; font-size: 0.85rem; color: var(--accent); }
.cs-section h2 {
    display: flex; align-items: center; gap: 1rem;
    color: var(--text); font-size: clamp(1.35rem, 3vw, 1.7rem); margin: 0.3rem 0 1.1rem;
}
.cs-section h2::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.cs-section p, .cs-section li { font-size: 1rem; line-height: 1.75; }
.cs-section strong { color: var(--text); font-weight: 600; }
.cs-list { list-style: none; padding: 0; margin: 0; }
.cs-list li { position: relative; padding-left: 1.5rem; margin-bottom: 0.9rem; }
.cs-list li::before { content: "▹"; position: absolute; left: 0; color: var(--accent); }

/* Callout */
.cs-callout {
    margin: 1.75rem 0; padding: 1.25rem 1.5rem; color: var(--text);
    background: linear-gradient(135deg, var(--cs-glow), transparent);
    border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px;
}
.cs-callout-label {
    display: block; font-family: var(--mono), monospace; font-size: 0.7rem;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.35rem;
}

/* Code */
.cs-body code {
    font-family: var(--mono), monospace; font-size: 0.88em; color: var(--text);
    background: var(--bg-alt); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px;
}
.cs-code { margin: 1.1rem 0; background: #000; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cs-code-bar {
    display: flex; align-items: center; gap: 6px; padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border); font-family: var(--mono), monospace; font-size: 0.7rem;
}
.cs-code-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.cs-code-bar span { margin-left: 0.5rem; }
.cs-code pre { margin: 0; padding: 1.1rem; overflow-x: auto; font-size: 0.8rem; line-height: 1.6; }
.cs-code pre code { background: none; border: 0; padding: 0; color: var(--text); }

/* Cards */
.cs-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.9rem; margin: 1.4rem 0; }
.cs-card {
    background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.cs-card:hover { transform: translateY(-3px); border-color: var(--cs-line); }
.cs-card h3 { color: var(--text); font-size: 1rem; margin: 0 0 0.4rem; }
.cs-card p { font-size: 0.9rem; line-height: 1.6; margin: 0; }
.cs-big { display: block; font-family: var(--mono), monospace; font-size: 1.6rem; color: var(--text); margin-bottom: 0.25rem; }

/* Pipeline diagram */
.cs-flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; margin: 1.6rem 0; counter-reset: step; }
.cs-flow div {
    position: relative; background: var(--bg-alt); border: 1px solid var(--border);
    border-radius: 8px; padding: 1.1rem 1rem; font-size: 0.88rem; line-height: 1.5;
}
.cs-flow div::before {
    counter-increment: step; content: "0" counter(step); display: block;
    font-family: var(--mono), monospace; font-size: 0.7rem; color: var(--muted); margin-bottom: 0.5rem;
}
.cs-flow div:not(:last-child)::after {
    content: "→"; position: absolute; top: 50%; right: -7px; transform: translate(50%, -50%);
    color: var(--accent); z-index: 1;
}
.cs-flow strong { display: block; color: var(--text); margin-bottom: 0.25rem; }

/* Live stats */
.cs-live { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin: 1.4rem 0 0.6rem; }
.cs-live div { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.cs-live b { display: block; font-family: var(--mono), monospace; font-size: 1.5rem; font-weight: 600; color: var(--text); }
.cs-live span { font-size: 0.8rem; }
.cs-live-note { display: flex; align-items: center; gap: 0.5rem; font-family: var(--mono), monospace; font-size: 0.72rem; }
.cs-live-note::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.cs-live-note.on::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* Table */
.cs-table {
    width: 100%; border-collapse: separate; border-spacing: 0; margin: 1.25rem 0; font-size: 0.9rem;
    background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.cs-table th, .cs-table td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.cs-table tr:last-child td { border-bottom: 0; }
.cs-table th {
    font-family: var(--mono), monospace; font-size: 0.68rem; font-weight: 400;
    text-transform: uppercase; letter-spacing: 0.08em;
}
.cs-swatch { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); white-space: nowrap; }
.cs-swatch::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--sw); }

/* Numbered steps */
.cs-steps { list-style: none; padding: 0; margin: 1.4rem 0; counter-reset: s; }
.cs-steps li {
    display: flex; align-items: center; gap: 0.9rem; margin-bottom: 0.5rem; padding: 0.75rem 1rem;
    background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem;
}
.cs-steps li::before {
    counter-increment: s; content: counter(s); flex: none; display: grid; place-items: center;
    width: 26px; height: 26px; border-radius: 50%; font-family: var(--mono), monospace; font-size: 0.75rem;
    color: var(--bg); background: var(--sw, var(--muted));
}

/* Next case study */
.cs-next {
    display: block; margin-top: 1.5rem; padding: 1.75rem;
    background: var(--bg-alt); border: 1px solid var(--border); border-radius: 10px;
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.cs-next:hover { border-color: var(--accent); }
.cs-next small { font-family: var(--mono), monospace; font-size: 0.75rem; color: var(--muted); }
.cs-next strong { display: block; margin-top: 0.4rem; font-size: 1.35rem; color: var(--text); }
.cs-footer { text-align: center; padding: 2.5rem 1.25rem 3.5rem; margin: 0; font-family: var(--mono), monospace; font-size: 0.7rem; }

/* Scroll reveal (only when JS runs) */
.cs-js .cs-reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.cs-js .cs-reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
    .cs-js .cs-reveal { opacity: 1; transform: none; transition: none; }
}

/* Mobile */
@media (max-width: 860px) {
    .cs-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .cs-toc { display: none; }
    .cs-flow { grid-template-columns: 1fr 1fr; }
    .cs-flow div::after { display: none; }
}
@media (max-width: 520px) {
    .cs-flow { grid-template-columns: minmax(0, 1fr); }
}