/* ---------------------------------------------------------------------------
 * image-tools.css — the widget on the four free image utility pages
 * (/tools/image-resizer, /tools/image-compressor, /tools/image-converter,
 * /tools/heic-to-jpg).
 *
 * Everything is scoped under `.imgtool-section` / `.imgtool` so it cannot leak
 * into the other `body.templates-page` verticals (glossary, alternatives,
 * features, use-cases, styles, faq) that share that body class.
 *
 * House rules honoured: flat fills only, no gradients, no glows, hairline
 * borders, buttons at 10px radius with compact padding, colours read from the
 * theme-aware --t-* tokens so light mode needs no second block, Satoshi via
 * --font-clash. Loaded as a raw <link> so it carries a ?v= token.
 * ------------------------------------------------------------------------- */

.imgtool-section {
    padding: 0 20px 64px;
}

.imgtool {
    max-width: 900px;
    margin: 0 auto;
    background: var(--t-bg-card, #FFFFFF);
    border: 1px solid var(--t-border, #E7E4DF);
    border-radius: 24px;
    padding: 28px;
    box-sizing: border-box;
}

/* ── drop zone ─────────────────────────────────────────────────────────── */

.imgtool-drop {
    display: block;
    border: 1px dashed var(--t-border-mid, #DAD6D0);
    border-radius: 14px;
    background: var(--t-bg-card, #FFFFFF);
    padding: 34px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 180ms ease-in-out, background-color 180ms ease-in-out;
}

.imgtool-drop:hover,
.imgtool-drop.is-over {
    border-color: var(--ss-ink, #141414);
    background: var(--ss-pink-3, #FFF3FC);
}

.imgtool-drop:focus-within {
    outline: 2px solid var(--ss-ink, #141414);
    outline-offset: 2px;
}

.imgtool-drop-title {
    font-family: var(--font-clash), sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--t-text, #141414);
    margin: 0 0 6px;
}

.imgtool-drop-hint {
    font-size: 14px;
    color: var(--t-text-muted, #6B6660);
    margin: 0;
}

/* The real input stays in the DOM and keyboard-reachable; the label is the
   visible target. Never display:none — that removes it from the tab order.

   `input.imgtool-input` (0,1,1), NOT the bare class (0,1,0): app-critical.css
   ships `input[type="file"] { width: 100% }` at (0,1,1), which outranked the
   class and stretched this "hidden" input to the full viewport width. Being
   absolutely positioned at its static offset, it then pushed the document to
   twice the viewport — a measured 2160px document at a 1440px viewport, so
   every page using this tool scrolled sideways at EVERY width. inset pins it
   to the corner so it can never contribute to layout again. */
input.imgtool-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
}

.imgtool-privacy {
    font-size: 13px;
    color: var(--t-text-muted, #6B6660);
    text-align: center;
    margin: 14px 0 0;
}

/* ── controls ──────────────────────────────────────────────────────────── */

.imgtool-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.imgtool-field {
    min-width: 0;
}

.imgtool-field > label,
.imgtool-field > .imgtool-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--t-text-secondary, #57534E);
    margin-bottom: 6px;
}

.imgtool-field select,
.imgtool-field input[type="number"],
.imgtool-field input[type="text"] {
    width: 100%;
    height: 42px;
    box-sizing: border-box;
    background: var(--t-bg-input, #FFFFFF);
    border: 1px solid var(--t-border-mid, #DAD6D0);
    border-radius: 14px;
    color: var(--t-text, #141414);
    font-size: 15px;
    padding: 0 12px;
    margin: 0;
    box-shadow: none;
}

.imgtool-field select:focus-visible,
.imgtool-field input:focus-visible {
    outline: 2px solid var(--ss-ink, #141414);
    outline-offset: 2px;
}

.imgtool-pair {
    display: flex;
    gap: 8px;
    align-items: center;
}

.imgtool-pair span {
    color: var(--t-text-muted, #6B6660);
    font-size: 14px;
}

.imgtool-field input[type="color"] {
    width: 100%;
    height: 42px;
    padding: 4px;
    background: var(--t-bg-input, #FFFFFF);
    border: 1px solid var(--t-border-mid, #DAD6D0);
    border-radius: 14px;
    box-sizing: border-box;
}

.imgtool-field input[type="range"] {
    width: 100%;
    accent-color: var(--ss-ink, #141414);
    margin: 10px 0 0;
}

.imgtool-qval {
    color: var(--t-text, #141414);
    font-weight: 600;
}

/* ── status + results ──────────────────────────────────────────────────── */

.imgtool-status {
    margin: 20px 0 0;
    font-size: 14px;
    color: var(--t-text-secondary, #57534E);
    min-height: 20px;
}

.imgtool.is-busy .imgtool-status {
    color: var(--t-text, #141414);
}

.imgtool-list {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
}

.imgtool-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--t-border, #E7E4DF);
    flex-wrap: wrap;
}

.imgtool-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--t-border, #E7E4DF);
    background: var(--t-bg, #F4F2EF);
    flex: 0 0 auto;
}

.imgtool-meta {
    flex: 1 1 200px;
    min-width: 0;
}

.imgtool-name {
    margin: 0;
    font-size: 15px;
    color: var(--t-text, #141414);
    overflow-wrap: anywhere;
}

.imgtool-facts {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--t-text-muted, #6B6660);
}

.imgtool-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

/* A class rule that sets `display` outranks the UA stylesheet's [hidden]
   { display: none }, so every element this file gives a display value to needs
   its own [hidden] rule or the markup's `hidden` attribute does nothing. Without
   this the download buttons sit there before a file has been chosen. */
.imgtool [hidden] {
    display: none !important;
}

/* Buttons: Soft Studio ink pill, compact padding. Pills supersede the sitewide
   10px radius on migrated surfaces (DESIGN-SYSTEM-SOFT-STUDIO.md §2). */
.imgtool a.imgtool-dl,
.imgtool button.imgtool-all,
.imgtool button.imgtool-clear {
    display: inline-block;
    border: none;
    border-radius: var(--ss-r-pill, 999px);
    padding: 10px 22px;
    font-family: var(--font-clash), sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 150ms ease-in-out, transform 100ms ease-in-out;
}

.imgtool a.imgtool-dl,
.imgtool button.imgtool-all {
    background: var(--ss-ink, #141414);
    color: #fff;
}

.imgtool a.imgtool-dl:hover,
.imgtool button.imgtool-all:hover {
    background: #000;
    color: #fff;
}

.imgtool button.imgtool-clear {
    background: var(--t-bg-card, #FFFFFF);
    border: 1px solid var(--t-border, #E7E4DF);
    color: var(--t-text, #141414);
}

.imgtool button.imgtool-clear:hover {
    border-color: var(--ss-ink, #141414);
    color: var(--t-text, #141414);
}

.imgtool a.imgtool-dl:active,
.imgtool button.imgtool-all:active,
.imgtool button.imgtool-clear:active {
    transform: scale(0.98);
}

.imgtool a.imgtool-dl:focus-visible,
.imgtool button:focus-visible {
    outline: 2px solid var(--ss-ink, #141414);
    outline-offset: 2px;
}

/* ── fallback panels ───────────────────────────────────────────────────── */

.imgtool-unsupported,
.imgtool-legacy {
    margin-top: 20px;
    padding: 18px;
    border: 1px solid var(--t-border, #E7E4DF);
    border-left: 3px solid var(--ss-pink, #FFD3F6);
    border-radius: 14px;
    background: var(--t-bg-card, #FFFFFF);
}

.imgtool-unsupported h3,
.imgtool-legacy h3 {
    font-family: var(--font-clash), sans-serif;
    font-size: 16px;
    color: var(--t-text, #141414);
    margin: 0 0 8px;
}

.imgtool-unsupported p,
.imgtool-legacy p {
    font-size: 14px;
    color: var(--t-text-secondary, #57534E);
    margin: 0 0 8px;
}

.imgtool-unsupported ol {
    margin: 0 0 0 18px;
    padding: 0;
}

.imgtool-unsupported li {
    font-size: 14px;
    color: var(--t-text-secondary, #57534E);
    margin-bottom: 6px;
}

/* ── specs table (the page's own answer block, not part of the widget) ──── */

.imgtool-specs {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 0;
    font-size: 15px;
}

.imgtool-specs caption {
    text-align: left;
    font-size: 14px;
    color: var(--t-text-muted, #6B6660);
    padding-bottom: 10px;
}

.imgtool-specs th,
.imgtool-specs td {
    text-align: left;
    padding: 10px 14px 10px 0;
    border-bottom: 1px solid var(--t-border, #E7E4DF);
    color: var(--t-text-secondary, #57534E);
    background: transparent;
}

.imgtool-specs th {
    color: var(--t-text, #141414);
    font-weight: 600;
}

.imgtool-specs-wrap {
    overflow-x: auto;
}

@media (max-width: 640px) {
    .imgtool {
        padding: 18px;
    }

    .imgtool-controls {
        grid-template-columns: 1fr;
    }

    .imgtool-row {
        gap: 10px;
    }

    .imgtool a.imgtool-dl {
        width: 100%;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {

    .imgtool-drop,
    .imgtool a.imgtool-dl,
    .imgtool button.imgtool-all,
    .imgtool button.imgtool-clear {
        transition: none;
    }

    .imgtool a.imgtool-dl:active,
    .imgtool button.imgtool-all:active,
    .imgtool button.imgtool-clear:active {
        transform: none;
    }
}
