/* The GIF Maker (inc/gif-tool.inc.php): the frames, the controls and the
   playing GIF. The layout is pt-ui.css's, the phone editor pt-app.css's. */

.gif-editor [hidden] { display: none !important; }

/* ── Empty state: the samples ─────────────────────────────────────────── */
.gif-editor .sample-thumbnails-container {
  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%;
}
/* By id: in the phone editor the box is out of the card. */
#gif-empty.hidden { display: none; }
.gif-editor .sample-thumbnails { display: flex; justify-content: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.gif-editor .sample-thumbnail {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  width: 110px;
  height: 110px;
  padding: 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.gif-editor .sample-thumbnail:hover,
.gif-editor .sample-thumbnail:focus-visible { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 4px 12px rgba(15, 112, 230, 0.25); }
.gif-editor .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* How many frames the sample has: a stack of cards in the corner. */
.gif-sample-n {
  position: absolute;
  bottom: 5px;
  inset-inline-end: 5px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(30, 34, 40, 0.78);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
@media (max-width: 767px) { .gif-editor .sample-thumbnail { width: 84px; height: 84px; } }

/* ── The GIF, playing ─────────────────────────────────────────────────── */
/* By id: in the phone editor the box is in the stage, out of the card. */
#gif-viewport { display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; }
#gif-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(30, 34, 40, 0.18), 0 4px 14px rgba(30, 34, 40, 0.1);
  cursor: pointer;
}
.gif-play {
  position: absolute;
  bottom: 12px;
  inset-inline-start: 12px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(30, 34, 40, 0.72);
  color: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}
.gif-play svg { width: 20px; height: 20px; }
.gif-play:hover { background: rgba(30, 34, 40, 0.88); }
.gif-play:focus-visible { outline: 3px solid rgba(15, 112, 230, 0.6); outline-offset: 2px; }
.gif-at {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 6;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(30, 34, 40, 0.72);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.gif-progress {
  position: absolute;
  inset-inline: 12px;
  bottom: 4px;
  z-index: 7;
  height: 4px;
  border-radius: 2px;
  background: rgba(15, 112, 230, 0.18);
  overflow: hidden;
}
.gif-progress-bar { width: 0; height: 100%; background: var(--pt-accent, #0f70e6); transition: width 0.15s linear; }

/* ── The frames ───────────────────────────────────────────────────────── */
.gif-frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.gif-frame, .gif-addtile { position: relative; border-radius: 10px; outline: none; }
.gif-thumb {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 10px;
  background: #e9eef6;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.gif-thumb canvas { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.gif-num, .gif-frame .gif-time {
  position: absolute;
  bottom: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(30, 34, 40, 0.75);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.gif-num { inset-inline-start: 4px; }
/* A frame's own time shows once the frames differ, and on the one selected. */
.gif-frame .gif-time { inset-inline-end: 4px; display: none; font-weight: 600; }
.gif-mixed .gif-frame .gif-time, .gif-frame.is-selected .gif-time { display: block; }
.gif-mixed .gif-frame .gif-num { display: none; }
.gif-frame.is-selected .gif-num { display: none; }
.gif-del {
  position: absolute;
  top: 3px;
  inset-inline-end: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(30, 34, 40, 0.75);
  color: #fff;
}
/* A bigger target round the small badge, grown outwards (into the gap
   between tiles) and only a little inwards: the middle of the frame is
   where a drag starts, and a press there must never remove it. */
.gif-del::before { content: ""; position: absolute; inset-block-start: -7px; inset-inline-end: -7px; inset-block-end: 0; inset-inline-start: 0; }
.gif-del svg { width: 14px; height: 14px; }
.gif-del:hover { background: #d63939; }
.gif-del:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 1px; }
.gif-frame:focus-visible .gif-thumb { box-shadow: 0 0 0 3px rgba(15, 112, 230, 0.5); }
.gif-frame.is-selected .gif-thumb { box-shadow: 0 0 0 3px var(--pt-accent, #0f70e6); }
/* The frame on screen now: a bar under it. */
.gif-frame::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -5px;
  height: 3px;
  border-radius: 2px;
  background: transparent;
}
.gif-frame.is-playing::after { background: var(--pt-accent, #0f70e6); }
.gif-frame.pt-reorder-chosen .gif-thumb { box-shadow: 0 0 0 3px var(--pt-accent, #0f70e6); }
.gif-frame.pt-reorder-ghost { opacity: 0.35; }
.gif-frame.pt-reorder-drag .gif-thumb { box-shadow: 0 10px 24px rgba(30, 34, 40, 0.35); }
.gif-frames.pt-reorder-active, .gif-frames.pt-reorder-active .gif-thumb { cursor: grabbing; }
.gif-addbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 2px dashed #c5d3ea;
  border-radius: 10px;
  background: var(--pt-accent-soft, rgba(15, 112, 230, 0.06));
  color: var(--pt-accent, #0f70e6);
}
.gif-addbtn:hover { border-color: var(--pt-accent, #0f70e6); }
.gif-addbtn:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 2px; }
.gif-addbtn svg { width: 24px; height: 24px; }

/* ── Controls ─────────────────────────────────────────────────────────── */
.gif-hint { font-size: 0.75rem; line-height: 1.45; color: #6c757d; margin: 2px 0 0; }
/* Two side by side where they fit, one above the other where a choice
   ("Like the first frame") would be cut off. */
.gif-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; width: 100%; align-items: end; }
.gif-dither-col { display: flex; align-items: center; min-height: calc(1.5em + 0.9rem + 2px); }
.gif-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.gif-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 3px 14px;
  font-size: 0.85rem;
  border-radius: 20px;
  border: 1px solid #dee2e6;
  background: transparent;
  color: #555;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.gif-pill[aria-pressed="true"] { background: var(--pt-accent, #0f70e6); border-color: var(--pt-accent, #0f70e6); color: #fff; }
.gif-pill:hover:not([aria-pressed="true"]):not(:disabled) { background: #f0f4ff; border-color: var(--pt-accent, #0f70e6); color: var(--pt-accent, #0f70e6); }
.gif-pill:focus-visible, .gif-swatch:focus-visible, .gif-swatch-pick:focus-within { outline: 3px solid rgba(15, 112, 230, 0.45); outline-offset: 2px; }
.gif-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 2px; }
.gif-swatch {
  position: relative;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #dee2e6;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.gif-swatch[aria-pressed="true"], .gif-swatch.is-on, .gif-swatch:hover { border-color: var(--pt-accent, #0f70e6); transform: scale(1.1); }
/* Any colour: a colour wheel until one is picked, then that colour. */
.gif-swatch-pick { margin: 0; overflow: hidden; background: conic-gradient(#f44, #fd4, #4d4, #4dd, #44f, #d4d, #f44); }
.gif-swatch-pick input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.gif-out { font-variant-numeric: tabular-nums; }
.gif-out.gif-out-warn { color: #8a5a00 !important; }
.gif-editor fieldset:disabled .gif-pill,
.gif-editor fieldset:disabled .gif-swatch { opacity: 0.55; cursor: default; }

/* ── Phone editor ─────────────────────────────────────────────────────── */
/* Play is in the tool bar there. */
.pt-app-open #gif-play { display: none !important; }
/* The frames in the bottom bar: one row that scrolls sideways. */
.pt-app-strip.gif-frames { display: flex; gap: 10px; padding-top: 2px; padding-bottom: 8px; }
.pt-app-strip .gif-frame, .pt-app-strip .gif-addtile { flex: 0 0 64px; width: 64px; }
.pt-app-strip .gif-thumb { background: var(--pt-app-fill); }
.pt-app-strip .gif-addbtn { border-color: var(--pt-app-line-strong); background: var(--pt-app-fill); color: var(--pt-app-fg); }
.pt-app-strip .gif-frame.is-selected .gif-thumb { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pt-app-fg); }
.pt-app-strip .gif-frame.is-playing::after { background: #fff; }
.pt-app-panels .gif-pill {}
.pt-app-panels .gif-pill[aria-pressed="true"] {}
