/* Image Resizer (image-resizer.html). Loaded after tools.css; uses the site tokens. */

.tgrid.ir-grid { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); }
@media (max-width: 900px) {
  /* one column: pictures, then the result, then the settings */
  .tgrid.ir-grid { grid-template-columns: minmax(0, 1fr); }
  .tgrid.ir-grid > .tstack { display: contents; }
  #files-card { order: 1; } #result-card { order: 2; } .ir-grid .tcard[aria-labelledby="h-size"] { order: 3; }
  #shape-card { order: 4; } .ir-grid .tcard[aria-labelledby="h-q"] { order: 5; }
}

/* checkerboard behind pictures, so transparency shows */
.ir-stage, .ir-thumb {
  background-color: #c4c4c4;
  background-image: linear-gradient(45deg, #9a9a9a 25%, transparent 25%, transparent 75%, #9a9a9a 75%), linear-gradient(45deg, #9a9a9a 25%, transparent 25%, transparent 75%, #9a9a9a 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}

/* adding pictures */
.ir-drop { padding: 18px; text-align: center; border: 2px dashed var(--rule-paper); background: var(--paper-2); }
.ir-drop > p:first-child { margin: 0 0 12px; }
.ir-drop .thint { margin: 12px 0 0; }
.ir-droprow { justify-content: center; }
#files-card.dropping .ir-drop { border-color: var(--red-500); background: color-mix(in srgb, var(--red-500) 10%, var(--paper-2)); }

.ir-files { list-style: none; margin: 14px 0 0; padding: 0; max-height: 360px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.ir-files:empty { display: none; }
.ir-file { display: flex; align-items: stretch; gap: 0; min-width: 0; box-shadow: inset 0 0 0 1px var(--rule-paper); }
.ir-file.sel { box-shadow: inset 0 0 0 2px var(--red-500); }
.ir-pick { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ir-pick:hover { background: var(--paper-2); }
.ir-pick:focus-visible, .ir-x:focus-visible, .ir-pos button:focus-visible, #pv:focus-visible { outline: 2px solid var(--red-400); outline-offset: -2px; }
.ir-thumb { flex: none; width: 44px; height: 44px; background-size: 8px 8px; background-position: 0 0, 4px 4px; display: flex; align-items: center; justify-content: center; }
.ir-thumb canvas { width: 44px; height: 44px; display: block; }
.ir-meta { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.ir-meta b { font-size: 0.88rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ir-meta small { font-family: var(--mono); font-size: 0.74rem; color: var(--on-paper-soft); overflow-wrap: anywhere; }
.ir-file.bad .ir-meta small { color: var(--accent); }
.ir-x { flex: none; width: 40px; border: 0; background: none; color: var(--on-paper-soft); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.ir-x:hover { color: var(--accent); background: var(--paper-2); }
.ir-filebar { margin-top: 10px; }

/* size */
.ir-panel { margin-top: 14px; }
.ir-wh { flex-wrap: nowrap; align-items: end; }
.ir-wh > .tf { flex: 1 1 0; min-width: 0; }
.tbtn.ir-swap { flex: none; min-height: 40px; min-width: 40px; font-size: 1.05rem; }
.ir-preset { margin: 14px 0 0; }
.trow > .tf.ir-pctf { flex: 0 1 120px; }
.ir-quick { align-self: end; padding-bottom: 2px; }
.ir-check { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; min-height: 36px; font-size: 0.88rem; font-weight: 600; cursor: pointer; }
.ir-check input { width: 18px; height: 18px; flex: none; accent-color: var(--red-500); }
.ir-check small { font-weight: 400; color: var(--on-paper-soft); }
.ir-check.off, .tf.off { opacity: 0.5; }
.ir-check.off { cursor: default; }
#sizeinfo, #fitinfo { font-family: var(--mono); font-size: 0.8rem; }
#sizeinfo:empty, #fitinfo:empty, #fmtinfo:empty, #status:empty { display: none; }

/* shape */
.ir-posrow, .ir-bars { margin-top: 16px; }
.ir-posrow .tlabel, .ir-bars .tlabel { margin-bottom: 6px; }
.ir-pos { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
.ir-pos button { width: 34px; height: 34px; padding: 0; border: 0; cursor: pointer; background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--rule-paper); display: flex; align-items: center; justify-content: center; }
.ir-pos button i { width: 8px; height: 8px; border-radius: 50%; background: var(--on-paper-soft); }
.ir-pos button[aria-pressed="true"] { background: var(--ink); }
.ir-pos button[aria-pressed="true"] i { background: #fff; }
@media (prefers-color-scheme: dark) { .ir-pos button[aria-pressed="true"] { background: var(--red-600); } }
.ir-pos button:hover:not([aria-pressed="true"]) { background: var(--rule-paper); }
.thint.ir-poshint { margin-top: 6px; }
.ir-barrow { align-items: center; }

/* format */
.ir-fmt { margin-top: 14px; }
.ir-name { margin: 14px 0 0; }

/* result */
.ir-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ir-bar .seg button { padding: 6px 11px; font-size: 0.82rem; }
.ir-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 220px; max-height: min(72vh, 760px); overflow: hidden; box-shadow: inset 0 0 0 1px var(--rule-paper); }
.ir-stage canvas { display: block; max-width: 100%; max-height: min(72vh, 760px); width: auto; height: auto; }
.ir-stage.full { display: block; overflow: auto; }
.ir-stage.full canvas { max-width: none; max-height: none; height: auto; }
.ir-stage.movable #pv { cursor: grab; touch-action: none; }
.ir-stage.movable #pv:active { cursor: grabbing; }
#pv.pixel { image-rendering: pixelated; }
.ir-empty, .ir-msg { margin: 0; padding: 28px 18px; text-align: center; background: var(--white); max-width: 92%; }
@media (prefers-color-scheme: dark) { .ir-empty, .ir-msg { background: #1d1718; } }
.ir-empty p { margin: 0 0 12px; font-weight: 600; }
.ir-msg { font-weight: 600; }
.ir-busy { position: absolute; top: 10px; right: 10px; padding: 6px 10px; font-size: 0.8rem; font-weight: 700; background: var(--ink); color: #fff; }
.ir-stats { margin: 10px 0 0; font-family: var(--mono); font-size: 0.8rem; color: var(--on-paper-soft); white-space: pre-wrap; }
.ir-stats:empty { display: none; }
.ir-actions { margin-top: 12px; align-items: center; }
.ir-more { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule-paper); }

.ir-tool [hidden] { display: none !important; }
