/* ============================================================
   .uk-tool-form — proposed canonical tool-form primitives (loaded only on /docs/ui-kit)
   ============================================================
   Replaces the form-primitive cluster on `/tools/*` pages plus the
   landing-page tools demo in `public/css/style.css`:

     .tools-demo                    -> .uk-tool-form-demo                  (2-col input vs output grid)
     .tools-demo--stacked           -> .uk-tool-form-demo .uk-tool-form-demo--stacked
     .tool-input-group              -> .uk-tool-form-row                   (flex row of fields)
     .tool-input                    -> .uk-tool-form-input                 (mono main input)
     .tool-input-host               -> .uk-tool-form-input--host           (flex-grow main host field)
     .tool-input-port               -> .uk-tool-form-input--port           (narrow centred port, no spinner)
     .tool-input-protocol           -> .uk-tool-form-input--protocol       (compact select)
     .tool-input-starttls           -> .uk-tool-form-input--starttls       (select with custom caret)
     .tool-input-field              -> .uk-tool-form-field                 (stacked label + input wrapper)
     .tool-input-field--host        -> .uk-tool-form-field--host
     .tool-input-field--port        -> .uk-tool-form-field--port
     .tool-input-field--starttls    -> .uk-tool-form-field--starttls
     .tool-input-label              -> .uk-tool-form-label                 (uppercase eyebrow)
     .tool-protocol-toggle          -> .uk-tool-form-protocol              (segmented button group)
     .tool-protocol-btn             -> .uk-tool-form-protocol-btn          (single segment, .is-active state)
     .tool-options                  -> .uk-tool-form-options               (checkbox row)
     .tool-checkbox                 -> .uk-tool-form-checkbox              (single labelled checkbox)
     .tool-error                    -> .uk-tool-form-error                 (inline error pill)

   The form *card chrome* (background + border + radius + padding) lives in
   `.uk-tool-interface` (Tier 4.1). This file owns the form *primitives*
   that sit inside that card — inputs, field wrappers, segmented toggles,
   options, error display.

   Mode-chip tab row composes with `.uk-tabs + .uk-tabs--pill`
   (tabs.css) — that one's already canonical and exactly matches the
   legacy `.tool-tab.active` look. No re-implementation here.

   Composes with: `.uk-tool-interface` (card chrome), `.uk-tabs --pill`
   (mode chips). Spinner on submit composes with
   `.uk-spinner --sm --inverse` (Tier 1.4).
   ============================================================ */

/* ============================================
   Demo shell — 2-col grid (input ↔ output) or stacked
   ============================================
   Landing-page tools demo uses `2-col grid` (input on the left,
   placeholder/result preview on the right). `/tools/*` pages stack
   to a single column because the result area is full-width below
   the form.
   ============================================ */
.uk-tool-form-demo {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-xl);
    margin-bottom: var(--space-2xl);
    align-items: center;
}

.uk-tool-form-demo--stacked {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
}

@media (max-width: 900px) {
    .uk-tool-form-demo {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ============================================
   Row — flex wrapper for inputs + submit
   ============================================
   Wraps on overflow so wide form rows (host + port + starttls + submit)
   re-flow gracefully on narrow viewports.
   ============================================ */
.uk-tool-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    align-items: flex-end;
}

/* Trailing margin collapses to 0 when the row is the last child — for
   sidebar / compact embeds without a privacy note or options row below. */
.uk-tool-form-row:last-child {
    margin-bottom: 0;
}

/* ============================================
   Field — stacked label + input wrapper
   ============================================
   Width is governed by per-field flex modifiers below — the field
   itself only owns the column flow + min-width-zero so the inner
   input can shrink inside flex-row contexts.
   ============================================ */
.uk-tool-form-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.uk-tool-form-field > .uk-tool-form-input {
    width: 100%;
}

.uk-tool-form-field--host     { flex: 1 1 220px; }
.uk-tool-form-field--port     { flex: 0 0 7ch; }
.uk-tool-form-field--starttls { flex: 0 0 14ch; }

/* ============================================
   Label — uppercase eyebrow above input
   ============================================ */
.uk-tool-form-label {
    display: block;
    margin-bottom: 4px;
    color: var(--color-text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ============================================
   Input — main mono input (host, url, query target)
   ============================================
   Mono font matches the diagnostic / technical context of the tools.
   Focus glow uses `--color-primary-glow` (already a brand token).
   ============================================ */
.uk-tool-form-input {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition: var(--transition-fast);
}

.uk-tool-form-input::placeholder {
    color: var(--color-text-muted);
}

.uk-tool-form-input:hover:not(:focus) {
    border-color: var(--color-border-light);
}

.uk-tool-form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.uk-tool-form-input:focus-visible {
    outline-color: var(--color-primary);
}

/* ============================================
   Input variants — port / protocol / starttls
   ============================================
   `--port`: narrow centred numeric without browser spinner controls.
   `--protocol`: compact dropdown (a select) for protocol picking.
   `--starttls`: select with a hand-rendered caret so the option text
   isn't truncated by inconsistent native chrome across browsers.
   ============================================ */
.uk-tool-form-input--port {
    flex: 0 0 auto;
    width: 7ch;
    padding-right: var(--space-sm);
    padding-left: var(--space-sm);
    text-align: center;
    -moz-appearance: textfield;
}

.uk-tool-form-input--port::-webkit-outer-spin-button,
.uk-tool-form-input--port::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.uk-tool-form-input--protocol {
    flex: 0 0 80px;
    padding: var(--space-md);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    cursor: pointer;
}

.uk-tool-form-input--starttls {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-left: var(--space-md);
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2394a3b8' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    cursor: pointer;
}

/* ============================================
   Protocol toggle — segmented button group
   ============================================
   Hard-edge segmented control: each segment shares a border with the
   next, no gap. Active segment fills with primary; the joining
   border-right hides at the segment boundary.
   ============================================ */
.uk-tool-form-protocol {
    display: flex;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.uk-tool-form-protocol-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    border: none;
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.uk-tool-form-protocol-btn:not(:last-child) {
    border-right: 1px solid var(--color-border);
}

.uk-tool-form-protocol-btn:not(.is-active):hover {
    background: var(--color-bg-hover, var(--color-bg-card-hover));
    color: var(--color-text);
}

.uk-tool-form-protocol-btn.is-active,
.uk-tool-form-protocol-btn[aria-pressed="true"] {
    background: var(--color-primary);
    color: #fff;
}

/* ============================================
   Options — checkbox row
   ============================================
   Wrapping flex row of labelled checkboxes. Used as the "Follow
   redirects / Verify SSL chain" row below the host input.
   ============================================ */
.uk-tool-form-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
}

.uk-tool-form-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-text-secondary);
    font-size: var(--font-md);
    cursor: pointer;
}

.uk-tool-form-checkbox > input {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}

/* ============================================
   Error — inline post-submit error pill
   ============================================
   Shows below the input row when the submit handler returns a
   validation error. Distinct from `.uk-feedback-message` (Tier 1.5)
   which is the rounded-pill "post-submit success/error" — this one
   sits inline as a tinted box with a flat radius, more like an
   inline form error than a celebratory pill.
   ============================================ */
.uk-tool-form-error {
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(var(--color-error-rgb), 0.1);
    border: 1px solid rgba(var(--color-error-rgb), 0.3);
    border-radius: var(--radius-md);
    color: var(--color-error);
    font-size: var(--font-sm);
}

/* ============================================
   Submit button helpers
   ============================================
   Submit button itself composes with `.btn .btn-primary` — no
   re-implementation here. The play-icon helper sizes an inline svg
   to match the button's text height so the icon never breaks the
   button's vertical rhythm.
   ============================================ */
.uk-tool-form-btn-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}
