/* UtilTools components.

   The half of the stylesheet that is specific to this site: the header and its search,
   the anatomy of a tool page, cards, the home page, the primitives the tool modules
   build their interfaces from, the footer, and the advertising and consent surfaces.

   Depends on assets/css/tokens.css for its custom properties, reset and controls. */

/* ---------------------------------------------------------------- header */
.site-header {
  border-bottom: 1px solid var(--ut-border);
  background: var(--ut-bg);
  position: sticky; top: 0; z-index: 30;
}
.site-header .wrap { display: flex; align-items: center; gap: 1rem; min-height: 3.75rem; }
.brand { font-weight: 700; letter-spacing: -0.02em; text-decoration: none; font-size: 1.0625rem; white-space: nowrap; }
.brand span { color: var(--ut-accent); }
.site-nav { display: flex; gap: 1rem; margin-left: auto; align-items: center; }
.site-nav a { text-decoration: none; font-size: .9375rem; padding: .35rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover, .site-nav a[aria-current="page"] { border-bottom-color: var(--ut-border-strong); }
.header-search { flex: 1 1 18rem; max-width: 26rem; position: relative; }
.icon-btn {
  background: none; border: 1px solid var(--ut-border); width: 2.25rem; height: 2.25rem;
  display: inline-grid; place-items: center; padding: 0; line-height: 1;
}
.icon-btn:hover { border-color: var(--ut-border-strong); }
.icon-btn svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 60rem) {
  .site-nav a:not(.nav-keep) { display: none; }
  .header-search { flex-basis: 8rem; }
}

/* ---------------------------------------------------------------- search */
.search-input {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--ut-border);
  background: var(--ut-surface); color: var(--ut-text);
}
.search-input:focus { border-color: var(--ut-border-strong); background: var(--ut-bg); }
.search-results {
  position: absolute; inset-inline: 0; top: calc(100% + .25rem); z-index: 40;
  background: var(--ut-bg); border: 1px solid var(--ut-border-strong);
  max-height: 60vh; overflow-y: auto; display: none;
}
.search-results[data-open="true"] { display: block; }
.search-results a { display: block; padding: .5rem .75rem; text-decoration: none; border-bottom: 1px solid var(--ut-border); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--ut-surface-alt); }
.search-results .sr-cat { font-size: .75rem; color: var(--ut-text-muted); }
.search-empty { padding: .75rem; color: var(--ut-text-muted); font-size: .875rem; }

/* ---------------------------------------------------------------- tool page */
.breadcrumb { font-size: .8125rem; color: var(--ut-text-muted); padding: .75rem 0; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.tool-head { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.answer-block {
  border-left: 3px solid var(--ut-accent);
  padding: .75rem 0 .75rem 1rem;
  max-width: var(--ut-measure);
  font-size: 1.0625rem;
}
.tool-app { border: 1px solid var(--ut-border-strong); margin: 1.5rem 0; }
.tool-app > .tool-app-body { padding: 1rem; }
@media (min-width: 40rem) { .tool-app > .tool-app-body { padding: 1.5rem; } }
.privacy-badge {
  display: flex; gap: .5rem; align-items: center; font-size: .8125rem;
  border: 1px solid var(--ut-border); padding: .5rem .75rem; background: var(--ut-surface);
}
.privacy-badge svg { width: 1rem; height: 1rem; flex: none; stroke: var(--ut-success); fill: none; stroke-width: 2; }
.tool-sections { display: grid; gap: 2.5rem; grid-template-columns: 1fr; margin-top: 2.5rem; }
@media (min-width: 64rem) { .tool-sections { grid-template-columns: minmax(0, 1fr) 18rem; gap: 3rem; } }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; padding-left: 2.25rem; position: relative; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: .1rem;
  width: 1.6rem; height: 1.6rem; display: grid; place-items: center;
  border: 1px solid var(--ut-border-strong); font-size: .8125rem; font-weight: 650;
}
.steps li + li { margin-top: .75rem; }
.faq details { border-bottom: 1px solid var(--ut-border); }
.faq summary { padding: .875rem 0; font-weight: 600; cursor: pointer; list-style: none; display: flex; gap: .75rem; align-items: baseline; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; margin-left: auto; font-weight: 400; font-size: 1.25rem; line-height: 1; }
.faq details[open] summary::after { content: "\2212"; }
.faq details > div { padding-bottom: .875rem; max-width: var(--ut-measure); }

/* ---------------------------------------------------------------- cards */
.card-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); list-style: none; padding: 0; }
.tool-card { border: 1px solid var(--ut-border); padding: .875rem; display: flex; flex-direction: column; gap: .35rem; position: relative; background: var(--ut-bg); }
.tool-card:hover { border-color: var(--ut-border-strong); }
.tool-card h3 { font-size: .9375rem; font-weight: 650; }
.tool-card h3 a { text-decoration: none; }
.tool-card h3 a::after { content: ""; position: absolute; inset: 0; }
.tool-card p { font-size: .8125rem; color: var(--ut-text-muted); line-height: 1.45; }
.tool-card .fav { position: relative; z-index: 1; margin-left: auto; }
.tool-card-top { display: flex; align-items: flex-start; gap: .5rem; }
.badge { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; border: 1px solid var(--ut-border); padding: .05rem .3rem; color: var(--ut-text-muted); }
.badge-new { color: var(--ut-accent); border-color: var(--ut-accent); }
.fav {
  background: none; border: 0; padding: .15rem; line-height: 0; color: var(--ut-text-muted);
}
.fav svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.75; }
.fav[aria-pressed="true"] { color: var(--ut-accent); }
.fav[aria-pressed="true"] svg { fill: currentColor; }

/* ---------------------------------------------------------------- home */
.hero { padding: 3rem 0 2rem; border-bottom: 1px solid var(--ut-border); }
.hero h1 { max-width: 20ch; }
.hero p { max-width: 58ch; font-size: 1.125rem; color: var(--ut-text-muted); margin-top: .75rem; }
.hero-search { margin-top: 1.5rem; max-width: 34rem; position: relative; }
.hero-search input { padding: .75rem 1rem; font-size: 1rem; border-color: var(--ut-border-strong); }
.stat-row { display: flex; gap: 2rem; flex-wrap: wrap; margin-top: 1.5rem; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.1; }
.stat span { font-size: .8125rem; color: var(--ut-text-muted); }
.section { padding: 2.5rem 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.section-head a { font-size: .875rem; }
/* Borders overlap rather than being painted by the grid background: with nine cards
   in a four-column grid the last row is mostly empty, and a background would show
   through it as a grey slab. */
.cat-grid { display: grid; gap: 0; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.cat-grid > * { border: 1px solid var(--ut-border); margin: -1px 0 0 -1px; }
.cat-card { background: var(--ut-bg); padding: 1.25rem; text-decoration: none; display: block; }
.cat-card:hover { background: var(--ut-surface); }
.cat-card h3 { display: flex; justify-content: space-between; gap: 1rem; }
.cat-card h3 em { font-style: normal; color: var(--ut-text-muted); font-weight: 400; font-size: .875rem; }
.cat-card p { font-size: .875rem; color: var(--ut-text-muted); margin-top: .35rem; }

/* ---------------------------------------------------------------- tool widget primitives */
.drop {
  border: 2px dashed var(--ut-border); padding: 2rem 1rem; text-align: center; background: var(--ut-surface);
}
.drop[data-drag="true"] { border-color: var(--ut-accent); background: var(--ut-accent-soft); }
.drop p { color: var(--ut-text-muted); font-size: .875rem; margin-top: .5rem; }
.result { border: 1px solid var(--ut-border); background: var(--ut-surface); padding: 1rem; }
/* Tools clear their output by emptying this box; an empty one must not leave a bar. */
.result:empty { display: none; }
.result-big { font-size: clamp(1.5rem, 1.1rem + 2vw, 2.25rem); font-weight: 650; line-height: 1.15; letter-spacing: -0.02em; word-break: break-word; }
.out { width: 100%; font-family: var(--ut-font-mono); font-size: .875rem; }
.progress { height: .375rem; background: var(--ut-surface-alt); border: 1px solid var(--ut-border); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ut-action); width: 0; transition: width .15s linear; }

/* The status line a tool shows while it is working. It reserves no space when idle, so
   a page does not shift as work starts and finishes. */
.working { display: grid; grid-template-columns: auto 1fr; align-items: center;
  gap: .5rem .625rem; margin-top: .75rem; }
.working .progress { grid-column: 1 / -1; }
.working-label { font-size: .875rem; color: var(--ut-text-muted); }

.spinner { width: 1rem; height: 1rem; border-radius: 50%; display: block;
  border: 2px solid var(--ut-border); border-top-color: var(--ut-action);
  animation: ut-spin .7s linear infinite; }
@keyframes ut-spin { to { transform: rotate(360deg); } }

/* A spinner is decoration, and a moving one can trigger symptoms for people with
   vestibular disorders. Anyone who has asked for less motion gets a static ring; the
   text beside it carries the meaning either way. */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--ut-action); opacity: .6; }
  .progress > i { transition: none; }
}

/* A button mid-job says what it is doing and cannot be pressed again. */
.btn[data-busy="true"] { cursor: progress; }
.note { border-left: 3px solid var(--ut-border); padding: .5rem 0 .5rem .75rem; font-size: .875rem; color: var(--ut-text-muted); }
.note-warn, .note-warning { border-color: var(--ut-warning); color: var(--ut-text); }
.note-danger { border-color: var(--ut-danger); color: var(--ut-text); }
.note-info { border-color: var(--ut-info); }
.err { color: var(--ut-danger); font-size: .875rem; }
.ok { color: var(--ut-success); font-size: .875rem; }
.file-list { list-style: none; padding: 0; display: grid; gap: .5rem; }
.file-item { border: 1px solid var(--ut-border); padding: .5rem .625rem; display: flex; gap: .625rem; align-items: center; background: var(--ut-bg); }
.file-item[draggable="true"] { cursor: grab; }
.file-item.dragging { opacity: .4; }
.file-item .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.file-item .size { font-size: .75rem; color: var(--ut-text-muted); white-space: nowrap; }
.thumb-grid { display: grid; gap: .625rem; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); list-style: none; padding: 0; }
.thumb { border: 1px solid var(--ut-border); padding: .35rem; background: var(--ut-bg); position: relative; }
.thumb[data-selected="true"] { border-color: var(--ut-accent); background: var(--ut-accent-soft); }
.thumb[data-removed="true"] { opacity: .35; }
.thumb canvas, .thumb img { width: 100%; height: auto; background: var(--ut-surface-alt); }
.thumb .n { font-size: .75rem; text-align: center; color: var(--ut-text-muted); }
.swatch { width: 100%; aspect-ratio: 3 / 2; max-height: 12rem; border: 1px solid var(--ut-border); }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data th, table.data td { border: 1px solid var(--ut-border); padding: .35rem .5rem; text-align: left; }
table.data th { background: var(--ut-surface); font-weight: 600; }
table.data tbody tr:nth-child(even) { background: var(--ut-surface); }
.scroll-x { overflow-x: auto; }
.kv { display: grid; grid-template-columns: minmax(6rem, auto) 1fr; gap: .25rem .75rem; font-size: .875rem; }
.kv dt { color: var(--ut-text-muted); }
.kv dd { margin: 0; font-family: var(--ut-font-mono); word-break: break-all; }
.two-col { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 48rem) { .two-col { grid-template-columns: 1fr 1fr; } }
.tabs { display: flex; border-bottom: 1px solid var(--ut-border); flex-wrap: wrap; gap: 0; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: .5rem .875rem; font-size: .875rem; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--ut-border-strong); font-weight: 600; }
.canvas-wrap { background: var(--ut-surface-alt); border: 1px solid var(--ut-border); overflow: auto; max-height: 70vh; display: grid; place-items: center; padding: .5rem; }
.checker { background-image: linear-gradient(45deg,#c8c8c8 25%,transparent 25%),linear-gradient(-45deg,#c8c8c8 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#c8c8c8 75%),linear-gradient(-45deg,transparent 75%,#c8c8c8 75%); background-size:16px 16px; background-position:0 0,0 8px,8px -8px,-8px 0; }

/* -------------------------------------------------- image tool primitives */
.crop-wrap { border: 1px solid var(--ut-border); background: var(--ut-surface-alt); overflow: auto; max-width: 100%; }
.crop-canvas { display: block; max-width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.crop-canvas:focus-visible { outline: 2px solid var(--ut-border-strong); outline-offset: 2px; }
.preview-canvas { display: block; max-width: 100%; height: auto; border: 1px solid var(--ut-border); background: var(--ut-surface-alt); }
.picker-row { display: flex; gap: .75rem; align-items: flex-start; flex-wrap: wrap; }
.picker-row .crop-canvas { border: 1px solid var(--ut-border); flex: 1 1 18rem; }
.loupe { border: 1px solid var(--ut-border); image-rendering: pixelated; background: var(--ut-surface-alt); flex: 0 0 auto; }
.swatch-row { display: flex; flex-wrap: wrap; gap: .375rem; align-items: center; }
.swatch-row .swatch { width: 2.5rem; aspect-ratio: 1; }
.swatch-big { height: 5rem; border: 1px solid var(--ut-border); }
pre.code { background: var(--ut-surface-alt); border: 1px solid var(--ut-border); padding: .75rem; overflow-x: auto; font-size: .8125rem; }
pre.code code { background: none; border: 0; padding: 0; }
.tag { display: inline-block; font-size: .6875rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; border: 1px solid var(--ut-border); padding: .05rem .3rem; margin-left: .4rem; vertical-align: middle; }
.tag-warning { border-color: var(--ut-warning); color: var(--ut-warning); }
table.kv { display: table; width: 100%; border-collapse: collapse; font-size: .875rem; }
table.kv th, table.kv td { border-bottom: 1px solid var(--ut-border); padding: .3rem .5rem .3rem 0; text-align: left; vertical-align: top; }
table.kv th { color: var(--ut-text-muted); font-weight: 500; width: 40%; }
table.kv td { font-family: var(--ut-font-mono); word-break: break-word; }

/* ---------------------------------------------------------------- footer */
.site-footer { border-top: 1px solid var(--ut-border); margin-top: 3rem; padding: 2rem 0; background: var(--ut-surface); }
.footer-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.site-footer h4 { font-size: .8125rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ut-text-muted); margin-bottom: .5rem; }
.site-footer ul { list-style: none; padding: 0; font-size: .875rem; }
.site-footer li + li { margin-top: .25rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-note { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--ut-border); font-size: .8125rem; color: var(--ut-text-muted); display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }

/* ------------------------------------------- advertising and consent
   Both are styled to sit inside the design rather than fight it: no colour, no
   shadow, square corners, and an ad is labelled as an ad because a utility people
   trust with documents should not be ambiguous about which parts of the page it
   wrote. */
.ad-slot { margin: 2rem 0; border: 1px solid var(--ut-border); padding: .5rem; background: var(--ut-surface); min-height: 6rem; display: grid; align-content: start; gap: .35rem; }
.ad-label { font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ut-text-muted); }
.ad-slot ins { display: block; width: 100%; }
/* A refused or blocked slot is removed by consent.js; this keeps it from flashing. */
.ad-slot:not(:has(ins)) { display: none; }
@media print { .ad-slot, .consent { display: none !important; } }

.consent { position: fixed; inset: auto 0 0 0; z-index: 60; background: var(--ut-bg); border-top: 1px solid var(--ut-border-strong); padding: 1rem; display: grid; gap: .75rem; grid-template-columns: 1fr; align-items: center; }
.consent-text { font-size: .875rem; max-width: 68ch; }
.consent-text p { margin: 0; }
.consent-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
@media (min-width: 44rem) {
  .consent { grid-template-columns: 1fr auto; padding: 1rem clamp(1rem, 4vw, 3rem); }
  .consent-actions { justify-content: flex-end; }
}

/* --------------------------------------------------- footer shortcuts and UX */
.footer-shortcuts { padding-bottom: 1.25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--ut-border); }
.footer-shortcuts h4, .footer-recent h4 { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ut-text-muted); margin-bottom: .625rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: .375rem; list-style: none; padding: 0; margin: 0; }
.chip { display: inline-block; border: 1px solid var(--ut-border); padding: .25rem .6rem; font-size: .8125rem; text-decoration: none; color: var(--ut-text); background: var(--ut-bg); }
.chip:hover { border-color: var(--ut-border-strong); text-decoration: none; }
.footer-recent { padding-bottom: 1.25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--ut-border); }
.footer-recent ul { display: flex; flex-wrap: wrap; gap: .375rem; list-style: none; padding: 0; margin: 0; }
.footer-recent a { font-size: .8125rem; border: 1px solid var(--ut-border); padding: .25rem .6rem; display: inline-block; background: var(--ut-bg); }
.install-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .875rem; }
.install-row:empty { display: none; }
.kbd-hint { margin-top: .75rem; }
kbd { font-family: var(--ut-font-mono); font-size: .75rem; border: 1px solid var(--ut-border); padding: .05rem .3rem; background: var(--ut-surface-alt); }

/* Actions beside a tool's title. */
.tool-actions { display: flex; gap: .25rem; align-items: center; flex: none; margin-top: .5rem; }

/* Appears only well past the fold, so it never covers a short page. */
.to-top { position: fixed; right: 1rem; bottom: 1rem; z-index: 40; width: 2.5rem; height: 2.5rem; border: 1px solid var(--ut-border-strong); background: var(--ut-bg); color: var(--ut-text); font-size: 1.125rem; line-height: 1; cursor: pointer; }
.to-top[hidden] { display: none; }
.to-top:hover { background: var(--ut-surface); }
/* The button is fixed to the bottom-right corner, which is exactly where the footer
   note ends. Reserve the space rather than letting it sit on top of the text. */
.site-footer .footer-note { padding-right: 3.5rem; }
@media print { .to-top, .footer-shortcuts, .footer-recent, .install-row { display: none !important; } }
.filter-banner { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; border: 1px solid var(--ut-border); background: var(--ut-surface); padding: .5rem .75rem; margin: .75rem 0 0; font-size: .875rem; }
.offline-bar { background: var(--ut-action); color: var(--ut-action-text); padding: .5rem 1rem; font-size: .875rem; text-align: center; }
@media print { .offline-bar { display: none !important; } }
