/* PhotoFilter — editor widget + content polish.
   Theme colors come from site.config.json (--primary fuchsia / --accent amber). */

.pf {
  margin: 1.4rem 0 2rem;
}

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

.pf-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;
}
.pf-drop strong {
  font-size: 1.1rem;
}
.pf-drop span {
  font-size: 0.92rem;
  color: var(--text-dim);
}
.pf-drop u {
  color: var(--primary);
  text-decoration: none;
  font-weight: 650;
}
.pf-drop:hover,
.pf-drop:focus-visible,
.pf-drop-hot {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--bg));
  outline: none;
}
.pf-drop-hot {
  transform: scale(1.005);
}
.pf-drop-min {
  padding: 0.9rem 1.25rem;
}

/* ---- editor shell ---- */

.pf-editor:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
}

/* filmstrip */
.pf-strip:not([hidden]) {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.45rem 0.25rem 0.15rem;
}
.pf-thumbwrap {
  position: relative;
  flex: none;
}
.pf-thumb {
  position: relative;
  flex: none;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  overflow: visible;
}
.pf-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.pf-thumb.pf-on {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent);
}
.pf-thumb-dot:not([hidden]) {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
}
/* per-image remove — 24px target (WCAG 2.2 AA minimum) */
.pf-thumb-x {
  position: absolute;
  top: -7px;
  left: -7px;
  z-index: 1;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.pf-thumb-x:hover,
.pf-thumb-x:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
}

/* toolbar row */
.pf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.pf-filemeta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pf-fname {
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 22rem;
}
.pf-dims {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.pf-tools {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.pf-tools label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-dim);
}
.pf-tools select,
.pf-export select {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
}
.pf-cmpbtn,
.pf-undo,
.pf-redo,
.pf-reset,
.pf-clear {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  color: var(--text-dim);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.38rem 0.7rem;
  cursor: pointer;
}
.pf-cmpbtn:hover,
.pf-undo:hover,
.pf-redo:hover,
.pf-reset:hover,
.pf-clear:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.pf-cmpbtn[aria-pressed="true"] {
  color: var(--primary);
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg));
}
.pf-undo:disabled,
.pf-redo:disabled {
  opacity: 0.45;
  cursor: default;
}

/* viewport + stage */
.pf-view {
  overflow: auto;
  max-width: 100%;
  max-height: 72vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: repeating-conic-gradient(#e9e9ef 0% 25%, #f8f8fb 0% 50%) 0 0 / 18px 18px;
}
.pf-stage {
  position: relative;
  width: 100%;
  margin: 0 auto;
  line-height: 0;
}
.pf-stage canvas {
  display: block;
  width: 100%;
  height: auto;
}
.pf-stage.pf-zoomed canvas {
  image-rendering: pixelated;
}
.pf-cv-after {
  position: absolute;
  inset: 0;
}

/* compare divider + its (invisible but accessible) range overlay */
.pf-cmp {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}
.pf-cmp-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.pf-cmp-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
}
.pf-cmp-grip::before {
  content: "◂ ▸";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.05em;
}
.pf-cmp:focus-visible ~ .pf-cmp-line .pf-cmp-grip {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 35%, transparent);
}
.pf:not(.pf-compare) .pf-cmp,
.pf:not(.pf-compare) .pf-cmp-line {
  display: none;
}
.pf-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.pf:not(.pf-compare) .pf-hint {
  display: none;
}

/* presets */
.pf-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.pf-preset {
  font: inherit;
  font-size: 0.83rem;
  font-weight: 650;
  color: var(--text-dim);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
}
.pf-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.pf-preset.pf-on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* sliders */
.pf-sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 1.4rem;
}
.pf-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.84rem;
}
.pf-row .pf-name {
  flex: none;
  width: 5.4rem;
  font-weight: 650;
  color: var(--text-dim);
}
.pf-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--primary);
}
.pf-val {
  flex: none;
  width: 2.5rem;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text);
}

/* actions */
.pf-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}
.pf-hist,
.pf-export {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pf-export label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-dim);
}
.pf-f-quality input[type="range"] {
  width: 6.5rem;
  accent-color: var(--primary);
}
.pf-qv {
  font-family: var(--mono);
}
.pf-dl,
.pf-dlall {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  cursor: pointer;
}
.pf-dl:hover,
.pf-dlall:hover {
  filter: brightness(1.08);
}
.pf-dlall:not([hidden]) {
  background: var(--bg);
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

/* status */
.pf-status {
  min-height: 1.2em;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

/* ---- content helpers ---- */

.formula {
  display: block;
  font-family: var(--mono);
  font-size: 0.95rem;
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  padding: 0.7rem 1rem;
  border-radius: 0 8px 8px 0;
  margin: 0.9rem 0;
  overflow-x: auto;
  white-space: nowrap;
}

.prose table.preset-table td:first-child,
.prose table.preset-table th:first-child {
  min-width: 6.5rem;
}

@media (max-width: 640px) {
  .pf-sliders {
    grid-template-columns: 1fr;
  }
  .pf-toolbar,
  .pf-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .pf-tools,
  .pf-hist,
  .pf-export {
    width: 100%;
  }
  .pf-dl {
    flex: 1;
  }
  .pf-fname {
    max-width: 100%;
  }
}
