/* PDF tools: hub, tool pages and the tool interface (static/js/pdf/app.mjs). */
.pdf-page {
  --product-accent: var(--ink);
  --card: #fff;
  --soft: #eeeee7;
  --danger: #b3261e;
}
.pdf-page .tool-hero {
  padding: 28px 0 32px;
}
.pdf-page .tool-hero h1 {
  font-size: clamp(36px, 4.6vw, 60px);
}
.pdf-page :is(button, input) {
  font: inherit;
  color: inherit;
}
.pdf-page :is(button, a, input, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tool cards (hub and "more tools"). */
.pdf-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  /* Six tools: three by two on wide screens, never five and one. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.pdf-cards a {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 1px 3px rgb(32 35 30 / 6%);
}
.pdf-cards a:hover {
  box-shadow: 0 2px 6px rgb(32 35 30 / 8%), 0 10px 22px rgb(32 35 30 / 8%);
}
.pdf-cards strong {
  font-size: 18px;
  font-weight: 650;
}
.pdf-cards span {
  font-size: 15px;
  color: var(--muted);
}
.pdf-steps,
.pdf-features,
.pdf-more {
  padding: 72px 0 0;
}
.pdf-steps h2,
.pdf-features h2,
.pdf-more h2 {
  font-size: 30px;
  margin: 0 0 28px;
}
.pdf-steps ol {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}
.pdf-steps li {
  counter-increment: step;
  font-size: 17px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.pdf-steps li::before {
  content: counter(step);
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* The tool. */
.pdf-tool {
  position: relative;
  min-height: 300px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 1px 3px rgb(32 35 30 / 6%);
}
.pdf-tool.is-dropping::after {
  content: attr(data-drop);
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: rgb(247 247 242 / 92%);
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
}
.pdf-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.pdf-note,
.pdf-tool > .pdf-message {
  margin: 0;
  padding: 0 24px 28px;
  text-align: center;
}
.pdf-message {
  margin: 0;
  font-size: 15px;
  color: var(--danger);
}
.pdf-primary,
.pdf-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 28px;
  border: 0;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.pdf-primary {
  background: var(--accent);
  color: #fff !important;
}
.pdf-primary:hover {
  filter: brightness(1.08);
}
.pdf-primary:disabled {
  background: var(--soft);
  color: #9a9d93 !important;
  cursor: default;
  filter: none;
}
.pdf-secondary {
  min-height: 44px;
  padding: 0 18px;
  font-size: 15px;
  background: var(--soft);
}
.pdf-secondary:hover {
  background: #e4e4db;
}

/* Empty state. */
.pdf-drop {
  min-height: 300px;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px;
  border: 1.5px dashed #c9cabf;
  border-radius: 10px;
}
.pdf-drop .pdf-primary {
  min-height: 60px;
  padding: 0 40px;
  font-size: 19px;
}
.pdf-drop p {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}
.pdf-local {
  margin-top: 14px !important;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.pdf-local::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2f9e5b;
}
@media (hover: none) {
  .pdf-drop-hint {
    display: none;
  }
}

/* Workspace: files on the left, options and the action on the right. */
.pdf-work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
}
.pdf-main {
  padding: 20px;
  min-width: 0;
}
.pdf-side {
  position: sticky;
  top: 86px;
  padding: 20px;
  display: grid;
  gap: 18px;
  border-left: 1px solid var(--line);
  min-height: 300px;
  align-content: start;
}
.pdf-options {
  display: grid;
  gap: 16px;
}
.pdf-options[inert] {
  opacity: 0.5;
}
.pdf-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.pdf-card {
  position: relative;
  align-self: start;
  min-width: 0;
  padding: 10px;
  border-radius: 10px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pdf-thumb {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
}
.pdf-thumb :is(canvas, img) {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  box-shadow: 0 1px 4px rgb(32 35 30 / 18%);
}
.pdf-card .pdf-thumb img {
  object-fit: contain;
}
.pdf-card-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.pdf-card-text strong {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-card-text > span {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pdf-card.is-damaged .pdf-card-text > span {
  color: var(--danger);
  white-space: normal;
}
.pdf-card.is-reading .pdf-thumb {
  background: var(--soft);
}
.pdf-remove,
.pdf-moves button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 1px 4px rgb(32 35 30 / 22%);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.pdf-remove {
  position: absolute;
  top: 4px;
  right: 4px;
}
.pdf-moves {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  gap: 4px;
}
.pdf-moves button:disabled {
  opacity: 0.35;
  cursor: default;
}
@media (hover: hover) {
  .pdf-card:not(:hover, :focus-within) :is(.pdf-remove, .pdf-moves) {
    opacity: 0;
  }
}
.pdf-items:has(.pdf-moves) .pdf-card {
  cursor: grab;
  user-select: none;
}
.pdf-card.is-dragging {
  z-index: 3;
  pointer-events: none;
  opacity: 0.85;
  box-shadow: 0 12px 28px rgb(32 35 30 / 22%);
}
.pdf-card.drop-before::before,
.pdf-card.drop-after::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -9px;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.pdf-card.drop-after::before {
  left: auto;
  right: -9px;
}
.pdf-unlock {
  margin-top: 6px;
  display: grid;
  gap: 6px;
}
.pdf-unlock span {
  font-size: 13px;
  color: var(--muted);
}
.pdf-unlock .is-wrong {
  color: var(--danger);
}
.pdf-unlock input {
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
}
.pdf-unlock .pdf-secondary {
  min-height: 40px;
}
.pdf-add {
  display: inline-flex;
  align-items: center;
  margin-top: 14px;
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px dashed #c9cabf;
  border-radius: 10px;
  background: none;
  font-size: 15px;
  cursor: pointer;
}
.pdf-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* One file with its pages shown: the file sits in a single row above the page grid. */
.pdf-items.is-compact {
  display: block;
}
.pdf-items.is-compact .pdf-card {
  flex-direction: row;
  align-items: center;
  padding: 8px 48px 8px 8px;
}
.pdf-items.is-compact .pdf-thumb {
  flex: none;
  width: 36px;
}
.pdf-items.is-compact .pdf-remove {
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  opacity: 1;
}
.pdf-pages {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 12px;
}
.pdf-page-cell {
  width: 100%;
  padding: 8px 8px 6px;
  display: grid;
  gap: 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
}
.pdf-page-cell[aria-pressed="true"] {
  border-color: var(--accent);
  background: #eef1fd;
}
.pdf-page-cell .pdf-thumb {
  aspect-ratio: 1;
}
.pdf-page-cell canvas {
  rotate: var(--turn, 0deg);
  transition: rotate 0.2s ease;
}
.pdf-page-number {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
  .pdf-page-cell canvas {
    transition: none;
  }
}

/* Options. */
.pdf-field {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.pdf-field legend.is-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.pdf-field legend,
.pdf-text > span {
  padding: 0;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--muted);
}
.pdf-segments {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(min-content, 1fr);
  padding: 3px;
  border-radius: 10px;
  background: var(--soft);
}
.pdf-segments:has(label:nth-child(4)) {
  grid-auto-flow: row;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.pdf-segments input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.pdf-segments span {
  min-height: 40px;
  padding: 4px 6px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}
.pdf-segments input:checked + span {
  background: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgb(32 35 30 / 14%);
}
.pdf-segments input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.pdf-detail {
  min-height: 96px;
  display: grid;
  align-content: start;
  gap: 10px;
}
.pdf-hint {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.pdf-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.pdf-chips :is(button, input),
.pdf-chip {
  min-width: 0;
  height: 40px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.pdf-chips input {
  cursor: text;
  text-align: center;
  font-size: 16px;
}
.pdf-chips .is-on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.pdf-text {
  display: grid;
}
.pdf-text input,
.pdf-inline input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.pdf-text input[aria-invalid="true"] {
  border-color: var(--danger);
}
.pdf-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}
.pdf-inline input {
  width: 76px;
  text-align: center;
}
.pdf-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  cursor: pointer;
}
.pdf-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.pdf-buttons {
  display: grid;
  gap: 8px;
}
.pdf-run {
  width: 100%;
}
.pdf-running {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 52px;
}
.pdf-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--soft);
  overflow: hidden;
}
.pdf-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0.02);
  transition: transform 0.25s linear;
}
:dir(rtl) .pdf-progress span {
  transform-origin: right;
}

/* Result. */
.pdf-result {
  min-height: 300px;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}
.pdf-headline {
  display: grid;
  gap: 4px;
  max-width: 100%;
}
.pdf-headline strong {
  font-size: clamp(24px, 3.4vw, 36px);
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.pdf-headline span {
  font-size: 17px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pdf-result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
}
.pdf-result .pdf-primary {
  min-height: 60px;
  padding: 0 44px;
  font-size: 19px;
}
.pdf-files {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  width: min(100%, 560px);
  max-height: 264px;
  overflow: auto;
  text-align: start;
  border-top: 1px solid var(--line);
}
.pdf-files a {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.pdf-files a:hover span {
  text-decoration: underline;
}
.pdf-files span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-files small {
  flex: none;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pdf-next {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
.pdf-chip {
  color: var(--ink);
  padding: 0 14px;
}
.pdf-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 860px) {
  .pdf-work {
    grid-template-columns: minmax(0, 1fr);
  }
  .pdf-side {
    position: static;
    min-height: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px 16px max(16px, env(safe-area-inset-bottom));
    gap: 12px;
  }
  .pdf-detail {
    min-height: 0;
  }
  .pdf-main {
    padding: 14px;
  }
  .pdf-items {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
  .pdf-pages {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
  }
  .pdf-steps ol {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
  .pdf-steps,
  .pdf-more {
    padding-top: 52px;
  }
}

/* A preview that has not been drawn yet holds a page-shaped blank. */
.pdf-thumb canvas:not([data-drawn]) {
  height: 100%;
  box-shadow: none;
  background: var(--soft);
}
.pdf-secondary,
.pdf-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pdf-card:is(.is-locked, .is-damaged) .pdf-thumb {
  display: none;
}
.pdf-card:is(.is-locked, .is-damaged) .pdf-card-text {
  padding-right: 34px;
}

/* Entry on the home page. */
.home-tools {
  padding-top: 72px;
}
.home-tools-heading {
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
}
.home-tools-heading h2 {
  margin: 0;
  font-size: 30px;
}
.home-tools-heading p {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
}
.home-tools {
  width: min(1320px, calc(100% - 96px));
  margin-inline: auto;
}
@media (max-width: 1000px) {
  .home-tools {
    width: calc(100% - 48px);
  }
}
@media (max-width: 650px) {
  .home-tools {
    width: calc(100% - 36px);
    padding-top: 52px;
  }
}
.pdf-items:has(.pdf-moves) .pdf-card {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}
@media (max-width: 650px) {
  .pdf-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .pdf-cards a {
    padding: 16px;
  }
  .pdf-cards strong {
    font-size: 17px;
  }
  .pdf-cards span {
    font-size: 14px;
  }
}

/* Four choices sit in one row only where every language's labels fit. */
@media (min-width: 480px) and (max-width: 860px) {
  .pdf-segments:has(label:nth-child(4)) {
    grid-auto-flow: column;
    grid-template-columns: none;
  }
}
@media (max-width: 400px) {
  .pdf-segments span {
    font-size: 14px;
    padding-inline: 4px;
  }
}
@media (min-width: 651px) and (max-width: 860px) {
  .pdf-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* What sets each tool apart: short blocks under their own headings. */
.pdf-features > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 48px;
}
.pdf-features h3 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 650;
  line-height: 1.35;
}
.pdf-features p {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
  max-width: 52ch;
}
@media (max-width: 650px) {
  .pdf-features > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .pdf-features {
    padding-top: 52px;
  }
}
