@font-face { font-family: 'Hellix'; src: url('assets/fonts/Hellix-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Hellix'; src: url('assets/fonts/Hellix-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Hellix'; src: url('assets/fonts/Hellix-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }

/* Colores del diseño (Figma: estilos UE) */
:root {
  --rojo: #ff3228;
  --blanco: #ffffff;
  --gris-4: #d7d2d2;
  --gris: #504b4b;
  --negro: #1e1e1e;
  --crema: #fffdf8;
  --linea: #ddd4c4;
  --placeholder: #868685;
  --seleccion: #6a77b6;
  --noche: #1b2350;
  --cristal: rgba(238, 238, 238, .2);
}

* { box-sizing: border-box; }

html { background: var(--noche); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--blanco);
  font-family: 'Hellix', system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Fondo: paisaje nevado + copos ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}
.scene-bg {
  position: absolute;
  inset: -12px;
  background: url('assets/figma/background.jpg') center bottom / cover no-repeat;
  filter: blur(4.5px);
}
.scene-snow {
  position: absolute;
  top: -10px;
  left: 50%;
  width: max(106.6%, 1100px);
  height: auto;
  transform: translateX(-50%);
}

/* ---------- Marca ---------- */
.brand {
  padding: 20px 16px 12px;
}
.brand img {
  display: block;
  width: 150px;
  height: auto;
}

/* ---------- Panel (móvil primero) ---------- */
.panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 0 16px;
}

h1 {
  margin: 0;
  font-weight: 600;
  font-size: clamp(28px, 7.5vw, 48px);
  line-height: 1.1;
  text-wrap: balance;
}
.lead { margin: 6px 0 0; font-size: 15px; line-height: 1.5; }

/* Móvil: la postal se queda fija arriba para verla mientras se escribe con el teclado abierto */
.preview {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -16px;
  padding: 10px 16px;
  background: rgba(27, 35, 80, .9);
  -webkit-backdrop-filter: blur(17px);
  backdrop-filter: blur(17px);
  border-bottom: 1px solid rgba(255, 255, 255, .15);
}
.frame {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 4px;
  background: var(--blanco);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6);
}
.frame canvas {
  display: block;
  height: 38vh;
  height: 38svh;
  width: auto;
  max-width: 100%;
}

h2 {
  display: flex;
  align-items: center;
  margin: 26px 0 10px;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
}
h2 label { display: flex; align-items: center; }
.editor h2:first-child { margin-top: 0; }

.step {
  display: inline-grid;
  place-items: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  margin-right: 10px;
  border-radius: 12px;
  background: var(--rojo);
  color: var(--blanco);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

/* Paso 1: diseños */
.picker {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 4px 4px 10px;
  margin: 0 -4px;
  scroll-snap-type: x proximity;
}
.thumb {
  flex: 0 0 84px;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 18px;
  color: var(--gris-4);
  text-align: center;
  white-space: nowrap;
  scroll-snap-align: start;
}
.thumb .pic {
  display: grid;
  place-items: center;
  width: 88px;
  height: 109px;
  border: 2px solid transparent;
  border-radius: 8px;
}
.thumb img {
  display: block;
  width: 66px;
  height: 82.5px;
  border-radius: 5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
  transition: transform .2s;
}
.thumb[aria-checked="true"] { color: var(--blanco); font-weight: 600; }
.thumb[aria-checked="true"] .pic { border-color: var(--seleccion); }
.thumb[aria-checked="true"] img { width: 72px; height: 90px; }
.thumb:focus-visible { outline: none; }
.thumb:focus-visible .pic { outline: 2px solid var(--blanco); outline-offset: 2px; }

/* Paso 2: mensaje */
.names {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 14px;
}
.names label { font-size: 16px; font-weight: 600; }

input[type="text"],
textarea {
  display: block;
  width: 100%;
  border: .5px solid var(--gris);
  border-radius: 10px;
  background: var(--crema);
  color: var(--negro);
  font: inherit;
  font-size: 16px; /* evita el zoom automático en iOS */
}
input[type="text"] { height: 40px; padding: 0 14px; }
textarea { min-height: 102px; padding: 12px 14px; resize: vertical; line-height: 24px; }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
input[type="text"]:focus, textarea:focus { outline: 2px solid var(--seleccion); outline-offset: 1px; }

.counter {
  margin: 6px 0 0;
  text-align: right;
  font-size: 12px;
  line-height: 18px;
  color: var(--gris-4);
  font-variant-numeric: tabular-nums;
}

/* Paso 3: foto y stickers */
.extras {
  scrollbar-width: none;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 4px 10px;
  margin: 0 -4px;
}
.extras::-webkit-scrollbar, .picker::-webkit-scrollbar { display: none; }
.picker { scrollbar-width: none; }
.extras .btn { flex: 0 0 auto; min-height: 52px; padding: 0 18px; }
.sticker {
  flex: 0 0 52px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--linea);
  border-radius: 10px;
  background: var(--crema);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.sticker:focus-visible { outline: 2px solid var(--blanco); outline-offset: 2px; }
.hint { margin: 4px 0 0; font-size: 13px; font-weight: 500; line-height: 19.5px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 440px;
  margin: 8px auto 0;
  font-size: 12px;
}
.toolbar[hidden] { display: none; }
.toolbar label { flex: 1; display: grid; gap: 2px; min-width: 0; }
.toolbar input[type="range"] { width: 100%; margin: 0; accent-color: var(--rojo); }
.icon-btn {
  flex: 0 0 44px;
  height: 44px;
  border: 1px solid var(--linea);
  border-radius: 10px;
  background: var(--crema);
  color: var(--rojo);
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:focus-visible { outline: 2px solid var(--blanco); outline-offset: 2px; }
.preview canvas.has-items { touch-action: none; cursor: grab; }

/* Paso 4: descargar. Móvil: barra fija abajo, al alcance del pulgar */
.actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  gap: 6px;
  margin: 20px -16px 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(27, 35, 80, .9);
  -webkit-backdrop-filter: blur(17px);
  backdrop-filter: blur(17px);
  border-top: 1px solid rgba(255, 255, 255, .15);
}
.save-hint { margin: 0; font-size: 12px; line-height: 18px; text-align: center; color: var(--gris-4); }
.save-hint[hidden] { display: none; }
.step-send { display: none; }

.btn {
  min-height: 50px;
  padding: 0 18px;
  border: 1px solid var(--gris);
  border-radius: 10px;
  background: var(--blanco);
  color: var(--negro);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn.outline { border-color: var(--blanco); background: transparent; color: var(--blanco); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--blanco); outline-offset: 2px; }

/* Plan B para guardar: imagen a pantalla completa para mantenerla pulsada */
.save-sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(10, 14, 36, .88);
}
.save-sheet[hidden] { display: none; }
.save-box { display: grid; gap: 14px; justify-items: center; width: min(100%, 440px); }
.save-box p { margin: 0; font-size: 16px; font-weight: 600; text-align: center; }
.save-box img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 70vh;
  max-height: 70svh;
  border: 4px solid var(--blanco);
  -webkit-touch-callout: default; /* permite el menú de mantener pulsado en iOS */
  user-select: auto;
}
.save-box .btn { width: 100%; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 5;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--negro);
  color: var(--blanco);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Escritorio: diseño Figma (1920 × 1254) ---------- */
@media (min-width: 1000px) {
  .brand {
    position: absolute;
    top: 66px;
    left: 81px;
    padding: 0;
  }
  .brand img { width: 267px; }

  .panel {
    position: relative;
    width: min(1216px, calc(100% - 64px));
    margin: 200px auto 128px;
    grid-template-columns: minmax(0, 447px) minmax(0, 552px);
    justify-content: space-between;
    align-items: start;
    gap: 28px 41px;
    padding: 62px 75px 52px 94px;
    border-radius: 40px;
    background: var(--cristal);
    -webkit-backdrop-filter: blur(17px);
    backdrop-filter: blur(17px);
    box-shadow: 5px 4px 11px 2px rgba(0, 0, 0, .25);
  }
  .intro { grid-column: 1 / -1; }
  h1 { font-size: 48px; line-height: 52.8px; }
  .lead { margin-top: 2px; font-size: 16px; line-height: 24px; }

  .preview {
    position: sticky;
    top: 24px;
    margin: 51px 0 0 8px;
    padding: 0;
    border: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .frame { width: 100%; padding: 8px; }
  .frame canvas { width: 100%; height: auto; }

  .picker { gap: 20px; }
  h2 { margin-top: 24px; }

  .names { grid-template-columns: auto minmax(0, 1fr); gap: 6px 8px; margin-bottom: 16px; }
  .names label { line-height: 24px; }
  input[type="text"] { height: 24px; padding: 0 14px; font-size: 12px; }

  .step-send { display: flex; }
  .actions {
    position: static;
    grid-template-columns: minmax(0, 272px);
    justify-items: start;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .thumb img { transition: none; }
}
