:root {
  --navy: 11, 42, 82;
  --teal: 13, 148, 136;
  --cyan: 8, 145, 178;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
}

html { scroll-behavior: smooth; }
body { overflow-x: clip; }
::selection { background: rgba(var(--teal), 0.18); color: #0B2A52; }

/* =========================================================
   Left-to-right slow sliding system
   ========================================================= */
html .reveal {
  opacity: 0;
  transform: translate3d(calc(var(--dist, 110px) * -1), 0, 0);
  transition:
    opacity 1.9s ease var(--d, 0ms),
    transform 2.6s var(--ease-out) var(--d, 0ms);
  will-change: opacity, transform;
}
html .reveal.is-in { opacity: 1; transform: none; }

/* Curtain wipe, left edge to right edge */
html .wipe {
  clip-path: inset(-20% 100% -20% 0);
  transform: translate3d(-32px, 0, 0);
  transition:
    clip-path 2.4s var(--ease-io) var(--d, 0ms),
    transform 2.8s var(--ease-out) var(--d, 0ms);
}
html .wipe.is-in { clip-path: inset(-20% 0 -20% 0); transform: none; }

/* Lines drawn from left to right */
html .draw {
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 2.8s var(--ease-io) var(--d, 0ms);
}
html .draw.is-in { transform: scaleX(1); }

html .draw-y {
  transform: scaleY(0);
  transform-origin: center top;
  transition: transform 2.8s var(--ease-io) var(--d, 0ms);
}
html .draw-y.is-in { transform: scaleY(1); }

/* =========================================================
   Horizontal mode: vertical scroll drives a left-to-right track
   (html.is-h is set by JS with the same media query as the
   Tailwind "h:" screen)
   ========================================================= */
/* Slide mode (html.is-h, set by JS on every screen size).
   No page scroll: the track is fixed and moved one slide at a time. */
html.is-h,
html.is-h body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  scroll-behavior: auto;
}
html.is-h #hwrap { position: fixed; inset: 0; overflow: hidden; }
html.is-h #hstage { height: 100%; }
html.is-h #track { display: flex; height: 100%; width: max-content; touch-action: pan-y pinch-zoom; }
html.is-h #track > main { display: contents; }
html.is-h .hpanel { width: var(--vw, 100vw); height: 100%; flex-shrink: 0; }
html.is-h #progress-wrap { display: none; }
html.is-h #hud { display: block; }
html.is-h .reveal { transform: translate3d(var(--dist, 90px), 0, 0); }
html.is-h .reveal.is-in { transform: none; }
#track { will-change: transform; }

/* Phones, tablets and short screens: each slide fits the screen and its
   content scrolls vertically inside the slide when it is taller. */
@media not all and (min-width: 1024px) and (min-height: 620px) {
  html.is-h .hpanel {
    display: flex;
    flex-direction: column;
    min-height: 0 !important;
    padding: 84px 0 calc(96px + env(safe-area-inset-bottom)) !important;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  html.is-h .hpanel::-webkit-scrollbar { display: none; }
  html.is-h .slide-body { margin-top: auto; margin-bottom: auto; width: 100%; }
  html.is-h .slide-fill { flex: 1 1 auto; display: flex; flex-direction: column; }
  html.is-h .slide-fill > .wipe { flex: 1 1 auto; height: auto; }
  html.is-h .slides-hide { display: none !important; }
}
@media (max-width: 639px) {
  .hud-dot { display: none; }
}

.nudge { animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(7px); } }

.wheel-dot { animation: wheel 1.8s ease-in-out infinite; }
@keyframes wheel { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(5px); opacity: 0; } 100% { opacity: 0; } }

.hud-dot { transition: background-color 0.6s ease, transform 0.6s var(--ease-out), border-color 0.6s ease; }
.hud-dot.is-active { background-color: #0D9488; border-color: #0D9488; transform: translate(-50%, -50%) scale(1.35); }

/* =========================================================
   Background layers
   ========================================================= */
.blob {
  position: absolute;
  border-radius: 9999px;
  filter: blur(100px);
  opacity: 0.55;
  will-change: transform;
}
.blob-1 { width: 46vw; height: 46vw; left: -14vw; top: -12vw; background: #A7F3EC; animation: blob-1 46s ease-in-out infinite alternate; }
.blob-2 { width: 40vw; height: 40vw; left: 30vw; top: 30vh; background: #BAE6FD; animation: blob-2 54s ease-in-out infinite alternate; }
.blob-3 { width: 36vw; height: 36vw; left: -6vw; bottom: -18vw; background: #C7D7FE; animation: blob-3 50s ease-in-out infinite alternate; }
@keyframes blob-1 { to { transform: translate(55vw, 18vh) scale(1.15); } }
@keyframes blob-2 { from { transform: translate(-20vw, 0) scale(0.9); } to { transform: translate(40vw, -12vh) scale(1.1); } }
@keyframes blob-3 { to { transform: translate(70vw, -10vh) scale(1.2); } }

.bg-grid {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: -200px;
  background-image:
    linear-gradient(rgba(var(--navy), 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--navy), 0.06) 1px, transparent 1px),
    linear-gradient(rgba(var(--navy), 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--navy), 0.03) 1px, transparent 1px);
  background-size: 200px 200px, 200px 200px, 40px 40px, 40px 40px;
  animation: grid-pan 45s linear infinite;
  -webkit-mask-image: radial-gradient(ellipse at 50% 35%, #000 25%, transparent 85%);
          mask-image: radial-gradient(ellipse at 50% 35%, #000 25%, transparent 85%);
}
@keyframes grid-pan { to { background-position: 200px 0, 200px 0, 40px 0, 40px 0; } }

.bg-sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -24vw;
  width: 24vw;
  background: linear-gradient(90deg, transparent, rgba(var(--teal), 0.07) 70%, rgba(var(--teal), 0.12) 100%);
  animation: sweep 16s var(--ease-io) infinite;
}
@keyframes sweep { to { transform: translateX(150vw); } }

.plus {
  position: absolute;
  left: -4vw;
  top: var(--t);
  width: var(--s);
  height: var(--s);
  color: rgba(var(--teal), 0.35);
  animation: drift var(--dur) linear var(--delay) infinite;
}
@keyframes drift {
  from { transform: translateX(0) rotate(0deg); }
  to   { transform: translateX(112vw) rotate(180deg); }
}

/* =========================================================
   Components
   ========================================================= */
.panel {
  position: relative;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(var(--navy), 0.09);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 24px 48px -30px rgba(var(--navy), 0.28);
  transition: border-color 0.7s ease, box-shadow 0.7s ease, transform 0.7s var(--ease-out);
}
.panel-hover:hover {
  transform: translateX(6px);
  border-color: rgba(var(--teal), 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 30px 60px -30px rgba(var(--teal), 0.45);
}

/* Technical corner brackets */
.corners::before {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  border-radius: inherit;
  --c: rgba(var(--navy), 0.35);
  background:
    linear-gradient(var(--c), var(--c)) top left / 16px 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 1.5px 16px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 16px 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 1.5px 16px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 16px 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 1.5px 16px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 16px 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 1.5px 16px no-repeat;
  transition: opacity 0.7s ease;
}
.corners:hover::before { --c: rgb(var(--teal)); }

.ico {
  display: grid;
  place-items: center;
  border-radius: 0.85rem;
  background: linear-gradient(145deg, #ECFEFF, #F0FDFA);
  border: 1px solid rgba(var(--teal), 0.22);
  color: #0F766E;
  box-shadow: 0 10px 24px -14px rgba(var(--teal), 0.6);
}

.text-grad {
  background: linear-gradient(90deg, #0E7490 0%, #0D9488 35%, #0B2A52 70%, #0E7490 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  animation: text-flow 10s linear infinite;
}
@keyframes text-flow { from { background-position: 220% center; } to { background-position: 0% center; } }

/* Monitor */
.ecg-scroll { animation: ecg-right 1.6s linear infinite; }
@keyframes ecg-right { to { transform: translateX(120px); } }

.mon-sweep { animation: mon-sweep 4.5s linear infinite; }
@keyframes mon-sweep { to { transform: translateX(560px); } }

.bar-fill {
  position: relative;
  overflow: hidden;
  transform-origin: left center;
  animation: bar-in 2.8s var(--ease-io) var(--bd, 1s) both;
}
.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  transform: translateX(-100%);
  animation: bar-shine 3.6s ease-in-out calc(var(--bd, 1s) + 2.8s) infinite;
}
@keyframes bar-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes bar-shine { to { transform: translateX(100%); } }

.flow { stroke-dasharray: 4 10; animation: flow 2.8s linear infinite; }
.flow-slow { stroke-dasharray: 2 12; animation: flow 6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -140; } }

.bob { display: inline-flex; animation: bob 9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(12px, -6px); } }

.spin { animation: spin 40s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pulse-ring { transform-box: fill-box; transform-origin: center; animation: pulse-ring 3.4s ease-out infinite; }
@keyframes pulse-ring { from { transform: scale(0.5); opacity: 0.8; } to { transform: scale(2.6); opacity: 0; } }

.check-draw { stroke-dasharray: 40; stroke-dashoffset: 40; animation: check 5s var(--ease-io) infinite; }
@keyframes check { 0%, 15% { stroke-dashoffset: 40; } 45%, 85% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -40; } }

.pan-right { animation: pan-right 36s ease-in-out infinite alternate; }
@keyframes pan-right { from { transform: scale(1.16) translateX(-5%); } to { transform: scale(1.16) translateX(5%); } }

.scan-x { animation: scan-x 7s var(--ease-io) infinite; }
@keyframes scan-x { from { transform: translateX(-10%); } to { transform: translateX(1100%); } }

/* Ticker, moving left to right */
.ticker { -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.ticker-track { display: flex; width: max-content; animation: ticker 75s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateX(-50%); } to { transform: translateX(0); } }

/* Header */
.header-in { animation: header-in 1.8s var(--ease-out) both; }
@keyframes header-in { from { transform: translateX(-60px); opacity: 0; } to { transform: none; opacity: 1; } }
.nav-link.is-active { color: #0B2A52; }
.nav-link.is-active .nav-bar { transform: scaleX(1); }

/* =========================================================
   Reduced motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  html .reveal, html .wipe, html .draw, html .draw-y { opacity: 1 !important; transform: none !important; clip-path: none !important; }
}
