/* SQL data type reference (/sql-data-types and /sql-data-types/{slug}) -
   page-specific rules ONLY. Tokens come from tokens.css, primitives from
   site.css; the crumbs, "Related on SQLly" list and CTA strip come from
   tools.css. Everything here is scoped under .dt-page so it cannot leak into
   the other reference sections that share tools.css. */

/* ---------- Full-width frame ---------- */
.dt-page .wrap { max-width: none; padding: 0 clamp(16px, 2vw, 32px); }
.dt-page :target,
.dt-page [id] { scroll-margin-top: 92px; }

.dt-page .visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.dt-page h1, .dt-page h2, .dt-page h3 { text-wrap: balance; }
.dt-page p, .dt-page li, .dt-page td { text-wrap: pretty; }

/* ---------- Page head ---------- */
.dt-head { padding-bottom: 8px; }
.dt-head .lede { max-width: 62ch; }
.dt-head .eyebrow { display: table; }
.dt-facts { display: flex; flex-wrap: wrap; gap: 12px 40px; margin: 22px 0 0; }
.dt-facts div { display: flex; flex-direction: column; gap: 2px; }
.dt-facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dt-facts dd { margin: 0; color: var(--heading); font-weight: 600; }

/* ---------- Rail + main ---------- */
.dt-body { padding: clamp(32px, 4vw, 48px) 0 clamp(48px, 6vw, 80px); }
.dt-layout {
    display: grid;
    grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
    gap: clamp(24px, 3.5vw, 64px);
    align-items: start;
}
.dt-main { min-width: 0; }

.dt-rail {
    position: sticky; top: 94px;
    max-height: calc(100vh - 110px); overflow-y: auto;
    display: grid; gap: 28px; padding-bottom: 8px;
}
.dt-rail-title {
    font-family: "Inter", system-ui, sans-serif; font-size: .78rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px;
}
.dt-rail-list { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--line); }
.dt-rail-list a {
    display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
    padding: 7px 12px; margin-left: -1px; min-height: 36px; box-sizing: border-box;
    border-left: 1px solid transparent;
    color: var(--muted); font-size: .94rem; line-height: 1.35;
}
.dt-rail-list a:hover { color: var(--heading); text-decoration: none; border-left-color: var(--muted); }
.dt-rail-list a[aria-current] { color: var(--heading); font-weight: 600; border-left-color: var(--blue-bright); }
.dt-rail-count { font-family: "JetBrains Mono", monospace; font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Hub: search ---------- */
.dt-toolbar {
    display: grid; grid-template-columns: auto minmax(0, 420px) 1fr; align-items: center;
    gap: 8px 14px; margin: 0 0 14px;
}
.dt-search-label { font-size: .9rem; font-weight: 600; color: var(--heading); }
.dt-search {
    width: 100%; min-height: 44px; padding: 9px 14px;
    font: inherit; font-size: .98rem; color: var(--ink);
    background: var(--card); border: 1px solid var(--line); border-radius: 999px;
}
.dt-search::placeholder { color: var(--muted); }
.dt-search:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 1px; border-color: var(--blue-bright); }
.dt-count { margin: 0; font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dt-search-hint { grid-column: 2 / -1; margin: 0; font-size: .86rem; color: var(--muted); }
.dt-search-hint code, .dt-empty code { font-family: "JetBrains Mono", monospace; font-size: .9em; }

.dt-legend {
    display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center;
    margin: 0 0 8px; font-size: .88rem; color: var(--muted);
}
.dt-legend-item { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Hub: families and cards ---------- */
.dt-family { padding: 36px 0 0; }
.dt-family[hidden] { display: none; }
.dt-family-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; margin: 0 0 16px; }
.dt-family-head h2 { font-size: clamp(1.4rem, 2.2vw, 1.75rem); margin: 0; }
.dt-family-head p { margin: 0; color: var(--muted); max-width: 72ch; }

.dt-grid {
    list-style: none; padding: 0; margin: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px;
}
.dt-grid > li { display: flex; }
.dt-grid > li[hidden] { display: none; }
.dt-card {
    flex: 1; display: flex; flex-direction: column; gap: 8px;
    padding: 18px 20px; color: var(--ink);
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    transition: border-color .16s ease-out;
}
.dt-card:hover { border-color: var(--blue-bright); text-decoration: none; }
.dt-card:hover h3 { color: var(--link); }
.dt-card:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; border-radius: 12px; }
.dt-card h3 { font-size: 1.15rem; margin: 0; }
.dt-card p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.5; }

.dt-engines { list-style: none; padding: 0; margin: auto 0 0; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; }
.dt-eng {
    display: inline-block; padding: 2px 8px;
    font-family: "JetBrains Mono", monospace; font-size: .72rem; line-height: 1.5;
    border-radius: 999px; white-space: nowrap;
}
.dt-eng-yes { color: var(--blue-on-soft); background: var(--blue-soft); border: 1px solid var(--blue-soft); }
.dt-eng-no { color: var(--muted); background: transparent; border: 1px dashed var(--muted); text-decoration: line-through; }

.dt-empty { margin: 32px 0 0; padding: 20px 22px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); max-width: 72ch; }

/* ---------- Detail sections ---------- */
.dt-page .dt-sec { padding: 0 0 clamp(40px, 5vw, 64px); }
.dt-sec h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); margin: 0 0 12px; }
.dt-prose { max-width: 64ch; margin: 0 0 22px; font-size: 1.04rem; }
.dt-sub { color: var(--muted); }

/* Engine comparison: one row per engine, always in the same order. */
.dt-table-wrap {
    overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
.dt-table-wrap:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; }
.dt-compare { width: 100%; border-collapse: collapse; font-size: .96rem; }
.dt-compare th, .dt-compare td { padding: 14px 18px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.dt-compare tbody tr:last-child > * { border-bottom: none; }
.dt-compare thead th {
    font-family: "Inter", system-ui, sans-serif; font-size: .76rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--cream);
}
.dt-compare tbody th { font-family: "Fredoka", "Inter", sans-serif; font-weight: 600; color: var(--heading); white-space: nowrap; width: 1%; }
.dt-compare td code { font-family: "JetBrains Mono", monospace; font-size: .9rem; color: var(--heading); font-variant-ligatures: none; }
.dt-compare td:nth-child(2) { width: 24%; }
.dt-storage { width: 16%; color: var(--ink); font-variant-numeric: tabular-nums; }
.dt-note { color: var(--muted); max-width: 70ch; }
.dt-row-none td code { color: var(--muted); }
.dt-none-tag {
    display: inline-block; margin: 6px 0 0; padding: 1px 8px;
    font-size: .72rem; font-weight: 600; letter-spacing: .02em;
    color: var(--amber-ink); background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: 999px;
}

/* Gotchas: a numbered list, two columns when there is room. */
.dt-gotchas {
    list-style: none; counter-reset: dt-g; padding: 0; margin: 0;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 40px;
}
.dt-gotchas li {
    counter-increment: dt-g; position: relative;
    padding: 14px 0 14px 44px; border-top: 1px solid var(--line); line-height: 1.6; max-width: 70ch;
}
.dt-gotchas li::before {
    content: counter(dt-g); position: absolute; left: 0; top: 14px;
    width: 28px; height: 28px; display: grid; place-items: center;
    font-family: "JetBrains Mono", monospace; font-size: .8rem; font-weight: 600;
    color: var(--pink-ink); background: var(--pink-wash); border-radius: 999px;
}

/* FAQ: question and answer pairs with hairlines, two columns on wide screens. */
.dt-faq { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 40px; }
.dt-qa { padding: 18px 0; border-top: 1px solid var(--line); max-width: 70ch; }
.dt-qa h3 { font-size: 1.12rem; margin: 0 0 8px; }
.dt-qa p { margin: 0; color: var(--muted); line-height: 1.6; }

/* "Related on SQLly" (shared partial) sits inside the main column here. */
.dt-main .tools-xref-sec { padding: 0; border-top: none; }
.dt-main .tools-xref-sec .wrap { padding: 0; }
.dt-main .tools-xref-sec h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }

/* ---------- CTA ---------- */
.dt-cta { margin-top: 0; }
.dt-cta p { max-width: 62ch; }

/* ---------- Narrow screens ---------- */
@media (max-width: 960px) {
    .dt-layout { grid-template-columns: minmax(0, 1fr); }
    .dt-rail { position: static; max-height: none; overflow: visible; gap: 18px; }
    /* On one column the sibling-type list moves below the content; the
       on-this-page links stay on top. */
    .dt-detail-layout .dt-rail { display: contents; }
    .dt-detail-layout .dt-rail-family { order: 2; margin-top: 8px; }
    .dt-detail-layout .dt-main { order: 1; }
    .dt-rail-list { border-left: none; display: flex; flex-wrap: wrap; gap: 8px; }
    .dt-rail-list a {
        margin: 0; padding: 6px 12px; min-height: 40px; align-items: center;
        border: 1px solid var(--line); border-radius: 999px; background: var(--card);
    }
    .dt-rail-list a[aria-current] { border-color: var(--blue-bright); }
    .dt-toolbar { grid-template-columns: minmax(0, 1fr); }
    .dt-search-hint { grid-column: auto; }
}

@media (max-width: 700px) {
    .dt-table-wrap { border: none; background: none; overflow: visible; }
    .dt-compare, .dt-compare tbody, .dt-compare tr, .dt-compare th, .dt-compare td { display: block; width: auto; }
    .dt-compare thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .dt-compare tr { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; padding: 4px 0; }
    .dt-compare th, .dt-compare td { border-bottom: none; padding: 6px 16px; }
    .dt-compare tbody th { padding-top: 12px; font-size: 1.05rem; }
    .dt-compare td[data-label]::before {
        content: attr(data-label); display: block;
        font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
    }
    .dt-compare td:last-child { padding-bottom: 14px; }
    .dt-compare td:empty { display: none; }
    .dt-compare td:nth-child(2), .dt-compare .dt-storage, .dt-compare tbody th { width: auto; }
    .dt-compare td code { overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
    .dt-card { transition: none; }
}
