/* Grupo RFI · Natal 2026 */
:root {
  --s: 1;          /* escala da cena (definida em js/main.js) */
  --sx: 0px;       /* posição X da cena */
  --sy: 0px;       /* posição Y da cena */
  --green: #0C2318;
  --red: #C8102E;
  --cream: #F6EFE3;
  --muted: #D9D0BF;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Archivo', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--green);
  color: var(--cream);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  touch-action: none;
}

img { display: block; }
p, h1, h2 { margin: 0; }

/* ---------- Neve ---------- */
.snow { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.snow i {
  position: absolute; top: 0;
  border-radius: 50%;
  background: var(--cream);
  animation: fall linear infinite;
}
@keyframes fall { from { transform: translateY(-30px); } to { transform: translateY(105vh); } }

/* ---------- Cena ---------- */
.stage {
  position: fixed; left: 0; top: 0; z-index: 3;
  width: 1280px; height: 720px;
  transform: translate(var(--sx), var(--sy)) scale(var(--s));
  transform-origin: 0 0;
  pointer-events: none;
}
.stage svg { overflow: visible; }
.ground { position: absolute; left: 0; bottom: 0; }

.year {
  position: absolute; right: 70px; top: 96px;
  font-family: var(--display); font-weight: 800; font-size: 260px; line-height: 1; letter-spacing: -0.04em;
  color: transparent; -webkit-text-stroke: 2px rgba(227, 38, 58, .4);
  transition: opacity .9s;
}

#pow span {
  position: relative;
  font-family: var(--display); font-weight: 800; font-size: 40px;
  color: #fff; letter-spacing: .02em; white-space: nowrap;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  transform: translate(140px, 24px) rotate(-8deg);
}

/* ---------- Carimbo ---------- */
.stamp {
  position: fixed; z-index: 4;
  left: calc(var(--sx) + 540px * var(--s));
  top: calc(var(--sy) + 240px * var(--s));
  padding: .18em .55em;
  border: max(3px, calc(5px * var(--s))) solid currentColor;
  border-radius: 12px;
  font-family: var(--display); font-weight: 800;
  font-size: max(20px, calc(44px * var(--s)));
  line-height: 1.1; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: rotate(-9deg) scale(1.6);
  transition: opacity .35s, transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
.stamp.is-on { opacity: 1; transform: rotate(-9deg) scale(1); }
.stamp--gold { color: #F2C14E; }
.stamp--red { color: #FF5A6A; }

/* ---------- Escuridão ---------- */
.dark {
  position: fixed; inset: 0; z-index: 5;
  background: #000; opacity: 0; pointer-events: none;
  transition: opacity 1.2s;
}
.dark.is-half { opacity: .55; }
.dark.is-full { opacity: 1; }

/* ---------- Herói ---------- */
.stage--hero { z-index: 6; opacity: 0; transition: opacity 1.4s; }
.stage--hero.is-on { opacity: 1; }
.hero-bg { position: absolute; inset: 0; transition: filter 1.6s; filter: brightness(.35) saturate(.7); }
.hero-bg.is-lit { filter: brightness(.6) saturate(.8); }

@keyframes shake { 0%,100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-16px) rotate(-6deg); } 75% { transform: translateX(16px) rotate(6deg); } }
@keyframes emerge { 0% { filter: brightness(0); transform: translateY(24px) scale(.96); } 60% { filter: brightness(.35); } 100% { filter: brightness(1); transform: none; } }
@keyframes jumpPunch { 0% { transform: translateY(440px); } 100% { transform: translateY(0); } }
@keyframes launch { 0% { transform: none; opacity: 1; } 100% { transform: translate(560px, -820px) rotate(600deg); opacity: 1; } }
@keyframes pow { 0% { transform: scale(0) rotate(-20deg); opacity: 0; } 40% { transform: scale(1.35) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes nudge { 0%,100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes twinkle { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- Suspense ---------- */
.suspense {
  position: fixed; inset: 0; z-index: 7;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center; pointer-events: none;
  opacity: 0; transform: scale(.96);
  transition: opacity 1s, transform 1.4s;
}
.suspense.is-on { opacity: 1; transform: none; }
.suspense__kicker { font-size: 15px; font-weight: 800; letter-spacing: .3em; text-transform: uppercase; color: #FF5A6A; min-height: 1em; }
.suspense__title { font-family: var(--display); font-weight: 800; font-size: clamp(34px, 6vw, 72px); line-height: 1.02; letter-spacing: -0.02em; }

/* ---------- Legenda ---------- */
.caption {
  position: fixed; z-index: 8;
  left: calc(var(--sx) + 80px * var(--s));
  top: calc(var(--sy) + 118px * var(--s));
  width: calc(760px * var(--s));
  display: flex; flex-direction: column; gap: max(8px, calc(12px * var(--s)));
  pointer-events: none;
  opacity: 0; transition: opacity .5s;
}
.caption.is-on { opacity: 1; }
.caption__kicker { font-size: max(12px, calc(15px * var(--s))); font-weight: 800; letter-spacing: .22em; text-transform: uppercase; color: #FF5A6A; }
.caption__title { font-family: var(--display); font-weight: 800; font-size: max(28px, calc(64px * var(--s))); line-height: 1; letter-spacing: -0.02em; }
.caption__sub { font-size: max(15px, calc(22px * var(--s))); line-height: 1.4; color: var(--muted); }
.caption__sub:empty { display: none; }

/* ---------- Painéis (intro e convite) ---------- */
.panel {
  position: fixed; inset: 0; z-index: 20;
  background: var(--cream); color: var(--green);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 110px 24px 96px; text-align: center; overflow: hidden;
  opacity: 0; pointer-events: none;
  transition: opacity .8s, transform .8s;
}
.panel.is-on { opacity: 1; pointer-events: auto; transform: none; }
.intro { transform: scale(1.04); }
.invite { transform: translateY(40px); }

.kicker { font-size: clamp(12px, 1.4vw, 15px); font-weight: 800; letter-spacing: .24em; text-transform: uppercase; color: var(--green); }

.intro__hand { position: absolute; left: 0; top: 24%; width: min(420px, 32vw); height: auto; transform: scaleX(-1); }
.intro__logo { height: clamp(70px, 11vw, 130px); width: auto; margin-bottom: 6px; }
.intro__title { font-family: var(--display); font-weight: 800; font-size: clamp(52px, 9vw, 108px); line-height: .95; letter-spacing: -0.03em; color: var(--red); }
.intro__sub { font-size: clamp(17px, 1.8vw, 22px); color: #4B5A50; }
.intro__hint { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 22px; font-size: 13px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.intro__hint svg { animation: nudge 1.4s ease-in-out infinite; }

.invite__logo { height: clamp(56px, 7vw, 80px); width: auto; margin-bottom: 8px; }
.invite__date { font-family: var(--display); font-weight: 800; font-size: clamp(60px, 10vw, 128px); line-height: .92; letter-spacing: -0.03em; color: var(--red); }
.invite__text { font-size: clamp(18px, 2.2vw, 28px); line-height: 1.35; color: var(--green); text-decoration-line: underline; max-width: 900px; }
.countdown { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; width: min(560px, 100%); margin-top: 10px; }
.countdown__box { padding: 18px 0 14px; border-radius: 16px; background: var(--red); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.countdown__value { font-family: var(--display); font-weight: 800; font-size: clamp(40px, 4.5vw, 56px); line-height: 1; color: var(--cream); font-variant-numeric: tabular-nums; }
.countdown__label { font-size: 12px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: #FBE3E6; }
.invite__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 16px; align-items: center; margin-top: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 28px; border: 0; border-radius: 999px;
  background: var(--green); color: var(--cream);
  font: 800 17px/1 var(--body); cursor: pointer;
  transition: transform .15s, background .2s;
}
.btn:hover { background: #17402c; }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.invite__small { font-size: 15px; color: #4B5A50; }
.credit {
  position: absolute; left: 0; right: 0; bottom: max(16px, env(safe-area-inset-bottom));
  font-family: 'Dancing Script', cursive; font-weight: 500; font-size: 20px; letter-spacing: .04em;
  color: #6B776F; text-align: center; pointer-events: none;
}
.credit__heart { display: inline-block; vertical-align: -1px; margin: 0 2px; color: var(--red); }
.invite__mario { position: absolute; left: 36px; bottom: 0; height: clamp(150px, 34vh, 300px); width: auto; }

/* ---------- Luzes ---------- */
.lights {
  position: fixed; left: 0; right: 0; top: 0; height: 110px; z-index: 25;
  pointer-events: none; transform-origin: 0 0;
  transition: transform .9s cubic-bezier(.2, .8, .2, 1), opacity .6s;
}
.lights__wire { position: absolute; left: 0; top: 0; width: 100%; height: 110px; overflow: visible; }
.lights__wire path { stroke: #1E3B2C; transition: stroke .6s; }
.lights.on-light .lights__wire path { stroke: #8A9A8F; }
.lights.is-fallen { transform: translateY(26px) rotate(1deg); }
.lights.is-hidden { opacity: 0; }
.bulbs { position: absolute; inset: 0; }
.bulb {
  position: absolute; width: 14px; height: 20px; margin-left: -7px; margin-top: 4px;
  border-radius: 7px 7px 9px 9px;
  background: var(--c); box-shadow: 0 0 14px var(--c);
  animation: twinkle var(--d) ease-in-out var(--dl) infinite;
  transition: opacity .6s, box-shadow .6s;
}
.bulb::before {
  content: ''; position: absolute; left: 3px; top: -5px; width: 8px; height: 7px;
  border-radius: 2px; background: #2B3A30;
}
.lights.is-fallen .bulb { opacity: .25; box-shadow: none; animation: none; }

/* ---------- Ecrã de carregamento ---------- */
.loader {
  position: fixed; inset: 0; z-index: 50;
  background: #E9EAE6; color: var(--cream);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  overflow: hidden; text-align: center;
  transition: opacity .6s .9s, visibility 0s 1.5s;
}
.loader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
/* Ao entrar: a imagem desfoca e só depois o ecrã desaparece */
.loader.is-done .loader__grinch { filter: blur(24px); transform: scale(1.06); }
.loader.is-done .loader__top { opacity: 0; transition: opacity .3s; }
.loader__grinch {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 40%;
  transition: filter 1.2s ease-in, transform 1.2s ease-in;
  animation: focusIn 1.6s cubic-bezier(.2, .7, .3, 1) .2s backwards;
}
/* Ao abrir: a imagem começa desfocada e ganha foco */
@keyframes focusIn { from { filter: blur(24px); transform: scale(1.06); } to { filter: blur(0); transform: scale(1); } }
.loader::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 30%; z-index: 1;
  background: linear-gradient(to top, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}
.loader__top {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 0 24px max(48px, 8vh);
}
.loader__logo { height: clamp(40px, 5vw, 54px); width: auto; padding: 8px 14px; border-radius: 12px; background: rgba(246, 239, 227, .92); box-sizing: content-box; }
.loader__title { font-family: var(--display); font-weight: 800; font-size: clamp(26px, 3.6vw, 40px); letter-spacing: -0.02em; color: var(--cream); text-shadow: 0 2px 12px rgba(0, 0, 0, .4); }
.loader__bar { width: min(280px, 70vw); height: 8px; border-radius: 999px; background: rgba(246, 239, 227, .25); overflow: hidden; }
.loader__bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--red); transition: width .3s ease-out; }
.loader__actions { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: rise .7s ease-out 1.3s both; }
.loader__actions[hidden] { display: none; }
.btn--red { background: var(--red); gap: 10px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.btn--red:hover { background: #A50D26; }
.loader__mute {
  min-height: 44px; padding: 0 16px; border: 0; background: transparent; cursor: pointer;
  font: 600 15px/1 var(--body); color: var(--cream); opacity: .85; text-decoration: underline; text-underline-offset: 3px;
}
.loader__mute:hover { opacity: 1; }
.loader__mute:focus-visible { outline: 3px solid #F2C14E; outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .loader__grinch { transition: none; animation: none; } .loader__actions { animation: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Navegação ---------- */
.dots {
  position: fixed; right: 18px; top: 50%; z-index: 30;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 2px;
}
.dots button {
  width: 28px; height: 28px; padding: 0; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.dots span { display: block; width: 8px; height: 8px; border-radius: 999px; background: #4E6B5A; transition: all .3s; }
body.is-light .dots span { background: #B9B0A0; }
.dots button[aria-current="step"] span { width: 10px; height: 22px; background: var(--red); }

.controls {
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); z-index: 30;
  display: flex; gap: 10px; align-items: center;
}
.controls__counter {
  margin-right: 4px; padding: 6px 10px; border-radius: 999px;
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--muted); background: rgba(12, 35, 24, .55);
}
body.is-light .controls__counter { color: #33443A; background: rgba(246, 239, 227, .7); }
.controls__btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--cream); background: var(--green);
  transition: transform .15s, opacity .2s;
}
.controls__btn--next { background: var(--red); }
.controls__btn--sound .icon-on { display: none; }
.controls__btn--sound[aria-pressed="true"] .icon-on { display: block; }
.controls__btn--sound[aria-pressed="true"] .icon-off { display: none; }
.controls__btn:active { transform: scale(.94); }
.controls__btn:disabled { opacity: .35; cursor: default; }
.controls__btn:focus-visible, .dots button:focus-visible { outline: 3px solid #F2C14E; outline-offset: 2px; }

/* ---------- Ecrãs verticais (telemóvel) ---------- */
@media (max-aspect-ratio: 1/1) {
  .caption { left: 20px; right: 20px; width: auto; top: max(104px, 13vh); }
  .caption__title { font-size: clamp(30px, 8.5vw, 46px); }
  .caption__sub { font-size: clamp(15px, 4.2vw, 19px); }
  .stamp { left: 50%; top: calc(var(--sy) - 4px); transform: translateX(-50%) rotate(-9deg) scale(1.6); font-size: clamp(18px, 5.4vw, 26px); }
  .stamp.is-on { transform: translateX(-50%) rotate(-9deg) scale(1); }
  .intro__hand { top: auto; bottom: 7%; width: 40vw; }
  .invite { padding-bottom: 150px; }
  .credit { bottom: 84px; font-size: 17px; }
  .invite__mario { left: 8px; height: 120px; }
}
@media (max-width: 700px) {
  .countdown { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .countdown__box { padding: 14px 0 10px; }
  .btn { width: 100%; }
  .invite__actions { flex-direction: column; width: 100%; }
}
@media (max-width: 700px), (max-height: 520px) {
  .dots { display: none; }
}
@media (max-height: 560px) and (min-aspect-ratio: 1/1) {
  .panel { padding-top: 70px; padding-bottom: 70px; gap: 8px; }
  .intro__logo { height: 60px; }
  .invite__mario { height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .snow { display: none; }
  .bulb { animation: none; }
}