/* =========================================
   NAVIDAD · GORRO DE PAPÁ NOEL EN LA P DEL LOGO
   Se carga desde el bloque "GORRO NAVIDAD" de fscustomhtml (displayHeader) en todas las páginas e idiomas.
   Solo CSS: pseudo-elemento ::before sobre el enlace del logo.
     .site-logo        logo de la tienda (templates/_partials/header.tpl)
     #_desktop_logo a  logo del checkout (templates/checkout/_partials/header.tpl)
   Ajustes: --gorro-x (horizontal), --gorro-y (cuánto sube, % de su altura), --gorro-w (ancho, % del logo).
   Origen: pedalmoto-navidad-elementos/02-gorro-logo/css/estilos.css
   ========================================= */

.site-logo,
#_desktop_logo a {
  /* Calculado sobre el SVG del logo (1998,6 × 384,9): la barra superior de la P va de x 55 a 215
     y su borde superior está al 18 % de la altura; el ala del gorro se apoya ahí */
  --gorro-x: 0%;
  --gorro-y: -50%;
  --gorro-w: 18%;
  position: relative;
}

.site-logo::before,
#_desktop_logo a::before {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
  left: var(--gorro-x);
  top: 0;
  width: var(--gorro-w);
  aspect-ratio: 120 / 100;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10' shape-rendering='crispEdges'%3E%3Cpath fill='%23B42A22' d='M1 8V6h1V5h1V4h1V3h1V2h2V1h3v2H9v4H6v1Z'/%3E%3Cpath fill='%2395221D' d='M8 3h1v4H6V6h2Z'/%3E%3Cpath fill='%23CAECFF' d='M0 8h4V7h5v2H4v1H0ZM9 2h1V1h1v1h1v2h-1v1h-1V4H9Z'/%3E%3C/svg%3E") no-repeat center / contain;
  /* El tema escala el SVG del logo en :hover (1.1) y :active (.95) desde su centro, con transición de .4s
     (theme.css: .site-logo:hover svg). El gorro escala igual y desde el mismo punto para no despegarse:
     - transform-origin = centro del logo expresado en % de la caja del gorro
       (x: 50% del logo / 18% = 277.78%; y: (384,9/1998,6)/2 del ancho / alto del gorro 15% = 64.2%).
       Si cambias --gorro-x o --gorro-w hay que recalcularlo.
     - el balanceo gira sobre el ala (30% 85% del gorro): translate al ala, rotate y vuelta
       (30% - 277.78% = -247.78%; 85% - 64.2% = 20.8%). */
  transform-origin: 277.78% 64.2%;
  transform: scale(1) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(0deg) translate(247.78%, -20.8%);
  transition: transform .4s ease-in-out;
}

.site-logo:hover::before {
  transform: scale(1.1) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(0deg) translate(247.78%, -20.8%);
  animation: pmx-gorro .9s ease-in-out;
}

.site-logo:active::before {
  transform: scale(.95) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(0deg) translate(247.78%, -20.8%);
  animation: none;
}

/* Checkout: el logo es una imagen sin escalado, solo balanceo */
#_desktop_logo a:hover::before {
  animation: pmx-gorro-fijo .9s ease-in-out;
}

/* Balanceo mientras acompaña el escalado del logo (la escala sigue la transición .4s del tema) */
@keyframes pmx-gorro {
  0% { transform: scale(1) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(0deg) translate(247.78%, -20.8%); }
  30% { transform: scale(1.08) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(-7deg) translate(247.78%, -20.8%); }
  65% { transform: scale(1.1) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(4deg) translate(247.78%, -20.8%); }
  100% { transform: scale(1.1) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(0deg) translate(247.78%, -20.8%); }
}

@keyframes pmx-gorro-fijo {
  0%, 100% { transform: scale(1) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(0deg) translate(247.78%, -20.8%); }
  30% { transform: scale(1) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(-7deg) translate(247.78%, -20.8%); }
  65% { transform: scale(1) translateY(var(--gorro-y)) translate(-247.78%, 20.8%) rotate(4deg) translate(247.78%, -20.8%); }
}

@media (prefers-reduced-motion: reduce) {
  .site-logo::before,
  #_desktop_logo a::before {
    transition: none;
  }

  .site-logo:hover::before,
  #_desktop_logo a:hover::before {
    animation: none;
  }
}
