/*!
 * TeaLabs — language switch "Phase change" (pairs with js/langfx.js).
 * Departure: the visible words evaporate into glyph vapour, glide to their mirrored side and
 * condense into the other language behind a cobalt phase front travelling in the NEW reading
 * direction. Arrival: the front completes its run, display lines lock in, the island confirms.
 * Everything here lives on an aria-hidden overlay (.lfx) or only recolours real nodes
 * (.lfx-hide = color:transparent), so screen readers only ever meet the real text.
 */

/* Cross-document swap: the two pre-rendered pages are near-identical frames, so a short root
   crossfade is enough. The island holds still across it (its vial already shows the target). */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 220ms; animation-timing-function: var(--ease); }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 150ms; animation-timing-function: linear; }
}
.island { view-transition-name: tl-island; }
::view-transition-group(tl-island) { animation-duration: 0s; }

/* ------------------------------------------------------------- overlay */
.lfx {
  position: fixed;
  inset: 0;
  z-index: var(--z-lfx, 90);
  pointer-events: none;
  overflow: hidden;
  contain: layout paint;
}

/* Blueprint tint shown while the front crosses: the site's grid, in cobalt. */
.lfx__grid {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image:
    linear-gradient(to right, rgba(46, 107, 124, .07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(46, 107, 124, .07) 1px, transparent 1px);
  background-size: var(--grid-pitch, 56px) var(--grid-pitch, 56px);
}

/* Phase front: a 1px cobalt line (at the box's inline-right edge) with a liquid wave edge and a
   64px trailing tint behind it. Drawn for left-to-right travel; js mirrors it with scaleX(-1). */
.lfx__front {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -76px;
  width: 77px;
  transform-origin: calc(100% - .5px) 50%;
  will-change: transform;
}
.lfx__front::before { /* trailing tint */
  content: "";
  position: absolute;
  inset: 0 13px 0 0;
  background: linear-gradient(to left, rgba(46, 107, 124, .10), rgba(46, 107, 124, 0));
}
.lfx__front::after { /* the line itself */
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 1px;
  background: var(--liquid, #2e6b7c);
  box-shadow: 0 0 14px 1px rgba(46, 107, 124, .45);
}
.lfx__wave { /* 12px liquid edge: the shared --wave tile, rotated 90deg so its crests face the travel */
  position: absolute;
  top: 0;
  bottom: 0;
  right: 1px;
  width: 12px;
  overflow: hidden;
}
.lfx__wave::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12px;
  width: 140vh;
  height: 12px;
  transform-origin: 0 0;
  transform: rotate(90deg);
  background: linear-gradient(to bottom, var(--liquid-top, #5b97a6), var(--liquid, #2e6b7c));
  opacity: .28;
  -webkit-mask: var(--wave, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 24'%3E%3Cpath d='M0 12Q32 -4 64 12T128 12T192 12T256 12V24H0Z' fill='%23000'/%3E%3C/svg%3E")) 0 0 / 128px 12px repeat-x;
  mask: var(--wave, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 24'%3E%3Cpath d='M0 12Q32 -4 64 12T128 12T192 12T256 12V24H0Z' fill='%23000'/%3E%3C/svg%3E")) 0 0 / 128px 12px repeat-x;
}

/* ------------------------------------------------------------- clones */
.lfx__c {
  position: absolute;
  margin: 0;
  padding: 0;
  white-space: normal;
  overflow-wrap: break-word;
  will-change: transform;
}
.lfx__c .n { color: var(--accent, #2e6b7c); } /* the frontier: the 3 glyphs currently changing */
.lfx__c .hl { color: var(--accent, #2e6b7c); } /* final frame of the H1: the accent line in cobalt */
.lfx__c .ln { display: block; }

/* Residual lock (arrival): noise glyphs sit on a patch of the page colour so they replace,
   rather than overprint, the real last characters for two frames. */
.lfx__c--lock .s { color: transparent; }
.lfx__c--lock .n { background: var(--lfx-bg, transparent); }

/* ------------------------------------------------------------- real nodes during departure */
/* Only recoloured: they keep their layout and stay in the accessibility tree. */
.lfx-hide,
.lfx-hide * {
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  text-shadow: none !important;
}
.lfx-hide .hl { opacity: 0 !important; } /* the hero's liquid accent line paints with backgrounds */

/* Text beyond the clone budget only gets the vapour treatment. */
.lfx-vapor {
  animation: lfx-vapor 320ms var(--ease) var(--lfx-d, 0ms) both;
}
@keyframes lfx-vapor {
  to { opacity: .18; filter: blur(2px); transform: translateY(-3px); }
}

/* Untranslated Latin (project names, tags, the eyebrow) twitches as the front passes. */
.lfx-flick {
  animation: lfx-flick 80ms steps(2, jump-none) var(--lfx-d, 0ms) both;
}
@keyframes lfx-flick {
  0%, 100% { transform: none; opacity: 1; }
  50% { transform: translateX(calc(1px * var(--dir, 1))); opacity: .8; }
}

/* An open sheet is closed instantly at departure. */
html.lfx-snap body * { transition: none !important; }

/* Fallback vial when the island does not draw its own: a cobalt droplet that pours from the
   current language to the target one. */
.lfx-vial {
  position: fixed;
  background: var(--liquid, #2e6b7c);
  color: #FFFFFF;
}
.lfx-vial span {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.lfx-lang-off,
.lfx-lang-off::before,
.lfx-lang-off::after { background: transparent !important; box-shadow: none !important; }

/* Arrival confirmation chip (fallback when the island does not show its own status row). */
.lfx-chip {
  position: fixed;
  z-index: var(--z-lfx, 90);
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--island, #0d1b21);
  color: var(--island-ink-hi, #FFFFFF);
  box-shadow: var(--island-shadow, 0 18px 40px -18px rgba(13, 27, 33, .45));
  font: 500 11px/1 var(--mono, ui-monospace, monospace);
  letter-spacing: .08em;
  white-space: nowrap;
}
.lfx-chip b { font-weight: 500; color: var(--liquid-top, #5b97a6); }

/* Keyboard switch: focus restored on arrival keeps the site's focus ring. */
.lfx-kb { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Arrival renders settled: no scroll-reveal travel or delays. */
html.lang-arrive [data-reveal] {
  transition: none !important;
  opacity: 1 !important;
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .lfx-vapor, .lfx-flick { animation: none; }
}
