/* Components: panels, badges, buttons, tool items, tabs, code blocks. */

/* 1. Corner-bracket panel */
.panel { position: relative; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
.panel::before, .panel::after {
  content: ""; position: absolute; left: -1px; right: -1px; height: 10px; pointer-events: none; transition: filter var(--ease);
  --c: var(--accent);
  background:
    linear-gradient(var(--c), var(--c)) left top / 10px 1px no-repeat,
    linear-gradient(var(--c), var(--c)) left top / 1px 10px no-repeat,
    linear-gradient(var(--c), var(--c)) right top / 10px 1px no-repeat,
    linear-gradient(var(--c), var(--c)) right top / 1px 10px no-repeat;
}
.panel::before { top: -1px; }
.panel::after { bottom: -1px; transform: scaleY(-1); }
.panel--hover:hover { border-color: var(--accent); transform: scale(1.01); box-shadow: 0 0 0 1px rgba(233, 235, 239, 0.25), 0 0 32px -8px rgba(233, 235, 239, 0.45); }
.panel__index { display: block; margin-bottom: 40px; }
.panel h3 { font-size: 20px; margin-bottom: 12px; }
.panel p { color: var(--text-muted); font-size: 15px; }
@media (prefers-reduced-motion: reduce) { .panel--hover:hover { transform: none; } }

/* 2. Live badge */
.badge-live { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text); }
.badge-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.55); animation: live-pulse 2s ease-out infinite; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.55); } 100% { box-shadow: 0 0 0 9px rgba(76, 175, 80, 0); } }
@media (prefers-reduced-motion: reduce) { .badge-live::before { animation: none; } }

/* Buttons: no box, just a pair of corner marks (top-left, bottom-right) like the reference's X button. */
.btn, .btn-x { position: relative; display: inline-flex; align-items: center; gap: 12px; height: 44px; padding: 0 26px; font-family: var(--font-display); font-weight: 300; font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--text); transition: color var(--ease), background var(--ease); }
.btn::before, .btn::after, .btn-x::before, .btn-x::after { content: ""; position: absolute; width: 9px; height: 9px; border: 0 solid rgba(255,255,255,0.75); transition: width var(--ease), height var(--ease), border-color var(--ease); pointer-events: none; }
.btn::before, .btn-x::before { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.btn::after, .btn-x::after { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }
.btn:hover::before, .btn:hover::after, .btn-x:hover::before, .btn-x:hover::after { width: 16px; height: 16px; border-color: #fff; }
.btn:hover, .btn-x:hover { color: #fff; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: #f0f1f3; color: #0b0c0e; font-weight: 400; }
.btn--primary:hover { background: #fff; color: #0b0c0e; }
.btn--primary::before, .btn--primary::after { top: -5px; left: -5px; width: 10px; height: 10px; }
.btn--primary::after { top: auto; left: auto; bottom: -5px; right: -5px; }
.btn--primary:hover::before, .btn--primary:hover::after { width: 18px; height: 18px; }
.btn .arrow { transition: transform var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }
.btn-x { height: 34px; padding: 0 22px; gap: 10px; }
.btn-x svg { width: 12px; height: 12px; fill: currentColor; }
.link-arrow { display: inline-flex; gap: 10px; align-items: center; font-family: var(--font-display); font-weight: 300; font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--text); border-bottom: 1px solid rgba(255,255,255,0.25); padding-bottom: 6px; transition: border-color var(--ease), gap var(--ease); }
.link-arrow:hover { border-color: #fff; gap: 16px; }

/* 5. Stats */
.stats-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--text-muted); }
.stats-row b { color: var(--text); font-weight: 400; }
.pills { display: flex; flex-wrap: wrap; gap: 12px; }
.pill { background: var(--bg-2); border: 1px solid rgba(255,255,255,0.1); padding: 20px 28px; min-width: 140px; transition: border-color var(--ease); }
.pill:hover { border-color: rgba(255,255,255,0.22); }
.pill .label { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-muted); }
.pill .n { display: block; margin-top: 12px; font-family: var(--font-mono); font-size: 36px; line-height: 1; font-weight: 300; color: #fff; letter-spacing: -0.03em; }
@media (max-width: 520px) { .pills { gap: 10px; } .pill { flex: 1 1 calc(50% - 10px); min-width: 0; padding: 14px 16px; } }

/* 7. Tab filter. Inactive text uses --text-muted (#8c8c8c, readable) rather than #666. */
.tab-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.tab-filter button { font-family: var(--font-display); font-weight: 300; background: transparent; border: 1px solid rgba(255,255,255,0.12); border-radius: 0; padding: 7px 18px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,0.45); transition: border-color var(--ease), color var(--ease), background var(--ease); }
.tab-filter button:hover { border-color: rgba(255,255,255,0.3); color: rgba(255,255,255,0.8); }
.tab-filter button[aria-pressed="true"] { border-color: var(--accent); color: #fff; background: rgba(233,235,239,0.08); }

/* 3. Tool item + 4. Ask button */
.tool-list { border-top: 0; }
.tool-item { display: grid; gap: 12px; padding: 0 0 32px; margin-bottom: 32px; border-bottom: 1px solid #1a1a1a; }
.tool-item:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.tool-item[hidden] { display: none; }
.tool-item__name { font-family: var(--font-mono); font-size: 15px; color: var(--accent); letter-spacing: 0; }
.tool-item__desc { color: var(--text-muted); font-size: 15px; max-width: 64ch; }
.tool-item__group { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted); margin-left: 10px; }
.tool-item__ask { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.btn-ask { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 14px; border: 1px solid #333; border-radius: 999px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); transition: border-color var(--ease), color var(--ease); }
.btn-ask:hover, .btn-ask:focus-visible, .btn-ask.is-copied { border-color: var(--accent); color: var(--accent); }
/* The brief asks for #444, which is 2:1 on this background and unreadable; the query is content, so it gets #7a7a7a. */
.tool-item__query { font-style: italic; font-size: 13px; color: #7a7a7a; }

/* 6. Code block */
.code-block { position: relative; margin: 20px 0; border: 1px solid var(--border); background: var(--bg-2); border-radius: var(--radius); }
.code-block pre { margin: 0; padding: 20px 64px 20px 20px; overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; color: var(--text); tab-size: 2; }
.code-block .k { color: var(--accent-2); }
.code-block .s { color: var(--accent); }
.code-block .c { color: var(--text-muted); }
.code-block__copy { position: absolute; top: 8px; right: 8px; height: 26px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); background: var(--bg-2); transition: color var(--ease), border-color var(--ease); }
.code-block__copy:hover { color: var(--text); border-color: var(--text-muted); }
.code-block__copy.is-copied { color: var(--live); border-color: var(--live); }

/* Steps */
.step { position: relative; padding: 0 28px 0 0; }
.step::before { content: ""; position: absolute; top: 28px; left: 56px; right: 8px; height: 1px; background: linear-gradient(90deg, var(--border-strong), transparent); }
.step:last-child::before { display: none; }
.step__n { display: block; font-family: var(--font-mono); font-weight: 200; font-size: 56px; line-height: 1; color: var(--accent); letter-spacing: -0.04em; }
.step p { margin-top: 24px; color: var(--text-muted); font-size: 15px; max-width: 26ch; }
@media (max-width: 900px) {
  .step { display: grid; grid-template-columns: 72px 1fr; align-items: start; padding: 24px 0; border-top: 1px solid var(--border); }
  .step::before { display: none; }
  .step p { margin-top: 8px; max-width: none; }
}

/* Tools catalog: a sticky visual on the left that changes chapter as you scroll, the tools on the right */
.catalog { display: flex; flex-direction: column; }
.tool-group { display: grid; grid-template-columns: 1fr 1fr; gap: 0; min-height: 100vh; border-top: 1px solid var(--border); }
.tool-group[hidden] { display: none; }
.group-sticky { position: sticky; top: var(--nav-h); align-self: start; min-height: calc(100vh - var(--nav-h)); display: flex; flex-direction: column; gap: 28px; padding: clamp(24px, 5vh, 48px) 48px; border-right: 1px solid #1a1a1a; }
.group-canvas { position: relative; flex: 1; min-height: 450px; }
.group-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.6s ease; }
.group-canvas canvas.active { opacity: 1; }
/* Corner brackets: top pair on ::before, bottom pair on ::after */
.group-canvas::before, .group-canvas::after {
  content: ""; position: absolute; left: 0; right: 0; height: 20px; pointer-events: none;
  background:
    linear-gradient(rgba(233,235,239,0.6), rgba(233,235,239,0.6)) left top / 20px 1px no-repeat,
    linear-gradient(rgba(233,235,239,0.6), rgba(233,235,239,0.6)) left top / 1px 20px no-repeat,
    linear-gradient(rgba(233,235,239,0.6), rgba(233,235,239,0.6)) right top / 20px 1px no-repeat,
    linear-gradient(rgba(233,235,239,0.6), rgba(233,235,239,0.6)) right top / 1px 20px no-repeat;
}
.group-canvas::before { top: 0; }
.group-canvas::after { bottom: 0; transform: scaleY(-1); }
.group-text { display: flex; flex-direction: column; gap: 12px; }
.group-text h2 { font-size: clamp(30px, 3.4vw, 44px); letter-spacing: -0.03em; }
.group-text p { color: var(--text-muted); font-size: 15px; max-width: 38ch; }
.group-scroll { padding: 48px 48px 48px 64px; }
/* Scroll distance: the left panel can only stay put while the right column is taller than the screen, so each tool gets
   about two fifths of a screen to itself and the page reads as a sequence of beats. */
@media (min-width: 768px) {
  .tool-group .tool-item { align-content: start; min-height: max(40vh, 280px); }
  .tool-group .tool-item:last-child { padding-bottom: 0; border-bottom: 0; }
}

/* Chapter change: the text slides up and fades in when its group becomes the active one */
@media (min-width: 768px) {
  .js .group-text > * { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
  .js .group-text > :nth-child(2) { transition-delay: 70ms; }
  .js .group-text > :nth-child(3) { transition-delay: 140ms; }
  .js .tool-group.is-active .group-text > * { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .group-canvas canvas, .js .group-text > * { transition: none !important; }
}
/* Phones: no sticky; the visual sits above its tool list */
@media (max-width: 767px) {
  .tool-group { grid-template-columns: 1fr; min-height: 0; }
  .group-sticky { position: static; min-height: 0; border-right: 0; padding: 40px 0 0; gap: 24px; }
  .group-canvas { flex: none; height: 260px; min-height: 0; }
  .group-canvas canvas { opacity: 1; }
  .group-scroll { padding: 24px 0 40px; }
}

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 12px); padding: 10px 16px; background: var(--bg-3); border: 1px solid var(--accent); border-radius: var(--radius); font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; opacity: 0; pointer-events: none; transition: opacity var(--ease), transform var(--ease); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Docs prose */
.prose h2 { font-size: 28px; letter-spacing: -0.02em; margin: 56px 0 16px; scroll-margin-top: calc(var(--nav-h) + 24px); }
.prose h2:first-of-type { margin-top: 16px; }
.prose h3 { font-size: 17px; margin: 32px 0 10px; scroll-margin-top: calc(var(--nav-h) + 24px); }
.prose p { color: #c4c4c4; margin: 0 0 16px; max-width: 66ch; }
.prose ul { margin: 0 0 16px; padding-left: 0; }
.prose li { position: relative; padding-left: 20px; color: #c4c4c4; margin-bottom: 8px; }
.prose li::before { content: "–"; position: absolute; left: 0; color: var(--accent); }
.prose code { font-family: var(--font-mono); font-size: 0.88em; padding: 1px 6px; background: var(--bg-3); border-radius: var(--radius); color: var(--text); }
.prose a { color: var(--accent); border-bottom: 1px solid rgba(233, 235, 239, 0.35); }
.prose a:hover { border-bottom-color: var(--accent); }
.prose .anchor { margin-left: 10px; color: var(--text-dim); opacity: 0; font-size: 0.8em; border: 0; transition: opacity var(--ease), color var(--ease); }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus-visible { opacity: 1; color: var(--accent); }
.prose .note { margin: 20px 0; padding: 14px 18px; border-left: 1px solid var(--accent); background: var(--bg-2); color: var(--text-muted); font-size: 14px; max-width: 66ch; }
.kicker { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted); }

/* About */
.manifesto p { font-size: clamp(20px, 2.4vw, 28px); line-height: 1.45; color: var(--text); font-weight: 300; letter-spacing: -0.015em; max-width: 30ch; }
.manifesto p + p { margin-top: 28px; }
.manifesto p:nth-child(n + 2) { color: var(--text-muted); }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.cols-2 ul li { padding: 14px 0; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 14px; }
@media (max-width: 720px) { .cols-2 { grid-template-columns: 1fr; } }

/* Docs tables */
.table-wrap { overflow-x: auto; margin: 20px 0 24px; border: 1px solid var(--border); background: var(--bg-2); }
.doc-table { width: 100%; min-width: 520px; font-size: 14px; }
.doc-table th { padding: 11px 16px; text-align: left; font-family: var(--font-display); font-weight: 300; font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.doc-table td { padding: 12px 16px; vertical-align: top; color: #c4c4c4; border-top: 1px solid var(--border); }
.doc-table tbody tr:first-child td { border-top: 0; }
.doc-table code { word-break: break-word; }
.doc-table code.addr { font-size: 12px; word-break: break-all; color: var(--text); background: none; padding: 0; }
.prose h3 + .table-wrap { margin-top: 12px; }

/* Live / Planned marks on tools, and the live count under each group total */
.tool-item__status { margin-left: 12px; font-family: var(--font-display); font-weight: 300; font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-muted); border: 1px solid var(--border-strong); padding: 2px 7px; vertical-align: 1px; }
.tool-item__status.is-live { color: #fff; border-color: rgba(255,255,255,0.45); }
.tool-item__status.is-live::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 6px; border-radius: 50%; background: #fff; vertical-align: 1px; }
.pill .sub { display: block; margin-top: 8px; font-family: var(--font-display); font-weight: 300; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted); }
