/* Database configuration reference (/sql-configuration) - page-specific rules only.
   Shared primitives (tokens, cards, .tools-sec, .tools-faq, .tools-cta, .fmt-code)
   come from tokens.css / site.css / tools.css. Everything here is scoped under .cfg
   so overrides of shared rules never leak to other pages. Tokens only. */

/* ---------- Full-width shell ---------- */
.cfg .wrap { max-width: none; padding: 0 clamp(16px, 2vw, 32px); }
.cfg .page-head .lede { max-width: 62ch; text-wrap: pretty; }
.cfg p { text-wrap: pretty; }
.cfg h1, .cfg h2, .cfg h3 { text-wrap: balance; }
.cfg [id] { scroll-margin-top: 90px; }
.cfg ::selection { background: var(--blue-soft); color: var(--heading); }

.cfg-note { color: var(--muted); margin: 0 0 14px; max-width: 62ch; }
.cfg-after { margin: 26px 0 0; max-width: 62ch; }
.cfg code { font-variant-ligatures: none; }
h1 code { font-size: inherit; overflow-wrap: anywhere; }
.cfg .tools-cta h2, .cfg-prose h2 { overflow-wrap: anywhere; }

/* FAQ: cards side by side on wide screens, each answer at a readable measure. */
.cfg .tools-faq { max-width: none; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.cfg .tools-faq .card p { max-width: 62ch; }
.cfg-setting .tools-faq { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }

/* "Related on SQLly" (shared partial): columns instead of one 80ch list. */
.cfg .tools-xref { max-width: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); column-gap: 32px; }
.cfg .tools-xref li:last-child { border-bottom: 1px solid var(--line); }
.cfg .tools-xref-also { max-width: 62ch; }

/* ---------- Hub: engine cards ---------- */
.cfg-engines { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.cfg-engine-card {
    display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 22px 22px 24px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    color: var(--ink); text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.cfg-engine-card:hover, .cfg-engine-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--blue-bright); text-decoration: none; }
.cfg-engine-card h3 { margin: 0; font-size: 1.3rem; color: var(--heading); }
.cfg-engine-card p { margin: 0; color: var(--muted); font-size: .94rem; }
.cfg-engine-meta { font-family: "JetBrains Mono", monospace; font-size: .8rem; color: var(--muted); }

/* ---------- Tables ---------- */
.cfg-table-wrap { overflow-x: auto; margin: 4px 0 8px; border-radius: 4px; }
.cfg-table-wrap:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; }
.cfg-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cfg-table th, .cfg-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cfg-table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.cfg-table tbody th { font-weight: 600; color: var(--heading); }
.cfg-table tbody th a { text-decoration: none; }
.cfg-table tbody th a:hover code, .cfg-table td a:hover code { color: var(--blue-bright); }
.cfg-table td { color: var(--muted); }
.cfg-table td code { white-space: normal; overflow-wrap: anywhere; }
.cfg-table tbody tr:hover > * { background: var(--blue-soft); }
.cfg-none { color: var(--muted); }
.cfg-restart { color: var(--amber-ink); font-weight: 600; }
.cfg-live { color: var(--green); font-weight: 600; }

/* Hub comparison: job column sticks while the engines scroll on narrow screens. */
.cfg-compare { min-width: 1120px; }
.cfg-compare thead th, .cfg-compare tbody th { position: sticky; left: 0; }
.cfg-compare thead th:not(:first-child) { position: static; }
.cfg-compare tbody th, .cfg-compare thead th:first-child { background: var(--cream); z-index: 1; width: 12%; }
.cfg-compare td { width: 17.6%; }
.cfg-compare td a code { white-space: nowrap; overflow-wrap: normal; }
.cfg-compare td a { text-decoration: none; display: inline-block; }
.cfg-compare td a code { font-weight: 600; color: var(--heading); }
.cfg-cell-default { display: block; margin-top: 4px; font-size: .84rem; color: var(--muted); }
.cfg-cell-default code { font-size: .92em; }

/* Engine page settings table */
.cfg-settings { min-width: 720px; }
.cfg-settings tbody th { width: 26%; }
.cfg-settings tbody th code { overflow-wrap: anywhere; }
.cfg-settings td:nth-child(2) { width: 18%; }
.cfg-settings td:nth-child(3) { width: 7%; white-space: nowrap; }

/* ---------- Search / filter ---------- */
.cfg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 8px 0 22px; }
.cfg-toolbar-stacked { flex-direction: column; align-items: stretch; gap: 8px; margin: 0 0 24px; }
.cfg-search-label { font-size: .86rem; font-weight: 600; color: var(--heading); }
.cfg-search-box { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 420px; }
.cfg-toolbar-stacked .cfg-search-box { flex: none; max-width: none; }
.cfg-search { width: 100%; padding: 10px 76px 10px 14px; font-size: .95rem; }
.cfg-search::placeholder { color: var(--muted); opacity: 1; }
.cfg-search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.cfg-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    min-height: 32px; padding: 4px 12px; border-radius: 999px;
    font: 600 .8rem/1 "Inter", system-ui, sans-serif; color: var(--heading);
    background: var(--blue-soft); border: 1px solid var(--line); cursor: pointer;
}
.cfg-clear:hover { border-color: var(--blue-bright); }
.cfg-count { font-size: .86rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cfg-hint { font-size: .8rem; color: var(--muted); }
.cfg-hint kbd, .cfg kbd {
    font-family: "JetBrains Mono", monospace; font-size: .78rem;
    padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); color: var(--heading);
}
.cfg-empty {
    margin: 0 0 24px; padding: 14px 18px; max-width: 62ch;
    border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
}

/* Hub: all settings in one column per engine. */
.cfg-index { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 8px 28px; align-items: start; }
.cfg-index-col h3 { display: flex; align-items: baseline; gap: 8px; font-size: 1.15rem; margin: 0 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.cfg-index-col h3 a { color: var(--heading); text-decoration: none; }
.cfg-index-col h3 a:hover { color: var(--blue-bright); }
.cfg-group-n { font-family: "JetBrains Mono", monospace; font-size: .78rem; font-weight: 400; color: var(--muted); }
.cfg-index-col ul { list-style: none; margin: 0 0 18px; padding: 0; }
.cfg-index-col li a { display: block; padding: 5px 0; text-decoration: none; overflow-wrap: anywhere; }
.cfg-index-col li a code { font-size: .86rem; color: var(--ink); }
.cfg-index-col li a:hover code { color: var(--blue-bright); }

/* ---------- Two-column layouts with a sticky aside ---------- */
.cfg-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: clamp(24px, 3vw, 56px); align-items: start; }
.cfg-layout-setting { grid-template-columns: minmax(0, 1fr) 240px; }
.cfg-main { min-width: 0; }
.cfg-aside-inner { position: sticky; top: 94px; max-height: calc(100vh - 110px); overflow-y: auto; padding-bottom: 8px; }
.cfg .cfg-toc-h {
    font-family: "JetBrains Mono", monospace; font-size: .78rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px;
}
.cfg-toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.cfg-toc a {
    display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
    padding: 7px 12px; margin-left: -1px; border-left: 1px solid transparent;
    color: var(--ink); text-decoration: none; font-size: .92rem;
}
.cfg-toc a:hover { color: var(--blue-bright); border-left-color: var(--blue-bright); }
.cfg-toc a[aria-current="true"] { color: var(--heading); font-weight: 600; border-left-color: var(--pink-strong); }
.cfg-toc-n { font-family: "JetBrains Mono", monospace; font-size: .78rem; color: var(--muted); }
.cfg-toc a.is-empty { color: var(--muted); }

/* ---------- Engine page ---------- */
.cfg-inspect { margin: 0 0 40px; }
.cfg-inspect h2, .cfg-group h2 { font-size: clamp(1.35rem, 2.2vw, 1.6rem); margin: 0 0 6px; }
.cfg-group { margin: 0 0 44px; }
.cfg-group:last-child { margin-bottom: 0; }

/* Code blocks with a copy button */
.cfg-codebox { position: relative; }
.cfg-code { padding: 14px 18px; margin: 0 0 8px; }
.cfg-codebox:has(.cfg-copy:not([hidden])) .cfg-code { padding-right: 84px; }
.cfg-copy {
    position: absolute; top: 8px; right: 8px; min-height: 32px; padding: 4px 14px;
    border-radius: 999px; border: 1px solid var(--line); background: var(--cream);
    font: 600 .8rem/1 "Inter", system-ui, sans-serif; color: var(--heading); cursor: pointer;
}
.cfg-copy:hover { border-color: var(--blue-bright); }
.cfg-copy.is-done { color: var(--green); border-color: var(--green); }

/* ---------- Setting page ---------- */
.cfg-facts { display: flex; flex-wrap: wrap; gap: 12px 44px; margin: 22px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); }
.cfg-facts div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cfg-facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cfg-facts dd { margin: 0; color: var(--heading); overflow-wrap: anywhere; }

.cfg-prose > section, .cfg-sql-pair > section, .cfg-pair > section { margin: 0 0 40px; min-width: 0; }
.cfg-prose h2 { font-size: clamp(1.35rem, 2.2vw, 1.6rem); margin: 0 0 10px; }
.cfg-prose p { max-width: 62ch; }
.cfg-sql-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 28px; }
.cfg-sql-pair > section { min-width: 0; }
.cfg-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 clamp(28px, 3vw, 48px); align-items: start; }

/* Risk: a caution panel (tinted fill and hairline, no thick side stripe). */
.cfg-risk { padding: 20px 22px; border: 1px solid var(--amber-line); border-radius: 12px; background: var(--amber-soft); }
.cfg-risk h2 { color: var(--amber-ink); }
.cfg-risk p { margin: 0; color: var(--ink); }

.cfg-xeng { min-width: 560px; }
.cfg-xeng td a { text-decoration: none; }
.cfg-xeng td a code { font-weight: 600; color: var(--heading); }
.cfg-current > * { background: var(--blue-soft); }
.cfg-this { font-size: .8rem; color: var(--muted); margin-left: 6px; }

.cfg-links { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); column-gap: 32px; }
.cfg-links li { border-bottom: 1px solid var(--line); }
.cfg-links a { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; min-height: 44px; box-sizing: border-box; text-decoration: none; }
.cfg-links a:hover code { color: var(--blue-bright); }
.cfg-links code { font-weight: 600; color: var(--heading); overflow-wrap: anywhere; }
.cfg-links span { color: var(--muted); font-size: .94rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .cfg-layout-setting { grid-template-columns: minmax(0, 1fr); }
    .cfg-layout-setting .cfg-aside { display: none; }
}
@media (max-width: 960px) {
    .cfg-layout { grid-template-columns: minmax(0, 1fr); }
    .cfg-aside-inner { position: static; max-height: none; overflow: visible; }
    .cfg-engine .cfg-toc ol { display: flex; flex-wrap: nowrap; gap: 8px; border-left: none; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
    .cfg-engine .cfg-toc li { flex: none; }
    .cfg-engine .cfg-toc a { border: 1px solid var(--line); border-radius: 999px; margin: 0; padding: 8px 14px; min-height: 44px; align-items: center; white-space: nowrap; }
    .cfg-engine .cfg-toc a[aria-current="true"] { border-color: var(--pink-strong); }
    .cfg-hint { display: none; }
}
@media (max-width: 600px) {
    .cfg-facts { gap: 12px 28px; }
    .cfg-risk { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .cfg-engine-card { transition: none; }
    .cfg-engine-card:hover, .cfg-engine-card:focus-visible { transform: none; }
}
