/* ─────────────────────────────────────────────────────────────────────
   Ridoco Tools  -  self-hosted stylesheet

   Deliberately plain CSS, not Tailwind. The site's Tailwind build lives in
   public/build/ and is regenerated by `npm run build`; making this section
   depend on freshly-scanned utility classes would mean every tools change
   required a full asset rebuild to render at all. Plain CSS keyed to the
   site's existing custom properties renders correctly whatever state the
   build is in.

   Colours come exclusively from the --color-* variables defined in
   resources/css/app.css, so light and dark themes both work with no rules
   of our own. Nothing here hardcodes a colour except pure black/white
   overlays expressed as rgba, which read correctly on both.

   No @import, no @font-face, no url() to any host. This file makes zero
   network requests.
   ───────────────────────────────────────────────────────────────────── */

.rt {
    --rt-gap: 1.25rem;
    --rt-radius: 12px;
    max-width: 72rem;
    margin: 0 auto;
    padding: 2rem 1rem 5rem;
}

@media (min-width: 640px) {
    .rt { padding: 3rem 1.5rem 6rem; }
}

/* ── Typography ───────────────────────────────────────────────────── */

.rt-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: .75rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .65;
    margin-bottom: .75rem;
}

.rt-h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 .75rem;
}

.rt-h2 {
    font-size: clamp(1.15rem, 3vw, 1.4rem);
    font-weight: 650;
    margin: 0 0 .25rem;
}

.rt-lede {
    font-size: 1.05rem;
    line-height: 1.6;
    opacity: .8;
    margin: 0 0 1.5rem;
    max-width: 46rem;
}

.rt-muted { opacity: .65; }

/* ── Privacy banner ───────────────────────────────────────────────── */

.rt-privacy {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .8rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--rt-radius);
    background: var(--color-surface);
    font-size: .875rem;
    line-height: 1.5;
    margin-bottom: 1.75rem;
}

.rt-privacy i { margin-top: .15rem; opacity: .7; flex-shrink: 0; }

/* ── Category grid (index) ────────────────────────────────────────── */

.rt-section { margin-bottom: 3rem; }

.rt-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--color-border);
}

.rt-count {
    font-size: .8rem;
    opacity: .6;
    white-space: nowrap;
}

.rt-grid {
    display: grid;
    gap: .875rem;
    grid-template-columns: 1fr;
}

@media (min-width: 560px)  { .rt-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .rt-grid { grid-template-columns: repeat(3, 1fr); } }

.rt-card {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--rt-radius);
    background: var(--color-card);
    text-decoration: none;
    color: inherit;
    transition: border-color .15s ease, transform .15s ease;
    min-height: 100%;
}

.rt-card:hover,
.rt-card:focus-visible {
    border-color: var(--color-accent);
    transform: translateY(-2px);
    outline: none;
}

.rt-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.rt-card-name {
    font-weight: 620;
    font-size: 1rem;
    line-height: 1.3;
}

.rt-card-desc {
    font-size: .85rem;
    line-height: 1.5;
    opacity: .7;
}

/* ── Form ─────────────────────────────────────────────────────────── */

.rt-panel {
    border: 1px solid var(--color-border);
    border-radius: var(--rt-radius);
    background: var(--color-card);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 640px) { .rt-panel { padding: 1.5rem; } }

.rt-field { margin-bottom: 1.1rem; }
.rt-field:last-child { margin-bottom: 0; }

.rt-label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: .4rem;
}

.rt-help {
    font-size: .78rem;
    opacity: .62;
    margin-top: .35rem;
    line-height: 1.45;
}

.rt-input,
.rt-textarea,
.rt-select {
    width: 100%;
    box-sizing: border-box;
    /* 16px minimum stops iOS Safari zooming the viewport on focus. */
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    padding: .6rem .75rem;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: border-color .15s ease;
}

.rt-input:focus,
.rt-textarea:focus,
.rt-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(128, 128, 128, .18);
}

.rt-textarea {
    resize: vertical;
    min-height: 6rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: .9rem;
}

.rt-select {
    appearance: none;
    padding-right: 2.25rem;
    /* Inline SVG chevron as a data URI: no file request, and it inherits
       nothing so it stays legible on both themes via currentColor swap
       below. */
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23888' stroke-width='1.6'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    background-size: 1rem;
}

/* Checkbox rows */
.rt-check {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .4rem 0;
    cursor: pointer;
    font-size: .9rem;
    line-height: 1.45;
}

.rt-check input {
    width: 1.15rem;
    height: 1.15rem;
    margin: .1rem 0 0;
    flex-shrink: 0;
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* Range */
.rt-range-row { display: flex; align-items: center; gap: .9rem; }
.rt-range { flex: 1; accent-color: var(--color-primary); height: 1.6rem; }
.rt-range-val {
    min-width: 3.2rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: .9rem;
    font-weight: 600;
}

/* File input: the native control is unstyleable and ugly, so it is visually
   hidden behind a label that is a real click target. Keyboard focus is
   preserved because the input still receives focus and :focus-within paints
   the surrogate. */
.rt-file { position: relative; }
.rt-file input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.rt-file-face {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    text-align: center;
    padding: 1.5rem 1rem;
    border: 1.5px dashed var(--color-border);
    border-radius: var(--rt-radius);
    background: var(--color-bg);
    font-size: .9rem;
    transition: border-color .15s ease;
    pointer-events: none;
    flex-wrap: wrap;
}
.rt-file:hover .rt-file-face,
.rt-file:focus-within .rt-file-face { border-color: var(--color-accent); }
.rt-file-face strong { font-weight: 620; }

/* ── Buttons ──────────────────────────────────────────────────────── */

.rt-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.rt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    /* 44px min target: the WCAG 2.2 pointer-target size, and the difference
       between usable and infuriating on a phone. */
    min-height: 44px;
    padding: .6rem 1.1rem;
    font-size: .925rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: opacity .15s ease, border-color .15s ease;
}

.rt-btn:hover { border-color: var(--color-accent); }
.rt-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.rt-btn[disabled] { opacity: .5; cursor: not-allowed; }

.rt-btn-primary {
    background: var(--color-btn-bg);
    color: var(--color-bg);
    border-color: var(--color-btn-bg);
}
.rt-btn-primary:hover { opacity: .9; border-color: var(--color-btn-bg); }

.rt-btn-sm {
    min-height: 34px;
    padding: .3rem .7rem;
    font-size: .8rem;
    font-weight: 500;
}

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

/* Touch-target sizing lives at the END of this file, not here. See the
   final block. */

/* ── Output ───────────────────────────────────────────────────────── */

.rt-out { margin-top: 1.5rem; }
.rt-out:empty { display: none; }

.rt-out-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .6rem;
    flex-wrap: wrap;
}

.rt-out-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; opacity: .6; }

.rt-pre {
    margin: 0;
    padding: 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: .85rem;
    line-height: 1.6;
    /* Long unbroken output (a hash, a token, a base64 blob) must wrap rather
       than force the whole page to scroll sideways on a phone. */
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-height: 30rem;
    overflow-y: auto;
}

.rt-error {
    padding: .8rem 1rem;
    border: 1px solid var(--color-flash-err-bd);
    background: var(--color-flash-err-bg);
    border-radius: 10px;
    font-size: .875rem;
    line-height: 1.5;
}

/* Stat tiles */
.rt-stats {
    display: grid;
    gap: .6rem;
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 560px) { .rt-stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .rt-stats { grid-template-columns: repeat(6, 1fr); } }

.rt-stat {
    padding: .8rem .6rem;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg);
    text-align: center;
}
.rt-stat-val {
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.rt-stat-lbl {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .6;
    margin-top: .25rem;
}

/* Result list rows */
.rt-list { display: flex; flex-direction: column; gap: .4rem; }
.rt-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .55rem .75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .875rem;
    word-break: break-all;
}
.rt-row-copy { flex-shrink: 0; }

/* Key/value table */
.rt-kv { width: 100%; border-collapse: collapse; font-size: .875rem; }
.rt-kv th, .rt-kv td {
    text-align: left;
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}
.rt-kv th { font-weight: 600; white-space: nowrap; opacity: .75; width: 1%; }
.rt-kv td { word-break: break-word; font-variant-numeric: tabular-nums; }
.rt-table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: 10px; }

/* Colour swatches */
.rt-swatches {
    display: grid;
    gap: .6rem;
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 520px) { .rt-swatches { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .rt-swatches { grid-template-columns: repeat(6, 1fr); } }

.rt-swatch {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--color-bg);
    cursor: pointer;
    padding: 0;
    font: inherit;
    color: inherit;
    text-align: left;
}
.rt-swatch-chip { height: 4.5rem; width: 100%; display: block; }
.rt-swatch-meta { padding: .45rem .55rem; font-size: .72rem; line-height: 1.5; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Regex highlight */
.rt-mark {
    background: var(--color-primary);
    color: var(--color-bg);
    border-radius: 3px;
    padding: 0 .1em;
}

/* Rendered HTML preview */
.rt-preview {
    padding: 1rem 1.15rem;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg);
    line-height: 1.65;
    overflow-x: auto;
}
.rt-preview :where(h1,h2,h3,h4) { font-weight: 680; line-height: 1.25; margin: 1.2em 0 .5em; }
.rt-preview :where(h1) { font-size: 1.6em; }
.rt-preview :where(h2) { font-size: 1.3em; }
.rt-preview :where(h3) { font-size: 1.1em; }
.rt-preview :where(p, ul, ol, blockquote, pre, table) { margin: 0 0 1em; }
.rt-preview :where(ul, ol) { padding-left: 1.4em; }
.rt-preview :where(li) { margin: .25em 0; }
.rt-preview :where(code) {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: .88em;
    background: var(--color-surface);
    padding: .12em .35em;
    border-radius: 4px;
}
.rt-preview :where(pre) {
    background: var(--color-surface);
    padding: .8rem 1rem;
    border-radius: 8px;
    overflow-x: auto;
}
.rt-preview :where(pre) code { background: none; padding: 0; }
.rt-preview :where(blockquote) {
    border-left: 3px solid var(--color-border);
    padding-left: 1em;
    opacity: .82;
}
.rt-preview :where(table) { border-collapse: collapse; width: 100%; }
.rt-preview :where(th, td) { border: 1px solid var(--color-border); padding: .4em .6em; text-align: left; }
.rt-preview :where(hr) { border: none; border-top: 1px solid var(--color-border); margin: 1.5em 0; }
.rt-preview :where(img) { max-width: 100%; height: auto; }
.rt-preview :where(a) { color: var(--color-link); }

/* Social share card preview */
.rt-og {
    max-width: 32rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-bg);
}
.rt-og-img {
    aspect-ratio: 1200 / 630;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    font-size: .78rem;
    opacity: .55;
    text-align: center;
    padding: 1rem;
    line-height: 1.5;
    word-break: break-all;
}
.rt-og-body { padding: .7rem .9rem; }
.rt-og-site { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; opacity: .55; }
.rt-og-title { font-weight: 640; font-size: .95rem; margin: .2rem 0; line-height: 1.35; }
.rt-og-desc { font-size: .82rem; opacity: .7; line-height: 1.45; }

.rt-meter { font-size: .75rem; opacity: .65; margin-top: .3rem; }
.rt-meter.rt-over { opacity: 1; font-weight: 600; }

/* Image result */
.rt-img-out { display: grid; gap: 1rem; }
@media (min-width: 700px) { .rt-img-out { grid-template-columns: minmax(0, 1fr) 15rem; } }
.rt-img-frame {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg);
    padding: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Chequerboard so transparency is visible rather than reading as white. */
    background-image:
        linear-gradient(45deg, rgba(128,128,128,.16) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(128,128,128,.16) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(128,128,128,.16) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(128,128,128,.16) 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.rt-img-frame img { max-width: 100%; max-height: 22rem; height: auto; display: block; }

/* ── FAQ ──────────────────────────────────────────────────────────── */

.rt-faq { margin-top: 3rem; }
.rt-faq details {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-card);
    margin-bottom: .6rem;
    overflow: hidden;
}
.rt-faq summary {
    padding: .85rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: .925rem;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: 44px;
}
.rt-faq summary::-webkit-details-marker { display: none; }
.rt-faq summary::after {
    content: "+";
    font-weight: 400;
    font-size: 1.25rem;
    opacity: .5;
    flex-shrink: 0;
    line-height: 1;
}
.rt-faq details[open] summary::after { content: "\2212"; }
.rt-faq-body {
    padding: 0 1rem 1rem;
    font-size: .9rem;
    line-height: 1.6;
    opacity: .82;
}

/* ── Breadcrumb / related ─────────────────────────────────────────── */

.rt-crumb {
    display: flex;
    gap: .4rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: .8rem;
    opacity: .65;
    margin-bottom: 1rem;
}
.rt-crumb a { color: inherit; text-decoration: none; }
.rt-crumb a:hover { text-decoration: underline; }

.rt-chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.rt-chip {
    display: inline-flex;
    align-items: center;
    padding: .4rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-card);
    font-size: .82rem;
    text-decoration: none;
    color: inherit;
    min-height: 34px;
}
.rt-chip:hover { border-color: var(--color-accent); }

.rt-toast {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%) translateY(1rem);
    padding: .6rem 1.1rem;
    border-radius: 999px;
    background: var(--color-text);
    color: var(--color-bg);
    font-size: .85rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    z-index: 9999;
}
.rt-toast.rt-show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
    .rt-card, .rt-btn, .rt-toast, .rt-input, .rt-textarea, .rt-select { transition: none; }
    .rt-card:hover { transform: none; }
}

/* ── Touch targets ────────────────────────────────────────────────────
   Restores the full 44px target on the compact variants when the pointer
   is a finger. 34px is fine under a mouse and awkward under a thumb, and
   the Copy buttons and category chips are the most-tapped controls here.

   Keyed to pointer type, not viewport width: a large tablet is still a
   thumb, and a narrow desktop window is still a mouse.

   MUST STAY LAST IN THIS FILE. These selectors are no more specific than
   the .rt-btn-sm and .rt-chip rules they override, so they only win on
   source order. Placing this block next to the button rules (where it
   reads more naturally) silently stopped applying to .rt-chip, which is
   defined further down. */
@media (pointer: coarse) {
    .rt-btn-sm,
    .rt-chip {
        min-height: 44px;
        padding-top: .5rem;
        padding-bottom: .5rem;
    }
}
