/**
 * ToolDuck — Developer toolkit styles
 * ===============================================================
 * Shared by every /developer-tools/* page. One stylesheet rather than
 * five near-identical ones, and it only uses the tokens from
 * main.css so both themes work without a second palette.
 *
 * Loaded after main.css and tool.css, so `.btn`, `.field`, `.prose`
 * and `.tool-shell` are already available and are reused rather than
 * reimplemented here.
 */

/* -----------------------------------------------------------------
   1. Tool frame — tabs and panels
   ----------------------------------------------------------------- */

.dev {
    --dev-mono: var(--mono);
    display: block;
}

.dev__tabs {
    display: flex;
    gap: .35rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    padding-bottom: .2rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--border);
}

.dev__tab {
    flex: 0 0 auto;
    font: inherit;
    font-size: .89rem;
    font-weight: 600;
    color: var(--ink-3);
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: .6rem .85rem;
    min-height: 44px;
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.dev__tab:hover {
    color: var(--ink);
    background: var(--bg-soft);
}

.dev__tab[aria-selected="true"] {
    color: var(--brand-strong);
    border-bottom-color: var(--brand);
    background: var(--brand-soft);
}

.dev__panel {
    animation: dev-fade .18s ease;
}

.dev__panel[hidden] {
    display: none;
}

@keyframes dev-fade {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .dev__panel { animation: none; }
}

.dev__lede {
    margin: 0 0 1rem;
    color: var(--ink-3);
    font-size: .92rem;
    max-width: 68ch;
}

/* -----------------------------------------------------------------
   2. Fields
   ----------------------------------------------------------------
   `.field` (label + control) already exists in tool.css; these are
   the control shapes the developer tools need on top of it.
   ----------------------------------------------------------------- */

.dev-textarea,
.dev-input,
.dev-select {
    font-family: var(--dev-mono, var(--mono));
    font-size: .875rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .7rem .8rem;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.dev-textarea {
    min-height: 9rem;
    resize: vertical;
    tab-size: 2;
}

.dev-textarea--short { min-height: 4.5rem; }
.dev-textarea--tall  { min-height: 15rem; }

.dev-select { font-family: inherit; font-size: .9rem; min-height: 44px; }

.dev-textarea:focus-visible,
.dev-input:focus-visible,
.dev-select:focus-visible,
.dev__tab:focus-visible {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus-ring);
}

.dev-input[readonly] { color: var(--ink-3); }

.dev-hint {
    margin: 0;
    font-size: .8rem;
    color: var(--ink-4);
    line-height: 1.5;
}

/* -----------------------------------------------------------------
   3. Layout helpers
   ----------------------------------------------------------------- */

.dev-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 768px) {
    .dev-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.dev-stack { display: flex; flex-direction: column; gap: .9rem; }

.dev-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-top: .7rem;
}

.dev-actions--end { justify-content: flex-end; }

/* Grows to fill, then wraps — keeps touch targets full width on phones
   without the row overflowing on a 390px viewport. */
.dev-actions .btn { flex: 0 1 auto; }

@media (max-width: 430px) {
    .dev-actions .btn { flex: 1 1 100%; }
}

.dev-inline {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem .9rem;
    align-items: center;
}

/* -----------------------------------------------------------------
   4. Status messages
   ----------------------------------------------------------------- */

.dev-status {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: .87rem;
    line-height: 1.55;
    padding: .6rem .75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--ink-2);
    margin: .8rem 0 0;
    overflow-wrap: anywhere;
}

.dev-status:empty { display: none; }

.dev-status__icon {
    flex: 0 0 auto;
    display: inline-flex;
    margin-top: .1em;
    color: currentColor;
}

.dev-status__icon svg { width: 16px; height: 16px; display: block; }

.dev-status--success { background: var(--ok-bg);   border-color: color-mix(in srgb, var(--ok) 30%, transparent);   color: var(--ok); }
.dev-status--error   { background: var(--err-bg);  border-color: color-mix(in srgb, var(--err) 30%, transparent);  color: var(--err); }
.dev-status--warn    { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }

.dev-status--success .dev-status__text,
.dev-status--error .dev-status__text,
.dev-status--warn .dev-status__text {
    color: var(--ink-2);
}

/* -----------------------------------------------------------------
   5. Output
   ----------------------------------------------------------------- */

.dev-out {
    font-family: var(--dev-mono, var(--mono));
    font-size: .85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
    padding: .8rem;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 22rem;
    overflow: auto;
}

.dev-out--empty { color: var(--ink-4); }

/* -----------------------------------------------------------------
   6. Result cards and key/value output
   ----------------------------------------------------------------- */

.dev-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 1rem;
}

.dev-card + .dev-card { margin-top: .75rem; }

.dev-card__title {
    margin: 0 0 .6rem;
    font-size: .95rem;
    font-weight: 650;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}

.dev-kv {
    display: grid;
    grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr);
    gap: .35rem .9rem;
    margin: 0;
    font-size: .87rem;
}

.dev-kv dt {
    color: var(--ink-3);
    font-weight: 600;
}

.dev-kv dd {
    margin: 0;
    color: var(--ink);
    font-family: var(--dev-mono, var(--mono));
    overflow-wrap: anywhere;
}

.dev-kv dd.is-plain { font-family: inherit; }

@media (max-width: 430px) {
    .dev-kv { grid-template-columns: minmax(0, 1fr); gap: .1rem 0; }
    .dev-kv dt { margin-top: .5rem; }
}

/* -----------------------------------------------------------------
   7. Chips, badges and callouts
   ----------------------------------------------------------------- */

.dev-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    padding: .2rem .5rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    border: 1px solid var(--brand-border);
    white-space: nowrap;
}

.dev-badge--ok   { background: var(--ok-bg);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.dev-badge--warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.dev-badge--err  { background: var(--err-bg);  color: var(--err);  border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.dev-badge--mute { background: var(--bg-muted); color: var(--ink-3); border-color: var(--border); }

/* Warnings and privacy notes inside a tool. Uses an accent border and
   an icon so meaning never depends on colour alone. */
.dev-note {
    display: flex;
    gap: .55rem;
    align-items: flex-start;
    font-size: .85rem;
    line-height: 1.6;
    padding: .7rem .85rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--ink-4);
    background: var(--bg-soft);
    color: var(--ink-2);
    margin: .9rem 0 0;
}

.dev-note--warn    { border-left-color: var(--warn); background: var(--warn-bg); }
.dev-note--lock    { border-left-color: var(--ok);   background: var(--ok-bg); }
.dev-note strong   { color: var(--ink); }

.dev-note svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: .15em; }

/* -----------------------------------------------------------------
   8. Lists of generated values (bulk UUID, match lists)
   ----------------------------------------------------------------- */

.dev-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: .3rem;
    max-height: 20rem;
    overflow: auto;
}

.dev-list li {
    font-family: var(--dev-mono, var(--mono));
    font-size: .85rem;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    overflow-wrap: anywhere;
}

.dev-list--inline {
    grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
}

@media (max-width: 430px) {
    .dev-list--inline { grid-template-columns: minmax(0, 1fr); }
}

/* -----------------------------------------------------------------
   9. Regex highlighting and text diff
   ----------------------------------------------------------------- */

.dev-match {
    background: color-mix(in srgb, var(--brand) 22%, transparent);
    border-radius: 3px;
    padding: 0 .1em;
    box-shadow: inset 0 -2px 0 var(--brand);
}

.dev-match--group {
    background: color-mix(in srgb, var(--ok) 22%, transparent);
    box-shadow: inset 0 -2px 0 var(--ok);
}

.dev-mark {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: var(--dev-mono, var(--mono));
    font-size: .85rem;
    line-height: 1.7;
    margin: 0;
    padding: .8rem;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 22rem;
    overflow: auto;
}

.dev-diff {
    font-family: var(--dev-mono, var(--mono));
    font-size: .82rem;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 26rem;
}

.dev-diff li {
    display: flex;
    gap: .6rem;
    padding: .3rem .6rem;
    border-bottom: 1px solid var(--border);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.dev-diff li:last-child { border-bottom: 0; }

/* The sign column carries the meaning; the tint is reinforcement, so
   the diff still reads correctly in monochrome or with colour
   perception differences. */
.dev-diff__sign { flex: 0 0 1ch; font-weight: 700; color: var(--ink-3); }
.dev-diff__num  { flex: 0 0 auto; color: var(--ink-4); min-width: 2.5ch; text-align: right; }

.dev-diff li.is-add { background: var(--ok-bg); }
.dev-diff li.is-add .dev-diff__sign { color: var(--ok); }
.dev-diff li.is-del { background: var(--err-bg); }
.dev-diff li.is-del .dev-diff__sign { color: var(--err); }
.dev-diff li.is-same { color: var(--ink-3); }

/* -----------------------------------------------------------------
   10. Small print
   ----------------------------------------------------------------- */

.dev-mono { font-family: var(--dev-mono, var(--mono)); }

.dev-count {
    font-size: .8rem;
    color: var(--ink-4);
    font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------
   11. Digest rows (Hash Generator)
   ----------------------------------------------------------------
   Algorithm, value, copy. The value column is the only flexible one,
   so a long digest wraps inside the row instead of widening the page.
   ----------------------------------------------------------------- */

.dev-hash-row {
    display: grid;
    grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr) auto;
    gap: .4rem .8rem;
    align-items: center;
    padding: .55rem .6rem;
    border-bottom: 1px solid var(--border);
}

.dev-hash-row:last-child { border-bottom: 0; }

.dev-hash-row__value {
    font-family: var(--dev-mono, var(--mono));
    font-size: .78rem;
    line-height: 1.5;
    color: var(--ink);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

@media (max-width: 560px) {
    .dev-hash-row {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
    }
    .dev-hash-row__value { grid-column: 1 / -1; }
}

/* Drop target feedback for the file picker. */
.dev-input.is-dragover {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: var(--focus-ring);
}
