/*
  resize.nirmaan.online: the PDF tool's own components (loaded only on the PDF pages). The tool reuses site.css's .tool steps, drop
  zone, checks and result, and nirmaan.css's .choice, .field, .input and .notice; this
  file adds only what is new: the mode switch, limit fields, progress line, photo list
  and the page preview. nirmaan.css tokens only: no raw colours, no radius, no new fonts.
*/
@layer reset, base, layout, components, pages, motion;

@layer pages {
  /* One tool, two modes: words and controls that belong to the other mode are hidden. */
  .pdf-tool[data-mode="compress"] [data-when="images"],
  .pdf-tool[data-mode="images"] [data-when="compress"] { display: none !important; }

  /* ---------- 01 Mode, size limit, black and white ---------- */
  .pdf-mode, .pdf-size { border: 0; padding: 0; margin: 0; min-width: 0; }
  /* Two short choices fit side by side even on a phone. */
  .pdf-tool .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pdf-tool .choice__box { padding: 0.8rem 0.9rem; }
  .pdf-target { margin-top: var(--s3); }
  .pdf-target select.input { font-weight: 600; text-overflow: ellipsis; }
  .pdf-for { margin-top: 0.6rem; font-size: var(--fs-small); color: var(--ink-2); }
  .pdf-for .link-arrow { margin-left: 0.25rem; }
  .pdf-limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin-top: var(--s2); }
  .pdf-tool .tick { margin-top: var(--s1); }

  /* ---------- 02 The photo list: number, picture, name, then turn / up / down / remove ---------- */
  .pdf-photos { display: grid; gap: var(--s2); }
  .pdf-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line-2); }
  .pdf-item {
    display: grid; grid-template-columns: auto 3.25rem minmax(0, 1fr) auto; align-items: center; gap: 0.75rem;
    padding-block: 0.6rem; border-bottom: 1px solid var(--line);
  }
  .pdf-item__n { color: var(--ink-3); letter-spacing: 0.08em; }
  .pdf-item__thumb {
    display: grid; place-items: center; width: 3.25rem; aspect-ratio: 1; overflow: hidden;
    border: 1px solid var(--line-2); background: var(--paper-2);
  }
  .pdf-item__thumb img { max-width: 100%; max-height: 100%; object-fit: contain; transform: rotate(var(--turn, 0deg)); transition: transform 0.25s var(--ease-out); }
  /* A turned photo swaps its sides, so it shrinks to stay inside the square. */
  .pdf-item__thumb img.is-turned { max-width: 75%; max-height: 75%; }
  .pdf-item__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-small); }
  .pdf-item__actions { display: flex; gap: 0.25rem; }
  .pdf-item .ctl { min-width: 2.75rem; font-size: 1.05rem; }
  .pdf-item .ctl[disabled] { opacity: 0.35; pointer-events: none; }
  @media (max-width: 30rem) {
    /* Small phones: the buttons move under the name, still 44 px tall. */
    .pdf-item { grid-template-columns: auto 3.25rem minmax(0, 1fr); }
    .pdf-item__actions { grid-column: 2 / -1; }
  }
  .pdf-photos__add { justify-self: start; min-height: 2.75rem; }
  .pdf-size { display: grid; gap: 0.6rem; }
  .pdf-size legend { font-size: 0.8125rem; font-weight: 600; margin-bottom: 0.6rem; }

  /* ---------- 03 Progress: one line of words and a hairline bar ---------- */
  .pdf-progress { display: grid; gap: 0.6rem; }
  .pdf-progress__text { font-size: var(--fs-small); color: var(--ink-2); font-variant-numeric: tabular-nums; }
  .pdf-progress__bar { position: relative; height: 2px; background: var(--line-2); overflow: hidden; }
  .pdf-progress__bar span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--blue); transition: width 0.2s linear; }
  .pdf-how { display: grid; gap: 0.25rem; }
  .pdf-how__text { font-size: var(--fs-small); color: var(--ink-2); max-width: 52ch; }
  .pdf-how__details { margin-top: var(--s2); }
  .pdf-how__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0 0 var(--s1); border: 1px solid var(--line); background: var(--line); }
  .pdf-how__grid > div { display: grid; gap: 0.2rem; padding: 0.6rem 0.8rem; background: var(--paper); }
  .pdf-how__grid dt { font-family: var(--mono); font-size: var(--fs-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
  .pdf-how__grid dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

  /* ---------- 04 Result: the page preview is page-shaped, on white like paper ---------- */
  .pdf-fig { aspect-ratio: 3 / 4; }
  .pdf-fig img { background: var(--paper); }
  .pdf-note { margin-bottom: var(--s3); }
  .is-working [data-step="3"] .tool__n { border-color: var(--blue); color: var(--blue); }

}
