/* Postal — sistema visual: postal de viaje vintage.
   La UI queda subordinada a la postal: cromo discreto, la tarjeta manda. */

:root {
  --bg: #F3ECDF;
  --ink: #2B2620;
  --cta: #B5502F;
  --accent: #2B3A5C;
  --surface: #FBF6EC;
  --line: #DCCBA8;
  --line-2: #E4D6B8;
  --muted: #8A6F45;
  --muted-2: #6b5b3f;
  --bar: 76px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Archivo, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cta); outline-offset: 2px; }

/* grano para superficies que no son canvas (el canvas lo lleva horneado) */
.grain { position: relative; }
.grain::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  opacity: .22; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------ shell */

.app {
  min-height: 100svh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: rgba(243, 236, 223, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.topbar__back {
  border: none; background: none; padding: 6px 4px; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--accent);
}
.topbar__back[hidden] { display: none; }
.topbar__title {
  font-family: Yellowtail, cursive; font-size: 24px; color: var(--accent);
  line-height: 1; margin-right: auto;
}
.topbar__step {
  font-family: "Special Elite", monospace; font-size: 11px; color: var(--muted);
  letter-spacing: .08em;
}
.topbar__link {
  border: none; background: none; cursor: pointer;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 6px 0;
}

.screen { display: none; flex: 1; flex-direction: column; padding: 20px 20px 0; }
.screen.is-active { display: flex; }
.screen--pad { padding-bottom: 0; }

.h1 { font-weight: 700; font-size: 17px; margin: 0 0 4px; }
.sub { font-size: 12.5px; color: var(--muted-2); margin: 0 0 18px; line-height: 1.45; }
.eyebrow {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px;
}

/* ---------------------------------------------------------------- botones */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px; border-radius: 4px; border: none;
  font-weight: 700; font-size: 15px; cursor: pointer;
  text-decoration: none; text-align: center;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--cta); color: #fff; }
.btn--ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn--quiet { background: transparent; color: var(--muted-2); border: 1px solid var(--line); font-weight: 600; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn--sm { padding: 12px; font-size: 13px; }

.bar {
  position: sticky; bottom: 0; z-index: 30; margin-top: auto;
  display: flex; gap: 10px;
  padding: 24px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 0 74%, rgba(243, 236, 223, 0));
}

/* ------------------------------------------------------------------ inicio */

.home { align-items: center; justify-content: center; text-align: center; gap: 0; }
.home__logo { font-family: Yellowtail, cursive; font-size: 46px; color: var(--accent); line-height: 1; }
.home__tag {
  font-size: 11px; color: var(--muted); letter-spacing: .12em;
  text-transform: uppercase; margin: 6px 0 34px;
}
.home__stack { position: relative; width: 230px; height: 158px; margin-bottom: 40px; }
.home__card {
  position: absolute; inset: 0; border: 7px solid #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .2);
}
.home__card:nth-child(1) { transform: rotate(7deg) translateY(10px); opacity: .6;
  background: repeating-linear-gradient(90deg, #F2B6C4 0 16px, #A7D3D8 16px 32px, #F5D98B 32px 48px); }
.home__card:nth-child(2) { transform: rotate(-5deg) translateY(4px); opacity: .8;
  background: repeating-linear-gradient(180deg, #7C8156 0 10px, #fff 10px 20px); }
.home__card:nth-child(3) {
  background: #FBF3DD; background-image: repeating-linear-gradient(90deg, #E3A63D 0 22px, #FBF3DD 22px 38px);
  display: flex; align-items: center; justify-content: center;
  font-family: Yellowtail, cursive; font-size: 30px; color: var(--accent);
}
.home__actions { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.home__mine {
  margin-top: 22px; background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--muted-2); text-decoration: underline;
  text-underline-offset: 4px;
}

/* --------------------------------------------------------------- el lienzo */

.stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 6px 0 18px; min-height: 0;
}
.card-shadow { box-shadow: 0 12px 28px rgba(0, 0, 0, .22); display: block; }

/* --------------------------------------------------------------- carrusel */

.rail {
  display: flex; gap: 12px; overflow-x: auto; padding: 4px 20px 16px;
  margin: 0 -20px; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0; scroll-snap-align: center; text-align: center;
  border: none; background: none; padding: 0; cursor: pointer;
}
.chip__thumb {
  width: 62px; height: 78px; border: 4px solid #fff; border-bottom-width: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .18); display: block;
  transition: transform .15s ease;
}
.chip__label { font-size: 10.5px; margin-top: 6px; color: var(--muted-2); display: block; }
.chip.is-on .chip__thumb { transform: translateY(-4px); box-shadow: 0 8px 16px rgba(0, 0, 0, .26); }
.chip.is-on .chip__label { color: var(--cta); font-weight: 700; }

/* plantillas: deslizar hojas */
.sheets {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  gap: 0; margin: 0 -20px; padding: 10px 0 4px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.sheets::-webkit-scrollbar { display: none; }
.sheet {
  flex: 0 0 100%; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 20px;
}
.sheet__name { font-family: "Special Elite", monospace; font-size: 11px; color: var(--muted); }
.dots { display: flex; gap: 12px; justify-content: center; padding: 12px 0 2px; }
.dot {
  width: 16px; height: 16px; border-radius: 50%; border: none; padding: 0;
  background: var(--line); cursor: pointer; transition: transform .15s ease;
}
.dot.is-on { transform: scale(1.3); }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 16px; }
.label {
  display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px;
}
.input, .textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px; padding: 13px 14px; font-size: 16px; color: var(--ink);
  font-family: Archivo, sans-serif;
}
.textarea { min-height: 108px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus { outline: none; border-color: var(--cta); }
.counter { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 5px; }

.fontlist { display: flex; flex-direction: column; gap: 7px; }
.fontopt {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; border-radius: 4px; background: var(--surface);
  border: 1px solid var(--line); cursor: pointer; text-align: left; width: 100%;
}
.fontopt.is-on { background: #FBF3DD; border-color: var(--cta); }
.fontopt__sample { font-size: 22px; color: var(--ink); line-height: 1.3; }
.fontopt__tick { font-size: 12px; color: var(--cta); opacity: 0; }
.fontopt.is-on .fontopt__tick { opacity: 1; }

/* ------------------------------------------------------------------ sellos */

.stamps { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stampopt {
  background: var(--surface); border: 2px solid var(--line); border-radius: 4px;
  padding: 14px 10px 11px; cursor: pointer; display: flex;
  flex-direction: column; align-items: center; gap: 9px;
}
.stampopt.is-on { border-color: var(--cta); background: #FBF3DD; }
.stampopt__label { font-size: 11px; color: var(--muted-2); }
.stampopt canvas { display: block; }

/* -------------------------------------------------------------------- flip */

.flip { perspective: 1400px; width: 100%; }
.flip__inner {
  position: relative; width: 100%; transform-style: preserve-3d;
  transition: transform .65s cubic-bezier(.2, .7, .2, 1);
}
.flip.is-flipped .flip__inner { transform: rotateY(180deg); }
.flip__face {
  display: block; width: 100%; backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .24);
}
.flip__face--back { position: absolute; inset: 0; transform: rotateY(180deg); }
.flip__hint {
  text-align: center; font-family: "Special Elite", monospace;
  font-size: 11px; color: var(--muted); margin-top: 14px;
}

/* ---------------------------------------------------------------- compartir */

.done { text-align: center; }
.done__title { font-family: Yellowtail, cursive; font-size: 34px; color: var(--accent); margin: 18px 0 2px; }
.done__sub { font-size: 12.5px; color: var(--muted-2); margin: 0 0 20px; }
.linkbox {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px dashed var(--line); border-radius: 4px; padding: 11px 12px; margin-bottom: 14px;
}
.linkbox__url {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: "Special Elite", monospace; font-size: 12px; color: var(--muted-2); text-align: left;
}
.linkbox__copy {
  border: none; background: var(--accent); color: #fff; border-radius: 3px;
  padding: 7px 11px; font-size: 11px; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.meta { font-family: "Special Elite", monospace; font-size: 11px; color: var(--muted); margin-top: 12px; }
.row { display: flex; gap: 10px; }

/* -------------------------------------------------------------- mis postales */

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding-bottom: 30px; }
.tile { border: none; background: none; padding: 0; cursor: pointer; text-align: left; text-decoration: none; }
.tile img {
  width: 100%; display: block; border: 5px solid #fff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .18);
}
.tile span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 7px; font-family: "Special Elite", monospace; }
.empty { text-align: center; color: var(--muted-2); font-size: 13px; padding: 40px 10px; }

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 4px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 90;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.loading {
  position: fixed; inset: 0; background: rgba(243, 236, 223, .86); z-index: 80;
  display: none; align-items: center; justify-content: center;
  font-family: "Special Elite", monospace; font-size: 13px; color: var(--muted-2);
}
.loading.is-on { display: flex; }

/* --------------------------------------------------------- página pública */

.shared-page { background: var(--bg); }
.shared {
  max-width: 480px; margin: 0 auto; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 20px calc(34px + env(safe-area-inset-bottom, 0px));
}
.shared__logo {
  font-family: Yellowtail, cursive; font-size: 32px; color: var(--accent);
  text-decoration: none; margin-bottom: 26px;
}
.shared__stage { width: 100%; margin-bottom: 22px; }
.shared .flip { cursor: pointer; }
.shared__note { font-family: "Special Elite", monospace; font-size: 11px; color: var(--muted); margin: 16px 0 26px; }
.shared__cta { max-width: 260px; }
.shared .btn { max-width: 260px; }
