/*
 * Social Media Image Resizer (inc/smr-tool.inc.php). The layout is
 * pt-ui.css's, the phone editor pt-app.css's, the segmented track
 * pt-theme.css's (.pt-cseg); this is the size list, the swatches, the samples
 * and the pictures. Sizes in px: the theme's rem is 20px. Panel rows are
 * styled by id: in the phone editor they are moved out of .smr-editor.
 */
.smr-ic { width: 20px; height: 20px; flex: 0 0 auto; }

/* ── The sizes ────────────────────────────────────────────────────────── */
.smr-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.smr-count-all { font-size: 12.5px; font-weight: 700; color: var(--cb-muted, #626973); font-variant-numeric: tabular-nums; white-space: nowrap; }
#smr-plats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.smr-plat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 11px;
  border: 0;
  border-radius: 999px;
  background: var(--cb-bg, #f2f4f8);
  color: var(--cb-text, #3d434b);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
}
.smr-plat:hover { color: var(--cb-ink, #16181d); background: var(--cb-hover-bg, #e6eaf1); }
.smr-plat.active { background: var(--cb-ink, #16181d); color: #fff; }
.smr-plat:focus-visible { outline: none; box-shadow: var(--cb-focus, 0 0 0 3px rgba(15, 112, 230, 0.28)); }
.smr-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--pt-accent, #0f70e6);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.smr-badge[hidden] { display: none; }
.smr-list[hidden] { display: none; }
.smr-size {
  display: grid;
  grid-template-columns: 18px 22px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 9px;
  min-height: 34px;
  margin: 0;
  padding: 3px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.6px;
  font-weight: 600;
  color: var(--cb-text, #3d434b);
}
.smr-size:hover { background: var(--cb-bg, #f2f4f8); }
.smr-size .form-check-input { margin: 0; float: none; width: 18px; height: 18px; border: 1.5px solid #aeb6c2; }
.smr-size .form-check-input:checked { border-color: var(--pt-accent, #0f70e6); }
.smr-shape { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; color: var(--cb-muted, #626973); }
.smr-shape i { display: block; max-width: 100%; max-height: 100%; border: 1.5px solid currentColor; border-radius: 2.5px; box-sizing: border-box; min-width: 4px; min-height: 4px; }
.smr-size:has(:checked) .smr-shape { color: var(--cb-ink, #16181d); }
.smr-size-name { min-width: 0; overflow-wrap: anywhere; hyphens: auto; line-height: 1.25; }
.smr-size-px { font-size: 12.5px; color: var(--cb-muted, #626973); font-variant-numeric: tabular-nums; white-space: nowrap; }
.smr-list-actions { display: flex; gap: 16px; padding: 6px 8px 0; }
.smr-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--pt-accent, #0f70e6);
  font-size: 13px;
  font-weight: 700;
}
.smr-link:hover { text-decoration: underline; }
.smr-link[hidden] { display: none; }
.smr-link:focus-visible { outline: none; border-radius: 4px; box-shadow: var(--cb-focus, 0 0 0 3px rgba(15, 112, 230, 0.28)); }

/* Custom sizes: a row each, with a remove button; then width × height. */
.smr-custom { display: flex; align-items: center; gap: 6px; padding: 0 0 0 0; }
.smr-custom .smr-custom-label { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: 18px 22px minmax(0, 1fr); align-items: center; column-gap: 9px; margin: 0; padding: 3px 8px; cursor: pointer; }
.smr-custom.smr-size { display: flex; padding: 0; }
.smr-remove {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cb-muted, #626973);
}
.smr-remove svg { width: 16px; height: 16px; }
.smr-remove:hover { background: var(--cb-hover-bg, #e6eaf1); color: var(--cb-ink, #16181d); }
.smr-custom-add { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: center; gap: 6px; margin: 6px 0 4px; }
.smr-custom-add > span { color: var(--cb-muted, #626973); font-weight: 700; }
.smr-custom-add .form-control { min-width: 0; }
.smr-note { font-size: 12.5px; }
.smr-warn { color: #9a4a00 !important; font-size: 12.5px; font-weight: 600; }
p.smr-warn[hidden] { display: none; }

/* ── Crop or fit ──────────────────────────────────────────────────────── */
#smr-fit > button { flex: 1 1 0; min-width: 0; }
#smr-bg { display: flex; flex-wrap: wrap; gap: 10px; }
.smr-swatch {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(22, 24, 29, 0.18);
  cursor: pointer;
}
.smr-swatch.active { box-shadow: inset 0 0 0 1px rgba(22, 24, 29, 0.18), var(--cb-ring, 0 0 0 2px #fff, 0 0 0 4px #16181d); }
.smr-swatch:focus-visible { outline: none; box-shadow: inset 0 0 0 1px rgba(22, 24, 29, 0.18), 0 0 0 2px #fff, 0 0 0 4px rgba(15, 112, 230, 0.6); }
.smr-swatch-blur {
  background:
    radial-gradient(circle at 30% 32%, rgba(255, 196, 120, 0.95), rgba(255, 196, 120, 0) 55%),
    radial-gradient(circle at 70% 70%, rgba(90, 160, 255, 0.95), rgba(90, 160, 255, 0) 58%),
    radial-gradient(circle at 75% 25%, rgba(120, 210, 150, 0.9), rgba(120, 210, 150, 0) 50%),
    #cfd6e0;
}
.smr-swatch-pick { overflow: hidden; background: conic-gradient(#ff4d4d, #ffd84d, #4dff88, #4dc3ff, #a64dff, #ff4dc3, #ff4d4d); }
.smr-swatch-pick:focus-within { box-shadow: inset 0 0 0 1px rgba(22, 24, 29, 0.18), 0 0 0 2px #fff, 0 0 0 4px rgba(15, 112, 230, 0.6); }
.smr-swatch-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
#smr-bg-row[hidden], #smr-focus-note[hidden] { display: none; }

/* ── The pictures ─────────────────────────────────────────────────────── */
#smr-viewport { position: relative; }
#smr-viewport.pt-app-loaded { overflow-y: auto; padding: 14px; overscroll-behavior: auto; }
.smr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  align-items: start;
}
.smr-grid[hidden] { display: none; }
.smr-tile {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.smr-orig, .smr-wide { grid-column: span 2; }
.smr-pic { position: relative; height: 150px; display: flex; align-items: center; justify-content: center; }
.smr-orig .smr-pic { height: 230px; }
.smr-pic canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  background: repeating-conic-gradient(#e6e9ee 0% 25%, #fff 0% 50%) 50% / 12px 12px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
@media (hover: hover) and (pointer: fine) {
  .smr-grid.smr-fill .smr-tile:not(.smr-orig) canvas { cursor: grab; }
  .smr-grid.smr-fill .smr-tile:not(.smr-orig) canvas.smr-dragging { cursor: grabbing; }
}
.smr-orig canvas:focus-visible { outline: 3px solid rgba(90, 160, 255, 0.9); outline-offset: 2px; }
.smr-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.55), inset 0 0 0 1.5px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.smr-dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); }
.smr-dot[hidden] { display: none; }
.smr-tag-up, .smr-follow {
  position: absolute;
  top: 6px;
  display: none;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 12px);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.smr-tag-up { inset-inline-start: 6px; background: #ffcc66; color: #3b2600; pointer-events: none; }
.smr-up .smr-tag-up { display: inline-flex; }
.smr-follow { inset-inline-end: 6px; border: 0; background: rgba(22, 24, 29, 0.78); color: #fff; }
.smr-follow svg { width: 14px; height: 14px; flex: 0 0 auto; }
.smr-follow:hover { background: #16181d; }
.smr-moved .smr-follow { display: inline-flex; }
.smr-up.smr-moved .smr-tag-up { max-width: calc(50% - 9px); }
.smr-up.smr-moved .smr-follow { max-width: calc(50% - 9px); }
/* The name over the size; the save button beside both. */
.smr-cap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.3;
}
.smr-cap-text { grid-column: 1; grid-row: 1; min-width: 0; }
.smr-cap-plat { font-weight: 800; overflow-wrap: break-word; }
.smr-cap-name { color: rgba(255, 255, 255, 0.78); overflow-wrap: break-word; hyphens: auto; }
.smr-cap-name::before { content: " · "; color: rgba(255, 255, 255, 0.5); }
.smr-cap-name:empty { display: none; }
.smr-cap-px { grid-column: 1; grid-row: 2; color: rgba(255, 255, 255, 0.6); font-variant-numeric: tabular-nums; white-space: nowrap; }
.smr-tile-save {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.smr-tile-save svg { width: 17px; height: 17px; }
.smr-tile-save:hover { background: rgba(255, 255, 255, 0.24); }
.smr-tile-save:focus-visible, .smr-follow:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ── Empty: the samples ───────────────────────────────────────────────── */
.smr-editor .smr-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  /* Without a width it shrinks to half the box (left: 50%). */
  width: 90%;
}
[dir="rtl"] .smr-editor .smr-empty { left: auto; right: 50%; transform: translate(50%, -50%); }
#smr-empty.hidden { display: none; }
.smr-samples { display: flex; justify-content: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.smr-sample {
  flex-shrink: 0;
  width: 110px;
  height: 110px;
  padding: 0;
  border: 2px solid #dee2e6;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
.smr-sample:hover, .smr-sample:focus-visible { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 4px 12px rgba(15, 112, 230, 0.25); outline: none; }
.smr-sample img { display: block; width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 767px) {
  .smr-sample { width: 72px; height: 72px; }
  .smr-samples { gap: 8px; }
  .smr-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .smr-pic { height: 120px; }
  .smr-orig .smr-pic { height: 190px; }
}

/* ── Phone editor ─────────────────────────────────────────────────────── */
/* The pictures scroll in the stage; the size list scrolls in the sheet. */
.pt-app-stage > #smr-viewport { padding: 10px; }
.pt-app-panels #smr-sizes, .pt-app-sheet #smr-sizes { max-height: 46vh; overflow-y: auto; }
.pt-app-panels .smr-size, .pt-app-panels .smr-plat { min-height: 40px; }

/* ── The size table on a phone ────────────────────────────────────────── */
/* Three columns are too narrow for the size lists: the platform takes its
   own line, the two lists sit side by side under it. */
@media (max-width: 575.98px) {
  body:has(.smr-editor) .ptc-vs table,
  body:has(.smr-editor) .ptc-vs thead,
  body:has(.smr-editor) .ptc-vs tbody { display: block; }
  body:has(.smr-editor) .ptc-vs tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 14px; border-bottom: 1px solid var(--ptc-line); }
  body:has(.smr-editor) .ptc-vs thead tr { border-bottom-width: 2px; }
  body:has(.smr-editor) .ptc-vs tbody tr:last-child { border-bottom: 0; }
  body:has(.smr-editor) .ptc-vs th,
  body:has(.smr-editor) .ptc-vs td { padding: 4px 0; border-bottom: 0; }
  body:has(.smr-editor) .ptc-vs thead td { display: none; }
  body:has(.smr-editor) .ptc-vs thead th { padding-bottom: 10px; }
  body:has(.smr-editor) .ptc-vs tbody th { grid-column: 1 / -1; padding-top: 14px; }
  body:has(.smr-editor) .ptc-vs tbody td { padding-bottom: 14px; }
}
