/* world.css: what lives in the water column. Light over the section backgrounds and under the text, the deep layer, the lane thread,
   the depth gauge, the pause control and the gap. No filters and no blend modes (SPEC 9). */

/* ---------- World: fixed, under .sec__inner, under the hero ---------- */
.world {
  display: none;
}

html.has-js .world {
  position: fixed;
  inset: 0;
  z-index: var(--z-world);
  display: block;
  overflow: hidden;
  pointer-events: none;
}

/* Wrapper opacities come from world.js (SPEC 1). At rest there is no light: no JS and reduced motion stay clean. */
.world-rays,
.world-caustics,
.world-deep,
.world-vignette,
.world-particles {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
}

/* All rays share the skew of the wrapper, so they are parallel and never add up on one pixel. The cap holds per ray. */
.world-rays {
  inset: -4% -18%;
  transform: skewX(-13deg);
}

/* Peak .30 (SPEC 2.2). Elliptical falloff: soft on both sides and down the shaft, with no mask and no blur. */
.world-ray {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9%;
  background: radial-gradient(50% 100% at 50% 0, rgba(220, 246, 247, .3) 0, rgba(220, 246, 247, .15) 46%, rgba(220, 246, 247, 0) 100%);
  will-change: transform, opacity;
}

.world-ray--1 {
  left: 7%;
}

.world-ray--2 {
  left: 24%;
  width: 7%;
}

.world-ray--3 {
  left: 41%;
  width: 11%;
}

.world-ray--4 {
  left: 62%;
  width: 6%;
}

.world-ray--5 {
  left: 78%;
  width: 10%;
}

.world-caustics {
  overflow: hidden;
  --tile: 512px;
}

/* Each layer runs one tile: it only needs that much spare on the side it comes from. */
.world-caustics__layer {
  position: absolute;
  background: url("/assets/img/caustics.svg") 0 0 / var(--tile) var(--tile);
  will-change: transform, opacity;
}

.world-caustics__layer--a {
  inset: calc(-1 * var(--tile)) 0 0 calc(-1 * var(--tile));
  opacity: .18;
}

.world-caustics__layer--b {
  inset: 0 calc(-1 * var(--tile)) calc(-1 * var(--tile)) 0;
  opacity: .1;
}

.world-vignette {
  background: radial-gradient(ellipse 78% 72% at 50% 46%, rgba(4, 24, 47, 0) 42%, rgba(4, 24, 47, .85) 100%);
}

.world-particles {
  width: 100%;
  height: 100%;
}

/* ---------- Deep: the pool seen from inside, below the blue bands ----------
   One large layer for Promociones and Tienda. All that lies behind text is DARKER than the band, so it can only raise the contrast of light
   text; light is spent on the walls, in the margins. Its opacity comes from world.js. */
.world-deep {
  overflow: hidden;
}

.world-deep__pool {
  position: absolute;
  top: -5%;
  left: 0;
  width: 100%;
  height: 110%;
  will-change: transform;
}

/* A far rope leaves each bottom corner along the foot of the wall. The wrapper is still; the floats run one period. */
.world-deep__rope {
  position: absolute;
  bottom: 0;
  width: 36vh;
  height: 7px;
  overflow: hidden;
  opacity: .12; /* with the mask, under .10 by the time it reaches the first text column */
  mask-image: linear-gradient(90deg, #000 25%, transparent);
}

.world-deep__rope--a {
  left: 0;
  transform: rotate(-57deg);
  transform-origin: 0 50%;
}

.world-deep__rope--b {
  right: 0;
  transform: rotate(57deg) scaleX(-1);
  transform-origin: 100% 50%;
}

.world-deep__floats {
  position: absolute;
  top: 0;
  right: -44px;
  bottom: 0;
  left: -44px;
  background: repeating-linear-gradient(90deg, var(--coral) 0 16px, transparent 16px 22px, var(--foam) 22px 38px, transparent 38px 44px);
  will-change: transform;
}

/* Out of focus: no outline, a soft rim. Kept to the edges of the frame, never behind a text column. */
.world-deep__bubble {
  position: absolute;
  top: 100%;
  width: var(--b);
  height: var(--b);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, rgba(220, 246, 247, .3) 0, rgba(220, 246, 247, .05) 42%, rgba(220, 246, 247, .2) 66%, rgba(220, 246, 247, 0) 72%);
  will-change: transform;
}

.world-deep__bubble--1 {
  left: -14px;
  --b: 76px;
}

.world-deep__bubble--2 {
  left: 4px;
  --b: 40px;
}

.world-deep__bubble--3 {
  left: -22px;
  --b: 58px;
}

.world-deep__bubble--4 {
  right: -18px;
  --b: 88px;
}

.world-deep__bubble--5 {
  right: 22px;
  --b: 44px;
}

.world-deep__bubble--6 {
  right: 2px;
  --b: 60px;
}

/* Light from above on each card: a gradient on the card itself, over its top padding, never an overlay on text. */
.sec--promos .promo-item[data-tone] {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .38) 0, rgba(255, 255, 255, 0) 26px);
}

.sec--shop .product-card {
  position: relative;
}

.sec--shop .product-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .62) 0, rgba(255, 255, 255, 0));
  pointer-events: none;
}

/* ---------- Thread: the lane. Down the left margin, along the floor, and a T right after the last word ---------- */
.thread {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--thread-x) - var(--line) / 2);
  z-index: var(--z-thread);
  width: var(--line);
  pointer-events: none;
  --flip: 24%;
  --line: 16px;       /* one tile of the lane */
  --bar-w: 32px;      /* the T: twice the line */
  --bar-l: 192px;     /* the longest it may be; world.js writes --bar-now */
  --floor-tile: 64px; /* the grid of .sec--contact */
  --lane-deep: var(--aqua-400);
  --grout: rgba(6, 33, 63, .34);
  --joint: calc(var(--line) * 3); /* a solid line first: the joints are only what tells it from a scrollbar */
}

/* A lane is laid in tiles: solid colour, a fine joint now and then. world.js clips it, so the joints stay put while it grows. */
.thread__stem {
  position: absolute;
  left: 0;
  width: 100%;
}

.thread__stem--shallow {
  top: 0;
  height: var(--flip);
  background: repeating-linear-gradient(180deg, var(--blue-700) 0 calc(var(--joint) - 1px), rgba(220, 246, 247, .4) calc(var(--joint) - 1px) var(--joint));
}

.thread__stem--deep {
  top: var(--flip);
  bottom: 0;
  border-bottom-left-radius: calc(var(--line) * .75);
  background: repeating-linear-gradient(180deg, var(--lane-deep) 0 calc(var(--joint) - 1px), var(--grout) calc(var(--joint) - 1px) var(--joint));
}

.thread__run,
.thread__plate {
  display: none;
}

.thread.is-laid .thread__run {
  position: absolute;
  bottom: 0;
  left: calc(var(--line) / 2);
  display: block;
  width: calc(var(--run-w) - var(--line) / 2);
  height: var(--line);
  background: repeating-linear-gradient(90deg, var(--lane-deep) 0 calc(var(--joint) - 1px), var(--grout) calc(var(--joint) - 1px) var(--joint));
  transform-origin: left center;
}

/* The tiles of the floor, lit around the T once it lands. world.js snaps the box to the grid of the section. */
.thread.is-laid .thread__plate {
  position: absolute;
  top: var(--plate-y);
  left: var(--plate-x);
  display: block;
  width: calc(var(--floor-tile) * 7 + 1px);
  height: calc(var(--floor-tile) * 5 + 1px);
  background:
    repeating-linear-gradient(180deg, rgba(191, 239, 242, .3) 0 1px, transparent 1px var(--floor-tile)),
    repeating-linear-gradient(90deg, rgba(191, 239, 242, .3) 0 1px, transparent 1px var(--floor-tile));
  opacity: 0;
  mask-image: radial-gradient(closest-side, #000 30%, transparent);
  transition: opacity var(--t-m);
}

.thread.is-landed .thread__plate {
  opacity: 1;
}

/* Without world.js the T stands where the line ends, across it, as wide as the margin allows. */
.thread__cross {
  position: absolute;
  bottom: 0;
  left: calc(var(--line) / 2 - var(--thread-x) + 8px);
  width: calc(var(--thread-x) * 2 - 16px);
  height: var(--bar-w);
  background: var(--foam);
}

.thread.is-laid .thread__cross {
  bottom: calc((var(--line) - var(--bar-now)) / 2);
  left: var(--run-w);
  width: var(--bar-w);
  height: var(--bar-now);
}

/* The one warm accent: the core lights when the lane lands, with «aquí.» */
.thread__cross::before {
  content: "";
  position: absolute;
  inset: calc(var(--bar-w) * .22);
  background: var(--sun);
  opacity: 0;
  transition: opacity var(--t-m);
}

.thread.is-landed .thread__cross::before {
  opacity: 1;
}

.thread__tip {
  display: none;
}

html.has-js .thread__tip {
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
  width: 0;
  height: 0;
  color: var(--blue-800);
  will-change: transform;
}

html[data-zone="deep"] .thread__tip {
  color: var(--foam);
}

.thread__dot {
  position: absolute;
  top: -11px;
  left: -11px;
  width: 22px;
  height: 22px;
  border: 3px solid currentColor;
  border-radius: 50%;
  background: var(--foam);
  transition: opacity var(--t-s);
}

.thread.is-home .thread__dot,
.thread.is-dry .thread__dot {
  opacity: 0;
}

.thread__ring {
  position: absolute;
  top: -36px;
  left: -36px;
  width: 72px;
  height: 72px;
  border: 3px solid currentColor;
  border-radius: 50%;
  opacity: 0;
}

@media (max-width: 767px) {
  .thread {
    left: calc(var(--thread-x) - var(--line) / 2 - 3px); /* 3 px further out: the text starts right next to it */
    --line: 8px;
    --bar-w: 18px;
    --bar-l: 76px;
    --floor-tile: 40px;
  }

  .thread__dot {
    top: -7px;
    left: -7px;
    width: 14px;
    height: 14px;
    border-width: 2px;
  }

  .thread__ring {
    top: -24px;
    left: -24px;
    width: 48px;
    height: 48px;
    border-width: 2px;
  }

  .world-caustics {
    --tile: 320px;
  }

  .world-deep__rope--a {
    transform: rotate(-78deg);
  }

  .world-deep__rope--b {
    transform: rotate(78deg) scaleX(-1);
  }

  .world-deep__bubble {
    --b: 44px;
    margin: 0 -16px;
  }

  .world-deep__bubble--2,
  .world-deep__bubble--5 {
    --b: 30px;
    margin: 0 -8px;
  }

  .world-deep__bubble--5 {
    right: 0;
  }
}

/* ---------- Gauge: capsule at the right edge ---------- */
.gauge {
  position: fixed;
  top: 50%;
  right: 10px;
  z-index: var(--z-gauge);
  display: none;
  width: 48px;
  padding: 6px 2px;
  border-radius: var(--r-pill);
  background: var(--navy-950); /* opaque: the full-bleed ropes pass behind it, not through it */
  box-shadow: inset 0 0 0 1px rgba(191, 239, 242, .18); /* the capsule keeps its edge on the navy of the deep end */
  transform: translateY(-50%);
  transition: opacity var(--t-s), visibility var(--t-s);
}

/* Keyboard users never tab into something invisible (SPEC 5.5). Without JS, and in the failsafe, it is simply there. */
html.has-js:not(.is-failsafe) .gauge:not(.is-shown) {
  opacity: 0;
  visibility: hidden;
}

.gauge__rope {
  position: absolute;
  top: 28px;
  bottom: 28px;
  left: 50%;
  width: 4px;
  margin-left: -2px;
  border-radius: var(--r-pill);
  background: repeating-linear-gradient(180deg, var(--coral) 0 8px, var(--paper) 8px 16px);
  opacity: .55;
}

.gauge-marker {
  position: absolute;
  top: 18px;
  left: 12px;
  z-index: 1;
  width: 24px;
  height: 20px;
  pointer-events: none;
  will-change: transform;
}

.gauge a {
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--white);
  text-decoration: none;
}

.gauge a::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--foam);
  transition: transform var(--t-xs);
}

.gauge a:hover::before,
.gauge a:focus-visible::before {
  transform: scale(1.5);
}

.gauge a[aria-current]::before {
  background: var(--coral);
}

/* Hidden, not removed: the label is still the name of the link. */
.gauge a span {
  position: absolute;
  top: 50%;
  right: calc(100% + 6px);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--navy-950);
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(8px, -50%);
}

/* The transition lives on the way in only: the name leaving the current stop would turn over in mid-air. */
.gauge a:hover span,
.gauge a:focus-visible span {
  z-index: 2;
  opacity: 1;
  transform: translate(0, -50%);
  transition: opacity var(--t-xs), transform var(--t-xs);
}

/* The current name stands on end, only where the gutter holds capsule and label. Narrower, it shows on hover and focus. */
@media (min-width: 1420px) {
  .gauge a[aria-current] span {
    right: calc(100% + 4px);
    padding: 10px 3px;
    font-size: .75rem;
    letter-spacing: .04em;
    opacity: 1;
    transform: translate(0, -50%) rotate(180deg);
    writing-mode: vertical-rl;
  }

  .gauge a[aria-current]:hover span,
  .gauge a[aria-current]:focus-visible span {
    transform: translate(0, -50%) rotate(180deg);
  }
}

@media (min-width: 1024px) and (min-height: 360px) {
  .gauge {
    display: block;
  }
}

/* ---------- Pause control (WCAG 2.2.2) ----------
   In the corner, over the gutter; on phones it hugs the edge, where only the ends of lines can reach it. If one does, world.js moves it up to
   the nearest free slot, or tucks it away when there is none: it stays in the Tab order and comes back with focus. */
.motion-toggle {
  position: fixed;
  right: clamp(0px, calc(var(--gutter) - 48px), 16px);
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: var(--z-toggle);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--navy-950);
  box-shadow: inset 0 0 0 1px rgba(191, 239, 242, .5); /* the ring of the gauge: it keeps its edge on navy */
  color: var(--white);
  cursor: pointer;
  transition: background-color var(--t-xs), opacity var(--t-s), transform var(--t-s);
}

.motion-toggle[hidden] {
  display: none;
}

.motion-toggle:hover {
  background: var(--navy-900);
}

.motion-toggle.is-tucked:not(:focus-visible) {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Gap: the thermocline, no text ---------- */
.depth-gap {
  position: relative;
  overflow: hidden;
}

.depth-gap::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(0deg, rgba(220, 246, 247, 0), rgba(220, 246, 247, .22) 50%, rgba(220, 246, 247, 0)) 19% 70% / 2px 46% no-repeat,
    linear-gradient(0deg, rgba(220, 246, 247, 0), rgba(220, 246, 247, .16) 50%, rgba(220, 246, 247, 0)) 53% 18% / 2px 38% no-repeat,
    linear-gradient(0deg, rgba(220, 246, 247, 0), rgba(220, 246, 247, .2) 50%, rgba(220, 246, 247, 0)) 81% 54% / 2px 52% no-repeat;
}

/* ---------- Reduced motion: still water, the finished line, nothing that moves by itself ---------- */
@media (prefers-reduced-motion: reduce) {
  .world-rays,
  .world-caustics,
  .world-particles,
  .world-deep__bubble,
  html.has-js .thread__tip {
    display: none;
  }

  .world-ray,
  .world-caustics__layer,
  .world-deep__pool,
  .world-deep__floats,
  .gauge-marker {
    will-change: auto;
  }
}
