/* ============================================================================
 * bolao-raspadinha · styles
 * Everything is namespaced under .bolaonesha-* so the plugin never clashes
 * with a host theme. Geometry is driven by the ticket art's 1229:642 ratio;
 * changing that ratio without reshooting the art will desync the slots.
 * ========================================================================= */

.bolaonesha-raspadinha {
  position: relative;
  width: 100%;
  display: block;
  /* Container queries let the redeem button rescale inside whatever column
     the host drops us into, without needing viewport media queries. */
  container-type: inline-size;
  container-name: bolaonesha;
}

.bolaonesha-raspadinha .bolaonesha-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1229 / 642;   /* native ticket ratio — do not override */
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* touch-action:none prevents the browser from grabbing vertical scrubs as
     page scrolls. Without it, the first drag on mobile scrolls the page. */
  touch-action: none;
  /* isolation creates a stacking context so the shine's mix-blend-mode blends
     against the ticket — not against whatever sits behind the host page. */
  isolation: isolate;
  background: transparent;    /* ticket PNG carries its own serrated edge */
}

.bolaonesha-ticket-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  z-index: 0;
  pointer-events: none;
  -webkit-user-drag: none;
}

.bolaonesha-prize-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  /* Hidden until covers are painted on top. This is the last line of defense
     against the prize flashing through during initial paint. */
  opacity: 0;
}
.bolaonesha-raspadinha.bolaonesha-ready .bolaonesha-prize-layer { opacity: 1; }

.bolaonesha-cell {
  position: absolute;
  display: grid;
  place-items: center;
  overflow: visible;
  transform: translateZ(0);                  /* promote for the reveal animation */
  transition: transform .26s cubic-bezier(.2, 1.6, .3, 1);
}

.bolaonesha-prize {
  /* 81% was tuned against the silver cutout — 100% bled past the edges,
     90% looked oversized on mobile. Do not change without re-tuning. */
  width: 81%;
  height: 81%;
  object-fit: contain;
  display: block;
  -webkit-user-drag: none;
}

.bolaonesha-prize-fallback {
  font-size: clamp(32px, 7vw, 72px);
  line-height: 1;
  color: #f5e4a0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
}

.bolaonesha-cell.bolaonesha-revealed {
  animation: bolaonesha-reveal .62s cubic-bezier(.175, .885, .32, 1.45);
}
@keyframes bolaonesha-reveal {
  0%   { transform: scale(1); }
  22%  { transform: scale(1.18) rotate(-3.5deg); }
  52%  { transform: scale(.93) rotate(1.8deg); }
  100% { transform: scale(1); }
}

.bolaonesha-ticket-id {
  position: absolute;
  left: 50%;
  /* 20.4% = (321 − 190) / 642 — the midline of the ticket art minus the
     logo's vertical offset. Derived from the 1229×642 background. */
  top: 20.4%;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
  color: #d0cec9;                            /* sampled from the Nesha logo */
  font: 800 clamp(8px, 1.7vw, 14px)/1 'Rajdhani', system-ui, -apple-system, sans-serif;
  letter-spacing: .08em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .55);
  white-space: nowrap;
}

.bolaonesha-scratch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 3;                                /* above prize (1), above bg (0) */
  cursor: grab;
}
.bolaonesha-raspadinha.bolaonesha-active .bolaonesha-scratch { cursor: grabbing; }
.bolaonesha-raspadinha.bolaonesha-done   .bolaonesha-scratch { pointer-events: none; cursor: default; }

.bolaonesha-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 4;                                /* above scratch so debris sits on top */
  pointer-events: none;
}

.bolaonesha-shine {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity .45s ease-out;
  /* Blend on the container (not the pseudo): inside the stage's isolated
     stacking context, applying blend to the ::before would render it inert
     because the blend needs an ancestor backdrop to reach. */
  mix-blend-mode: overlay;
  /* Mask is injected by JS with the ticket URL so the shine is clipped to the
     serrated ticket edge. Under file:// the mask is CORS-blocked — not a
     leak, just a minor visual regression. */
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  -webkit-mask-position: 0 0;
  mask-repeat: no-repeat;
  mask-size: 100% 100%;
  mask-position: 0 0;
}
.bolaonesha-raspadinha.bolaonesha-ready      .bolaonesha-shine { opacity: 1; }
.bolaonesha-raspadinha.bolaonesha-scratching .bolaonesha-shine,
.bolaonesha-raspadinha.bolaonesha-done       .bolaonesha-shine { opacity: 0; }

/* Single sweeping stripe. João rejected the double-stripe — don't reintroduce. */
.bolaonesha-shine::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateX(160%);
  will-change: transform;
  pointer-events: none;
  background: linear-gradient(110deg,
    transparent 40%,
    rgba(255, 255, 255, .50) 50%,
    transparent 60%);
  animation: bolaonesha-sweep 6s cubic-bezier(.45, .05, .5, .95) infinite;
}
@keyframes bolaonesha-sweep {
  0%   { transform: translateX(160%); }
  50%  { transform: translateX(-160%); }
  100% { transform: translateX(-160%); }
}

/* ───────── Redeem button ─────────
 * Lives below the stage in the root's flow. The pulse is the two rings
 * emanating from ::before/::after — the button itself is static, per João's
 * explicit "nada de pulse no botão". */
.bolaonesha-redeem {
  position: relative;
  display: block;
  margin: 14px auto 0;
  min-width: min(17rem, 100%);
  max-width: 22rem;
  width: 100%;
  border: 3px solid var(--bn-ink, #050505);
  border-radius: 0;
  padding: 0.95rem 1.4rem;
  min-height: 44px;
  font-family: "Archivo Black", "Archivo", sans-serif;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bn-ink, #050505);
  background: var(--bn-lime, #b7ff00);
  box-shadow: 8px 8px 0 var(--bn-ink, #050505);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity .35s ease-out, transform .45s cubic-bezier(.2, 1.6, .3, 1),
              box-shadow 0.14s ease, background 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}

.bolaonesha-raspadinha.bolaonesha-redeemable .bolaonesha-redeem {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.bolaonesha-raspadinha.bolaonesha-redeemed .bolaonesha-redeem {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}

.bolaonesha-redeem:hover:not([disabled])   {
  transform: translate(-2px, -2px);
  box-shadow: 10px 10px 0 var(--bn-ink, #050505);
  background: #c7ff3d;
}
.bolaonesha-redeem:active:not([disabled])  {
  transform: translate(3px, 3px);
  box-shadow: 5px 5px 0 var(--bn-ink, #050505);
}
.bolaonesha-redeem:focus-visible {
  outline: 3px solid var(--bn-ink, #050505);
  outline-offset: 3px;
}
/* opacity:0.75 only applies when the button is already visible (inside redeemable).
   Without this scope, [disabled] specificity would override the base opacity:0. */
.bolaonesha-raspadinha.bolaonesha-redeemable .bolaonesha-redeem[disabled] {
  cursor: not-allowed;
  opacity: 0.75;
}

/* Tight-column fallback for mobile columns below 480px. */
@container bolaonesha (max-width: 480px) {
  .bolaonesha-redeem { min-height: 36px; padding: 0.75rem 1.2rem; font-size: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bolaonesha-cell.bolaonesha-revealed { animation: none; }
  .bolaonesha-shine::before            { animation: none; transform: translateX(-150%); }
  .bolaonesha-redeem { transition: none; }
}

/* Publi mode — demo identity overlay ---------------------------------- */
.bolaonesha-raspadinha.bolaonesha-is-publi .bolaonesha-ticket-id {
  /* Display ids for publi are longer (e.g. PUBLI-7KD3-01) — prevent wrap */
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.bolaonesha-raspadinha .bolaonesha-publi-badge {
  position: absolute;
  top: 6%;
  right: 5%;
  z-index: 5;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(40, 40, 40, 0.92);
  color: #ffd34a;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: none;
  pointer-events: none;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.bolaonesha-raspadinha .bolaonesha-publi-notice {
  margin: 10px 4px 0;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #6a6257;
  text-align: center;
  letter-spacing: 0.01em;
}

@media (max-width: 420px) {
  .bolaonesha-raspadinha .bolaonesha-publi-badge {
    font-size: 0.72rem;
    padding: 3px 8px;
  }

  .bolaonesha-raspadinha .bolaonesha-publi-notice {
    font-size: 0.74rem;
  }
}
