/* PDF Tune — one page, one task. Restrained palette: neutral paper and ink,
   one blue for actions and selection, green only for "done". System sans:
   a tool should feel native and load instantly, with no font fetched. */

:root {
  --paper: #f5f4f0;
  --surface: #fdfdfb;
  --ink: #15171b;
  --muted: #565b64;
  --line: #dcdad2;
  --line-strong: #bdbab0;
  --accent: #1f3cf2;
  --accent-hover: #1a33cc;
  --accent-ink: #ffffff;
  --accent-soft: #e6e9fe;
  --ok: #17663f;
  --warn: #8a4a0b;
  --shadow: 0 1px 2px rgb(20 22 27 / 0.05), 0 8px 24px -12px rgb(20 22 27 / 0.18);
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1114;
    --surface: #16191e;
    --ink: #eceef1;
    --muted: #a0a6b0;
    --line: #272b32;
    --line-strong: #3a3f48;
    --accent: #7088ff;
    --accent-hover: #8a9dff;
    --accent-ink: #0b0d12;
    --accent-soft: #1b2242;
    --ok: #5fd39a;
    --warn: #f0b36a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 30px -14px rgb(0 0 0 / 0.7);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-strong) transparent;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  accent-color: var(--accent);
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-lg {
  width: 2.25rem;
  height: 2.25rem;
  stroke-width: 1.5;
}

/* Header */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
}

.wordmark {
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.bar-note {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.bar-note .icon {
  color: var(--ok);
}

/* The tool */

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.tool {
  padding: clamp(2.5rem, 7vh, 4.5rem) 0 3.5rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 1.4rem + 3vw, 3.25rem);
  font-weight: 680;
  line-height: 1.06;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.lede {
  margin: 0.9rem 0 2rem;
  color: var(--muted);
  font-size: 1.125rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  animation: panel-in 260ms var(--ease-out);
}

/* Slide only, never from invisible: in a throttled background tab an entrance
   that starts at opacity 0 can leave the result blank. */
@keyframes panel-in {
  from {
    transform: translateY(6px);
  }
}

/* Idle: the drop area */

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 15rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.drop:hover,
.drop.is-over {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}

.drop:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.drop .icon-lg {
  margin-bottom: 0.4rem;
  color: var(--accent);
}

.drop-title {
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 600;
}

.link-like {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Chosen file */

.file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.file-row > .icon {
  color: var(--muted);
}

.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.file-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--paper);
  color: var(--ink);
}

/* Presets: a radio group laid out as a 2x2 choice grid */

.presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 1.1rem 0 1.25rem;
  padding: 0;
  border: 0;
}

.presets legend {
  margin-bottom: 0.6rem;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.preset {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.preset:hover {
  border-color: var(--line-strong);
}

.preset input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.preset:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.preset:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.preset-name {
  font-weight: 600;
}

.preset-desc {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0 1.25rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 600 1rem/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

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

.button:active {
  transform: translateY(1px);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.button.primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

#go {
  width: 100%;
}

/* Working */

.work-title {
  margin: 0 0 0.9rem;
  font-weight: 600;
}

.meter {
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--line);
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 300ms var(--ease-out);
}

/* Until the engine knows how many images there are, the bar breathes
   rather than pretending to a percentage. */
.meter.is-indeterminate .meter-fill {
  width: 30%;
  animation: meter-sweep 1.4s ease-in-out infinite;
}

@keyframes meter-sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

.work-step {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

/* Done */

.result {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 0;
}

.result-sizes {
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.1rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.result-sizes > span:first-child {
  color: var(--muted);
  font-weight: 500;
}

.arrow {
  color: var(--muted);
  font-weight: 400;
}

.result-saved {
  color: var(--ok);
  font-weight: 650;
}

.result-detail {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.compare {
  margin: 1.25rem 0 0;
}

.compare-frame {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  touch-action: none;
}

.compare-frame canvas {
  display: block;
  width: 100%;
  height: auto;
}

#canvas-before {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0);
}

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split, 50%);
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.7);
}

.compare-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.compare-tag {
  position: absolute;
  top: 0.6rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgb(21 23 27 / 0.72);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

.compare-tag-left {
  left: 0.6rem;
}

.compare-tag-right {
  right: 0.6rem;
}

/* The range input is the real control (keyboard, screen readers); the frame
   above is its picture. */
.compare-range {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0.75rem auto 0;
}

.compare figcaption {
  margin-top: 0.35rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

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

.actions .button {
  flex: 1 1 12rem;
}

/* Notes: refused or nothing to do */

.note {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.note > .icon {
  margin-top: 0.15rem;
  color: var(--warn);
}

.note-title {
  margin: 0;
  font-weight: 650;
}

.note-body {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

/* Facts below the fold: plain text in a rule-separated list, not cards. */

.facts {
  padding: 3rem 0 4rem;
  border-top: 1px solid var(--line);
}

.facts h2 {
  margin: 0 0 1.5rem;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.facts dl {
  margin: 0;
}

.facts dl > div {
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 0.25rem 2rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
}

.facts dt {
  font-weight: 600;
}

.facts dd {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
}

.foot {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.foot p {
  margin: 0;
}

/* Phones */

@media (max-width: 34rem) {
  .bar-note {
    font-size: 0.8125rem;
  }

  .note-long {
    display: none;
  }

  .drop {
    min-height: 12rem;
  }

  .presets {
    grid-template-columns: 1fr;
  }

  .facts dl > div {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
