/* /tools/grant-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 generated statements and identifiers only. */

.gg-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.gg-tool code, .gg-ref code, .gg-why code, .gg-hint code { font-family: "JetBrains Mono", monospace; font-size: .88em; }
[hidden] { display: none !important; }

/* The head lines up with the full-width tool below it; the lede keeps its own measure. */
.gg-head .wrap { max-width: none; padding: 0 clamp(16px, 2vw, 32px); }
.gg-head .lede code { font-family: "JetBrains Mono", monospace; font-size: .86em; }

/* ---------- Full-width tool: options left, statements right ---------- */
.gg-tool { padding: 28px 0 clamp(48px, 6vw, 72px); }
.gg-shell { padding: 0 clamp(16px, 2vw, 32px); }
.gg-app { display: grid; gap: 24px; min-width: 0; }
html:not(.js) .gg-app { display: none; }

@media (min-width: 1024px) {
    .gg-app { grid-template-columns: minmax(380px, 5fr) minmax(0, 8fr); gap: clamp(24px, 2.4vw, 40px); align-items: start; }
    .gg-jump { display: none; }
}
/* Pin the options while the statements scroll, when the viewport is tall enough. */
@media (min-width: 1024px) and (min-height: 760px) {
    .gg-controls { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; }
}

/* ---------- Options panel ---------- */
.gg-controls {
    display: flex; flex-direction: column; gap: 18px; min-width: 0;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: clamp(16px, 1.6vw, 24px);
}
.gg-jump { align-self: flex-start; font-weight: 600; font-size: .92rem; min-height: 44px; display: inline-flex; align-items: center; }
.gg-controls fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
/* Floated so the legend sits inside the fieldset's padding like ordinary content. */
.gg-controls legend {
    float: left; width: 100%; padding: 0; margin-bottom: 10px;
    font-family: "JetBrains Mono", monospace; font-size: .78rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.gg-controls legend + * { clear: both; }
.gg-controls > fieldset + fieldset { box-shadow: inset 0 1px 0 var(--line); padding-top: 16px; }

/* Engine: the choice everything else depends on, as site pills. */
.gg-engine-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.gg-engine-pills label { position: relative; cursor: pointer; }
.gg-engine-pills input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.gg-engine-pills span {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
    border-radius: 999px; border: 1.5px solid var(--line); background: var(--card);
    color: var(--heading); font-weight: 600; font-size: .95rem;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.gg-engine-pills label:hover span { border-color: var(--blue-bright); }
.gg-engine-pills input:checked + span { background: var(--blue-bright); border-color: var(--blue-bright); color: #fff; }
.gg-engine-pills input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 3px; }

.gg-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 12px 14px; }
.gg-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gg-field-wide { grid-column: 1 / -1; }
.gg-field label { font-size: .88rem; font-weight: 600; color: var(--heading); }
/* 16px text: iOS Safari zooms the page on focus below that. */
.gg-field input, .gg-field select { width: 100%; padding: 10px 12px; font-size: 1rem; min-width: 0; min-height: 44px; }
.gg-field input { font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace; font-variant-ligatures: none; }
.gg-field input::placeholder { color: var(--muted); opacity: 1; }
.gg-field input[aria-invalid="true"] { border-color: var(--pink-strong); }
.gg-err { margin: 0; font-size: .86rem; font-weight: 600; color: var(--pink-ink); }
.gg-hint { margin: 0; font-size: .84rem; line-height: 1.5; color: var(--muted); }

.gg-privs-list { display: flex; flex-wrap: wrap; gap: 0 20px; }
.gg-privs-list label { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; font-family: "JetBrains Mono", monospace; min-height: 44px; cursor: pointer; color: var(--ink); }
.gg-privs-list input, .gg-check input { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--blue-bright); }

.gg-options { display: flex; flex-direction: column; gap: 0; margin-top: 8px; }
.gg-check { display: inline-flex; align-items: center; gap: 10px; font-size: .92rem; color: var(--ink); min-height: 44px; cursor: pointer; }
.gg-check:has(input:disabled) { color: var(--muted); cursor: not-allowed; }
.gg-options .gg-hint { margin: -6px 0 6px 28px; }

/* ---------- Statements pane ---------- */
.gg-results { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.gg-results:focus { outline: none; }
.gg-bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.gg-status { font-size: .92rem; color: var(--muted); }
.gg-status.is-error { color: var(--pink-ink); font-weight: 600; }
.gg-bar-note { margin: 0; font-size: .88rem; color: var(--muted); max-width: 64ch; }

.gg-outputs { display: grid; gap: 16px; min-width: 0; }
.gg-empty { margin: 0; padding: 24px 18px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }
/* Very wide screens: GRANT and REVOKE side by side. */
@media (min-width: 1680px) {
    .gg-outputs { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
.gg-out { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.gg-out[data-kind="alt"] { background: transparent; border-style: dashed; }
.gg-out-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gg-out-title { margin: 0; font-family: "JetBrains Mono", monospace; font-size: .92rem; font-weight: 600; color: var(--heading); overflow-wrap: anywhere; }
.gg-out[data-kind="revoke"] .gg-out-title { color: var(--pink-ink); }
.gg-card-copy { flex: none; min-height: 40px; padding: 0 16px; font-size: .88rem; }
.gg-row { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gg-code {
    margin: 0; padding: 12px 14px; background: var(--cream); border: 1px solid var(--line); border-radius: 10px;
    font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace; font-size: .86rem; line-height: 1.55;
    color: var(--ink); font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; tab-size: 2;
}
.gg-row[data-placeholder] .gg-code { border-color: var(--amber-line); }
.gg-why { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; max-width: 64ch; }
.gg-why.is-warn { color: var(--amber-ink); background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: 10px; padding: 8px 12px; }
.gg-tag { margin-right: 4px; vertical-align: 1px; }

/* ---------- Server-rendered example ---------- */
.gg-example { max-width: 860px; margin-top: 18px; }

/* ---------- Content ---------- */
/* Tighter measure than the shared tools.css defaults: about 70 characters a line. */
.gg-prose .tools-intro { max-width: 64ch; }
.gg-prose .tools-faq { max-width: 70ch; }
.tools-xref, .tools-xref-also { max-width: 70ch; }
.gg-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.gg-ref { width: 100%; border-collapse: collapse; }
.gg-ref th, .gg-ref td { vertical-align: top; text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); line-height: 1.55; }
.gg-ref th { font-family: "JetBrains Mono", monospace; font-size: .76rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.gg-ref td { font-size: .92rem; }
.gg-ref tr:last-child td { border-bottom: none; }
.gg-ref td:first-child { white-space: nowrap; }
.gg-ref td:nth-child(2) { color: var(--ink); min-width: 16ch; }
.gg-ref td:nth-child(3) { color: var(--muted); min-width: 32ch; max-width: 70ch; }

.gg-privacy { margin: 0; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: .92rem; color: var(--muted); }

@media (max-width: 640px) {
    .gg-ref td:first-child { white-space: normal; }
    .gg-ref td:nth-child(3) { min-width: 24ch; }
    .gg-engine-pills span { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .gg-engine-pills span { transition: none; }
}
