/* 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; }
.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; }
