/* Affiche foot : écran de personnalisation (téléphone d'abord, deux colonnes sur grand écran). */

@font-face {
  font-family: Anton;
  src: url(../fonts/anton.woff2) format('woff2');
  font-display: block;
}

@font-face {
  font-family: 'Archivo Black';
  src: url(../fonts/archivo-black.woff2) format('woff2');
  font-display: block;
}

:root {
  --navy: #14205e;
  --navy-2: #22318a;
  --red: #c8252c;
  --ink: #1b1e2b;
  --muted: #5b6075;
  --line: #d8dbe6;
  --bg: #eef0f6;
  --card: #ffffff;
  --focus: #2f6bff;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.top {
  background: var(--navy);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  text-align: center;
}

.top h1 {
  margin: 0;
  font: 400 28px/1.1 Anton, Impact, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top h1 span { color: #ff8a8f; }

.top p { margin: 4px 0 0; font-size: 14px; opacity: 0.9; }

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: grid;
  gap: 16px;
}

/* ---------- aperçu ---------- */

.preview { text-align: center; }

.frame {
  display: block;
  width: fit-content;
  margin: 0 auto;
  padding: 8px;
  background: #15161a;
  border-radius: 4px;
  box-shadow: 0 14px 30px rgba(20, 24, 50, 0.28);
  line-height: 0;
}

/* --ratio : hauteur / largeur du format choisi (1,4142 en A4 et A3, 1,5 en 40 × 60…) */
#poster {
  display: block;
  width: min(calc(100vw - 48px), calc(62vh / var(--ratio, 1.4142)));
  width: min(calc(100vw - 48px), calc(62svh / var(--ratio, 1.4142)));
  aspect-ratio: 1 / var(--ratio, 1.4142);
  background: #fff;
}

.preview-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- formulaire ---------- */

.options { display: grid; gap: 14px; min-width: 0; }

.card {
  margin: 0;
  min-width: 0;
  border: 0;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  box-shadow: 0 1px 3px rgba(20, 24, 50, 0.08);
}

.card legend {
  float: left;
  width: 100%;
  margin-bottom: 6px;
  font: 400 21px/1.2 Anton, Impact, sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--navy);
}

.card legend + * { clear: both; }

.field { margin-top: 12px; min-width: 0; }

.row { display: flex; gap: 12px; align-items: flex-end; }
.grow { flex: 1; }
.number { width: 112px; flex: none; }

.label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 650;
  font-size: 15px;
}

.count { font-weight: 400; color: var(--muted); }

input[type='text'] {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 600 18px/1.2 system-ui, -apple-system, sans-serif;
  text-transform: uppercase;
}

input[type='text']:focus { outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent); border-color: var(--focus); }

.choices { display: flex; flex-wrap: wrap; gap: 12px 10px; padding-top: 4px; }

.choice { position: relative; }

.choice input {
  position: absolute;
  z-index: 1;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.choice span {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
}

.choice input:checked + span {
  border-color: var(--navy);
  box-shadow: inset 0 0 0 1.5px var(--navy);
  background: #f2f4ff;
  font-weight: 650;
}

/* coche dans le coin : l'information « choisi » ne repose pas que sur la couleur */
.choice input:checked + span::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
}

.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.swatches .choice span { padding: 6px 12px 6px 8px; }

.layouts, .formats, .qualities { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.qualities { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

.layouts .choice span, .formats .choice span, .qualities .choice span { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; height: 100%; }

.choice small { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }

.people { display: grid; gap: 14px; min-width: 0; }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.themes .choice span { min-height: 52px; padding: 6px 10px 6px 6px; }

.mini-flag {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.custom {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.custom.on { display: grid; }

.custom label { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.custom input[type='color'] {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  flex: none;
}

.hint { margin: 12px 0 0; font-size: 14px; color: var(--muted); }

.hint.first { margin-top: 0; }

/* logo importé */
.logo-row { display: flex; align-items: center; gap: 14px; margin-top: 12px; }

.file-btn { position: relative; overflow: hidden; flex: 1; }

.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.logo-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 10px;
  background: repeating-conic-gradient(#e9ebf2 0 25%, #fff 0 50%) 0 0 / 16px 16px;
  box-shadow: inset 0 0 0 1px var(--line);
  flex: none;
}

.actions { display: grid; gap: 10px; margin-top: 14px; }

.btn {
  min-height: 52px;
  padding: 12px 16px;
  border: 1.5px solid var(--navy);
  border-radius: 12px;
  background: #fff;
  color: var(--navy);
  font: 700 17px/1.2 system-ui, -apple-system, sans-serif;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn.primary { background: var(--navy); color: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.link {
  margin-top: 12px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

[hidden] { display: none !important; }

/* ---------- mini aperçu flottant (téléphone) ---------- */

.mini {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 5;
  padding: 4px;
  border: 0;
  border-radius: 4px;
  background: #15161a;
  box-shadow: 0 8px 22px rgba(20, 24, 50, 0.35);
  line-height: 0;
  cursor: pointer;
}

.mini canvas { width: 84px; aspect-ratio: 1 / var(--ratio, 1.4142); display: block; background: #fff; }

/* ---------- fenêtre « fichier prêt » ---------- */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 14, 36, 0.6);
}

.dialog-box {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 20px;
  border-radius: 18px;
  background: #fff;
  text-align: center;
}

.dialog-box h2 { margin: 0 0 6px; font: 400 24px/1.2 Anton, Impact, sans-serif; letter-spacing: 0.03em; color: var(--navy); text-transform: uppercase; }
.dialog-box p { margin: 0; color: var(--muted); }

.spinner {
  width: 44px;
  height: 44px;
  margin: 18px auto 4px;
  border: 5px solid var(--line);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

/* ---------- grand écran : aperçu à gauche, réglages à droite ---------- */

@media (min-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); align-items: start; gap: 24px; }
  .preview { position: sticky; top: 16px; }
  #poster { width: min(calc(min(100vw, 1180px) - 540px), calc((100vh - 130px) / var(--ratio, 1.4142))); }
  .mini { display: none; }
}

/* téléphone en paysage : aperçu à gauche aussi */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 560px) {
  .top { display: none; }
  .layout { grid-template-columns: auto minmax(0, 1fr); align-items: start; padding-top: max(8px, env(safe-area-inset-top)); }
  .preview { position: sticky; top: 8px; }
  #poster { width: calc((100vh - 36px) / var(--ratio, 1.4142)); width: calc((100svh - 36px) / var(--ratio, 1.4142)); }
  .preview-note { display: none; }
  .mini { display: none; }
}

/* ---------- impression : seulement l'affiche, page entière ---------- */

.print-sheet { display: none; }

@media print {
  body { background: #fff; }
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; width: 100vw; height: 100vh; overflow: hidden; }
  .print-sheet img { display: block; width: 100%; height: 100%; object-fit: contain; }
}
