﻿@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,500&family=Montserrat:wght@300;400;500&display=swap');

:root{
  --paper:      oklch(22% 0.02 85); /* Marrom escuro luxuoso */
  --paper-edge: oklch(15% 0.02 80);
  --ink:        oklch(88% 0.02 70); /* Texto off-white dourado */
  --ink-soft:   oklch(65% 0.02 70);
  --wine:       oklch(45% 0.15 15); /* Vinho rico (acento) */
  --gold:       oklch(75% 0.15 75);
  --candle:     oklch(80% 0.14 65);
  --foil-x:     50%;
  --serif: 'Cormorant Garamond', serif;
  --sans: 'Montserrat', sans-serif;
  --mx: 0.5;
  --my: 0.5;
}

*{ box-sizing:border-box; }

html,body{
  margin:0; min-height:100%;
  background:
    radial-gradient(ellipse 60% 40% at calc(var(--mx) * 100%) calc(var(--my) * 60%),
      rgba(255, 180, 100, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse at 15% 85%, rgba(120, 30, 30, 0.15) 0%, transparent 55%),
    linear-gradient(165deg, #181210 0%, #0d0a08 100%);
  font-family: var(--serif);
  color: var(--ink);
  overflow-x:hidden;
}

body{
  display:flex; align-items:center; justify-content:center;
  min-height:100vh; padding: 40px 20px;
  position:relative;
}

.paper-texture{
  position:fixed; inset:0; pointer-events:none; z-index:1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.1'/%3E%3C/svg%3E");
  background-size: 300px 300px;
  mix-blend-mode: overlay;
  opacity: 0.25;
}

.candle-glow{
  position:fixed;
  left: calc(var(--mx, 0.1) * 100% - 240px);
  top: calc(var(--my, 0.1) * 100% - 240px);
  width: 480px; height: 480px; border-radius:50%;
  background: radial-gradient(circle, rgba(255,176,102,.45) 0%, rgba(255,140,60,.12) 50%, rgba(255,176,102,0) 70%);
  filter: blur(40px);
  animation: candle-flicker 5.5s ease-in-out infinite;
  pointer-events:none; z-index:0;
  transition: left 2.2s cubic-bezier(.25,.46,.45,.94), top 2.2s cubic-bezier(.25,.46,.45,.94);
}
@keyframes candle-flicker{
  0%, 100%{ opacity:.75; transform: scale(1); }
  30%{ opacity:.9; transform: scale(1.04); }
  50%{ opacity:.6; transform: scale(.97); }
  70%{ opacity:.85; transform: scale(1.02); }
}

/* --------------------------------------------------------------
   Gold foil â€” a MOLDURA da carta.
   TÃ‰CNICA: o gradiente tem stops FIXOS (nunca mudam de ordem) e
   é maior que o elemento (background-size 260%); o que anima via
   JS é só o background-position, deslizando essa faixa dourada
   por baixo do "recorte" visível. Isso evita o bug clássico de
   usar a posição do mouse como STOP de um gradiente (que trava
   perto das bordas, porque stops de gradiente não podem "voltar"
   pra trás â€” o browser força ordem crescente e clampa o valor).
-------------------------------------------------------------- */
.letter{
  position:relative; z-index:2;
  width:min(560px, 100%);
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box,
    linear-gradient(115deg, #6b4f1e, #f5d78e, #fff8dc, #f5d78e, #6b4f1e) border-box;
  background-size: 100% 100%, 260% 100%;
  background-position: 0 0, var(--foil-x) 0;
  border: 3px solid transparent;
  border-radius: 6px;
  box-shadow:
    calc((var(--mx, 0.5) - 0.5) * -24px) calc((var(--my, 0.5) - 0.5) * -12px) 60px -15px rgba(58,44,34,.4),
    0 2px 0 var(--paper-edge),
    0 20px 50px -15px rgba(58,44,34,.25);
  padding: 40px 38px 34px;
  transform:
    rotate(-.4deg)
    perspective(900px)
    rotateX(calc((var(--my, 0.5) - 0.5) * -4deg))
    rotateY(calc((var(--mx, 0.5) - 0.5) * 5deg));
  transition: transform 0.12s linear;
  overflow: hidden;
  animation: letter-appear 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes letter-appear {
  from {
    opacity: 0;
    transform: rotate(-.4deg) translateY(30px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: rotate(-.4deg) translateY(0) scale(1);
  }
}

/* sheen: uma faixa de brilho fina que "varre" a carta, por cima de
   tudo, mesma técnica de background-position */
.letter::before{
  content:'';
  position:absolute; inset:0;
  pointer-events:none;
  z-index: 5;
  background: linear-gradient(115deg, transparent, rgba(255,241,199,.6), transparent);
  background-size: 300% 100%;
  background-position: var(--foil-x) 0;
  mix-blend-mode: overlay;
  opacity:.9;
}

.letter::after{
  content:'';
  position:absolute; inset:0;
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(58,44,34,.1) 100%);
  pointer-events:none;
  z-index:4;
  border-radius: inherit;
}

.letter-header{ text-align:right; margin-bottom: 18px; }
.letter-date{
  font-size: 14px; letter-spacing:.06em; color: var(--ink-soft);
  font-style: italic; margin:0;
}

.letter-body{
  text-align: left;
  padding-left: 2.5rem;
  padding-right: 0.75rem;
}

.hidden{ display:none !important; }

.letter-intro{
  font-family: var(--sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

.letter-question{
  font-family: var(--serif);
  font-size: clamp(4rem, 10vw, 5.5rem);
  font-weight: 600;
  font-style: italic;
  margin: 0 0 16px;
  line-height: 1;
  /* texto também em folha de ouro, mesma técnica de pan */
  background: linear-gradient(100deg, var(--wine), #f6d989, var(--wine));
  background-size: 260% 100%;
  background-position: var(--foil-x) 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: letter-question-appear 0.9s cubic-bezier(.22,1,.36,1) both;
}

@keyframes letter-question-appear{
  from{
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
    filter: blur(4px);
    letter-spacing: 0.04em;
  }
  to{
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
    letter-spacing: normal;
  }
}

.letter-sub{
  font-family: var(--sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 0 0 30px;
}

.btn-row{
  position:relative;
  display:flex; justify-content:center; align-items:center;
  gap:20px; min-height: 90px;
}

.btn{
  font-family: var(--serif);
  font-size:15px; letter-spacing:.03em;
  padding: 13px 28px;
  border-radius: 2px;
  cursor:pointer;
  background: transparent;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

/* --------------------------------------------------------------
   Selo de cera interativo: clicar e SEGURAR por 1,5s pra romper.
   O anel SVG mostra o progresso; um brilho quente cresce junto
   (sensação de "derretendo"); ao completar, uma rachadura relampeja
   e o selo se despedaça com partículas douradas.
-------------------------------------------------------------- */
.wax-seal-btn{
  position:relative;
  width: 92px; height: 92px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor:pointer;
  background: radial-gradient(circle at 35% 30%, #9a2f3f, var(--wine) 70%);
  box-shadow:
    0 6px 14px -4px rgba(122,35,49,.6),
    inset 0 -3px 6px rgba(0,0,0,.25),
    0 0 calc(var(--hold-shake, 0) * 28px) calc(var(--hold-shake, 0) * 6px)
      rgba(255,205,110, calc(var(--hold-shake, 0) * .95));
  -webkit-user-select:none; user-select:none;
  touch-action: none;
  transition: transform .15s ease, box-shadow .08s linear;
}
.wax-seal-btn:active{ transform: scale(.97); }

/* tremor crescente: a intensidade real vem de --hold-shake (0 a 1),
   atualizada quadro a quadro via JS enquanto o usuário segura â€”
   o brilho dourado acima usa a MESMA variável, então o "derreter"
   e o "tremer" crescem sempre juntos, sincronizados */
.wax-seal-btn.holding{
  animation: seal-hold-shake .12s linear infinite;
}
@keyframes seal-hold-shake{
  0%{ transform: translate(calc(var(--hold-shake, 0) * -2px), calc(var(--hold-shake, 0) * 1px)); }
  50%{ transform: translate(calc(var(--hold-shake, 0) * 2px), calc(var(--hold-shake, 0) * -1px)); }
  100%{ transform: translate(calc(var(--hold-shake, 0) * -1px), calc(var(--hold-shake, 0) * 2px)); }
}

.seal-face{
  position:relative; z-index:2;
  display:flex; align-items:center; justify-content:center;
  width:100%; height:100%;
  color: var(--gold); font-size: 26px;
  pointer-events:none;
}

.seal-ring{
  position:absolute; inset:-6px;
  width: calc(100% + 12px); height: calc(100% + 12px);
  transform: rotate(-90deg);
  pointer-events:none;
}
.seal-ring-track{
  fill:none; stroke: rgba(201,162,75,.25); stroke-width:4;
}
.seal-ring-fill{
  fill:none; stroke: var(--gold); stroke-width:4; stroke-linecap:round;
  stroke-dasharray: 283; /* 2 * pi * r(45) */
  stroke-dashoffset: 283;
  filter: drop-shadow(0 0 4px rgba(201,162,75,.7));
}

/* rachadura: linhas escondidas por padrão, relampejam bem rápido
   no instante exato em que o hold completa, antes do estilhaçar */
.seal-crack{
  position:absolute; inset:0;
  pointer-events:none;
  opacity:0;
}
.seal-crack path{
  fill:none;
  stroke: #2a1a10;
  stroke-width: 1.6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 1px rgba(255,255,255,.4));
}
.wax-seal-btn.shattering .seal-crack{
  animation: crack-flash .18s ease-out forwards;
}
@keyframes crack-flash{
  0%{ opacity:0; }
  35%{ opacity:1; }
  100%{ opacity:1; }
}

/* estilhaçar: dispara logo depois do flash da rachadura */
.wax-seal-btn.shattering .seal-face,
.wax-seal-btn.shattering{
  animation: seal-shatter .45s ease forwards;
  animation-delay: .1s;
}
@keyframes seal-shatter{
  0%{ transform: scale(1); opacity:1; }
  40%{ transform: scale(1.25); opacity:1; }
  100%{ transform: scale(1.6); opacity:0; }
}

#question-block.sealing .seal-hint{
  opacity:.35;
  transition: opacity .2s ease;
}
.seal-hint{
  font-size: 14px; font-style:italic; color: var(--ink-soft);
  margin: 14px 0 0;
  transition: opacity .2s ease;
}

/* partículas douradas do estilhaçamento */
#gold-particle-layer{
  position: fixed; inset:0; pointer-events:none; z-index: 60;
}
.gold-particle{
  position:absolute;
  width: 6px; height:6px; border-radius:50%;
  background: radial-gradient(circle, #fff6da, var(--gold) 70%);
  box-shadow: 0 0 6px rgba(201,162,75,.8);
  animation-name: gold-burst;
  animation-timing-function: cubic-bezier(.2,.8,.3,1);
  animation-fill-mode: forwards;
}
@keyframes gold-burst{
  from{ transform: translate(0,0) scale(1); opacity:1; }
  to{ transform: translate(var(--px), var(--py)) scale(.3); opacity:0; }
}

#ember-canvas {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  pointer-events: none;
}

.letter.burning {
  opacity: 0;
  transition: opacity 0.1s ease-out;
}

/* --------------------------------------------------------------
   Botão NÃƒO â€” física de fuga (curva bezier via offset-path,
   calculada 100% no script.js, intocada) com visual refinado:
   parece um bilhetinho de papel avulso, não um botão de sistema.
-------------------------------------------------------------- */
.btn-no{ display:inline-flex; align-items:center; gap:6px; font-family: var(--serif); font-size:15px; font-weight: 600; letter-spacing:.05em; padding: 12px 24px; background: #3a2c22; color: #fffdf7; border: 1px solid #1a100b; border-radius: 4px; box-shadow: 0 4px 20px rgba(0,0,0,0.4); transform: rotate(-15deg); z-index: 100; }
.btn-no.placed{ transition: none; }

.btn-no.floating{ transition: none; }

.btn-no .btn-label{ display:inline-block; }
.btn-no.floating .btn-label{
  animation: leaf-wobble .9s ease-in-out;
}
@keyframes leaf-wobble{
  0%{ transform: rotate(0deg); }
  25%{ transform: rotate(-8deg); }
  50%{ transform: rotate(6deg); }
  75%{ transform: rotate(-4deg); }
  100%{ transform: rotate(0deg); }
}

.letter-whisper{
  position: fixed;
  pointer-events:none;
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: var(--wine);
  opacity:0;
  z-index: 31;
  max-width: 220px;
  text-align:center;
  transition: opacity .5s ease;
}
.letter-whisper.show{ opacity: .9; }

/* ------------------------------------------------------------ */
/* Sucesso: polaroid                                               */
/* ------------------------------------------------------------ */
.letter-success{
  display:flex; flex-direction:column; align-items:center; gap:20px;
  padding-top: 6px;
}

.polaroid{
  background:#fff;
  padding: 14px 14px 34px;
  box-shadow: 0 14px 30px -10px rgba(0,0,0,.35);
  transform: rotate(1.2deg);
  width: min(280px, 80%);
}
.polaroid-photo{
  width:100%; aspect-ratio: 1/1; object-fit:cover; display:block;
  filter: grayscale(1) sepia(.6) saturate(0) brightness(1.05);
  transition: filter 2.4s ease-out;
}
.polaroid.revealed .polaroid-photo{
  filter: grayscale(0) sepia(0) saturate(1) brightness(1);
}
.polaroid-caption{
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px; text-align:center; color: var(--ink-soft);
  margin: 10px 0 0;
}

.report-card{
  width: min(400px, 90%);
  border-top: 1px dashed var(--gold);
  padding-top: 14px;
  text-align:center;
}
.report-card h2{
  font-family: var(--serif);
  font-variant: small-caps;
  font-size: 16px; color: var(--wine); margin: 0 0 10px;
}
.report-row{ font-size: 15px; color: var(--ink-soft); margin: 4px 0; }
.report-row span{ font-weight:600; color: var(--ink); }
.report-resolution{
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px; color: var(--ink);
  margin: 10px 0 4px; line-height:1.4;
}
.report-notes{
  font-size: 14px; font-style: italic; color: var(--ink-soft); margin:0;
}

@media (max-width: 480px){
  .letter{ padding: 30px 20px 26px; }
  .letter-body{ padding-left: 1.25rem; padding-right: 0.5rem; }
  .btn{ padding: 11px 20px; font-size:14px; }
}

/* View Transition: carta se dobra saindo, sucesso entra como novo envelope */
@view-transition {
  navigation: none;
}
::view-transition-old(root){
  animation: 550ms cubic-bezier(.4,0,.6,1) letter-fold-out;
}
::view-transition-new(root){
  animation: 550ms cubic-bezier(.0,0,.2,1) letter-unfold-in;
}
@keyframes letter-fold-out{
  to { transform: perspective(600px) rotateX(20deg) scaleY(0); opacity: 0; }
}
@keyframes letter-unfold-in{
  from { transform: perspective(600px) rotateX(-20deg) scaleY(0); opacity: 0; }
}

@media (prefers-reduced-motion: reduce){
  .candle-glow, .btn-no.floating .btn-label, .polaroid-photo,
  .wax-seal-btn.holding, .wax-seal-btn.shattering, .seal-crack, .gold-particle{
    animation: none !important; transition: none !important;
  }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}


