/* ============================================================
   MemeForge — style.css
   Playful dark theme with yellow accents
   ============================================================ */
:root {
  --bg: #0f1115;
  --panel: #1a1d27;
  --panel-2: #232735;
  --border: rgba(255, 255, 255, 0.09);
  --text: #eef0f6;
  --muted: #9aa1b5;
  --yellow: #ffdd00;
  --pink: #ff5e78;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 1.35rem; font-weight: 900; }
.brand span { color: var(--yellow); }
.tagline { color: var(--muted); font-size: 0.9rem; font-weight: 600; }

/* ---------- Layout ---------- */
.layout {
  flex: 1; display: grid; grid-template-columns: 1.2fr 1fr;
  gap: 24px; padding: 24px; align-items: start;
  width: min(1200px, 100%); margin-inline: auto;
}

/* ---------- Canvas panel ---------- */
.canvas-frame {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: #000; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  max-width: 640px; margin-inline: auto;
}
#memeCanvas { display: block; width: 100%; height: auto; cursor: grab; touch-action: none; }
#memeCanvas.dragging { cursor: grabbing; }
.canvas-frame.dropping::after {
  content: "⬇️ Drop image here"; position: absolute; inset: 0;
  display: grid; place-items: center; font-size: 1.6rem; font-weight: 900;
  background: rgba(0, 0, 0, 0.6); color: #fff;
}

.canvas-hint { text-align: center; color: var(--muted); font-size: 0.82rem; margin: 12px 0; }
.canvas-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn {
  padding: 12px 22px; border-radius: 12px; font-weight: 800;
  background: var(--panel-2); border: 1px solid var(--border);
  transition: transform 0.2s, filter 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn.yellow {
  background: linear-gradient(135deg, #ffe94d, var(--yellow));
  color: #1a1a05; box-shadow: 0 8px 22px rgba(255, 221, 0, 0.25);
}
.btn.ghost { background: transparent; }
.btn.ghost:hover { border-color: var(--pink); color: var(--pink); }

/* ---------- Controls ---------- */
.controls { display: flex; flex-direction: column; gap: 18px; }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.panel h3 { margin-bottom: 14px; font-size: 1.02rem; }

.templates {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 12px;
}
.template-btn {
  border-radius: 10px; overflow: hidden; position: relative;
  border: 2px solid transparent; padding: 0;
  aspect-ratio: 1; transition: border-color 0.2s, transform 0.2s;
}
.template-btn:hover { transform: scale(1.04); }
.template-btn.active { border-color: var(--yellow); }
.template-btn canvas { width: 100%; height: 100%; display: block; }
.template-btn .t-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 0.62rem; font-weight: 800; color: #fff;
  background: rgba(0, 0, 0, 0.55); padding: 3px 0; text-align: center;
}

.upload-btn {
  display: block; text-align: center; padding: 12px;
  border: 2px dashed var(--border); border-radius: 12px;
  font-weight: 800; color: var(--muted); cursor: pointer; transition: 0.2s;
}
.upload-btn:hover { border-color: var(--yellow); color: var(--yellow); }

.ctl { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.ctl b { color: var(--yellow); }
.ctl input[type="text"], .ctl select {
  padding: 11px 13px; border-radius: 10px; color: var(--text);
  border: 1.5px solid var(--border); background: var(--panel-2);
}
.ctl input[type="text"]:focus, .ctl select:focus {
  outline: none; border-color: var(--yellow);
}
.ctl input[type="range"] { width: 100%; accent-color: var(--yellow); }
.ctl.color input[type="color"] {
  width: 52px; height: 38px; border: 1.5px solid var(--border);
  border-radius: 10px; background: var(--panel-2); cursor: pointer; padding: 3px;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--yellow); }
.row { display: flex; gap: 16px; align-items: center; }
.row .ctl { flex: 1; }

/* ---------- Footer & toast ---------- */
.footer { padding: 16px; text-align: center; color: var(--muted); font-size: 0.82rem; }

#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 80px);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 13px 26px; border-radius: 999px; font-weight: 700;
  opacity: 0; transition: 0.3s; z-index: 100; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
