/* /memes: the meme generator, in the site's tokens. Everything is .mm-scoped. */

.mm-page { max-width: 1240px; }

.mm__lede {
  max-width: 68ch;
  margin: 0;
  color: var(--dim);
}

.mm__fine {
  max-width: 76ch;
  margin: 28px 0 0;
  font-size: 12.5px;
  color: var(--dim);
}
.mm__fine a, .mm__lede a { color: var(--cyan); }

/* ---------- editor layout ---------- */

.mm {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
  font-size: 13.5px;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .mm { grid-template-columns: minmax(0, 1fr); }
}

.mm button {
  padding: 8px 14px;
  font: inherit;
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(53,231,224,.07);
  border: 1px solid var(--cyan);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}
.mm button:hover { background: rgba(53,231,224,.16); }
.mm .mm-ghost { color: var(--text); background: transparent; border: 1px solid var(--line-hi); }
.mm .mm-ghost:hover { color: var(--cyan); border-color: var(--cyan); background: transparent; }
.mm .mm-go {
  color: var(--void);
  background: var(--cyan);
  font-weight: 700;
  box-shadow: 0 0 18px rgba(53,231,224,.35);
}
.mm .mm-go:hover { background: #7ff5f0; box-shadow: 0 0 26px rgba(53,231,224,.55); }

.mm button:focus-visible,
.mm input:focus-visible,
.mm select:focus-visible,
.mm textarea:focus-visible,
.mm-gallery input:focus-visible,
.mm-gallery select:focus-visible,
.mm-tile:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.mm-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.mm-spacer { flex: 1; }

/* ---------- stage ---------- */

.mm-stage {
  position: sticky;
  top: 52px;
  background: var(--panel);
  border: 1px solid var(--line);
}
@media (max-width: 900px) { .mm-stage { position: relative; top: 0; } }

.mm-stage__bar,
.mm-stage__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-width: 0;
}
.mm-stage__bar { border-bottom: 1px solid var(--line); }
.mm-stage__foot { border-top: 1px solid var(--line); font-size: 12px; color: var(--dim); flex-wrap: wrap; }

.mm-stage__name {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.mm-stage__rank { font-size: 11px; letter-spacing: .14em; color: var(--amber); white-space: nowrap; }

.mm .mm-icon {
  width: 34px;
  height: 30px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0;
  color: var(--text);
  background: transparent;
  border-color: var(--line-hi);
}
.mm .mm-icon:hover { color: var(--cyan); border-color: var(--cyan); }

.mm-hint { margin-left: auto; }
@media (max-width: 560px) { .mm-hint { margin-left: 0; } }

.mm-canvas {
  position: relative;
  display: grid;
  place-items: center;
  padding: 14px;
  min-height: 240px;
  background:
    repeating-conic-gradient(rgba(255,255,255,.035) 0 25%, transparent 0 50%) 0 0 / 22px 22px,
    var(--void);
}

.mm-canvas canvas {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  box-shadow: 0 0 0 1px var(--line-hi), 0 12px 40px rgba(0,0,0,.6);
}

/* the box overlay sits exactly over the canvas; JS sets its rectangle */
.mm-boxes { position: absolute; pointer-events: none; }

.mm-box {
  position: absolute;
  pointer-events: auto;
  border: 1px dashed rgba(53,231,224,.55);
  background: rgba(53,231,224,.04);
  cursor: move;
  touch-action: none;
  transform-origin: 50% 50%;
}
.mm-boxes.hidden .mm-box:not(.active) { border-color: transparent; background: none; }
.mm-boxes.hidden .mm-box:not(.active):hover { border-color: rgba(53,231,224,.35); }
.mm-box:hover { border-color: var(--cyan); }
.mm-box.active {
  border: 1px solid var(--amber);
  background: rgba(255,179,71,.06);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 14px rgba(255,179,71,.25);
}

.mm-box__tag {
  position: absolute;
  top: -1px;
  left: -1px;
  padding: 0 5px;
  font-size: 10px;
  line-height: 16px;
  color: var(--void);
  background: rgba(53,231,224,.8);
  pointer-events: none;
}
.mm-box.active .mm-box__tag { background: var(--amber); }
.mm-boxes.hidden .mm-box:not(.active) .mm-box__tag { display: none; }

.mm-box__handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--amber);
  border: 2px solid var(--void);
  cursor: nwse-resize;
  touch-action: none;
  display: none;
}
.mm-box.active .mm-box__handle,
.mm-box:hover .mm-box__handle { display: block; }
@media (hover: none) { .mm-box__handle { display: block; width: 20px; height: 20px; right: -10px; bottom: -10px; } }

.mm-box__rot {
  position: absolute;
  left: 50%;
  top: -22px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--void);
  cursor: grab;
  touch-action: none;
  display: none;
}
.mm-box.active .mm-box__rot { display: block; }

.mm-drop {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-family: var(--disp);
  font-size: 22px;
  letter-spacing: .2em;
  color: var(--cyan);
  background: rgba(4,6,10,.82);
  border: 2px dashed var(--cyan);
}
.mm-canvas.dragging .mm-drop { display: grid; }

.mm-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.mm input[type=checkbox] { accent-color: var(--cyan); margin: 0; }

/* ---------- panel ---------- */

.mm-panel { display: grid; gap: 12px; min-width: 0; }

.mm-card {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.mm-card h2,
.mm-gallery__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--amber);
}

.mm-count { font-size: 10.5px; letter-spacing: .12em; color: var(--dim); text-transform: none; }

.mm-inputs { display: grid; gap: 8px; }

.mm-input {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 26px;
  align-items: start;
  gap: 6px;
}
.mm-input__n {
  padding-top: 8px;
  font-size: 11px;
  color: var(--dim);
  text-align: right;
}
.mm-input.active .mm-input__n { color: var(--amber); }

.mm textarea {
  width: 100%;
  min-height: 38px;
  max-height: 160px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text);
  background: var(--void);
  border: 1px solid var(--line-hi);
  border-radius: 0;
  resize: vertical;
  field-sizing: content;
}
.mm-input.active textarea { border-color: var(--amber); }
.mm textarea::placeholder { color: #4b6070; }

.mm .mm-input__x {
  width: 26px;
  height: 38px;
  padding: 0;
  font-size: 15px;
  letter-spacing: 0;
  color: var(--dim);
  background: transparent;
  border-color: transparent;
}
.mm .mm-input__x:hover { color: var(--alert); border-color: var(--alert); background: transparent; }

.mm-style {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  align-items: center;
}
.mm-style > label:not(.mm-check) {
  display: grid;
  gap: 4px;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
}

.mm select,
.mm-gallery select,
.mm-gallery input[type=search] {
  width: 100%;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--void);
  border: 1px solid var(--line-hi);
  border-radius: 0;
}

.mm input[type=range] { width: 100%; accent-color: var(--cyan); }
.mm input[type=color] {
  width: 100%;
  height: 30px;
  padding: 0 2px;
  background: var(--void);
  border: 1px solid var(--line-hi);
  cursor: pointer;
}

.mm-seg { display: flex; }
.mm .mm-seg button {
  flex: 1;
  padding: 6px 0;
  color: var(--dim);
  background: transparent;
  border-color: var(--line-hi);
}
.mm .mm-seg button + button { border-left: 0; }
.mm .mm-seg button.on { color: var(--void); background: var(--cyan); border-color: var(--cyan); }

.mm-file { position: relative; overflow: hidden; display: inline-block; padding: 8px 14px;
  font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; cursor: pointer; }
.mm-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mm-file:focus-within { outline: 2px solid var(--cyan); outline-offset: 2px; }

.mm-out { border-color: var(--line-hi); }
.mm-out .mm-row { margin-top: 0; }
.mm-out .mm-go { flex: 1 1 100%; padding: 12px; font-size: 13px; }

.mm-status { min-height: 1.5em; margin-top: 8px; font-size: 12px; color: var(--dim); }
.mm-status.ok { color: #4ade80; }
.mm-status.err { color: var(--alert); }

/* ---------- gallery ---------- */

.mm-gallery { margin-top: 34px; }

.mm-gallery__bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 170px;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.mm-gallery__title { margin: 0; white-space: nowrap; }
@media (max-width: 640px) {
  .mm-gallery__bar { grid-template-columns: minmax(0, 1fr) 130px; }
  .mm-gallery__title { grid-column: 1 / -1; }
}

.mm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
@media (max-width: 420px) { .mm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.mm-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.mm-tile:hover { border-color: var(--cyan); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.5), 0 0 0 1px rgba(53,231,224,.2); }
.mm-tile.on { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), 0 0 18px rgba(255,179,71,.25); }

.mm-tile__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: center top;
  background: var(--void);
}

.mm-tile__name {
  padding: 6px 8px 8px;
  font-size: 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(12px * 1.3 * 2 + 14px);
}

.mm-tile__rank,
.mm-tile__boxes {
  position: absolute;
  top: 6px;
  padding: 1px 6px;
  font-size: 10.5px;
  letter-spacing: .06em;
  background: rgba(4,6,10,.82);
  border: 1px solid var(--line-hi);
}
.mm-tile__rank { left: 6px; color: var(--amber); }
.mm-tile__boxes { right: 6px; color: var(--cyan); }

.mm-empty { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--dim); border: 1px dashed var(--line-hi); }

/* ---------- sharing online ---------- */

.mm .mm-post { width: 100%; }
.mm .mm-post:disabled { opacity: .45; cursor: not-allowed; }
.mm-posted { margin-top: 10px; }
.mm-posted input {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--cyan);
  background: var(--void);
  border: 1px solid var(--cyan);
}
.mm-posted a.mm-ghost {
  padding: 8px 14px;
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line-hi);
}
.mm-posted a.mm-ghost:hover { color: var(--cyan); border-color: var(--cyan); }
.mm .mm-del:hover { color: var(--alert); border-color: var(--alert); }
.mm-out__fine { margin: 10px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--dim); }

/* ---------- the guide ---------- */

.mm-guide__meaning { margin: 0 0 10px; color: var(--text); }
.mm-guide__try { display: grid; gap: 6px; }
.mm .mm-try {
  display: flex;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  padding: 7px 10px;
  text-align: left;
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  background: transparent;
  border: 1px dashed var(--line-hi);
}
.mm .mm-try:hover { color: var(--text); border: 1px solid var(--cyan); background: rgba(53,231,224,.06); }
.mm-try__n { flex: none; font-size: 10.5px; letter-spacing: .12em; color: var(--amber); text-transform: uppercase; }
.mm-try__text { min-width: 0; overflow-wrap: anywhere; }
.mm-try q { quotes: none; }
.mm-try q + q::before { content: none; }
.mm-guide__more { margin-top: 10px; font-size: 12.5px; color: var(--dim); }
.mm-guide__more summary { cursor: pointer; color: var(--cyan); font-size: 11.5px; letter-spacing: .08em; }
.mm-guide__more h3 {
  margin: 12px 0 4px;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--amber);
}
.mm-guide__more ul { margin: 0; padding-left: 18px; }
.mm-guide__more li { margin: 2px 0; color: var(--text); }
.mm-guide__seen { margin: 10px 0 0; font-size: 11px; }
