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

/* ---------- The tool runs edge to edge; prose below stays at reading width ---------- */
.mg-tool { padding: 28px 0 clamp(40px, 5vw, 64px); }
.mg-bleed { padding: 0 clamp(16px, 2vw, 32px); }

/* ---------- Settings bar: engines -> options -> Generate, read left to right ---------- */
.mg-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 28px;
    padding: 16px 20px; margin-bottom: 18px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.mg-route { display: flex; align-items: flex-end; gap: 10px; }
.mg-settings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; }
.mg-run { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-left: auto; }

.mg-opt { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; font-weight: 600; color: var(--heading); }
.mg-opt[hidden] { display: none; }
.mg-opt select, .mg-opt input { padding: 9px 12px; font-size: .95rem; min-width: 150px; min-height: 44px; }
.mg-opt input { font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace; font-variant-ligatures: none; }

.mg-swap {
    display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
    border: 1.5px solid var(--line); border-radius: 999px; background: var(--card); color: var(--heading);
    cursor: pointer; transition: border-color .15s ease, transform .2s cubic-bezier(.2, .8, .2, 1);
}
.mg-swap:hover { border-color: var(--blue-bright); }
.mg-swap:active { transform: rotate(180deg); }

.mg-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; max-width: 60ch; }
.mg-check { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--ink); min-height: 44px; cursor: pointer; }
.mg-check input { width: 18px; height: 18px; accent-color: var(--blue-bright); }

.mg-hint { margin: 0; font-size: .84rem; color: var(--muted); line-height: 1.45; text-wrap: pretty; }
.mg-hint[hidden] { display: none; }
#mg-tx-hint { color: var(--amber-ink); padding-bottom: 4px; }
.mg-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);
}

/* ---------- Work area: input | output | review notes ----------
   Wide screens get three columns; medium screens keep input and output side by side
   with the notes under the output; phones stack everything. */
.mg-work {
    display: grid; gap: 18px 20px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "in out" "notes notes";
    align-items: stretch;
}
.mg-pane-in { grid-area: in; }
.mg-pane-out { grid-area: out; }
.mg-notes { grid-area: notes; }

@media (min-width: 1440px) {
    .mg-work {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(300px, 400px);
        grid-template-areas: "in out notes";
    }
    /* The notes never set the row height: they fill it and scroll, so the
       two editors stay the size the row gives them. */
    .mg-notes { contain: size; overflow-y: auto; }
}

.mg-pane { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mg-pane-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; min-height: 44px; }
.mg-pane-label { font-family: "JetBrains Mono", monospace; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.mg-engine-tag {
    text-transform: none; letter-spacing: 0; font-size: .8rem; font-weight: 600;
    padding: 2px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-on-soft);
}
.mg-pane-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.mg-pane-tools [hidden] { display: none; }
.mg-text-btn {
    min-height: 44px; padding: 0 10px; border: none; background: none; cursor: pointer;
    font: inherit; font-size: .88rem; font-weight: 600; color: var(--link);
    text-decoration: underline; text-underline-offset: 3px; text-decoration-color: transparent;
}
.mg-text-btn:hover { text-decoration-color: currentColor; }

.mg-pane textarea {
    width: 100%;
    min-height: clamp(320px, 52vh, 640px);
    flex: 1 1 auto;
    resize: vertical;
    font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
    font-size: .88rem;
    line-height: 1.55;
    tab-size: 4;
    font-variant-ligatures: none;
    white-space: pre;
    overflow: auto;
}
.mg-pane textarea[readonly] { background: var(--cream); }
#mg-out::placeholder { color: var(--muted); opacity: 1; white-space: pre-wrap; }
#mg-in[aria-invalid="true"] { border-color: var(--pink-strong); }
.mg-pane-out textarea { transition: opacity .2s ease; }
.mg-pane-out.is-stale textarea { opacity: .55; }

.mg-status { margin: 0; min-height: 1.5em; font-size: .9rem; color: var(--muted); }
.mg-status.is-error { color: var(--pink-strong); }
.mg-status.is-stale { color: var(--amber-ink); }

/* ---------- Review notes: the product's promise, kept beside the script ---------- */
.mg-notes {
    min-width: 0; padding: 18px 20px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.mg-notes.has-notes { border-color: var(--amber-line); }
.mg-notes h2 { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; margin: 0 0 8px; }
.mg-count {
    font-family: "JetBrains Mono", monospace; font-size: .8rem; font-weight: 600;
    min-width: 26px; padding: 2px 9px; border-radius: 999px; text-align: center;
    background: var(--amber-soft); color: var(--amber-ink); border: 1px solid var(--amber-line);
}
.mg-count.is-clear { background: var(--green-soft); color: var(--green-on-soft); border-color: transparent; }
.mg-count[hidden], .mg-notes-intro[hidden], .mg-notes-empty[hidden] { display: none; }
.mg-notes-empty, .mg-notes-intro { margin: 0 0 6px; font-size: .92rem; color: var(--muted); text-wrap: pretty; }
.mg-notes ol { margin: 0; padding-left: 22px; max-width: 96ch; }
.mg-notes ol:empty { display: none; }
.mg-notes li { padding: 9px 0; line-height: 1.55; font-size: .94rem; color: var(--ink); text-wrap: pretty; }
.mg-notes li::marker { color: var(--amber-ink); font-weight: 700; }
.mg-notes li + li { border-top: 1px solid var(--line); }

/* ---------- Privacy note ---------- */
.mg-privacy { margin: 18px 0 0; font-size: .9rem; color: var(--muted); max-width: 90ch; }
.mg-privacy strong { color: var(--heading); }

/* ---------- Prose sections: keep a readable measure ---------- */
.mg-doc .tools-faq { max-width: 70ch; }
.mg-doc .tools-points, .mg-doc .tools-intro { max-width: 62ch; }
.mg-doc .tools-faq .card p { max-width: 66ch; }
.mg-doc p, .mg-doc li { text-wrap: pretty; }

/* ---------- Mapping reference table ---------- */
.mg-ref code { font-family: "JetBrains Mono", monospace; font-size: .85em; white-space: nowrap; }
.mg-ref td:last-child { color: var(--muted); font-size: .92rem; min-width: 28ch; }
.mg-ref th:first-child, .mg-ref td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; box-shadow: 1px 0 0 var(--line); }

/* ---------- Related links ---------- */
.mg-links { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px 28px; }
.mg-links li { display: flex; flex-direction: column; gap: 2px; }
.mg-links a { font-weight: 600; }
.mg-links span { color: var(--muted); font-size: .94rem; text-wrap: pretty; }

@media (max-width: 1100px) {
    .mg-run { margin-left: 0; }
}

@media (max-width: 900px) {
    .mg-work { grid-template-columns: minmax(0, 1fr); grid-template-areas: "in" "out" "notes"; }
    .mg-pane textarea { min-height: 240px; }
}

@media (max-width: 640px) {
    .mg-bar { padding: 14px; gap: 14px; }
    .mg-route { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 10px 10px; align-items: end; }
    .mg-route .mg-opt { grid-column: 1; min-width: 0; }
    .mg-swap { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin-top: 22px; transform: rotate(90deg); }
    .mg-swap:active { transform: rotate(270deg); }
    .mg-settings, .mg-settings .mg-opt { width: 100%; }
    .mg-opt select, .mg-opt input { width: 100%; min-width: 0; }
    .mg-run, .mg-run .btn { width: 100%; }
    .mg-run .btn { justify-content: center; }
    .mg-kbd-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .mg-swap, .mg-pane-out textarea { transition: none; }
    .mg-swap:active { transform: none; }
}
