/* The caption tool (inc/meme-tool.inc.php): the Meme Generator and Add Text
   to Photo. The layout is pt-ui.css's, the phone editor pt-app.css's; the
   fonts are assets/fonts/google/google-fonts.css. */

/* ── Start: a photo or a blank canvas ─────────────────────── */
.meme-start { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.meme-start .btn { min-height: 44px; }
#meme-drop-area { cursor: pointer; }
#meme-drop-area.dragover { border-color: var(--pt-accent, #0f70e6) !important; background: rgba(15, 112, 230, 0.1) !important; }
#meme-empty { width: 100%; max-width: 460px; text-align: center; padding: 8px; }
.meme-empty-text { color: #6c757d; font-size: 0.95rem; margin-bottom: 14px; }
.meme-start-lg .btn { min-width: 168px; }
.sample-thumbnails { display: flex; justify-content: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.sample-thumbnail {
  cursor: pointer;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 96px;
  height: 96px;
  padding: 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.sample-thumbnail:hover, .sample-thumbnail:focus-visible { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 4px 12px rgba(15, 112, 230, 0.25); }
.sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 767px) {
  .sample-thumbnail { width: 84px; height: 84px; }
  .meme-empty-text { font-size: 0.9rem; }
  .meme-start-lg { flex-direction: column; align-items: stretch; max-width: 260px; margin: 0 auto; }
}

/* ── The picture ──────────────────────────────────────────── */
#meme-viewport { display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 12px; }
#meme-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: default;
}
#meme-canvas.over-cap { cursor: move; }
#meme-canvas.over-handle { cursor: nwse-resize; }
#meme-canvas:focus-visible { outline: 3px solid rgba(15, 112, 230, 0.55); outline-offset: 2px; }

/* ── Captions: a row each, the selected one marked ────────── */
#meme-edit { border: 0; padding: 0; margin: 0; min-width: 0; }
#meme-edit:disabled { opacity: 0.55; }
.meme-captions { display: flex; flex-direction: column; gap: 6px; }
.meme-cap { display: flex; align-items: center; gap: 6px; padding: 3px; border-radius: 10px; border: 1.5px solid transparent; }
.meme-cap.sel { border-color: var(--pt-accent, #0f70e6); background: rgba(15, 112, 230, 0.06); }
.meme-cap .form-control { min-width: 0; flex: 1 1 auto; }
.meme-cap-del {
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid #e3e7ee;
  background: #fff;
  color: #c0392b;
}
.meme-cap-del:hover { border-color: #c0392b; }
.meme-text-none { display: none; }
.meme-text-title { display: block; }

/* ── Fonts: each name in its own font ─────────────────────── */
/* As many columns as fit the longest name ("Comic Sans" in bold), so no name
   is cut short at any width. */
.meme-fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
.meme-font {
  min-height: 42px;
  padding: 4px 6px;
  border: 1px solid #dbe3f0;
  border-radius: 8px;
  background: #fff;
  color: #343f52;
  font-size: 0.85rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.meme-font:hover { border-color: #9fb7e5; }
/* Upload a font...: a dashed tile, its words free to wrap. */
.meme-font-up { border-style: dashed; color: var(--pt-accent, #0f70e6); white-space: normal; font-family: inherit; font-weight: 600; }
.meme-font-up .uil { font-size: 1rem; vertical-align: -2px; }
.meme-font.active { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 0 0 1px var(--pt-accent, #0f70e6); color: var(--pt-accent, #0f70e6); }

/* ── Colours: the picker first, then the presets ──────────── */
.meme-color-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 8px; }
.meme-color-label { flex: 0 0 100%; margin-bottom: 0; }
.meme-color-ico { display: none; }
.meme-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.meme-swatch {
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.22);
}
.meme-swatch.active { box-shadow: 0 0 0 2px var(--pt-accent, #0f70e6); }
.meme-swatch-pick { position: relative; overflow: hidden; background: conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.meme-swatch-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
fieldset:disabled .meme-font, fieldset:disabled .meme-swatch { cursor: default; }

/* ── In the phone editor ──────────────────────────────────── */
/* Text: the selected caption's words, a hint when none is. */
.pt-app-panels #meme-text { margin: 0 !important; padding: 2px 4px; }
.pt-app-panels #meme-text .meme-text-title,
.pt-app-panels #meme-text #meme-add-btn,
.pt-app-panels #meme-text .meme-cap:not(.sel) { display: none; }
.pt-app-panels #meme-text .meme-cap { padding: 0; border: 0; background: none; }
.pt-app-panels #meme-text .meme-text-none { padding: 10px 4px; text-align: center; }
.pt-app-panels #meme-text.none .meme-text-none { display: block; }
.pt-app-panels .meme-cap-del { width: 44px; height: 44px; background: var(--pt-app-fill); border-color: var(--pt-app-line-strong); color: #d63939; }
/* Fonts: one sideways row. */
.pt-app-strip#meme-fonts > .meme-font { flex: 0 0 auto; min-width: 82px; min-height: 44px; background: var(--pt-app-fill); border-color: var(--pt-app-line-strong); color: var(--pt-app-fg); }
.pt-app-strip#meme-fonts > .meme-font.active { border-color: var(--pt-app-accent-fg); box-shadow: 0 0 0 1px var(--pt-app-accent-fg); color: var(--pt-app-fg); }
/* Colours: a row for the text, one for the outline. */
.pt-app-panels #meme-colors { margin: 0 !important; padding: 2px 2px 0; }
.pt-app-panels .meme-color-row { flex-wrap: nowrap; gap: 8px; margin-bottom: 6px; }
.pt-app-panels .meme-color-label { display: none; }
.pt-app-panels .meme-color-ico {
  display: flex;
  flex: none;
  width: 28px;
  justify-content: center;
  font: 700 22px/1 Arial, Helvetica, sans-serif;
  color: var(--pt-app-fg);
}
.pt-app-panels .meme-color-ico-stroke { color: transparent; -webkit-text-stroke: 1.5px var(--pt-app-fg); }
/* The background row: a dark A on a white box, the size of the other two. */
.pt-app-panels .meme-color-ico-bg::before {
  content: "A";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--pt-app-on);
  color: var(--pt-app-on-fg);
  font-size: 17px;
  line-height: 24px;
  text-align: center;
}
.pt-app-panels .meme-swatches {
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 3px 2px;
}
.pt-app-panels .meme-swatches::-webkit-scrollbar { display: none; }
.pt-app-panels .meme-swatch { width: 34px; height: 34px; border-color: #fff; box-shadow: 0 0 0 1px var(--pt-app-line-strong); }
/* Three 84px tiles and their gaps are wider than a 360px phone's photo
   box, which wrapped them 2 + 1; the site's small tile is 72px. */
@media (max-width: 400px) { .sample-thumbnail { width: 72px; height: 72px; } }

/* ── Add Text to Photo: alignment, the stamps ────────────────────────── */
.meme-seg { display: inline-flex; gap: 6px; }
.meme-seg-btn {
  width: 44px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dbe3f0;
  border-radius: 8px;
  background: #fff;
  color: #343f52;
  cursor: pointer;
}
.meme-seg-btn svg { width: 20px; height: 20px; }
.meme-seg-btn:hover { border-color: #9fb7e5; }
.meme-seg-btn[aria-pressed="true"] { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 0 0 1px var(--pt-accent, #0f70e6); color: var(--pt-accent, #0f70e6); }
/* Each button as wide as its label; a row too narrow for all three wraps
   (equal thirds cut "Text hinzufügen" short). */
.meme-add-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.meme-add-row .btn { flex: 1 1 auto; white-space: nowrap; }
.meme-add-row #meme-add-btn { margin-top: 0 !important; }
/* Many fonts: a scrolling grid, so the controls below stay in reach. */
/* Many fonts: columns wide enough for "Merriweather" in bold, as many as fit. */
.meme-fonts-many { grid-template-columns: repeat(auto-fill, minmax(134px, 1fr)); max-height: 196px; overflow-y: auto; padding: 2px; overscroll-behavior: contain; }
/* In the phone editor: the alignment buttons and the stamps on the dark bar. */
.pt-app-panels .meme-seg-btn { width: 48px; height: 44px;}
.pt-app-panels .meme-seg-btn[aria-pressed="true"] {}
#meme-align-title { display: block; }
.pt-app-panels #meme-style-row { margin: 0 !important; padding: 4px 4px 2px; display: flex; align-items: center; gap: 10px; }
.pt-app-panels #meme-style-row .form-label { display: none; }
.pt-app-strip#meme-fonts.meme-fonts-many { max-height: none; overflow-y: visible; }

/* A GIF: the frame on screen, next to Play */
.meme-frame { min-width: 4.5em; text-align: center; font-size: 13px; color: #626973; font-variant-numeric: tabular-nums; }
/* Text Behind Image: Behind the subject, under the text list, in a soft box;
   on a phone the note and Try Again stay, the AI line goes (the page says it). */
.meme-behind { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--cb-bg, #f5f4f2); }
.meme-behind .form-check-label { font-weight: 700; }
.meme-behind-note:empty { display: none; }
.pt-app-panels #meme-text .meme-behind { margin: 6px 0 2px; padding: 6px 8px; background: none; }
.pt-app-panels #meme-text .meme-behind-ai { display: none; }
/* Speech bubbles: the shapes, then the tail's corner under them; on a phone
   one row of icons, no labels (the buttons carry them). */
.meme-tail-wrap { margin-top: 10px; }
/* The phone's Bubble tab keeps its two labels: the arrows alone don't say
   they are the tail's corner. */
.pt-app-panels #meme-bubble-row { margin: 0 !important; padding: 4px 4px 2px; }
.pt-app-panels #meme-bubble-row .meme-tail-wrap { margin-top: 6px; }
.pt-app-panels #meme-bubble-row .meme-tail-wrap[hidden] { display: none; }
/* Add Text, Date, Name and Bubble: two by two, not three and a long one. */
.meme-add-row:has(#meme-bubble-btn) .btn { flex: 1 1 calc(50% - 3px); }

/* ── The Meme Generator: Layout, Motion, the template library ─────────── */
/* Words, not icons: each button as wide as its label, the track full width. */
.meme-seg-text { display: flex; width: 100%; }
.meme-seg-text .meme-seg-btn { flex: 1 1 auto; width: auto; padding: 0 10px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pt-app-panels #meme-layout-row, .pt-app-panels #meme-motion-row { margin: 0 !important; padding: 4px 4px 2px; }
.pt-app-panels #meme-layout-row > .form-label, .pt-app-panels #meme-motion-row > .form-label { display: none !important; }
.pt-app-panels .meme-seg-text .meme-seg-btn { width: auto; }
.pt-app-panels .meme-motion-note { margin-top: 6px !important; }
/* The upload card: four templates and an All tile. */
.meme-tpl-more { display: inline-flex; align-items: center; justify-content: center; color: var(--cb-ink, #16181d); background: var(--cb-bg, #f2f4f8); font-weight: 700; font-size: 13px; }
.meme-tpl-more span { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.meme-tpl-more svg { margin: 0 !important; }
.meme-start .btn svg { flex: none; }

/* The dialog: a search box and chips over a grid of tiles, the rights below. */
.meme-tpl-modal .modal-content { border: 0; border-radius: 22px; overflow: hidden; }
.meme-tpl-modal .modal-header { border-bottom: 0; padding: 18px 20px 6px; }
.meme-tpl-modal .modal-title { font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.meme-tpl-head { padding: 0 20px 12px; border-bottom: 1px solid var(--cb-line, #e1e5ec); }
#meme-tpl-q { height: 40px; border-radius: 12px; font-size: 15px; }
.meme-tpl-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.meme-tpl-cat {
  padding: 5px 13px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--cb-text, #3d434b);
  border: 0;
  border-radius: 999px;
  background: var(--cb-bg, #f2f4f8);
  cursor: pointer;
}
.meme-tpl-cat:hover { color: var(--cb-ink, #16181d); background: var(--cb-hover-bg, #e6eaf1); }
.meme-tpl-cat[aria-pressed="true"] { color: #fff; background: var(--cb-ink, #16181d); }
.meme-tpl-modal .modal-body { padding: 16px 20px; }
.meme-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.meme-tpl {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 0;
  text-align: start;
  border: 0;
  background: none;
  cursor: pointer;
}
.meme-tpl[hidden] { display: none; }
.meme-tpl-img { position: relative; display: block; aspect-ratio: 3 / 2; border-radius: 12px; overflow: hidden; background: var(--cb-bg, #f2f4f8); transition: box-shadow 0.15s ease, transform 0.15s ease; }
.meme-tpl-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.meme-tpl:hover .meme-tpl-img { transform: translateY(-2px); box-shadow: 0 10px 22px -12px rgba(22, 24, 29, 0.45); }
.meme-tpl:focus-visible { outline: none; }
.meme-tpl:focus-visible .meme-tpl-img { box-shadow: var(--cb-ring, 0 0 0 2px #fff, 0 0 0 4px #16181d); }
.meme-tpl-name { font-size: 13px; font-weight: 700; line-height: 1.25; color: var(--cb-ink, #16181d); overflow-wrap: anywhere; }
.meme-tpl-badge {
  position: absolute;
  inset-inline-end: 6px;
  top: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  border-radius: 999px;
  background: rgba(22, 24, 29, 0.72);
}
.meme-tpl-none { margin: 24px 0; text-align: center; }
.meme-tpl-rights { justify-content: flex-start; flex-wrap: nowrap; gap: 10px; padding: 12px 20px; font-size: 13px; color: var(--cb-text, #3d434b); background: var(--cb-bg, #f2f4f8); border-top: 0; }
.meme-tpl-rights svg { flex: none; color: #1a8a4a; margin: 0; }
.meme-tpl-rights p { margin: 0; }
@media (max-width: 575.98px) {
  .meme-tpl-modal .modal-content { border-radius: 0; }
  .meme-tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  #meme-tpl-q { font-size: 16px; }
  .meme-tpl-cats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .meme-tpl-cats::-webkit-scrollbar { display: none; }
  .meme-tpl-cat { flex: none; min-height: 34px; }
  .meme-tpl-rights { font-size: 12px; }
}
/* A phone's upload card: three templates and All, on one row. */
@media (max-width: 575.98px) {
  .meme-tpl-tiles { gap: 10px; flex-wrap: nowrap; }
  .meme-tpl-tiles .sample-thumbnail { width: 68px; height: 68px; flex: none; }
  .meme-tpl-tiles .meme-tpl-tile:nth-child(4) { display: none; }
}
/* The desk's upload card: the label, then four templates and All on one line. */
@media (min-width: 576px) {
  #meme-empty:has(.meme-tpl-tiles) { max-width: 600px; }
  .meme-tpl-tiles { flex-wrap: nowrap !important; }
}

/* ── Add Text to Photo: the Effect tiles ──────────────────────────────── */
/* Three to a row, each an "Ag" on a dusk-coloured chip in that look with its
   name under it (under, not beside: "Свечение" and "Schatten" fit). */
.meme-fx { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.meme-fx-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 50px;
  padding: 5px 4px 4px;
  border: 1px solid #dbe3f0;
  border-radius: 10px;
  background: #fff;
  color: #343f52;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
}
.meme-fx-btn:hover { border-color: #9fb7e5; }
.meme-fx-btn[aria-pressed="true"] { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 0 0 1px var(--pt-accent, #0f70e6); color: var(--pt-accent, #0f70e6); }
.meme-fx-name { max-width: 100%; overflow-wrap: anywhere; text-align: center; }
.meme-fx-ag {
  display: block;
  width: 46px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #6f7fa8, #b98aa6);
  color: #fff;
  font: 800 15px/22px Arial, Helvetica, sans-serif;
  text-align: center;
}
.meme-fx-ag-outline { text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 1.4px 0 #000, 0 -1.4px 0 #000, 1.4px 0 0 #000, -1.4px 0 0 #000; }
.meme-fx-ag-shadow { text-shadow: 1px 2px 3px rgba(0, 0, 0, 0.75); }
.meme-fx-ag-glow { text-shadow: 0 0 3px #ffd60a, 0 0 7px #ffd60a, 0 0 11px #ffd60a; }
.meme-fx-ag-neon { color: #ffd9ec; text-shadow: 0 0 2px #ff4fa3, 0 0 5px #ff4fa3, 0 0 9px #ff4fa3, 0 0 14px #ff4fa3; }
.meme-fx-ag-hollow { color: transparent; -webkit-text-stroke: 1.2px #fff; }
fieldset:disabled .meme-fx-btn { cursor: default; }
/* In the phone editor: one sideways row on the dark bar. */
.pt-app-strip#meme-fx > .meme-fx-btn { flex: 0 0 auto; min-width: 74px; min-height: 54px; background: var(--pt-app-fill); border-color: var(--pt-app-line-strong); color: var(--pt-app-fg); }
.pt-app-strip#meme-fx > .meme-fx-btn[aria-pressed="true"] { border-color: var(--pt-app-accent-fg); box-shadow: 0 0 0 1px var(--pt-app-accent-fg); color: var(--pt-app-fg); }
/* The glow colour row's mark on a phone: an A with a glow round it. */
.pt-app-panels .meme-color-ico-glowc { text-shadow: 0 0 4px #ffd60a, 0 0 8px #ffd60a; }
