/* Oller_Psicoesport — detalls de moviment ("avançar").
   Idea: els xebrons ›› del logo signifiquen avançar. Tot el que t'acosta a un servei
   respon fent un pas endavant. Tot és opcional: per treure-ho, elimina l'enllaç a aquest
   fitxer de src/_layout/head.html i torna a generar.
   Amb "reduir moviment" activat no es mou res; només queden els canvis de color. */

/* Programa 360°: un cercle complet al voltant de la icona (estàtic; l'animació el dibuixa) */
@property --op-arc{syntax:"<angle>";inherits:false;initial-value:360deg;}
#programa-360 .op-card__icon{position:relative;border-radius:50%;}
#programa-360 .op-card__icon::after{
  content:"";position:absolute;inset:-6px;border-radius:50%;
  background:conic-gradient(var(--brand-blue) var(--op-arc),transparent 0);
  -webkit-mask:radial-gradient(farthest-side,transparent calc(100% - 2px),#000 calc(100% - 2px));
  mask:radial-gradient(farthest-side,transparent calc(100% - 2px),#000 calc(100% - 2px));
}

/* Colors en hover (sense moviment): la icona de la targeta s'omple de blau */
a.op-card:hover .op-card__icon,
a.op-card:focus-visible .op-card__icon{background:var(--brand-blue);color:#FFFFFF;}

@media (prefers-reduced-motion: no-preference){

  /* 1. Els ›› fan un pas endavant en passar per sobre d'un enllaç, botó o targeta */
  .op-chev{display:inline-block;transition:transform .35s cubic-bezier(.16,1,.3,1);}
  a:hover .op-chev,
  a:focus-visible .op-chev{transform:translateX(5px);}

  .op-card__icon{transition:background-color .3s ease,color .3s ease;}
  .op-card__icon .i{transition:transform .6s cubic-bezier(.16,1,.3,1);}

  /* 2. Programa 360°: la icona fa mitja volta, com el nom del programa */
  a.op-card--featured:hover .op-card__icon .i,
  a.op-card--featured:focus-visible .op-card__icon .i{transform:rotate(180deg);}

  /* 3. El subratllat taronja del claim es dibuixa un sol cop, com una línia d'arribada */
  .hero__claim .accent{
    text-decoration:none;
    background-image:linear-gradient(var(--accent-energia),var(--accent-energia));
    background-repeat:no-repeat;
    background-position:0 92%;
    background-size:0% .09em;
    -webkit-box-decoration-break:clone;box-decoration-break:clone;
    padding-bottom:.08em;
    animation:op-finish-line 1s .45s cubic-bezier(.16,1,.3,1) forwards;
  }
  @keyframes op-finish-line{to{background-size:100% .09em;}}

  /* 4. Moment estrella: el camí de «Com treballo» es dibuixa.
     La línia blava avança d'esquerra a dreta pas a pas, i el número, el text i els ››
     apareixen quan la línia hi arriba. Només un cop, en arribar-hi fent scroll. */
  .js [aria-labelledby="proces-title"] .steps li{
    border-top-color:transparent;
    background:linear-gradient(var(--brand-blue),var(--brand-blue)) 0 0/0% 2px no-repeat;
  }
  .js [aria-labelledby="proces-title"] .steps li::before,
  .js [aria-labelledby="proces-title"] .steps li > *,
  .js [aria-labelledby="proces-title"] .steps li::after{opacity:0;transform:translateY(10px);}
  .js [aria-labelledby="proces-title"] .steps li::after{transform:translate(50%,-50%) translateX(-8px);}
  /* la transició només existeix en aparèixer: amagar-se en carregar és instantani */
  .js [aria-labelledby="proces-title"] .steps li.is-visible{background-size:100% 2px;transition-property:background-size;transition-duration:.45s;transition-timing-function:cubic-bezier(.16,1,.3,1);}
  .js [aria-labelledby="proces-title"] .steps li.is-visible::before,
  .js [aria-labelledby="proces-title"] .steps li.is-visible > *,
  .js [aria-labelledby="proces-title"] .steps li.is-visible::after{transition-property:opacity,transform;transition-duration:.4s,.5s;transition-timing-function:ease,cubic-bezier(.16,1,.3,1);}
  .js [aria-labelledby="proces-title"] .steps li.is-visible::before,
  .js [aria-labelledby="proces-title"] .steps li.is-visible > *{opacity:1;transform:none;}
  .js [aria-labelledby="proces-title"] .steps li.is-visible::after{opacity:1;transform:translate(50%,-50%);}
  /* ritme: línia 1 → text 1 → ›› → línia 2 → … (total ~1,1 s) */
  .js [aria-labelledby="proces-title"] .steps li:nth-child(1).is-visible::before,
  .js [aria-labelledby="proces-title"] .steps li:nth-child(1).is-visible > *{transition-delay:.2s;}
  .js [aria-labelledby="proces-title"] .steps li:nth-child(1).is-visible::after{transition-delay:.4s;}
  .js [aria-labelledby="proces-title"] .steps li:nth-child(2).is-visible{transition-delay:.35s;}
  .js [aria-labelledby="proces-title"] .steps li:nth-child(2).is-visible::before,
  .js [aria-labelledby="proces-title"] .steps li:nth-child(2).is-visible > *{transition-delay:.55s;}
  .js [aria-labelledby="proces-title"] .steps li:nth-child(2).is-visible::after{transition-delay:.75s;}
  .js [aria-labelledby="proces-title"] .steps li:nth-child(3).is-visible{transition-delay:.7s;}
  .js [aria-labelledby="proces-title"] .steps li:nth-child(3).is-visible::before,
  .js [aria-labelledby="proces-title"] .steps li:nth-child(3).is-visible > *{transition-delay:.9s;}

  /* 4c. Programa 360°: el cercle es tanca i la icona fa la volta quan la targeta entra a la pantalla */
  .js #programa-360 .op-card__icon::after{--op-arc:0deg;}
  .js #programa-360.is-visible .op-card__icon::after{animation:op-arc360 1s .25s cubic-bezier(.65,0,.35,1) forwards;}
  .js #programa-360.is-visible .op-card__icon .i{animation:op-spin360 1s .25s cubic-bezier(.65,0,.35,1);}
  @keyframes op-arc360{from{--op-arc:0deg;}to{--op-arc:360deg;}}
  @keyframes op-spin360{to{transform:rotate(360deg);}}

  /* 4d. Articles: la línia entre els passos 1 → 2 → 3 s'omple a mesura que llegeixes */
  @supports (animation-timeline: view()){
    .article ol.tips li:not(:last-child)::after{
      animation:op-fill-down linear both;
      animation-timeline:view();
      animation-range:entry 60% cover 65%;
    }
    @keyframes op-fill-down{from{transform:scaleY(0);}to{transform:scaleY(1);}}
  }

  /* 6. Desplegables: Serveis, respostes de Preguntes. Entren amb un lliscament curt; tanquen a l'instant */
  .nav__item--dd.is-open .nav__dd{animation:op-drop .2s cubic-bezier(.16,1,.3,1);}
  .faq details[open] .faq__body{animation:op-drop .22s cubic-bezier(.16,1,.3,1);}
  @keyframes op-drop{from{opacity:0;transform:translateY(-6px);}}
  @media (max-width:960px){
    .nav.is-open .nav__list > li,.nav.is-open .nav__tools{animation:op-drop .25s cubic-bezier(.16,1,.3,1) backwards;}
    .nav.is-open .nav__list > li:nth-child(2){animation-delay:.03s;}
    .nav.is-open .nav__list > li:nth-child(3){animation-delay:.06s;}
    .nav.is-open .nav__list > li:nth-child(4){animation-delay:.09s;}
    .nav.is-open .nav__list > li:nth-child(5){animation-delay:.12s;}
    .nav.is-open .nav__tools{animation-delay:.15s;}
  }

  /* 7. Transició entre pàgines: el contingut es fon i la capçalera queda quieta.
     Chrome, Edge i Safari; els altres navegadors canvien de pàgina com sempre. */
  @view-transition{navigation:auto;}
  .site-header{view-transition-name:site-header;}
  ::view-transition-old(root){animation:op-vt-out .18s ease both;}
  ::view-transition-new(root){animation:op-vt-in .3s cubic-bezier(.16,1,.3,1) both;}
  @keyframes op-vt-out{to{opacity:0;}}
  @keyframes op-vt-in{from{opacity:0;transform:translateY(8px);}}

  /* 5. El botó de trucada: el telèfon fa un petit "ring" en passar-hi per sobre */
  .op-btn[data-cal]:hover .i{animation:op-ring .5s ease-in-out;}
  @keyframes op-ring{
    0%,100%{transform:rotate(0);}
    20%{transform:rotate(-14deg);}
    40%{transform:rotate(12deg);}
    60%{transform:rotate(-8deg);}
    80%{transform:rotate(4deg);}
  }
}
