/* Flyer maker */

@font-face {
  font-family: "Inter Tight";
  src: url("../fonts/inter-tight-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --ink: #141010;
  --ink-2: #1d1817;
  --ink-3: #2a2321;
  --paper: #f4efe3;
  --dim: rgba(244, 239, 227, .6);
  --line: rgba(244, 239, 227, .12);
  --grad: linear-gradient(100deg, #ff9ec4 0%, #ffc7a3 48%, #96e8d2 100%);
  --orange: #ff8a00;
  --panel: 380px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--ink);
  color: var(--paper);
  font: 15px/1.4 "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

.fm {
  display: grid;
  grid-template-columns: var(--panel) minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* --- top bar ------------------------------------------------------------ */

.fm-top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.fm-brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.fm-brand img { width: 72px; height: auto; }
.fm-brand span { font-size: 15px; font-weight: 500; opacity: .8; }

.fm-sizes, .fm-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(244, 239, 227, .06);
}
.fm-sizes { margin-left: auto; }

.fm-sizes button, .fm-seg button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  color: var(--dim);
  transition: background-color .2s, color .2s;
}
.fm-sizes small { margin-left: 4px; font-size: 11px; opacity: .7; }
.fm-sizes button[aria-pressed="true"], .fm-seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.fm-seg button[hidden] { display: none; }

.fm-download {
  height: 42px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--grad);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  transition: transform .2s, opacity .2s;
}
.fm-download:active { transform: scale(.97); }
.fm-download:disabled { opacity: .6; cursor: progress; }

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

.fm-panel {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 6px 18px 40px;
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 239, 227, .2) transparent;
}

.fm-sec { padding: 18px 0; border-bottom: 1px solid var(--line); }
.fm-sec h2 { margin: 0 0 12px; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }

.fm-templates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.fm-tpl {
  display: grid;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.fm-thumb {
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 8px;
  background: var(--ink-3);
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow .2s, transform .2s;
}
.fm-thumb svg { display: block; width: 100%; height: 100%; }
.fm-tpl strong { font-size: 12px; font-weight: 500; color: var(--dim); }
.fm-tpl:hover .fm-thumb { transform: translateY(-2px); }
.fm-tpl[aria-pressed="true"] .fm-thumb { box-shadow: 0 0 0 2px #ff9ec4; }
.fm-tpl[aria-pressed="true"] strong { color: var(--paper); }

.fm-upload {
  position: relative;
  display: grid;
  gap: 2px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px dashed rgba(244, 239, 227, .25);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .2s, background-color .2s;
}
.fm-upload:hover { border-color: rgba(244, 239, 227, .5); background: rgba(244, 239, 227, .03); }
.fm-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.fm-upload span { font-weight: 500; }
.fm-upload em { font-style: normal; font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-upload[hidden] { display: none; }
body.is-dropping .fm-stage { outline: 2px dashed #ff9ec4; outline-offset: -12px; }

.fm-seg { margin-bottom: 8px; }

.fm-range { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 10px; margin: 6px 0; font-size: 13px; color: var(--dim); }
.fm-range input { width: 100%; accent-color: #ff9ec4; }

.fm-tip { margin: 8px 0 0; font-size: 12px; color: var(--dim); }

.fm-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--paper);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(244, 239, 227, .35);
  cursor: pointer;
}

.fm-field { display: grid; gap: 6px; margin-bottom: 12px; }
.fm-field > span { font-size: 13px; color: var(--dim); }
.fm-field input, .fm-field textarea, .fm-sec select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, .25);
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.fm-field textarea { resize: vertical; line-height: 1.45; }
.fm-field input:focus, .fm-field textarea:focus, .fm-sec select:focus { border-color: #ff9ec4; box-shadow: 0 0 0 3px rgba(255, 158, 196, .15); }
.fm-field .is-upper { text-transform: uppercase; }
.fm-field em { font-style: normal; font-size: 12px; color: var(--dim); }
.fm-field.is-over input, .fm-field.is-over textarea { border-color: #ff6b6b; box-shadow: 0 0 0 3px rgba(255, 107, 107, .15); }
.fm-field.is-over > span::after { content: " · too long"; color: #ff9a9a; }

.fm-check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 13px; color: var(--dim); cursor: pointer; }
.fm-check input { accent-color: #ff9ec4; }

.fm-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 10px; }
.fm-colors label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); }
.fm-colors .fm-check { margin: 0; }
.fm-colors input[type="color"] {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.fm-colors input[type="color"]:disabled { opacity: .3; }

.fm-fonts { margin: 18px 0 0; font-size: 12px; line-height: 1.5; color: var(--dim); }

/* --- the preview ------------------------------------------------------------ */

.fm-main {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(60% 50% at 50% 40%, rgba(255, 158, 196, .06), transparent 70%),
    #0e0b0b;
}

.fm-warnings {
  margin: 14px 18px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 107, 107, .12);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, .4);
  font-size: 14px;
  color: #ffc4c4;
}
.fm-warnings p { margin: 0; }
.fm-warnings p + p { margin-top: 6px; }
.fm-warnings[hidden] { display: none; }

.fm-stage {
  grid-row: 2;
  display: grid;
  place-items: center;
  min-height: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.fm-stage.is-dragging { cursor: grabbing; }

.fm-preview {
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9), 0 0 0 1px rgba(244, 239, 227, .06);
  background: #1d1817;
}
.fm-preview svg { display: block; width: 100%; height: 100%; }

body:not(.is-ready) .fm-preview { opacity: .3; }

/* --- phones and narrow windows: preview on top, settings below ------------- */

@media (max-width: 900px) {
  .fm { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; height: auto; }
  .fm-top { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .fm-brand span { display: none; }
  .fm-sizes small { display: none; }
  .fm-main { grid-row: 2; position: sticky; top: 0; z-index: 2; }
  .fm-stage { padding: 14px; height: 56vh; }
  .fm-panel { grid-row: 3; border-right: 0; overflow: visible; }
}
