/* ==========================================================
   Pixel Letter — la carta que recibe la otra persona
   Papel con tramado, bordes de píxel, casillas pixel y sobre pixelado
   ========================================================== */

.letter, .px-scene {
  --lt-ink: #3d2160;
  --lt-accent: #ff5fae;
  --lt-soft: #ffd6ec;
  --lt-paper: #fff4fa;
  --lt-paper-2: #ffe8f4;
  --f-px: "Pixelify Sans", "Silkscreen", monospace;
}
.letter.paper-sky { --lt-accent: #3d93e6; --lt-soft: #cfe6ff; --lt-paper: #f2f9ff; --lt-paper-2: #e2f0ff; }
.letter.paper-stars { --lt-accent: #8a5cf0; --lt-soft: #e2d6ff; --lt-paper: #f8f4ff; --lt-paper-2: #ece4ff; }
.letter.paper-cherry { --lt-accent: #e8355f; --lt-soft: #ffd3dc; --lt-paper: #fffaf0; --lt-paper-2: #fff0e4; }

/* ---------- pantalla del sobre ---------- */
.px-scene { image-rendering: pixelated; }
.px-title {
  margin: 0 0 6px; font-family: "Silkscreen", monospace; font-weight: 700; font-size: clamp(30px, 8vw, 64px); line-height: 1; letter-spacing: .02em;
  color: #fff; text-shadow: 3px 3px 0 #ff5fae, 6px 6px 0 #3d2160;
}
.px-env { padding: 26px; }
.px-env .px { width: min(300px, 72vw); height: auto; filter: drop-shadow(8px 8px 0 rgba(61, 33, 96, .35)); }
.px-env.opening { animation: px-open .7s steps(6) forwards; }
@keyframes px-open { 0% { transform: scale(1); } 40% { transform: scale(1.12) rotate(-4deg); } 70% { transform: scale(1.12) rotate(4deg); opacity: 1; } 100% { transform: scale(.2) translateY(-60px); opacity: 0; } }
.ygm-kicker { font-family: "Silkscreen", monospace; color: #3d2160; }
.px-blink { font-family: "Silkscreen", monospace; font-size: 12px; letter-spacing: .06em; color: #3d2160; animation: px-blink 1s steps(1) infinite; }
@keyframes px-blink { 50% { opacity: .25; } }
.mail-loading.px-scene .px { width: 120px; animation: floaty 1.5s steps(3) infinite; }
.mail-loading.px-scene p { font-family: "Silkscreen", monospace; font-size: 12px; letter-spacing: .1em; }

/* ---------- la carta ---------- */
.letter {
  position: relative; max-width: 660px; margin: 26px auto 18px; padding: 44px 40px 34px;
  font-family: var(--f-px); color: var(--lt-ink);
  background:
    repeating-conic-gradient(rgba(61, 33, 96, .045) 0 25%, transparent 0 50%) 0 0 / 4px 4px,
    linear-gradient(180deg, var(--lt-paper), var(--lt-paper-2));
  border: 4px solid var(--lt-ink);
  box-shadow:
    inset 0 0 0 4px #fff,
    inset 0 0 0 8px var(--lt-soft),
    inset 0 0 0 10px #fff,
    8px 8px 0 0 var(--lt-accent),
    12px 12px 0 0 var(--lt-ink);
}
.letter.enter { animation: letter-in .6s steps(8) backwards; }
@keyframes letter-in { from { transform: translateY(60px); opacity: 0; } }
.lt-corner { position: absolute; width: 26px; }
.lt-corner .px { width: 26px; height: auto; }
.lt-corner.tl { left: 18px; top: 18px; } .lt-corner.tr { right: 18px; top: 18px; } .lt-corner.bl { left: 18px; bottom: 18px; } .lt-corner.br { right: 18px; bottom: 18px; }
.lt-corner .px rect[fill="#ffd84d"] { fill: var(--lt-accent); }
.lt-stamp {
  position: absolute; right: 54px; top: 34px; width: 86px; padding: 8px 6px 6px; text-align: center; transform: rotate(5deg);
  background: #fff; border: 3px dashed var(--lt-accent); box-shadow: 4px 4px 0 var(--lt-ink);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.lt-stamp span { font-family: "Silkscreen", monospace; font-weight: 700; font-size: 18px; color: var(--lt-accent); line-height: 1; }
.lt-stamp .px { width: 28px; height: auto; }
.lt-stamp small { font-family: "Silkscreen", monospace; font-size: 7px; letter-spacing: .1em; color: var(--lt-ink); }
.lt-head { padding-right: 110px; }
.lt-kicker { margin: 0 0 10px; font-family: "Silkscreen", monospace; font-size: 10px; letter-spacing: .14em; color: var(--lt-accent); }
.lt-title { margin: 0 0 14px; font-family: var(--f-px); font-weight: 700; font-size: clamp(24px, 5vw, 34px); line-height: 1.1; color: var(--lt-ink); text-shadow: 2px 2px 0 var(--lt-soft), 3px 3px 0 #fff; word-break: break-word; }
.lt-meta { display: flex; flex-direction: column; gap: 3px; font-family: "Silkscreen", monospace; font-size: 11px; letter-spacing: .04em; color: color-mix(in srgb, var(--lt-ink) 65%, #fff); }
.lt-meta b { font-family: var(--f-px); font-size: 15px; letter-spacing: 0; color: var(--lt-ink); font-weight: 600; }
.lt-rule { height: 8px; margin: 18px 0; background: repeating-linear-gradient(90deg, var(--lt-accent) 0 8px, transparent 8px 12px, var(--lt-soft) 12px 20px, transparent 20px 24px); image-rendering: pixelated; }
.lt-text { margin: 0 0 22px; font-size: 19px; line-height: 1.65; }
.lt-list { padding: 18px 18px 14px; background: #fff; border: 3px solid var(--lt-ink); box-shadow: 5px 5px 0 var(--lt-soft); }
.lt-sub { margin: 0 0 12px; font-family: "Silkscreen", monospace; font-size: 14px; letter-spacing: .06em; color: var(--lt-accent); text-align: center; }
.lt-bar { display: flex; align-items: center; gap: 3px; margin-bottom: 12px; }
.lt-bar i { flex: 1; height: 16px; background: var(--lt-paper-2); border: 2px solid var(--lt-ink); }
.lt-bar i.on { background: var(--lt-accent); box-shadow: inset 0 3px 0 rgba(255,255,255,.45); }
.lt-bar b { margin-left: 8px; font-family: "Silkscreen", monospace; font-size: 13px; }
.lt-items { list-style: none; margin: 0; padding: 0; }
.lt-items li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 2px dotted color-mix(in srgb, var(--lt-ink) 25%, transparent); }
.lt-items li:last-child { border-bottom: 0; }
.lt-item { font-size: 19px; font-weight: 500; line-height: 1.25; word-break: break-word; }
.lt-item em { font-style: normal; font-family: "Silkscreen", monospace; font-size: 12px; color: var(--lt-accent); }
.lt-item small { display: block; font-size: 14px; opacity: .65; }
.lt-items li.is-packed .label { text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--lt-accent); opacity: .5; }
.px-ok { visibility: hidden; font-family: "Silkscreen", monospace; font-size: 11px; color: #fff; background: #2fa57d; padding: 3px 6px; box-shadow: 2px 2px 0 var(--lt-ink); }
.lt-items li.is-packed .px-ok { visibility: visible; animation: px-pop .3s steps(3); }
@keyframes px-pop { from { transform: scale(2); } }
.px-chk { position: relative; display: inline-grid; place-items: center; cursor: pointer; }
.px-chk input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.px-box { width: 28px; height: 28px; display: grid; place-items: center; background: #fff; border: 3px solid var(--lt-ink); box-shadow: 3px 3px 0 var(--lt-soft); }
.px-box .px { width: 16px; height: auto; opacity: 0; transform: scale(.4); }
.px-chk input:checked + .px-box { background: var(--lt-soft); }
.px-chk input:checked + .px-box .px { opacity: 1; transform: none; transition: transform .15s steps(3); }
.px-chk input:focus-visible + .px-box { outline: 3px dashed var(--lt-accent); outline-offset: 2px; }
.lt-done { margin: 14px 0 0; text-align: center; font-family: "Silkscreen", monospace; font-size: 12px; color: #fff; background: #2fa57d; padding: 8px; box-shadow: 3px 3px 0 var(--lt-ink); animation: px-blink 1.2s steps(1) 3; }
.lt-hint { margin: 10px 0 0; text-align: center; font-size: 15px; opacity: .7; }
.lt-sign { margin: 26px 0 4px; text-align: right; font-size: 20px; line-height: 1.4; }
.lt-sign b { font-size: 24px; color: var(--lt-accent); }
.lt-ps { margin: 0; text-align: right; font-size: 14px; opacity: .6; }
.lt-reply { margin-top: 26px; padding-top: 20px; border-top: 4px dashed color-mix(in srgb, var(--lt-ink) 25%, transparent); }
.lt-reply label { display: block; margin-bottom: 8px; font-family: "Silkscreen", monospace; font-size: 12px; letter-spacing: .06em; }
.lt-reply textarea { width: 100%; min-height: 90px; resize: vertical; padding: 10px 12px; font-family: var(--f-px); font-size: 18px; color: var(--lt-ink); background: #fff; border: 3px solid var(--lt-ink); border-radius: 0; box-shadow: 4px 4px 0 var(--lt-soft); outline: none; }
.lt-reply textarea:focus { box-shadow: 4px 4px 0 var(--lt-accent); }
.lt-reply-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.lt-reply-foot span { font-family: "Silkscreen", monospace; font-size: 11px; color: #2fa57d; }
.px-btn {
  font-family: "Silkscreen", monospace; font-weight: 700; font-size: 14px; letter-spacing: .06em; padding: 10px 18px;
  color: #fff; background: var(--lt-accent); border: 3px solid var(--lt-ink); border-radius: 0; box-shadow: 4px 4px 0 var(--lt-ink); cursor: pointer;
}
.px-btn:hover { filter: brightness(1.08); }
.px-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--lt-ink); }
.px-btn:disabled { opacity: .5; }
.lt-footer { max-width: 660px; margin: 0 auto 30px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center; font-family: "Silkscreen", monospace; font-size: 11px; letter-spacing: .04em; color: var(--ink-soft); }
.lt-footer a { color: #ff3d9d; }
.px-link { border: 0; background: none; padding: 0; font: inherit; color: var(--ink-soft); text-decoration: underline; cursor: pointer; }
.px-link:hover { color: #ff3d9d; }

@media (max-width: 640px) {
  .letter { padding: 52px 18px 26px; margin: 10px 4px 16px; box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 8px var(--lt-soft), inset 0 0 0 10px #fff, 5px 5px 0 var(--lt-accent), 8px 8px 0 var(--lt-ink); }
  .lt-head { padding-right: 0; }
  .lt-stamp { position: static; margin: -18px 0 14px auto; width: 78px; }
  .lt-list { padding: 14px 10px 10px; }
  .lt-item { font-size: 17px; }
  .lt-corner { width: 18px; } .lt-corner .px { width: 18px; }
  .lt-corner.tl, .lt-corner.bl { left: 12px; } .lt-corner.tr, .lt-corner.br { right: 12px; }
  .lt-corner.tl, .lt-corner.tr { top: 12px; } .lt-corner.bl, .lt-corner.br { bottom: 12px; }
}
@media print {
  body.mail-mode .lt-reply, body.mail-mode .lt-footer { display: none !important; }
  body.mail-mode .letter { box-shadow: none; margin: 0 auto; }
}

/* --- sobre: área de toque fija y grande (en iPhone, tocar algo que se mueve a veces no cuenta) --- */
.ygm.px-scene { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ygm-env.px-env { animation: none !important; touch-action: manipulation; }
.env-bob { display: block; animation: env-bounce 1.8s ease-in-out infinite; pointer-events: none; }
.px-env .px { pointer-events: none; }
.px-env.opening .env-bob { animation: px-open .55s steps(5) forwards; }
.px-env.opening { animation: none !important; }
.px-open { margin-top: 6px; font-size: 16px; padding: 14px 26px; touch-action: manipulation; animation: px-blink 1.2s steps(1) infinite; }
.px-open:hover, .px-open:focus-visible { animation: none; }
.ygm-from { font-family: "Silkscreen", monospace; font-size: 12px; letter-spacing: .06em; color: #3d2160; }
@media (prefers-reduced-motion: reduce) { .env-bob, .px-open { animation: none !important; } }

/* vista previa de quien envía */
.lt-owner { max-width: 660px; margin: 10px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: #fff7c2; border: 3px solid #3d2160; box-shadow: 4px 4px 0 #3d2160; font-family: "Silkscreen", monospace; font-size: 11px; color: #3d2160; }
.px-btn.small { font-size: 11px; padding: 7px 12px; box-shadow: 3px 3px 0 #3d2160; text-decoration: none; display: inline-block; }
.px-chk input:disabled { cursor: not-allowed; }
