/*
 * App feel · progress line, launch screen, arrival, photographs and press
 * feedback for the Infinity web apps (see public/app-feel.js).
 * Each app sets its own tint on :root:
 *   --af-tint        the progress line and launch stroke
 *   --af-splash-bg   launch background
 *   --af-splash-ink  launch wordmark
 * INF OS falls back to the Obsidyen ion accent.
 */
:root {
  --af-tint: var(--color-accent, #5EF0D6);
  --af-tint-2: var(--color-violet, #A68CFF);
  --af-splash-bg: var(--color-paper, #07090E);
  --af-splash-ink: var(--color-ink, #EEF2F8);
  --af-ease: cubic-bezier(.2, .8, .2, 1);
  --af-progress: 0;
}

/* ---------- Progress line ---------- */
.af-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 2147483000;
  pointer-events: none;
  opacity: 0;
  transition: opacity .32s var(--af-ease);
}
.af-progress.on { opacity: 1; }
.af-progress i {
  display: block;
  height: 2px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(var(--af-progress));
  background: linear-gradient(90deg, var(--af-tint-2), var(--af-tint) 70%, #fff);
  box-shadow: 0 0 10px var(--af-tint), 0 0 2px var(--af-tint);
  transition: transform .26s var(--af-ease);
}
.af-standalone .af-progress { top: env(safe-area-inset-top, 0px); }

/* ---------- Launch screen ---------- */
.af-splash {
  position: fixed;
  inset: 0;
  z-index: 2147482000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  background: var(--af-splash-bg);
  color: var(--af-splash-ink);
  transition: opacity .48s var(--af-ease), visibility 0s linear .48s;
}
.af-splash-out { opacity: 0; visibility: hidden; pointer-events: none; }
.af-splash-out .af-splash-mark { transform: scale(1.06); }
.af-splash-mark {
  width: 96px;
  height: 48px;
  overflow: visible;
  transition: transform .52s var(--af-ease);
}
.af-splash-mark path {
  fill: none;
  stroke: var(--af-tint);
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: af-draw 1.6s var(--af-ease) .1s forwards, af-glow 2.88s ease-in-out 1.7s infinite;
}
.af-splash-mark path + path {
  stroke: var(--af-splash-ink);
  opacity: .12;
  animation: none;
  stroke-dashoffset: 0;
}
.af-splash-word {
  font: 400 13px/1 var(--font-mono, ui-monospace, monospace);
  letter-spacing: .42em;
  text-indent: .42em;
  text-transform: uppercase;
  opacity: 0;
  animation: af-fade .72s var(--af-ease) .5s forwards;
}
.af-splash-word small {
  display: block;
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: .5em;
  opacity: .6;
}
.af-splash-track {
  width: 112px;
  height: 1px;
  background: color-mix(in srgb, var(--af-splash-ink) 14%, transparent);
  overflow: hidden;
  opacity: 0;
  animation: af-fade .5s var(--af-ease) .8s forwards;
}
.af-splash-track i {
  display: block;
  height: 100%;
  background: var(--af-tint);
  transform-origin: 0 50%;
  transform: scaleX(max(.08, var(--af-progress)));
  transition: transform .3s var(--af-ease);
}
@keyframes af-draw { to { stroke-dashoffset: 0; } }
@keyframes af-glow { 50% { filter: drop-shadow(0 0 6px var(--af-tint)); } }
@keyframes af-fade { to { opacity: 1; } }

/* ---------- Arrival on a route change ---------- */
.af-enter > * { animation: af-rise .48s var(--af-ease) both; }
.af-enter > :nth-child(2) { animation-delay: 40ms; }
.af-enter > :nth-child(3) { animation-delay: 80ms; }
.af-enter > :nth-child(n+4) { animation-delay: 120ms; }
@keyframes af-rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Photographs ---------- */
img.af-img { opacity: 0; transition: opacity .56s var(--af-ease); }
img.af-img.af-img-in { opacity: 1; }

/* ---------- Press feedback (touch screens) ---------- */
.af-touch :is(button, .button, .btn, [role="button"], .mobile-nav a, .nav-link):not(:disabled):active {
  scale: .97;
}
.af :is(button, a, [role="button"]) { -webkit-tap-highlight-color: transparent; }
.af-touch body { overscroll-behavior-y: none; }

@media (prefers-reduced-motion: reduce) {
  .af-splash-mark path { animation: none; stroke-dashoffset: 0; }
  .af-splash-word, .af-splash-track { animation: none; opacity: 1; }
  .af-enter > * { animation: none; }
  .af-progress i { transition: none; }
  .af-touch :is(button, .button, .btn, [role="button"], .mobile-nav a, .nav-link):active { scale: none; }
}
@media (forced-colors: active) {
  .af-progress i, .af-splash-track i { background: Highlight; box-shadow: none; }
  .af-splash-mark path { stroke: CanvasText; }
}
@media print { .af-progress, .af-splash { display: none !important; } }
