/* ===================================================================
   Groups E-I tools ("xt") - AI, performance, API/data, SEO/commerce and
   business tools, plus their five hubs.

   Builds on backlink-maker.css (bm-* hero, shell, buttons, toast) and
   icloud-tools.css (ic-* bench, forms, tables, stats, notices, drop zone),
   which is the design the brief points at. This file adds ONLY what those
   two lack: the execution badge, the workspace grid, code inputs, the
   editorial article, hub cards and filters, result reveal and the mobile
   table fallback. Scoped under .xt; nothing here reaches another page.
   =================================================================== */

.xt {
    --xt-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Liberation Mono", monospace;
    --xt-local: #17864f; --xt-local-soft: #e7f6ee;
    --xt-remote: #8f5600; --xt-remote-soft: #fff2dc;
    --xt-server: #3a5cc2; --xt-server-soft: #eef2fe;
}
.xt :where(p, li, dd, td, th, summary) { overflow-wrap: anywhere; }
/* The hidden attribute must win over component display rules (.ic-notice is flex). */
.xt [hidden] { display: none !important; }
.xt code { font-family: var(--xt-mono); font-size: .88em; padding: 1px 5px; border-radius: 6px; background: var(--bm-line-2); color: var(--bm-ink); }
.xt .xt-muted { color: var(--bm-ink-3); font-size: .88rem; }

/* ---------- Execution badge ---------- */
.xt-exec { margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-start; max-width: 78ch; }
.xt-exec-badge { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 999px; font-weight: 800; font-size: .88rem; white-space: nowrap; }
.xt-exec-detail { margin: 0; font-size: .9rem; color: var(--bm-ink-2); line-height: 1.5; flex: 1 1 320px; }
.xt-exec.is-local .xt-exec-badge, .xt-pill.is-local { background: var(--xt-local-soft); color: var(--xt-local); }
.xt-exec.is-passive .xt-exec-badge, .xt-exec.is-assisted .xt-exec-badge, .xt-pill.is-passive, .xt-pill.is-assisted { background: var(--xt-remote-soft); color: var(--xt-remote); }
.xt-exec.is-server .xt-exec-badge, .xt-pill.is-server { background: var(--xt-server-soft); color: var(--xt-server); }

/* ---------- Workspace ---------- */
.xt-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) {
    .xt-grid.is-split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
    .xt-grid.is-split > .xt-pane-out { position: sticky; top: 12px; }
}
.xt-pane { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.xt-pane-title { margin: 0; font-size: 1rem; font-weight: 800; color: var(--bm-ink); display: flex; gap: 8px; align-items: center; }
.xt-pane-title .xt-step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--bm-accent-soft); color: var(--bm-accent-strong); font-size: .8rem; }

.xt-code, .xt .ic-field textarea.xt-code {
    width: 100%; min-height: 180px; padding: 12px; border: 1px solid var(--bm-line); border-radius: 12px; resize: vertical;
    background: var(--bm-surface); color: var(--bm-ink); font-family: var(--xt-mono); font-size: .86rem; line-height: 1.5; tab-size: 2;
}
.xt-code.is-short { min-height: 96px; }
.xt-code.is-tall { min-height: 320px; }
.xt-code:focus { border-color: var(--bm-accent); outline: 3px solid var(--bm-accent-ring); outline-offset: 0; }
.xt-code[aria-invalid="true"] { border-color: var(--ic-bad); }
.xt-pre {
    margin: 0; padding: 12px; max-height: 480px; overflow: auto; border: 1px solid var(--bm-line); border-radius: 12px;
    background: var(--bm-bg); font-family: var(--xt-mono); font-size: .84rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.xt-counter { font-size: .78rem; color: var(--bm-ink-3); text-align: right; font-variant-numeric: tabular-nums; }

.xt-advanced { border: 1px solid var(--bm-line); border-radius: 12px; padding: 0 14px; background: var(--bm-surface); }
.xt-advanced > summary { padding: 12px 0; font-weight: 800; cursor: pointer; color: var(--bm-ink); }
.xt-advanced[open] > summary { border-bottom: 1px solid var(--bm-line-2); margin-bottom: 12px; }
.xt-advanced > :last-child { margin-bottom: 14px; }

.xt-examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .85rem; color: var(--bm-ink-3); }
.xt-examples .bm-btn { padding: 6px 10px; font-size: .82rem; }

/* ---------- Results ---------- */
.xt-result[hidden] { display: none !important; }
.xt-result { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.xt-result.is-revealed { animation: xt-reveal .28s var(--bm-ease, ease) both; }
@keyframes xt-reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.xt-empty { padding: 28px 16px; text-align: center; color: var(--bm-ink-3); border: 1px dashed var(--bm-line); border-radius: 14px; }
.xt-empty i { display: block; font-size: 1.6rem; margin-bottom: 8px; color: var(--bm-accent); }

.xt-hero-num { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; padding: 16px; border-radius: 16px; background: var(--bm-accent-soft); }
.xt-hero-num strong { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.1; color: var(--bm-accent-strong); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.xt-hero-num span { color: var(--bm-ink-2); font-weight: 600; }

.xt-findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.xt-finding { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; padding: 10px 12px; border: 1px solid var(--bm-line); border-left-width: 4px; border-radius: 10px; background: var(--bm-surface); }
.xt-finding > i { margin-top: 3px; }
.xt-finding strong { color: var(--bm-ink); }
.xt-finding p { margin: 2px 0 0; font-size: .88rem; color: var(--bm-ink-2); grid-column: 2; }
.xt-finding.is-bad { border-left-color: var(--ic-bad); } .xt-finding.is-bad > i { color: var(--ic-bad); }
.xt-finding.is-warn { border-left-color: var(--ic-warn); } .xt-finding.is-warn > i { color: var(--ic-warn); }
.xt-finding.is-ok { border-left-color: var(--ic-ok); } .xt-finding.is-ok > i { color: var(--ic-ok); }
.xt-finding.is-info { border-left-color: var(--bm-accent); } .xt-finding.is-info > i { color: var(--bm-accent-strong); }

.xt-meter { height: 12px; border-radius: 999px; background: var(--bm-line-2); overflow: hidden; display: flex; }
.xt-meter > span { display: block; height: 100%; transition: width .35s var(--bm-ease, ease); }

/* Tables keep the ic-table look; below 560px a table marked .xt-stack reads as cards. */
.xt .ic-table-wrap { max-height: 560px; overflow: auto; }
.xt-table-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.xt-table-tools input[type="search"] { min-height: 38px; padding: 6px 10px; border: 1px solid var(--bm-line); border-radius: 10px; font: inherit; font-size: .88rem; min-width: 0; flex: 1 1 180px; max-width: 320px; }
@media (max-width: 559px) {
    .xt .ic-table.xt-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .xt .ic-table.xt-stack, .xt .ic-table.xt-stack tbody, .xt .ic-table.xt-stack tr, .xt .ic-table.xt-stack td { display: block; width: 100%; max-width: none; }
    .xt .ic-table.xt-stack tr { border-bottom: 1px solid var(--bm-line); padding: 6px 0; }
    .xt .ic-table.xt-stack td { border: 0; padding: 3px 10px; display: grid; grid-template-columns: minmax(90px, 40%) 1fr; gap: 8px; text-align: left !important; white-space: normal !important; }
    .xt .ic-table.xt-stack td::before { content: attr(data-label); font-weight: 700; color: var(--bm-ink-3); }
}

.xt-copy-row { display: flex; flex-wrap: wrap; gap: 6px; }
.xt .bm-btn.is-done { border-color: var(--ic-ok); color: var(--ic-ok); }

/* Charts drawn as inline SVG by xt-core. */
.xt-chart { width: 100%; height: auto; display: block; }
.xt-chart text { font-size: 11px; fill: var(--bm-ink-3); }
.xt-chart .xt-axis { stroke: var(--bm-line); }
.xt-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--bm-ink-2); margin: 0; padding: 0; list-style: none; }
.xt-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Article ---------- */
.xt-article { margin-top: 28px; max-width: 900px; color: var(--bm-ink-2); line-height: 1.7; }
.xt-article h2 { margin: 28px 0 10px; font-size: 1.3rem; color: var(--bm-ink); }
.xt-article h2:first-child { margin-top: 0; }
.xt-article p { margin: 0 0 12px; }
.xt-steps { padding-left: 22px; } .xt-steps li { margin: 6px 0; }
.xt-example { padding: 14px 16px; border-left: 4px solid var(--bm-accent); background: var(--bm-accent-soft); border-radius: 0 12px 12px 0; }
.xt-example p:last-child { margin-bottom: 0; }
.xt-formulas { margin: 0; display: grid; gap: 10px; }
.xt-formulas dt { font-weight: 800; color: var(--bm-ink); }
.xt-formulas dd { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.xt-formulas dd code { display: block; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.xt-formulas dd span { font-size: .9rem; }
.xt-limits li, .xt-refs li { margin: 6px 0; }
.xt-faq details { border: 1px solid var(--bm-line); border-radius: 12px; padding: 0 14px; margin: 8px 0; background: var(--bm-surface); }
.xt-faq summary { padding: 12px 0; font-weight: 700; color: var(--bm-ink); cursor: pointer; }
.xt-faq details[open] summary { border-bottom: 1px solid var(--bm-line-2); margin-bottom: 8px; }
.xt-reviewed { margin-top: 20px; font-size: .88rem; color: var(--bm-ink-3); }

/* ---------- Hub ---------- */
.xt-hub-intro { margin-top: 18px; max-width: 900px; color: var(--bm-ink-2); line-height: 1.7; }
.xt-tasks, .xt-catalog, .xt-newest, .xt-elsewhere { margin-top: 22px; }
.xt-tasks h2, .xt-catalog h2, .xt-newest h2, .xt-elsewhere h2 { font-size: 1.25rem; margin: 0 0 10px; color: var(--bm-ink); }
.xt-task-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.xt-task-list a { display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border: 1px solid var(--bm-line); border-radius: 999px; background: var(--bm-surface); color: var(--bm-ink); text-decoration: none; font-weight: 600; font-size: .9rem; }
.xt-task-list a:hover { border-color: var(--bm-accent); color: var(--bm-accent-strong); }
.xt-task-list i { color: var(--bm-accent-strong); }
.xt-catalog-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.xt-hub-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.xt-hub-controls input[type="search"] { min-height: 42px; padding: 8px 12px; border: 1px solid var(--bm-line); border-radius: 10px; font: inherit; min-width: 0; flex: 1 1 200px; }
.xt-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); margin: 12px 0 0; padding: 0; list-style: none; }
.xt-card[hidden] { display: none; }
.xt-card a { display: flex; gap: 12px; height: 100%; padding: 14px; border: 1px solid var(--bm-line); border-radius: 14px; background: var(--bm-surface); color: var(--bm-ink); text-decoration: none; box-shadow: 4px 4px 0 var(--card-offset-background, #f8f2ee); transition: transform .16s var(--bm-ease, ease), border-color .16s; }
.xt-card a:hover { transform: translateY(-2px); border-color: var(--bm-accent); }
.xt-card-icon { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border-radius: 12px; background: var(--bm-accent-soft); color: var(--bm-accent-strong); }
.xt-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: .86rem; color: var(--bm-ink-2); }
.xt-card-body strong { font-size: 1rem; color: var(--bm-ink); }
.xt-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.xt-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 800; background: var(--bm-line-2); color: var(--bm-ink-2); }

/* ---------- Motion, contrast, print ---------- */
@media (prefers-reduced-motion: reduce) {
    .xt *, .xt *::before, .xt *::after { transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
    .xt-exec-badge, .xt-pill, .xt-finding, .xt-card a, .xt-code, .xt-hero-num, .xt-example, .ic-stat, .xt-meter { border: 1px solid CanvasText; forced-color-adjust: auto; }
    .xt-meter > span, .ic-bar-fill, .ic-progress-fill { background: Highlight !important; }
    .xt :focus-visible { outline: 3px solid Highlight !important; }
}
@media print {
    .xt-hero .bm-chips, .xt-related, .bm-ad, .xt-examples, .xt-copy-row, .ic-toolbar, .ic-drop, .xt-advanced > summary { display: none !important; }
    .xt-bench { box-shadow: none; border: 0; padding: 0; }
    .xt-result[hidden] { display: none !important; }
}
