/* Editor fotky pro zákazníka. Mobile first, bez build kroku. */

:root {
  --bg: #f5f5f4;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #1c1917;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --err: #991b1b;
  --err-bg: #fee2e2;
  /* PANTONE 10103 C z podkladu etikety */
  --frame: #b1b6b2;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Na mobilu nechceme dvojklik-zoom kazit gesta cropperu */
body { touch-action: manipulation; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: var(--ink);
  color: #fafaf9;
}
.brand { font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.8rem; }
.store { font-size: 0.8rem; opacity: 0.75; }

main { padding: 1rem 1rem 3rem; max-width: 34rem; margin: 0 auto; }

h1 { font-size: 1.35rem; margin: 0.5rem 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 0.25rem 0 0.25rem; }
.lead { color: var(--muted); margin: 0 0 1rem; }

.gate { text-align: center; padding-top: 4rem; }

/* --- výběr fotky ------------------------------------------------------- */

.pick {
  display: grid;
  place-items: center;
  gap: 0.35rem;
  padding: 2.5rem 1rem;
  background: var(--card);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.pick input { display: none; }
.pick-icon {
  width: 3rem; height: 3rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--ink); color: #fff;
  font-size: 1.8rem; line-height: 1;
}
.pick-label { font-weight: 600; }
.pick-hint { color: var(--muted); font-size: 0.85rem; }

/* --- ořez --------------------------------------------------------------- */

.cropbox {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  /* Cropper potřebuje blokový prvek s výškou */
  max-height: 58vh;
}
.cropbox img { display: block; max-width: 100%; }

/* Ořezový rámeček ať vypadá jako okno etikety */
.cropper-view-box, .cropper-face { border-radius: 2px; }
.cropper-view-box { outline: 2px solid #fff; outline-offset: -1px; }

/* --- náhled etikety ----------------------------------------------------- */

/* Mockup je obrázek skutečného artworku s průhledným oknem.
   Fotka leží pod ním a prosvítá dírou. */
.label-mock {
  position: relative;
  width: 100%;
  aspect-ratio: 137 / 101.6;
  margin-bottom: 1rem;
  filter: drop-shadow(0 2px 6px #0002);
}
.mock-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.mock-window {
  position: absolute;
  overflow: hidden;
  background: #fff;
}
.mock-window canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- text na fotku ------------------------------------------------------- */

.textbox {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.25rem 0.9rem;
  margin-bottom: 0.9rem;
}
.textbox summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.85rem 0;
  list-style: none;
}
.textbox summary::-webkit-details-marker { display: none; }
.textbox summary::before {
  content: "＋";
  margin-right: 0.5rem;
  color: var(--muted);
}
.textbox[open] summary::before { content: "－"; }
.textbox .opt {
  font-weight: normal;
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 0.35rem;
}

.field { display: block; margin-bottom: 0.9rem; }
.field > span {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.field input {
  width: 100%;
  font: inherit;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.picker { margin-bottom: 0.9rem; }
.picker-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.picker .opts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.4rem;
}
.picker .opts button {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.65rem 0.4rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--ink);
}
.picker .opts button.on {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

/* --- ovládání ----------------------------------------------------------- */

.actions { display: flex; gap: 0.5rem; margin: 0.9rem 0; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 1rem;
  font-size: 1.05rem;
}
.btn.primary:disabled { background: #a8a29e; cursor: not-allowed; }
.btn.ghost {
  flex: 1 1 auto;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn:active { transform: translateY(1px); }

.consent {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 0.25rem;
}
.consent input { width: 1.3rem; height: 1.3rem; margin: 0.1rem 0 0; flex: none; }

/* Neutrální sdělení; chyby dostanou navíc .error */
.note {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}
.note.error {
  background: var(--err-bg);
  border-color: transparent;
  color: var(--err);
}
.warn {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.9rem;
}

/* --- hotovo ------------------------------------------------------------- */

.done { text-align: center; padding-top: 2rem; }
.code {
  font-size: clamp(3rem, 22vw, 5.5rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  margin: 1rem 0;
  font-variant-numeric: tabular-nums;
}

/* --- překryv ------------------------------------------------------------ */

.overlay {
  position: fixed; inset: 0;
  background: #fffffff2;
  display: grid; place-items: center;
  gap: 1rem;
  z-index: 50;
  text-align: center;
}
.overlay[hidden] { display: none; }
.spinner {
  width: 2.5rem; height: 2.5rem;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}
