/* =========================================================================
   motion.css — sistema de movimento

   Regra fundamental: o conteúdo é visível por omissão. O estado oculto só é
   aplicado depois de o JavaScript marcar :root com .js-motion, garantindo que
   uma falha de script nunca esconde texto.

   Só se animam `transform`, `opacity`, `filter` e `clip-path` — nunca
   propriedades que forcem recálculo de layout.
   ========================================================================= */

/* ---------- 1 · Revelação ao entrar em campo de visão -------------------- */
:root.js-motion [data-reveal] {
  opacity: 0;
  will-change: transform, opacity;
}
:root.js-motion [data-reveal="up"]    { transform: translate3d(0, 26px, 0); }
:root.js-motion [data-reveal="fade"]  { transform: none; }
:root.js-motion [data-reveal="left"]  { transform: translate3d(-26px, 0, 0); }
:root.js-motion [data-reveal="right"] { transform: translate3d(26px, 0, 0); }
:root.js-motion [data-reveal="scale"] { transform: scale(.965); }

:root.js-motion [data-reveal].is-in {
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur-reveal) var(--ease-out),
    transform var(--dur-reveal) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
:root.js-motion [data-reveal].is-in { will-change: auto; }

/* ---------- 2 · Revelação de imagem por máscara -------------------------- */
:root.js-motion [data-reveal="mask"] {
  opacity: 1;
  overflow: clip;
  clip-path: inset(0 0 100% 0 round var(--radius-xl));
}
:root.js-motion [data-reveal="mask"] > img,
:root.js-motion [data-reveal="mask"] img { transform: scale(1.08); }
:root.js-motion [data-reveal="mask"].is-in {
  clip-path: inset(0 0 0 0 round var(--radius-xl));
  transition: clip-path 900ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
:root.js-motion [data-reveal="mask"].is-in img {
  transform: scale(1);
  transition: transform 1200ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

/* ---------- 3 · Revelação de título linha a linha ------------------------ */
.line-mask { display: block; overflow: hidden; padding-block-end: .08em; }
:root.js-motion .line-mask > span {
  display: block;
  transform: translate3d(0, 108%, 0);
}
:root.js-motion .is-in .line-mask > span,
:root.js-motion .line-mask.is-in > span {
  transform: none;
  transition: transform 860ms var(--ease-out);
  transition-delay: var(--line-delay, 0ms);
}

/* ---------- 4 · Traço do lápis sob os títulos ---------------------------- */
.pencil-rule { display: block; margin-block-start: var(--space-5); max-inline-size: 190px; }
.pencil-rule path {
  stroke-dasharray: var(--len, 200);
  stroke-dashoffset: var(--len, 200);
}
:root.js-motion .pencil-rule.is-in path,
:root.js-motion .is-in .pencil-rule path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1100ms var(--ease-out) 180ms;
}
:root:not(.js-motion) .pencil-rule path { stroke-dashoffset: 0; }

/* ---------- 5 · Coração que se desenha ----------------------------------- */
.heart-draw path {
  fill: none;
  stroke: currentColor;
  stroke-width: 6;
  stroke-linejoin: round;
  stroke-dasharray: var(--len, 4200);
  stroke-dashoffset: var(--len, 4200);
}
:root.js-motion .heart-draw.is-in path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 2200ms var(--ease-out);
}
:root:not(.js-motion) .heart-draw path { stroke-dashoffset: 0; }

/* ---------- 6 · Objectos flutuantes -------------------------------------- */
.float-obj {
  position: absolute;
  pointer-events: none;
  will-change: transform;
  --px: 0px; --py: 0px;       /* deslocação do ponteiro */
  --sy: 0px;                  /* deslocação do deslocamento vertical */
  transform: translate3d(var(--px), calc(var(--py) + var(--sy)), 0) rotate(var(--rot, 0deg));
  transition: transform 900ms var(--ease-out);
}
.float-obj--drift { animation: drift 9s ease-in-out infinite alternate; }
.float-obj--drift-slow { animation: drift 13s ease-in-out infinite alternate; }

@keyframes drift {
  from { translate: 0 0; rotate: 0deg; }
  to   { translate: 0 -12px; rotate: 2.2deg; }
}

/* ---------- 7 · Microinteracção de botões -------------------------------- */
.btn { transform: translateZ(0); }
.btn:active { transform: scale(.975); transition-duration: 90ms; }
.btn__arrow { transition: transform var(--dur) var(--ease); }
.btn:hover .btn__arrow { transform: translateX(4px); }

/* ---------- 8 · Inclinação de cartão sob o ponteiro ---------------------- */
.tilt {
  transform-style: preserve-3d;
  transition: transform var(--dur-slow) var(--ease-out);
}
.tilt > * { transform: translateZ(0); }

/* ---------- 9 · Marquise ------------------------------------------------- */
.marquee { overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent); mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent); }
.marquee__track { display: flex; inline-size: max-content; animation: marquee 44s linear infinite; }
.marquee:hover .marquee__track { animation-play-state: paused; }
@keyframes marquee { to { transform: translate3d(-50%, 0, 0); } }

/* ---------- 10 · Contador ------------------------------------------------- */
.count { font-variant-numeric: tabular-nums; }

/* ---------- 11 · Transição de entrada de página -------------------------- */
:root.js-motion .page-enter { animation: pageEnter 620ms var(--ease-out) both; }
@keyframes pageEnter {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================================
   MOVIMENTO REDUZIDO
   O sítio tem de continuar bonito sem uma única animação.
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  :root.js-motion [data-reveal],
  :root.js-motion [data-reveal="mask"] {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }
  :root.js-motion [data-reveal="mask"] img { transform: none !important; }
  :root.js-motion .line-mask > span { transform: none !important; }
  .pencil-rule path, .heart-draw path { stroke-dashoffset: 0 !important; }
  .float-obj { display: none !important; }
  .marquee__track { animation: none !important; transform: none !important; }
  :root.js-motion .page-enter { animation: none !important; }
  .tilt { transform: none !important; }
}

/* =========================================================================
   12 · Transição de página — folha que vira
   ========================================================================= */
.page-leaf {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  perspective: 1600px;
  perspective-origin: 0% 50%;
}
.page-leaf[hidden] { display: none !important; }
.page-leaf__sheet {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: rotateY(-100deg);
  background: linear-gradient(112deg, #FFFDF8 0%, #FFF4E2 54%, #FFEBCE 100%);
  box-shadow: 30px 0 80px rgba(8, 12, 30, .35);
  display: grid;
  place-items: center;
}
.page-leaf__mark {
  inline-size: clamp(110px, 16vw, 190px);
  color: var(--color-secondary);
  opacity: 0;
}
.page-leaf__mark svg { inline-size: 100%; block-size: auto; }

.page-leaf[data-state="turning"] .page-leaf__sheet {
  animation: leafTurn 420ms cubic-bezier(.5, .02, .3, 1) forwards;
}
.page-leaf[data-state="turning"] .page-leaf__mark {
  animation: leafMark 380ms var(--ease-out) 60ms forwards;
}
@keyframes leafTurn {
  from { transform: rotateY(-100deg); }
  to   { transform: rotateY(0deg); }
}
@keyframes leafMark {
  from { opacity: 0; transform: scale(.8); }
  to   { opacity: .9; transform: scale(1); }
}

/* =========================================================================
   13 · Perspectiva de entrada dos painéis-folha
   ========================================================================= */
:root.js-motion [data-reveal="sheet"] {
  opacity: 0;
  transform: perspective(1400px) rotateX(7deg) translate3d(0, 40px, 0) scale(.985);
  transform-origin: 50% 100%;
}
:root.js-motion [data-reveal="sheet"].is-in {
  opacity: 1;
  transform: none;
  transition: opacity 820ms var(--ease-out), transform 900ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

/* =========================================================================
   14 · Botão magnético (só com rato)
   ========================================================================= */
@media (hover: hover) and (pointer: fine) {
  .magnetic { transition: transform 320ms var(--ease-out); }
}

/* =========================================================================
   15 · Cartão com viragem 3D
   ========================================================================= */
.flip { perspective: 1200px; }
.flip__inner {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 720ms var(--ease-out);
  block-size: 100%;
}
.flip:hover .flip__inner,
.flip:focus-within .flip__inner { transform: rotateY(180deg); }
.flip__face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: inherit;
  overflow: hidden;
}
.flip__face--back { transform: rotateY(180deg); }

/* =========================================================================
   16 · Números
   ========================================================================= */
.price { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.price .price__n { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-primary-darker); }
.price small { font-size: .74em; font-weight: 600; color: var(--color-text-muted); }
.price-lg { margin-block-start: auto; padding-block-start: var(--space-4); }
.price-lg .price .price__n { font-size: var(--fs-h3); }
.table__note { display: block; font-size: var(--fs-tiny); font-weight: 400; color: var(--color-text-muted); margin-block-start: 2px; }
.iban { font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .page-leaf { display: none !important; }
  :root.js-motion [data-reveal="sheet"] { opacity: 1 !important; transform: none !important; }
  .flip__inner { transition: none !important; }
  .flip:hover .flip__inner { transform: none !important; }
  .magnetic { transform: none !important; }
}

/* =========================================================================
   17 · Ícones escolares em 3D, a flutuar em camadas
   ========================================================================= */
.obj3d {
  position: absolute;
  pointer-events: none;
  filter: drop-shadow(0 18px 26px rgba(20, 26, 54, .26));
  will-change: transform;
}
.obj3d svg { display: block; inline-size: 100%; block-size: auto; }
@media (max-width: 1023px) { .obj3d { display: none; } }
/* só aparecem quando há margem lateral suficiente para não tocarem no texto */
@media (max-width: 1379px) {
  .float-layer .obj3d { display: none; }
}
/* na folha escura do herói ganham um halo suave, para não se perderem no fundo */
.hero__sheet .obj3d { filter: drop-shadow(0 22px 30px rgba(8, 12, 30, .45)); }

/* =========================================================================
   18 · Profundidade por camadas — a secção respira em perspectiva
   ========================================================================= */
.depth { perspective: 1500px; perspective-origin: 50% 40%; }
.depth__layer { transform-style: preserve-3d; will-change: transform; }

/* =========================================================================
   19 · Mosaicos e cartões com relevo ao apontar
   ========================================================================= */
@media (hover: hover) and (pointer: fine) {
  .tile, .news-card, .card--link, .level-card {
    transform-style: preserve-3d;
  }
  .tile::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit;
    background: linear-gradient(135deg, rgba(255,255,255,.34), transparent 46%);
    opacity: 0; transition: opacity var(--dur-slow) var(--ease);
    pointer-events: none;
  }
  .tile:hover::after { opacity: 1; }
}

/* =========================================================================
   20 · Bordas de secção em curva — folhas que se sobrepõem
   ========================================================================= */
.curve-top, .curve-bottom { position: relative; }
.curve-top::before, .curve-bottom::after {
  content: ""; position: absolute; inset-inline: 0; block-size: 52px;
  background: inherit; pointer-events: none;
}
.curve-top::before { inset-block-start: -26px; border-radius: 50% 50% 0 0 / 52px 52px 0 0; }
.curve-bottom::after { inset-block-end: -26px; border-radius: 0 0 50% 50% / 0 0 52px 52px; }

/* =========================================================================
   21 · Brilho que segue o ponteiro nos painéis escuros
   ========================================================================= */
.spotlight { position: relative; overflow: hidden; }
.spotlight::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%),
              rgba(255, 255, 255, .11), transparent 62%);
  opacity: 0; transition: opacity var(--dur-slow) var(--ease);
}
.spotlight:hover::before { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .obj3d { display: none !important; }
  .depth__layer { transform: none !important; }
  .spotlight::before { display: none; }
}
