/* ─── Animated demo on docs/index.md ───────────────────────────────── */

.perch-demo {
    --bg:       #0f1320;
    --fg:       #e2e8f5;
    --muted:    #7a8aa8;
    --accent:   #fcd34d;
    --green:    #6cf2a4;
    --blue:     #93c5fd;
    --magenta:  #f0a0ff;
    --border:   #1e2540;

    margin: 1.5rem 0 2.5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--fg);
    font-family: ui-monospace, "JetBrains Mono", "Fira Code", monospace;
    overflow: hidden;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}

.perch-demo__chrome {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #161b2e;
    border-bottom: 1px solid var(--border);
}

.perch-demo__chrome .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4a5a76;
}
.perch-demo__chrome .dot.red    { background: #ff5f57; }
.perch-demo__chrome .dot.yellow { background: #febc2e; }
.perch-demo__chrome .dot.green  { background: #28c840; }

.perch-demo__title {
    margin-left: 8px;
    color: var(--muted);
    font-size: 13px;
}

.perch-demo__stage {
    position: relative;
    min-height: 380px;
    padding: 18px 20px 18px;
}

.perch-demo__slide {
    position: absolute;
    inset: 18px 20px 18px;
    opacity: 0;
    transition: opacity 280ms ease;
    pointer-events: none;
}

.perch-demo__slide.is-active {
    opacity: 1;
    pointer-events: auto;
}

.perch-demo__caption {
    color: var(--accent);
    font-size: 13px;
    margin-bottom: 12px;
    letter-spacing: 0.02em;
}

.perch-demo__body {
    white-space: pre-wrap;
    font-size: 13.5px;
    line-height: 1.55;
    min-height: 260px;
}

.perch-demo__cursor::after {
    content: "▌";
    color: var(--accent);
    margin-left: 1px;
    animation: perchBlink 1.05s steps(2) infinite;
}

@keyframes perchBlink {
    50% { opacity: 0; }
}

.perch-demo__body .kw      { color: var(--magenta); }
.perch-demo__body .str     { color: var(--green); }
.perch-demo__body .num     { color: var(--blue); }
.perch-demo__body .prompt  { color: var(--muted); }
.perch-demo__body .out     { color: var(--fg); }
.perch-demo__body .ok      { color: var(--green); }
.perch-demo__body .info    { color: var(--blue); }
.perch-demo__body .heading { color: var(--accent); }
.perch-demo__body .dim     { color: var(--muted); }
.perch-demo__body .url     { color: var(--blue); text-decoration: underline; }

.perch-demo__dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 8px 0 12px;
    background: var(--bg);
}

.perch-demo__dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2a3556;
    transition: background 200ms ease, transform 200ms ease;
    cursor: pointer;
}

.perch-demo__dots span.is-active {
    background: var(--accent);
    transform: scale(1.25);
}

/* Browser mock frame for the --server slide */
.perch-demo__browser {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #1a2138;
    margin: 6px 0;
    font-size: 12.5px;
}
.perch-demo__browser-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
}
.perch-demo__browser-bar .b-dot { width: 8px; height: 8px; border-radius: 50%; background: #4a5a76; }
.perch-demo__browser-body {
    padding: 14px 16px;
    line-height: 1.7;
}
.perch-demo__browser-body .h1 {
    font-size: 16px;
    color: var(--fg);
    margin-bottom: 6px;
}
.perch-demo__browser-body .row {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #243056;
}
.perch-demo__browser-body .row:last-child { border-bottom: none; }
.perch-demo__browser-body .btn {
    color: var(--bg);
    background: var(--accent);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
}
.perch-demo__browser-body .label {
    color: var(--muted);
    font-size: 12px;
}

/* ─── Feature grid on docs/index.md ────────────────────────────────── */

.perch-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 1.5rem 0;
}

.perch-features .card {
    border: 1px solid rgba(120, 130, 180, 0.18);
    border-radius: 8px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.02);
}
[data-md-color-scheme="slate"] .perch-features .card {
    background: rgba(255, 255, 255, 0.04);
}

.perch-features .card h4 {
    margin: 0 0 6px;
    font-size: 14px;
    letter-spacing: 0.01em;
    color: var(--md-primary-fg-color);
}

.perch-features .card p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--md-default-fg-color--light);
}

/* ─── CTA buttons under the hero demo ──────────────────────────────── */

.perch-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 1.5rem 0 2rem;
}

.perch-cta a {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.perch-cta a:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.perch-cta__primary {
    background: var(--md-primary-fg-color);
    color: #fff !important;
}

.perch-cta__secondary {
    border: 1px solid rgba(120, 130, 180, 0.35);
    color: var(--md-default-fg-color) !important;
    background: transparent;
}

/* ─── Persona cards ────────────────────────────────────────────────── */

.perch-personas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin: 1.25rem 0 1.5rem;
}

.perch-personas .persona {
    border-left: 3px solid var(--md-primary-fg-color);
    padding: 8px 14px 8px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 6px 6px 0;
}
[data-md-color-scheme="slate"] .perch-personas .persona {
    background: rgba(255, 255, 255, 0.04);
}

.perch-personas .persona h4 {
    margin: 0 0 4px;
    font-size: 14px;
    color: var(--md-primary-fg-color);
}

.perch-personas .persona p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--md-default-fg-color--light);
}

/* ─── Pain-point checklist ─────────────────────────────────────────── */

.perch-pain {
    background: rgba(252, 211, 77, 0.06);
    border-left: 3px solid #fcd34d;
    border-radius: 0 6px 6px 0;
    padding: 6px 18px;
    margin: 1.25rem 0;
}

.perch-pain ul {
    margin: 8px 0;
}

.perch-pain li {
    margin: 4px 0;
    font-size: 14px;
}

/* ─── Use-case blocks ──────────────────────────────────────────────── */

.perch-usecase {
    border: 1px solid rgba(120, 130, 180, 0.18);
    border-radius: 8px;
    padding: 14px 18px;
    margin: 1rem 0 1.5rem;
    background: rgba(255, 255, 255, 0.02);
}
[data-md-color-scheme="slate"] .perch-usecase {
    background: rgba(255, 255, 255, 0.03);
}

.perch-usecase p:first-child {
    margin-top: 0;
}

.perch-usecase p:last-child {
    margin-bottom: 0;
}

/* ─── Comparison table ─────────────────────────────────────────────── */

.perch-compare-wrap {
    overflow-x: auto;
    margin: 1rem 0 1.5rem;
}

.perch-compare-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.perch-compare-wrap th,
.perch-compare-wrap td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(120, 130, 180, 0.18);
    text-align: center;
}

.perch-compare-wrap th:first-child,
.perch-compare-wrap td:first-child {
    text-align: left;
    font-weight: 500;
}

.perch-compare-wrap th {
    color: var(--md-primary-fg-color);
    border-bottom: 2px solid rgba(120, 130, 180, 0.3);
}

/* ─── "Where to next" persona-specific cards ───────────────────────── */

.perch-next {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 1.25rem 0 1.5rem;
}

.perch-next .next {
    border: 1px solid rgba(120, 130, 180, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
}

.perch-next .next h4 {
    margin: 0 0 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--md-primary-fg-color);
}

.perch-next .next ul {
    margin: 0;
    padding-left: 18px;
    font-size: 13.5px;
    line-height: 1.7;
}

/* ─── Inline mini-terminals (.pterm) ──────────────────────────────── */

.pterm-shell {
    --bg:     #0f1320;
    --fg:     #e2e8f5;
    --muted:  #7a8aa8;
    --accent: #fcd34d;
    --ok:     #6cf2a4;
    --err:    #ff7a7a;
    --border: #1e2540;

    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin: 0.75rem 0 1rem;
    font-family: ui-monospace, "JetBrains Mono", "Fira Code", monospace;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pterm-chrome {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #161b2e;
    border-bottom: 1px solid var(--border);
}

.pterm-dot {
    width: 10px; height: 10px; border-radius: 50%; background: #4a5a76;
}
.pterm-red    { background: #ff5f57; }
.pterm-yellow { background: #febc2e; }
.pterm-green  { background: #28c840; }

.pterm-title {
    margin-left: 8px;
    color: var(--muted);
    font-size: 12px;
}

.pterm-replay {
    margin-left: auto;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 7px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}
.pterm-replay:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.pterm-body {
    padding: 12px 14px;
    margin: 0;
    min-height: 140px;
    line-height: 1.55;
    white-space: pre-wrap;
    background: var(--bg);
    color: var(--fg);
}

.pterm-row { display: block; }
.pterm-prompt { color: var(--accent); font-weight: 600; }
.pterm-fg     { color: var(--fg); }
.pterm-ok     { color: var(--ok); }
.pterm-err    { color: var(--err); }
.pterm-dim    { color: var(--muted); }
.pterm-accent { color: var(--accent); }

/* Side-by-side terminal pairs (before / after) */
.pterm-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 1rem 0;
}
@media (max-width: 720px) {
    .pterm-pair { grid-template-columns: 1fr; }
}

/* ─── Auto-bindings inspector (.pbind) ────────────────────────────── */

.pbind {
    background: #0f1320;
    border: 1px solid #1e2540;
    border-radius: 10px;
    overflow: hidden;
    margin: 1.5rem 0 2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pbind-chrome {
    background: #161b2e;
    border-bottom: 1px solid #1e2540;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pbind-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: #fcd34d;
    box-shadow: 0 0 8px #fcd34d;
}

.pbind-title {
    color: #e2e8f5;
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-size: 13px;
}

.pbind-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 4px 24px;
    padding: 14px 18px;
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-size: 13px;
}

.pbind-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 280ms ease, transform 280ms ease;
}
.pbind-row.is-shown {
    opacity: 1;
    transform: translateX(0);
}

.pbind-name  { color: #f0a0ff; min-width: 130px; }
.pbind-arrow { color: #7a8aa8; }
.pbind-val   { color: #6cf2a4; word-break: break-all; }

/* ─── Fan-out diagram (.pfan) ─────────────────────────────────────── */

.pfan {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 1.5rem 0 2rem;
    padding: 24px 16px;
    border: 1px solid rgba(120, 130, 180, 0.18);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}
[data-md-color-scheme="slate"] .pfan {
    background: rgba(255, 255, 255, 0.03);
}

.pfan-file {
    background: #0f1320;
    color: #fcd34d;
    border: 1px solid #1e2540;
    padding: 12px 28px;
    border-radius: 8px;
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(252, 211, 77, 0.15);
}

.pfan-arrows {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 600px;
    height: 28px;
    align-items: center;
}

.pfan-arrow {
    height: 28px;
    border-left: 2px dashed rgba(120, 130, 180, 0.3);
    border-bottom: 2px dashed rgba(120, 130, 180, 0.3);
    width: 50%;
    margin-left: 50%;
    transition: border-color 320ms ease;
}
.pfan-arrow.is-lit {
    border-left-color: #fcd34d;
    border-bottom-color: #fcd34d;
}

.pfan-targets {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 720px;
}
@media (max-width: 640px) {
    .pfan-targets,
    .pfan-arrows { grid-template-columns: repeat(5, minmax(60px, 1fr)); font-size: 11px; }
}

.pfan-target {
    text-align: center;
    padding: 14px 8px;
    border: 1px solid rgba(120, 130, 180, 0.18);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.04);
    opacity: 0.35;
    transform: translateY(6px);
    transition: opacity 320ms ease, transform 320ms ease, border-color 320ms ease, box-shadow 320ms ease;
}
[data-md-color-scheme="slate"] .pfan-target {
    background: rgba(255, 255, 255, 0.03);
}
.pfan-target.is-lit {
    opacity: 1;
    transform: translateY(0);
    border-color: #fcd34d;
    box-shadow: 0 4px 14px rgba(252, 211, 77, 0.18);
}

.pfan-icon  { font-size: 20px; line-height: 1; margin-bottom: 6px; }
.pfan-label { font-weight: 600; font-size: 13px; color: var(--md-default-fg-color); }
.pfan-sub   { font-size: 11px; color: var(--md-default-fg-color--light); font-family: ui-monospace, monospace; margin-top: 2px; }

/* ─── Capy / perch syntax highlighter ─────────────────────────────── */

.pcode-hl {
    color: #e2e8f5;
}

/* Token colors (light theme) — chosen to match the existing pterm palette. */
.pcode-kw     { color: #c084fc; font-weight: 500; }   /* keyword */
.pcode-str    { color: #6cf2a4; }                     /* string */
.pcode-interp { color: #fcd34d; font-weight: 500; }   /* ${name} inside string */
.pcode-num    { color: #93c5fd; }                     /* number */
.pcode-bool   { color: #93c5fd; font-weight: 500; }   /* true / false */
.pcode-com    { color: #7a8aa8; font-style: italic; } /* # comment */
.pcode-op     { color: #f0a0ff; }                     /* operators */
.pcode-id     { color: #e2e8f5; }                     /* identifier (op call) */

/* Slate-theme tweaks (mkdocs-material's dark mode) */
[data-md-color-scheme="slate"] .pcode-hl   { color: #e2e8f5; }
[data-md-color-scheme="slate"] .pcode-kw   { color: #d4b3ff; }
[data-md-color-scheme="slate"] .pcode-str  { color: #86efac; }

/* Make the code container darker so token colors pop. mkdocs-material's
 * default fenced-code background is lighter than our pterm palette;
 * line up with the rest of the page's monospace blocks. */
pre code.pcode-hl,
pre code.language-capy,
pre code.language-perch {
    background: #0f1320 !important;
    color: #e2e8f5 !important;
    border-radius: 6px;
}
pre:has(code.language-capy),
pre:has(code.language-perch),
pre:has(code.pcode-hl) {
    background: #0f1320 !important;
    border: 1px solid #1e2540;
}

/* When pymdownx remapped `capy`/`perch` to `language-text`, the parent
 * wrapper carries that class. Style the line-number anchors so they
 * stay readable on our dark code background. */
.language-text.highlight pre:has(code.pcode-hl) a {
    color: #4a5878;
}
.pcode-hl a {
    color: #4a5878;
}

/* ─── Stats bar under the hero ────────────────────────────────────── */

.pstats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin: 1rem 0 2rem;
    padding: 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(252, 211, 77, 0.08), rgba(108, 242, 164, 0.06));
    border: 1px solid rgba(120, 130, 180, 0.18);
}

.pstats-item {
    text-align: center;
    padding: 4px 6px;
}

.pstats-num {
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--md-primary-fg-color);
}

.pstats-label {
    font-size: 12px;
    color: var(--md-default-fg-color--light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

/* Counter animation: count up from 0 over 800ms on scroll-in. */
.pstats-num.is-counting {
    color: var(--md-primary-fg-color);
}

/* ─── Trust-model diagram (sandbox.md §2.5) ───────────────────────── */

.ptrust {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0 2rem;
}

.ptrust svg {
    max-width: 520px;
    width: 100%;
    height: auto;
}

.ptrust .ring {
    fill: none;
    stroke-width: 2;
}

.ptrust .ring-author { stroke: #fcd34d; fill: rgba(252, 211, 77, 0.06); }
.ptrust .ring-user   { stroke: #93c5fd; fill: rgba(147, 197, 253, 0.08); }
.ptrust .ring-admin  { stroke: #f0a0ff; fill: rgba(240, 160, 255, 0.06); }

.ptrust .core {
    fill: rgba(108, 242, 164, 0.18);
    stroke: #6cf2a4;
    stroke-width: 2;
}

.ptrust text {
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-size: 12px;
    fill: var(--md-default-fg-color);
}

.ptrust .label-author { fill: #fcd34d; font-weight: 600; }
.ptrust .label-user   { fill: #93c5fd; font-weight: 600; }
.ptrust .label-admin  { fill: #f0a0ff; font-weight: 600; }
.ptrust .label-core   { fill: #6cf2a4; font-weight: 700; font-size: 13px; }

[data-md-color-scheme="slate"] .ptrust text {
    fill: #e2e8f5;
}
