/* DE AQUÍ · loading screen
   The pin draws its outline, fills with gold from the base up, catches a sheen,
   and pulses at its tip like a location marker until the page is ready. */

.loader {
  --l-azul: #0C2340;
  --l-dorado: #B08A28;
  --l-dorado-claro: #E2C27A;
  --l-ease: cubic-bezier(.16, 1, .3, 1);

  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--l-azul);
  color: var(--l-dorado-claro);
  transition: opacity .9s var(--l-ease), visibility 0s linear .9s;
}

.loader::after {                      /* same film grain as the site */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform .9s var(--l-ease);
}

.loader .pin {
  width: clamp(76px, 9vw, 104px);
  height: auto;
  overflow: visible;
}

/* 1 · outline draws itself */
.pin-line {
  fill: none;
  stroke: var(--l-dorado-claro);
  stroke-width: 5;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation:
    pin-draw 1.3s cubic-bezier(.65, 0, .35, 1) .15s forwards,
    pin-fade .5s ease-out 1.9s forwards;
}

/* 2 · gold fills from the base up */
.pin-rise {
  transform-box: fill-box;
  transform: translateY(100%);
  animation: pin-rise 1.1s var(--l-ease) .95s forwards;
}

/* 3 · a sheen crosses the pin once it is solid */
.pin-sheen {
  transform-box: fill-box;
  transform: translateX(0) skewX(-18deg);
  animation: pin-sheen 1.2s cubic-bezier(.4, 0, .2, 1) 2s forwards;
}

/* 4 · location ping at the tip while we wait */
.pin-ping {
  fill: none;
  stroke: var(--l-dorado-claro);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;   /* stays a crisp hairline while it grows */
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: pin-ping 1.8s cubic-bezier(.2, .6, .3, 1) 1.7s infinite;
}

.pin-ping.two { animation-delay: 2.6s; }

.loader-word {
  margin: 22px 0 0;
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 500;
  letter-spacing: .5em;
  padding-left: .5em;                 /* keeps the tracked word optically centred */
  color: var(--l-dorado-claro);
  opacity: 0;
  animation: word-in 1.4s var(--l-ease) 1.35s forwards;
}

.loader .sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@keyframes pin-draw  { to { stroke-dashoffset: 0; } }
@keyframes pin-fade  { to { opacity: 0; } }
@keyframes pin-rise  { to { transform: translateY(0); } }
@keyframes pin-sheen { to { transform: translateX(380%) skewX(-18deg); } }
@keyframes word-in   { to { opacity: 1; letter-spacing: .24em; padding-left: .24em; } }
@keyframes pin-ping {
  0%   { opacity: .8; transform: scale(.25); }
  100% { opacity: 0;  transform: scale(1.6); }
}

/* exit: the pin lifts a touch and the curtain fades */
.loader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader.is-done .loader-inner { transform: translateY(-10px) scale(.97); }

/* returning in the same visit: skip the drawing, show the finished pin */
.loader-quick .pin-line { display: none; }
.loader-quick .pin-rise { animation: none; transform: none; }
.loader-quick .pin-sheen { animation-delay: .1s; animation-duration: .9s; }
.loader-quick .loader-word { animation: none; opacity: 1; letter-spacing: .24em; padding-left: .24em; }
.loader-quick .pin-ping { animation-delay: .2s; }
.loader-quick .pin-ping.two { animation-delay: 1.1s; }

@media (prefers-reduced-motion: reduce) {
  .pin-line { display: none; }
  .pin-rise, .pin-sheen, .pin-ping, .loader-word { animation: none; }
  .pin-rise { transform: none; }
  .loader-word { opacity: 1; letter-spacing: .24em; padding-left: .24em; }
  .loader, .loader-inner { transition-duration: .4s; }
}
