/* Tokens + shared pieces. 60% cream, 30% cacao and papel colors, 10% rosa accent. */
:root {
  --cream: #fbf1e3;
  --cream-deep: #f3e2c9;
  --cacao: #3a2318;
  --muted: rgba(58, 35, 24, 0.8); /* ~6:1 on cream */
  --rosa: #d6336c;
  --rosa-hover: #b8285a;
  --rosa-rgb: 214, 51, 108;
  --marigold-rgb: 242, 154, 29;
  --space-1: 0.5rem; --space-2: 1rem; --space-3: 1.5rem; --space-4: 2rem; --space-6: 3rem;
  --text-xs: 0.64rem; --text-sm: 0.8rem; --text-base: 1rem; --text-lg: 1.25rem; --text-xl: 1.563rem;
  --text-2xl: 1.953rem; --text-3xl: 2.441rem; --text-4xl: 3.052rem;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --pop: cubic-bezier(.3, 1.6, .5, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--cream-deep);
  color: var(--cacao);
  font: var(--text-base)/1.5 "Figtree", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
.display { font-family: "Bagel Fat One", serif; letter-spacing: -0.01em; line-height: 1.1; font-weight: 400; }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid var(--rosa); outline-offset: 4px; }

/* ---------- papel picado: CSS flags with punched holes ---------- */
.papel { position: absolute; inset: var(--safe-t) 0 auto 0; pointer-events: none; z-index: 4; }
.papel::before { /* the string */
  content: ""; position: absolute; left: -5%; right: -5%; top: 14px; height: 2px;
  background: rgba(58, 35, 24, 0.35); border-radius: 50%;
}
.papel ul { display: flex; justify-content: space-between; list-style: none; margin: 0; padding: 0 2%; }
.papel li {
  width: 15%; aspect-ratio: 4 / 5; margin-top: 14px; transform-origin: top center;
  background: var(--c);
  clip-path: polygon(0 0, 100% 0, 100% 86%, 90% 100%, 80% 86%, 70% 100%, 60% 86%, 50% 100%,
                     40% 86%, 30% 100%, 20% 86%, 10% 100%, 0 86%);
  -webkit-mask: radial-gradient(circle at 50% 42%, transparent 13%, #000 14%),
                radial-gradient(circle at 25% 22%, transparent 6%, #000 7%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
  animation: sway 3.2s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -0.45s);
  opacity: 0.95;
}
@keyframes sway { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

/* ---------- envelope intro ---------- */
.envelope-screen {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  padding: calc(var(--space-2) + var(--safe-t)) calc(var(--space-2) + var(--safe-r))
           calc(var(--space-2) + var(--safe-b)) calc(var(--space-2) + var(--safe-l));
  background: var(--cream);
  transition: opacity 0.6s ease, visibility 0.6s;
}
.envelope-screen.gone { opacity: 0; visibility: hidden; }
.envelope {
  width: min(86vw, 360px); aspect-ratio: 4 / 3; position: relative; cursor: pointer; border: 0; padding: 0;
  background: var(--cream-deep); border-radius: 14px;
  box-shadow: 0 10px 0 rgba(58, 35, 24, 0.12), 0 24px 40px rgba(58, 35, 24, 0.18);
  animation: bob 2.4s ease-in-out infinite;
}
.envelope:disabled { cursor: progress; }
.envelope::before { /* flap */
  content: ""; position: absolute; inset: 0 0 45% 0; background: #ead3b1;
  clip-path: polygon(0 0, 100% 0, 50% 100%); border-radius: 14px 14px 0 0;
}
.seal {
  position: absolute; left: 50%; top: 44%; translate: -50% -50%; width: 56px; height: 56px;
  border-radius: 50%; background: var(--rosa); color: #fff; display: grid; place-items: center;
  font-size: var(--text-xl); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}
.envelope .to { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; padding: 0 var(--space-2); }
.to small { display: block; color: var(--muted); font-size: var(--text-sm); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.to strong { font-size: clamp(var(--text-xl), 7vw, var(--text-2xl)); overflow-wrap: anywhere; }
.hint { margin: var(--space-3) 0 0; color: var(--muted); text-align: center; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-1deg); } }

/* ---------- comic speech bubble ---------- */
.bubble {
  position: absolute; z-index: 6; margin: 0; width: max-content;
  max-width: min(84cqw, 340px); padding: 0.75rem var(--space-2);
  background: #fff; border: 3px solid var(--cacao); border-radius: 22px;
  font-size: clamp(1.05rem, 5.4cqw, var(--text-xl)); box-shadow: 0 5px 0 var(--cacao);
  opacity: 0; transform: scale(0.6); transform-origin: var(--tail-x) 100%;
  transition: opacity 0.2s ease, transform 0.25s var(--pop);
  pointer-events: none;
}
.bubble.on { opacity: 1; transform: scale(1); }
.bubble::after { /* tail */
  content: ""; position: absolute; bottom: -18px; left: var(--tail-x); width: 24px; height: 18px;
  background: var(--cacao); clip-path: polygon(var(--tail-tip) 100%, 0 0, 100% 0);
}
.bubble[data-speaker="manuel"] { --tail-x: 24%; --tail-tip: 15%; }
.bubble[data-speaker="carolina"] { --tail-x: calc(76% - 24px); --tail-tip: 85%; }

/* ---------- Sí / No + replay ---------- */
.answers { display: flex; gap: var(--space-2); justify-content: center; }
.btn {
  min-width: 128px; min-height: 56px; padding: var(--space-2) var(--space-4); border-radius: 999px; cursor: pointer;
  font: 400 var(--text-xl)/1 "Bagel Fat One", serif; border: 3px solid var(--cacao);
  box-shadow: 0 5px 0 var(--cacao); transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--cacao); }
@keyframes squish {
  0% { transform: translateY(4px) scale(0.9, 0.85); box-shadow: 0 1px 0 var(--cacao); }
  60% { transform: translateY(-3px) scale(1.06, 1.08); }
  100% { transform: none; }
}
.btn-yes { background: var(--rosa); color: #fff; }
.btn-yes:hover { background: var(--rosa-hover); }
.btn-no { background: #fff; color: var(--cacao); }
.replay {
  border: 2px solid rgba(58, 35, 24, 0.25); cursor: pointer; min-height: 40px;
  background: rgba(255, 255, 255, 0.9); border-radius: 999px; padding: 0.375rem var(--space-2);
  font: 600 var(--text-sm) "Figtree", sans-serif; color: var(--cacao);
}
.resume {
  position: absolute; z-index: 12; left: 50%; top: 50%; translate: -50% -50%; cursor: pointer;
  border: 3px solid var(--cacao); border-radius: 999px; background: var(--rosa); color: #fff;
  padding: var(--space-2) var(--space-3); font: 400 var(--text-lg)/1 "Bagel Fat One", serif;
  box-shadow: 0 5px 0 var(--cacao);
}
.resume[hidden] { display: none; }

/* Media decks stay in the DOM (iOS keeps decoding them) but are invisible. */
.decks { position: fixed; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.decks video { width: 1px; height: 1px; }

@media (prefers-reduced-motion: reduce) {
  .papel li, .envelope { animation: none; }
  .bubble, .bubble.on { transform: none; transition: opacity 0.2s ease; }
  .envelope-screen { transition: none; }
}
