/* /tools/test-data-generator - page-specific rules ONLY. Shared primitives
   (tokens, buttons, cards, notices, pills, tables, form controls) come from
   tokens.css / site.css and tools.css. No new colors: every value here is a
   site token. Mono is for SQL and column definitions only. */

/* ---------- Page head: shorter, so the tool starts higher on the screen ---------- */
.tdg-head { padding-top: clamp(32px, 4vw, 48px); }
.tdg-head .lede { max-width: 68ch; margin-bottom: 0; }

/* ---------- Full-width tool ---------- */
/* The tool breaks out of the 1140px .wrap and uses the whole viewport; the
   prose sections below keep their reading width. */
.tdg-tool { padding: 28px 0 clamp(48px, 6vw, 72px); }
.tdg-bleed { padding: 0 clamp(16px, 2vw, 32px); }
.tdg code { font-family: "JetBrains Mono", monospace; font-size: .88em; overflow-wrap: anywhere; }
.tdg-noscript { margin: 0 0 22px; }

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

/* Narrow: one column, in the order you use it (table, shapes, output). */
.tdg-workspace {
    display: grid; gap: clamp(14px, 1.4vw, 22px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "input" "cols" "output";
    align-items: start;
}
.tdg-input { grid-area: input; }
.tdg-colpane { grid-area: cols; }
.tdg-output { grid-area: output; }

.tdg-pane {
    display: flex; flex-direction: column; gap: 10px; min-width: 0;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: clamp(14px, 1.3vw, 20px);
}
.tdg-pane-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; }
.tdg-pane-title {
    display: block; margin: 0;
    font-family: "JetBrains Mono", monospace; font-size: .8rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em; color: var(--heading);
}
.tdg-pane-link { font-size: .88rem; font-weight: 600; color: var(--link); }
.tdg-hint { font-size: .86rem; color: var(--muted); margin: 0; max-width: 70ch; }
.tdg-empty { font-size: .95rem; color: var(--muted); margin: 0; padding: 18px 0; }
.tdg-empty[hidden], .tdg-columns[hidden] { display: none; }

/* ---------- Schema input ---------- */
.tdg-input textarea,
.tdg-sql {
    width: 100%; resize: vertical;
    font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
    line-height: 1.55; tab-size: 4;
    /* SQL must read literally: no ">=" drawn as a ligature. */
    font-variant-ligatures: none;
    overflow: auto;
}
.tdg-input textarea { min-height: 300px; font-size: .9rem; white-space: pre; overflow: auto; }
.tdg-schema-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.tdg-schema-bar .tdg-field { flex: 1 1 200px; }
.tdg-schema-bar select { width: 100%; }

.tdg-notes { font-size: .88rem; color: var(--muted); }
.tdg-notes summary { cursor: pointer; font-weight: 600; color: var(--heading); min-height: 44px; display: flex; align-items: center; width: fit-content; }
.tdg-notes p { margin: 4px 0 0; max-width: 70ch; line-height: 1.6; }

/* ---------- Fields ---------- */
.tdg-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tdg-field label, .tdg-col label { font-size: .84rem; font-weight: 600; color: var(--heading); }
.tdg-field input, .tdg-field select { padding: 10px 12px; font-size: .95rem; min-width: 0; min-height: 44px; }
.tdg-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.tdg-options input[type="number"] { width: 100%; font-variant-numeric: tabular-nums; }
.tdg-options .tdg-field:last-child { grid-column: span 2; }
.tdg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tdg-actions .btn { padding: 11px 22px; min-height: 44px; }
.tdg-kbd-hint { font-size: .82rem; color: var(--muted); }
.tdg-kbd-hint kbd {
    font-family: "JetBrains Mono", monospace; font-size: .76rem;
    padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--cream);
}

[aria-invalid="true"] { border-color: var(--pink-ink) !important; }

.tdg-status { font-size: .9rem; color: var(--muted); min-height: 1.4em; margin: 0; }
.tdg-status.is-error { color: var(--pink-ink); font-weight: 600; }
.tdg-stale {
    font-size: .74rem; font-weight: 600; padding: 2px 10px; border-radius: 999px;
    color: var(--amber-ink); background: var(--amber-soft); border: 1px solid var(--amber-line);
}
.tdg-stale[hidden] { display: none; }

/* ---------- Per-column shapes ---------- */
/* Rows lay out by the width of their pane, not the viewport, so they fit the
   column whether it is a third of a wide screen or the whole phone. */
.tdg-colpane { container-type: inline-size; container-name: tdgcols; }
.tdg-columns { display: grid; }
.tdg-col {
    display: grid; gap: 10px 12px; align-items: start;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "shape" "opts" "null" "err";
    padding: 14px 0; border-top: 1px solid var(--line);
}
.tdg-col:first-child { border-top: none; padding-top: 4px; }
/* Rows are divided by hairlines, not boxed: the pane is already the card. */
.tdg-col.is-invalid { background: var(--pink-wash); padding-left: 10px; padding-right: 10px; border-radius: 8px; }
.tdg-col-head { grid-area: head; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.tdg-cell-shape { grid-area: shape; }
.tdg-cell-opts { grid-area: opts; display: flex; flex-wrap: wrap; gap: 8px 10px; }
.tdg-cell-opts.is-empty { display: none; }
.tdg-cell-null { grid-area: null; }
.tdg-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.tdg-cell-opts { flex-direction: row; }
.tdg-sub { display: flex; flex-direction: column; gap: 5px; flex: 1 1 96px; min-width: 0; }
.tdg-sub-wide { flex-basis: 100%; }
.tdg-col-name { font-family: "JetBrains Mono", monospace; font-size: .9rem; font-weight: 600; color: var(--heading); overflow-wrap: anywhere; }
.tdg-col-type { font-family: "JetBrains Mono", monospace; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.tdg-col-flags { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.tdg-flag {
    font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px;
    border: 1px solid var(--line); color: var(--muted);
}
.tdg-flag.pk { border-color: var(--blue-lift); color: var(--blue-lift); }
.tdg-col input, .tdg-col select { width: 100%; padding: 9px 10px; font-size: .92rem; min-width: 0; min-height: 44px; }
.tdg-col input[type="number"] { font-variant-numeric: tabular-nums; }
.tdg-col input:disabled, .tdg-col select:disabled { opacity: .7; cursor: not-allowed; }
.tdg-null-note { font-size: .78rem; color: var(--muted); }
.tdg-col-error { grid-area: err; margin: 0; font-size: .86rem; font-weight: 600; color: var(--pink-ink); }
.tdg-col-error[hidden] { display: none; }

@container tdgcols (min-width: 460px) {
    .tdg-col {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "head head" "shape null" "opts opts" "err err";
    }
}
@container tdgcols (min-width: 640px) {
    .tdg-col {
        grid-template-columns: minmax(120px, .9fr) minmax(170px, 1.1fr) minmax(0, 1.7fr) minmax(96px, .5fr);
        grid-template-areas: "head shape opts null" "err err err err";
    }
    .tdg-col-head { flex-direction: column; gap: 3px; padding-top: 2px; }
    .tdg-cell-opts.is-empty { display: block; }
}

/* ---------- Output ---------- */
.tdg-sql {
    min-height: 340px; font-size: .85rem;
    background: var(--cream); white-space: pre;
}
.tdg-output.is-stale .tdg-sql { opacity: .6; }

/* ---------- Wide screens: side by side ---------- */
/* 1200px+: table and shapes stacked on the left, output pinned on the right. */
@media (min-width: 1200px) {
    .tdg-workspace {
        grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
        grid-template-areas: "input output" "cols output";
    }
    /* Pinned below the 70px site header, one screen tall, so the SQL stays in
       view while you scroll through the column list. */
    .tdg-output {
        position: sticky; top: 86px;
        height: calc(100vh - 102px); height: calc(100dvh - 102px);
        min-height: 520px;
    }
    .tdg-output .tdg-sql { flex: 1 1 auto; min-height: 260px; resize: none; }
    .tdg-input textarea { min-height: 260px; }
}
/* 1600px+: three panes across - table, shapes, output. */
@media (min-width: 1600px) {
    .tdg-workspace {
        grid-template-columns: minmax(320px, .8fr) minmax(0, 1.5fr) minmax(0, 1.15fr);
        grid-template-areas: "input cols output";
    }
    .tdg-input { position: sticky; top: 86px; }
    .tdg-input textarea { min-height: 420px; }
}

/* ---------- Prose sections below the tool: reading width ---------- */
.tdg-prose .tools-intro { max-width: 60ch; }
.tdg-prose .tools-points { max-width: 62ch; }
.tdg-prose .tools-faq { max-width: 68ch; }
.tdg-prose .tools-faq .card p { max-width: 60ch; }
.tdg-prose p, .tdg-prose li { text-wrap: pretty; }

/* ---------- Shape reference table ---------- */
.tdg-ref { overflow-x: auto; max-width: 72ch; }
.tdg-ref table { width: 100%; border-collapse: collapse; }
.tdg-ref th, .tdg-ref td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tdg-ref th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tdg-ref td:first-child { font-family: "JetBrains Mono", monospace; font-size: .85rem; white-space: nowrap; }
.tdg-ref td:last-child { color: var(--muted); }
#shape-reference { scroll-margin-top: 96px; }

@media (max-width: 900px) {
    .tdg-ref td:first-child { white-space: normal; }
}
@media (max-width: 480px) {
    .tdg-ref th, .tdg-ref td { padding: 10px 8px; }
    .tdg-options .tdg-field:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    .tdg .btn { transition: none; }
    .tdg .btn:hover, .tdg .btn:active { transform: none; }
}
