/* ==========================================================================
   Cena "casa-moldura": a marca da Lamont (moldura de porta com abertura no
   canto) vira uma casa com a porta que se abre. Compartilhada pelas duas LPs.
   ========================================================================== */

@layer ui {
  .hs {
    position: relative;
    inline-size: 100%;
    aspect-ratio: 320 / 440;
  }
  .hs__svg {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    overflow: visible;
  }

  /* Porta (HTML p/ ter perspectiva 3D confiável em todos os navegadores) */
  .hs__door {
    position: absolute;
    inset-inline-start: 27.17%;
    inset-block-start: 21.82%;
    inline-size: 46.4%;
    block-size: 70.2%;
    perspective: 900px;
    perspective-origin: 100% 50%;
  }
  .hs__leaf {
    --door: 64deg; /* estado final = porta aberta */
    position: absolute;
    inset: 0;
    transform-origin: 0 50%;
    transform: rotateY(var(--door));
    background: linear-gradient(90deg, #2a6b38, #1a4e28 55%, #11391d);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1), 0 0 30px rgb(0 0 0 / 0.35);
    border-radius: 2px;
  }
  .hs__panel {
    position: absolute;
    inset-inline: 16%;
    inset-block: 7% 56%;
    border-radius: 3px;
    box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.12), inset 0 0 14px rgb(0 0 0 / 0.25);
  }
  .hs__panel--b {
    inset-block: 48% 7%;
  }
  .hs__knob {
    position: absolute;
    inset-inline-end: 9%;
    inset-block-start: 52%;
    inline-size: 7%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fbe9a6, #e8ba22 55%, #a8800b);
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
  }
  .hs__lamp,
  .hs__beam {
    transition: opacity 1.2s var(--ease-out);
  }

  /* Estados com movimento permitido (--door é registrada em tokens.css) */
  @keyframes door-open {
    from { --door: 0deg; }
    to { --door: 64deg; }
  }
  @keyframes lamp-on {
    from { opacity: 0; }
  }
  @keyframes bar-y {
    from { scale: 1 0; }
  }
  @keyframes bar-x {
    from { scale: 0 1; }
  }
  @keyframes line-draw {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
  }
  @keyframes pop-in {
    from { opacity: 0; scale: 0.3; }
  }
  @keyframes float-a {
    0%, 100% { translate: 0 0; rotate: -12deg; }
    50% { translate: 0 -0.9rem; rotate: -7deg; }
  }
  @keyframes float-b {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -0.6rem; }
  }

  /* Montagem da moldura no hero (um único momento coreografado) */
  @media (prefers-reduced-motion: no-preference) {
    .hv .hs__bars .b {
      transform-box: fill-box;
    }
    .hv .b-l { transform-origin: 50% 0; animation: bar-y 0.95s var(--ease-out) 0.15s backwards; }
    .hv .b-t { transform-origin: 0 50%; animation: bar-x 0.8s var(--ease-out) 0.5s backwards; }
    .hv .b-r { transform-origin: 50% 0; animation: bar-y 0.8s var(--ease-out) 0.85s backwards; }
    .hv .b-b { transform-origin: 0 50%; animation: bar-x 0.7s var(--ease-out) 1.1s backwards; }
    .hv .hs__roof {
      stroke-dasharray: 1;
      animation: line-draw 1s var(--ease-out) 1.2s backwards;
    }
    .hv .hs__attic { transform-box: fill-box; transform-origin: center; animation: pop-in 0.6s var(--ease-spring) 2s backwards; }
    .hv .hs__room { animation: lamp-on 0.9s var(--ease-out) 0.5s backwards; }
    .hv .hs__lamp { animation: lamp-on 1.4s var(--ease-out) 1.7s backwards; }
    .hv .hs__beam { animation: lamp-on 1.6s var(--ease-out) 1.9s backwards; }
    .hv .hs__leaf { animation: door-open 1.7s var(--ease-spring) 1.45s backwards; }
  }

  /* ---------- Paralaxe sutil guiado pelo ponteiro ---------- */
  .parallax {
    translate: calc(var(--tx, 0) * var(--depth, 0) * 1px) calc(var(--ty, 0) * var(--depth, 0) * 1px);
    transition: translate 0.7s var(--ease-out);
  }

  /* ---------- Documento "Carta de crédito imobiliário" e pílulas flutuantes ----------
     Folha de papel (cantos retos, sem chip e sem número), com o logo no topo,
     os campos ilustrativos e o selo dourado "Contemplada" sobre o canto. */
  .doc {
    position: relative;
    display: grid;
    gap: 0.55em;
    padding: 1.05em 1.1em 1.25em;
    border-radius: 3px;
    background:
      linear-gradient(180deg, rgb(255 255 255 / 0.7), transparent 40%),
      linear-gradient(160deg, #fdfbf4, #f4efe0);
    color: var(--forest-900);
    font-size: clamp(0.56rem, 2.7cqw, 0.8rem);
    line-height: 1.2;
    box-shadow: 0 1px 0 rgb(255 255 255 / 0.8) inset, 0 32px 42px -24px rgb(0 0 0 / 0.75), 0 2px 6px rgb(0 0 0 / 0.18);
    rotate: -5deg;
  }
  /* filete duplo de documento oficial */
  .doc::before {
    content: "";
    position: absolute;
    inset: 0.45em;
    border: 1px solid rgb(185 142 12 / 0.55);
    box-shadow: inset 0 0 0 2px #faf6ea, inset 0 0 0 3px rgb(185 142 12 / 0.25);
    pointer-events: none;
  }
  .doc__logo {
    display: block;
    inline-size: 58%;
    block-size: auto;
  }
  .doc__title {
    margin: 0.35em 0 0.1em;
    padding-block-end: 0.5em;
    border-block-end: 1px solid rgb(19 55 26 / 0.16);
    font-size: 1.22em;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.12;
    text-wrap: balance;
  }
  .doc__fields {
    display: grid;
    gap: 0.5em;
    margin: 0;
  }
  .doc__field {
    display: grid;
    gap: 0.12em;
  }
  .doc__field dt {
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-600);
  }
  .doc__field dd {
    margin: 0;
    font-size: 1.12em;
    font-weight: 800;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
  }
  .doc__lines {
    display: grid;
    gap: 0.35em;
    margin-block-start: 0.2em;
    inline-size: 62%;
  }
  .doc__lines i {
    display: block;
    block-size: 0.3em;
    border-radius: 1em;
    background: rgb(19 55 26 / 0.12);
  }
  .doc__lines i:last-child {
    inline-size: 70%;
  }
  .doc__seal {
    position: absolute;
    inset-inline-end: -11%;
    inset-block-end: -9%;
    inline-size: 44%;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    rotate: 12deg;
    filter: drop-shadow(0 10px 12px rgb(0 0 0 / 0.38));
  }
  .doc__seal svg {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    overflow: visible;
  }
  .doc__seal span {
    position: relative;
    padding: 0.28em 0.5em;
    background: var(--forest-800);
    box-shadow: 0 0 0 1px rgb(247 224 143 / 0.6);
    color: var(--gold-200);
    font-size: 0.7em;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
  }
  /* legenda da ilustração, logo abaixo da composição do hero */
  .doc__cap {
    position: absolute;
    inset-inline: 0;
    inset-block-start: calc(100% + 0.6rem);
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.3;
    text-align: center;
    color: rgb(244 247 241 / 0.7);
  }

  .hv__pill {
    --ico: var(--forest-900);
    --ico-accent: var(--forest-700);
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 1.05rem 0.5rem 0.6rem;
    border-radius: var(--r-pill);
    background: var(--gold-500);
    color: var(--forest-900);
    font-weight: 800;
    font-size: clamp(0.72rem, 3.2cqw, 0.92rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.5), 0 22px 30px -16px rgb(0 0 0 / 0.65);
    max-inline-size: 15rem;
  }
  .hv__pill .ico {
    --ico-size: clamp(1.4rem, 6.5cqw, 1.9rem);
  }
  .hv__pill--light {
    background: #fff;
    --ico-accent: var(--gold-600);
  }

  /* ---------- Nó de diagrama (entradas do infográfico) ---------- */
  .pn {
    --ico: var(--forest-900);
    --ico-accent: var(--forest-800);
    min-inline-size: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.8rem 0.35rem;
    border-radius: var(--r-md);
    background: rgb(255 255 255 / 0.62);
    box-shadow: inset 0 0 0 1px rgb(12 34 18 / 0.16), 0 14px 20px -16px rgb(12 34 18 / 0.5);
    text-align: center;
    font-weight: 700;
    font-size: 0.76rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
    transition: background-color 0.3s var(--ease-out), transform 0.4s var(--ease-spring);
  }
  .pn .ico {
    --ico-size: 2.15rem;
  }
  @media (hover: hover) and (pointer: fine) {
    .pn:hover {
      background: #fff;
      transform: translateY(-3px);
    }
  }

  /* ---------- Lista de verificação ---------- */
  .checks {
    display: grid;
    gap: 1.05rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .checks li {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    font-size: var(--fs-lg);
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.01em;
  }
  .checks .tick {
    inline-size: 1.85rem;
    block-size: 1.85rem;
    margin-block-start: 0.05rem;
  }

  /* ---------- Porta do CTA final (abre conforme a seção entra) ---------- */
  .cta__door {
    inline-size: min(100%, 21rem);
    margin-inline: auto;
  }
  @media (prefers-reduced-motion: no-preference) {
    .js .cta__door:not(.is-in) .hs__leaf {
      --door: 0deg;
    }
    .js .cta__door:not(.is-in) :is(.hs__lamp, .hs__beam) {
      opacity: 0;
    }
    .cta__door.is-in .hs__leaf {
      animation: door-open 1.8s var(--ease-spring) 0.4s backwards;
    }
    .cta__door.is-in :is(.hs__lamp, .hs__beam) {
      animation: lamp-on 1.6s var(--ease-out) 0.5s backwards;
    }
    /* Onde há scroll-driven animations, a porta abre conforme a seção entra na tela */
    @supports ((animation-timeline: view()) and (animation-range: entry 0% cover 50%)) {
      .cta__door .hs__leaf,
      .cta__door.is-in .hs__leaf {
        --door: 0deg;
        animation: door-open linear both;
        animation-timeline: view();
        animation-range: entry 10% cover 52%;
      }
      .cta__door:not(.is-in) :is(.hs__lamp, .hs__beam),
      .cta__door.is-in :is(.hs__lamp, .hs__beam) {
        opacity: 1;
        animation: lamp-on linear both;
        animation-timeline: view();
        animation-range: entry 20% cover 52%;
      }
    }
  }

  /* Revela linhas de diagrama em varredura (independe do comprimento do traço) */
  @keyframes wipe-x {
    from { clip-path: inset(-8% 100% -8% -2%); }
    to { clip-path: inset(-8% -2% -8% -2%); }
  }
  @keyframes wipe-y {
    from { clip-path: inset(-2% -8% 100% -8%); }
    to { clip-path: inset(-2% -8% -2% -8%); }
  }

  /* ---------- Fotos ----------
     .ph          figura com a foto (pode levar data-reveal)
     .ph--frame   moldura dourada da marca: quatro barras, com a abertura no canto inferior direito
     .ph__pic     recorte da foto; o verniz verde/dourado faz a foto "morar" na paleta */
  .ph {
    --t: clamp(0.5rem, 0.3rem + 0.9vw, 0.8rem);
    position: relative;
    margin: 0;
    isolation: isolate;
  }
  .ph__pic {
    position: relative;
    display: block;
    overflow: hidden;
    block-size: 100%;
    border-radius: var(--ph-r, 0.35rem);
    background: var(--forest-800);
    box-shadow: 0 34px 50px -30px rgb(3 15 8 / 0.7);
  }
  .ph__pic picture {
    display: contents;
  }
  .ph__pic img {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    object-fit: cover;
    object-position: var(--ph-pos, 50% 40%);
    transition: scale 0.9s var(--ease-out);
  }
  .ph__pic::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
      linear-gradient(135deg, rgb(232 186 34 / 0.12), transparent 42%),
      linear-gradient(0deg, rgb(7 23 12 / 0.26), transparent 38%);
  }
  .ph--frame::before {
    content: "";
    position: absolute;
    inset: calc(var(--t) * -1);
    z-index: -1;
    --gold-bar: linear-gradient(135deg, #f7e08f, #e8ba22 55%, #c8970f);
    background:
      var(--gold-bar) left top / var(--t) 100% no-repeat,
      var(--gold-bar) left top / 100% var(--t) no-repeat,
      var(--gold-bar) right top / var(--t) 74% no-repeat,
      var(--gold-bar) left bottom / 76% var(--t) no-repeat;
  }
  @media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    .ph:hover .ph__pic img {
      scale: 1.035;
    }
  }
}
