/* ImgResize — resizer/crop widget + content polish.
   Theme colors come from site.config.json (--primary teal / --accent orange). */

.rz {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem;
  margin: 1.4rem 0 2rem;
}

/* ---- dropzone ---- */

.rz-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
  padding: 2rem 1.25rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.rz-drop strong {
  font-size: 1.1rem;
}
.rz-drop span {
  font-size: 0.92rem;
  color: var(--text-dim);
}
.rz-drop u {
  color: var(--primary);
  text-decoration: none;
  font-weight: 650;
}
.rz-drop:hover,
.rz-drop:focus-visible,
.rz-drop-hot {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--bg));
  outline: none;
}
.rz-drop-hot {
  transform: scale(1.005);
}

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

.rz-opts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}
/* :not([hidden]) — mode field labels are toggled via the hidden attribute;
   the engine's [hidden]{display:none!important} guard is the real fix, this
   scoping keeps the site sheet from fighting it. */
.rz-opts label:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
}
.rz-opts select,
.rz-opts input[type='number'] {
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.6);
  padding: 0.45rem 0.55rem;
}
.rz-opts select:focus-visible,
.rz-opts input[type='number']:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.rz-opts input[type='range'] {
  accent-color: var(--primary);
  margin-top: 0.5rem;
}
.rz-opts .rz-f-px.rz-lock {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  align-self: end;
  padding-bottom: 0.55rem;
}
.rz-opts .rz-lock input {
  accent-color: var(--primary);
  width: 1.05rem;
  height: 1.05rem;
}

/* ---- status + result list ---- */

.rz-status {
  min-height: 1.2rem;
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.rz-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 0.4rem;
}

.rz-item {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: var(--bg);
}
.rz-item[data-state='working'] {
  opacity: 0.65;
}
.rz-item[data-state='error'] {
  border-color: color-mix(in srgb, #dc2626 55%, var(--border));
}
.rz-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.rz-thumb {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: calc(var(--radius) * 0.5);
  border: 1px solid var(--border);
  background:
    repeating-conic-gradient(#e5e7eb 0% 25%, #f8fafc 0% 50%) 0 0 / 16px 16px;
  flex: none;
}
.rz-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.rz-meta b {
  font-size: 0.95rem;
}
.rz-meta i {
  font-style: normal;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.rz-arrow {
  font-size: 1.3rem;
  color: var(--primary);
  font-weight: 700;
}
.rz-dl {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-weight: 650;
  color: #fff;
  background: var(--primary);
  border-radius: calc(var(--radius) * 0.6);
  padding: 0.4rem 0.8rem;
  text-decoration: none;
  align-self: flex-start;
}
.rz-dl:hover {
  filter: brightness(1.08);
}
.rz-line {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.rz-err {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.85rem;
  color: #dc2626;
}
.rz-item[data-state='done'] .rz-dims {
  color: var(--accent);
}

/* ---- crop editor ---- */

.rz-editor:not([hidden]) {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-start;
}
.rz-cropstage {
  position: relative;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.5);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.rz-cropimg {
  display: block;
  width: 100%;
  height: 100%;
}
.rz-shade {
  position: absolute;
  background: rgba(15, 23, 42, 0.55);
  pointer-events: none;
}
.rz-cropbox {
  position: absolute;
  border: 2px solid #fff;
  outline: 1px solid rgba(14, 116, 144, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset;
  cursor: move;
  box-sizing: border-box;
}
.rz-cropbox:focus-visible {
  outline: 3px solid var(--primary);
}
.rz-hd {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 3px;
}
/* Invisible ring around the 14px visual handle → ~32px touch target. The
   pseudo box hit-tests as the <i> itself, so drags still fire on .rz-hd. */
.rz-hd::after {
  content: '';
  position: absolute;
  inset: -9px;
}
.rz-hd[data-hd='nw'] { left: -8px; top: -8px; cursor: nwse-resize; }
.rz-hd[data-hd='ne'] { right: -8px; top: -8px; cursor: nesw-resize; }
.rz-hd[data-hd='sw'] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.rz-hd[data-hd='se'] { right: -8px; bottom: -8px; cursor: nwse-resize; }
.rz-cropbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.rz-cropinfo {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
}
.rz-cropbar button,
.rz-foot button {
  font: inherit;
  font-weight: 650;
  border: none;
  border-radius: calc(var(--radius) * 0.6);
  padding: 0.5rem 1rem;
  cursor: pointer;
}
.rz-apply {
  color: #fff;
  background: var(--accent);
}
.rz-apply:hover {
  filter: brightness(1.08);
}
.rz-skip {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border) !important;
}

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

.rz-foot:not([hidden]) {
  display: flex;
  gap: 0.7rem;
  margin-top: 1rem;
}
.rz-all {
  color: #fff;
  background: var(--primary);
}
.rz-all:hover {
  filter: brightness(1.08);
}
.rz-clear {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border) !important;
}

/* ---- cheat table + misc content ---- */

.size-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 1rem 0 1.6rem;
}
.size-table th,
.size-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.size-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.size-table td:first-child {
  font-weight: 600;
}
.size-table td code {
  white-space: nowrap;
}

@media (max-width: 540px) {
  .rz-item {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .rz-arrow {
    transform: rotate(90deg);
  }
  .rz-cell {
    flex-direction: column;
    text-align: center;
  }
  .rz-dl {
    align-self: center;
  }
}
