/* FileForge — client-side file tools */

/*
 * Contrast note: --line is deliberately low contrast. It draws decorative
 * rules and card edges where the surface fill already separates the regions,
 * which WCAG 1.4.11 does not cover. Anything that outlines an interactive
 * control uses --line-strong, which clears 3:1 in both palettes.
 */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --line: #d3cec3;
  --line-strong: #948d7e;
  --ink: #1b1a17;
  --ink-2: #5d574d;
  --ink-3: #6f695e;
  --accent: #c2410c;
  --accent-soft: #fdece3;
  --accent-ink: #ffffff;
  --good: #15703a;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(27,26,23,.05), 0 8px 24px -12px rgba(27,26,23,.18);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131211;
    --surface: #1c1b19;
    --surface-2: #232120;
    --line: #3d3936;
    --line-strong: #736c64;
    --ink: #f2efea;
    --ink-2: #b3aca2;
    --ink-3: #9b948a;
    --accent: #f97316;
    --accent-soft: #2a1a10;
    --accent-ink: #1b1a17;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.7);
  }
}

:root[data-theme="dark"] {
  --bg: #131211;
  --surface: #1c1b19;
  --surface-2: #232120;
  --line: #3d3936;
  --line-strong: #736c64;
  --ink: #f2efea;
  --ink-2: #b3aca2;
  --ink-3: #9b948a;
  --accent: #f97316;
  --accent-soft: #2a1a10;
  --accent-ink: #1b1a17;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 55%, #7c2d12 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
  flex: none;
}

.brand-name { font-weight: 660; letter-spacing: -.02em; font-size: 1.05rem; }
.brand-name span { color: var(--accent); }

.topbar-actions { display: flex; gap: 8px; }

.ghost-btn {
  font: inherit;
  font-size: .875rem;
  font-weight: 520;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.ghost-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.ghost-btn.wide { flex: 1; }

.theme-icon {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

/* ---------- layout ---------- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 40px) 64px;
}

.hero { text-align: center; margin-bottom: 34px; }

.hero h1 {
  font-size: clamp(1.7rem, 4.2vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -.03em;
  font-weight: 660;
  margin: 0 auto 12px;
  max-width: 20ch;
}

.lede {
  color: var(--ink-2);
  font-size: clamp(.98rem, 1.6vw, 1.08rem);
  max-width: 56ch;
  margin: 0 auto;
}

.trust {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 10px;
  padding: 0;
  margin: 20px 0 0;
}

.trust li {
  font-size: .8rem;
  font-weight: 540;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}

.trust li::before {
  content: "\2713";
  color: var(--good);
  margin-inline-end: 6px;
  font-weight: 700;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 20px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  font: inherit;
  font-size: .9rem;
  font-weight: 540;
  flex: 1 0 auto;
  white-space: nowrap;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tab:hover { color: var(--ink); }

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 860px) {
  .workspace { grid-template-columns: 1fr 300px; align-items: start; }
}

.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(32px, 7vw, 60px) 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dz-icon { width: 40px; height: 40px; color: var(--accent); margin-bottom: 8px; }
.dz-title { font-weight: 600; font-size: 1.1rem; margin: 0; }
.dz-sub { color: var(--ink-2); font-size: .9rem; margin: 0; }
.dz-accept { color: var(--ink-3); font-size: .78rem; margin: 10px 0 0; font-family: var(--mono); }

/* ---------- options ---------- */

.options {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.options-title {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-3);
  margin: 0 0 14px;
  font-weight: 620;
}

.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 20px; }

.field label,
.field .field-label {
  display: block;
  font-size: .85rem;
  font-weight: 540;
  margin-bottom: 6px;
  color: var(--ink);
}

.field-hint { font-size: .78rem; color: var(--ink-3); margin: 6px 0 0; }

.field input[type="number"],
.field input[type="text"],
.field select {
  font: inherit;
  font-size: .9rem;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 2px 0;
}

.range-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.range-val {
  font-family: var(--mono);
  font-size: .85rem;
  font-weight: 600;
  color: var(--accent);
}

.dims { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--ink-2);
  cursor: pointer;
}

.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.seg {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
}

.seg button {
  font: inherit;
  font-size: .82rem;
  font-weight: 540;
  flex: 1;
  padding: 7px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.seg button.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.options-actions { display: flex; gap: 8px; }

.primary-btn {
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  flex: 1;
  padding: 11px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: filter .15s, transform .06s;
}

.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.primary-btn.small { flex: none; padding: 8px 14px; font-size: .85rem; }

/* ---------- file list ---------- */

/*
 * Shown only by the tools where the order of the queue changes the output:
 * merging, and building a PDF from images. Splitting borrows it to display
 * the page count once the document has been read.
 */

.file-list {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.file-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.f-index {
  flex: none;
  min-width: 1.5em;
  text-align: center;
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-3);
}

.f-body { flex: 1; min-width: 0; }

.f-name {
  margin: 0;
  font-size: .88rem;
  font-weight: 540;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.f-meta { margin: 0; font-size: .76rem; color: var(--ink-2); font-family: var(--mono); }

.f-actions { display: flex; gap: 6px; flex: none; }

.f-move {
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.f-move:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.f-move:disabled { opacity: .4; cursor: not-allowed; }
.f-move:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- results ---------- */

.results { margin-top: 28px; }

.results-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.results-head h2 { font-size: 1.15rem; margin: 0; letter-spacing: -.02em; }
.results-summary { color: var(--ink-2); font-size: .88rem; margin-inline-end: auto; }
.results-summary strong { color: var(--good); }

.result-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }

.result {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

@media (max-width: 560px) {
  .result { grid-template-columns: 40px 1fr; }
  .result .r-action { grid-column: 1 / -1; }
  .result .r-action a { display: block; text-align: center; }
  /* Narrow screens are touch screens: 44px is the smallest comfortable
     target, and the reorder arrows are pressed repeatedly. */
  .file-list { padding: 14px; }
  .file-item { gap: 8px; padding: 8px; }
  .f-move { width: 44px; height: 44px; }
}

.r-thumb {
  width: 48px;
  height: 48px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.r-thumb.is-doc {
  display: grid;
  place-items: center;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  font-family: var(--mono);
}

.r-name {
  font-size: .9rem;
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0 0 3px;
}

.r-meta { font-size: .8rem; color: var(--ink-2); font-family: var(--mono); margin: 0; }
.r-meta .old { text-decoration: line-through; color: var(--ink-3); }
.r-meta .new { color: var(--ink); font-weight: 600; }
.r-meta .delta { color: var(--good); font-weight: 600; }
.r-meta .delta.up { color: var(--warn); }
.r-meta .err { color: var(--bad); font-family: var(--sans); }

.r-action a {
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  white-space: nowrap;
}

.r-action a:hover { background: var(--accent); color: var(--accent-ink); }

.progress {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- explain / seo ---------- */

.explain {
  margin-top: 52px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}

.explain h2 { color: var(--ink); font-size: 1.2rem; letter-spacing: -.02em; margin: 0 0 10px; }
.explain h3 { color: var(--ink); font-size: 1rem; margin: 26px 0 8px; }
.explain p { max-width: 68ch; margin: 0; font-size: .94rem; }

/* ---------- ads ---------- */

.ad-slot { margin: 28px 0; }
.ad-slot:empty { display: none; }

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 24px clamp(16px, 4vw, 40px);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-3);
  font-size: .85rem;
}

.foot-links { display: flex; gap: 16px; }
.foot-links a { color: var(--ink-2); text-decoration: none; }
.foot-links a:hover { color: var(--accent); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: 20px;
  margin-inline: auto;
  max-width: 380px;
  background: var(--ink);
  color: var(--bg);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  text-align: center;
  z-index: 50;
  box-shadow: var(--shadow);
}

/* ---------- rtl ---------- */

[dir="rtl"] .r-name,
[dir="rtl"] .f-name,
[dir="rtl"] .dz-accept { text-align: right; }

[dir="rtl"] .r-meta,
[dir="rtl"] .f-meta { direction: ltr; text-align: right; }

/* ---------- landing pages ---------- */

.crumbs {
  font-size: .82rem;
  color: var(--ink-3);
  margin-bottom: 18px;
}

.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs span { margin: 0 4px; }

.hero-compact { margin-bottom: 26px; }
.hero-compact h1 { max-width: 24ch; }

.steps {
  max-width: 68ch;
  padding-inline-start: 1.2em;
  margin: 0 0 26px;
}

.steps li { margin-bottom: 6px; font-size: .94rem; }

.explain ol.steps li::marker { color: var(--accent); font-weight: 700; }

.related {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.related a {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 560;
  font-size: .94rem;
}

.related a:hover { text-decoration: underline; }

/* home page directory of tool pages */

.tool-index {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

@media (min-width: 700px) {
  .tool-index { grid-template-columns: 1fr 1fr; }
}

.tool-index li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.tool-index a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: 3px;
}

.tool-index li:hover { border-color: var(--accent); }
.tool-index a:hover { color: var(--accent); }
.tool-index span { display: block; font-size: .84rem; color: var(--ink-2); }

/* Visible to assistive tech only. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
