/* MDI shared motion layer: progress bar, staggered reveals, card spotlight,
   magnetic buttons, cross-page transitions, and the home "Sound familiar?" ticker.
   Everything here is decorative and switches off under prefers-reduced-motion. */

:root {
  --mdi-motion-lime: #b9ff3b;
  --mdi-ease-out: cubic-bezier(.22, 1, .36, 1);
}

/* ---- Scroll progress ---- */
.mdi-scroll-progress {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(185, 255, 59, 0), var(--mdi-motion-lime) 40%, #e6ffb8);
  box-shadow: 0 0 12px rgba(185, 255, 59, .55);
  transform-origin: 0 50%;
  transform: scaleX(var(--mdi-progress, 0));
}

/* ---- Staggered reveal (uses the independent `translate` property so card hover transforms keep working) ---- */
.mdi-reveal { opacity: 0; translate: 0 26px; }
.mdi-reveal.is-in { animation: mdi-rise .8s var(--mdi-ease-out) var(--mdi-reveal-delay, 0ms) both; }
@keyframes mdi-rise {
  from { opacity: 0; translate: 0 26px; filter: blur(4px); }
  to { opacity: 1; translate: 0 0; filter: blur(0); }
}

/* ---- Cursor spotlight on cards ---- */
.mdi-spot {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(260px circle at var(--mdi-spot-x, 50%) var(--mdi-spot-y, 50%), rgba(214, 255, 150, .11), transparent 62%);
  transition: opacity .35s ease;
}
.mdi-spot-host { isolation: isolate; }
.mdi-spot-host:hover > .mdi-spot { opacity: 1; }
.principle-card-lime > .mdi-spot,
.principle-card-orange > .mdi-spot {
  background: radial-gradient(260px circle at var(--mdi-spot-x, 50%) var(--mdi-spot-y, 50%), rgba(255, 255, 255, .28), transparent 62%);
}

/* ---- Magnetic buttons ---- */
.mdi-magnetic { translate: var(--mdi-mag-x, 0) var(--mdi-mag-y, 0); transition: translate .45s var(--mdi-ease-out); }
.mdi-magnetic.is-pulling { transition-duration: .12s; }

/* ---- Cross-page transitions (supported browsers only) ---- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: mdi-page-out .22s ease both; }
  ::view-transition-new(root) { animation: mdi-page-in .38s var(--mdi-ease-out) both; }
  .site-nav .nav-pill { view-transition-name: mdi-nav; }
}
@keyframes mdi-page-out { to { opacity: 0; } }
@keyframes mdi-page-in { from { opacity: 0; translate: 0 10px; } }

/* ---- Home: journey line that fills while scrolling ---- */
.journey-track::after {
  content: "";
  position: absolute;
  top: 29px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--mdi-motion-lime), #e6ffb8);
  box-shadow: 0 0 10px rgba(185, 255, 59, .7);
  transform-origin: 0 50%;
  transform: scaleX(var(--journey-progress, 0));
  pointer-events: none;
}
.journey-step .step-node { transition: background-color .4s ease, box-shadow .4s ease; }
.journey-step.is-passed .step-node { background: var(--mdi-motion-lime); box-shadow: 0 0 0 5px var(--ink, #0b0c0a), 0 0 17px var(--mdi-motion-lime); }
.journey-step.is-passed h3 { color: var(--paper, #eef2e8); }
@media (max-width: 650px) {
  .journey-track::after { top: 20px; bottom: 0; left: 4px; right: auto; width: 1px; height: auto; transform-origin: 50% 0; transform: scaleY(var(--journey-progress, 0)); }
}

/* ---- Home: "Sound familiar?" ticker ---- */
.mdi-familiar {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin: 0;
  padding: 14px 14px 14px 22px;
  border: 1px solid rgba(220, 225, 213, .11);
  border-radius: 22px;
  box-shadow: inset 0 1px rgba(255, 255, 255, .05), 0 20px 50px -30px rgba(0, 0, 0, .8);
  background: linear-gradient(90deg, rgba(185, 255, 59, .045), rgba(220, 225, 213, .015) 40%, rgba(185, 255, 59, .03));
}
.mdi-familiar-label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--mdi-motion-lime);
  font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .14em;
  white-space: nowrap;
}
.mdi-familiar-label i { width: 6px; height: 6px; border-radius: 50%; background: var(--mdi-motion-lime); box-shadow: 0 0 12px var(--mdi-motion-lime); animation: mdi-blink 2.4s ease-in-out infinite; }
@keyframes mdi-blink { 50% { opacity: .35; } }
.mdi-marquee {
  overflow: hidden;
  display: flex;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
.mdi-marquee-track {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
  margin: 0;
  padding: 0 12px 0 0;
  list-style: none;
  animation: mdi-marquee 48s linear infinite;
}
.mdi-marquee:hover .mdi-marquee-track,
.mdi-familiar.is-paused .mdi-marquee-track { animation-play-state: paused; }
.mdi-marquee-track li {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 15px;
  border: 1px solid rgba(220, 225, 213, .13);
  border-radius: 999px;
  background: rgba(16, 19, 14, .7);
  color: #d5dccd;
  font-size: 13px;
  white-space: nowrap;
}
.mdi-marquee-track li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: rgba(185, 255, 59, .55); }
.mdi-marquee-track li.is-answer { border-color: rgba(185, 255, 59, .45); background: rgba(185, 255, 59, .1); color: #ecffcc; font-weight: 600; }
.mdi-marquee-track li.is-answer::before { background: var(--mdi-motion-lime); box-shadow: 0 0 8px var(--mdi-motion-lime); }
@keyframes mdi-marquee { to { transform: translateX(-100%); } }
.mdi-familiar-pause {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(220, 225, 213, .16);
  border-radius: 50%;
  background: transparent;
  color: #cfd6c7;
  font-size: 12px;
  transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.mdi-familiar-pause:hover { border-color: var(--mdi-motion-lime); color: var(--mdi-motion-lime); background: rgba(185, 255, 59, .08); }
@media (max-width: 650px) {
  .mdi-familiar { grid-template-columns: minmax(0, 1fr) auto; padding: 14px; gap: 12px; border-radius: 18px; }
  .mdi-familiar-label { grid-column: 1 / -1; }
  .mdi-marquee-track li { font-size: 12px; }
}

/* ---- Reduced motion: show everything, stop everything ---- */
@media (prefers-reduced-motion: reduce) {
  .mdi-reveal { opacity: 1; translate: none; }
  .mdi-scroll-progress, .mdi-spot { display: none; }
  .mdi-magnetic { translate: none; }
  .journey-track::after { display: none; }
  .mdi-marquee { -webkit-mask-image: none; mask-image: none; }
  .mdi-marquee-track { animation: none; flex-wrap: wrap; flex: 1 1 auto; padding: 0; }
  .mdi-marquee-track[aria-hidden="true"], .mdi-familiar-pause { display: none; }
  .mdi-familiar-label i { animation: none; }
}

/* =====================================================================
   3D layer: hero depth, card tilt, chart drawing, and chart fixes.
   ===================================================================== */

/* Charts wait until they scroll into view before drawing (only when JS runs). */
.mdi-js [data-draw]:not(.is-drawn) *,
.mdi-js [data-draw]:not(.is-drawn) { animation-play-state: paused !important; }

/* ---- Home hero: tilting 3D preview over a moving grid floor ---- */
.workspace-stage { position: relative; transform-style: preserve-3d; }
.workspace-preview {
  transform:
    perspective(1600px)
    rotateX(calc(var(--hero-rx, 0deg) + var(--hero-scroll, 0) * 9deg))
    rotateY(calc(-4deg + var(--hero-ry, 0deg)))
    scale(calc(1 - var(--hero-scroll, 0) * .035));
  transform-origin: 50% 60%;
  box-shadow:
    0 35px 100px rgba(0, 0, 0, .42),
    calc(var(--hero-ry, 0deg) / 1deg * -2.4px) 26px 60px -20px rgba(116, 174, 54, .22),
    inset 0 1px 0 rgba(255, 255, 255, .1);
}
.workspace-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(calc(115deg + var(--hero-ry, 0deg) * 6), rgba(255, 255, 255, 0) 30%, rgba(236, 255, 205, .075) 48%, rgba(255, 255, 255, 0) 62%);
  mix-blend-mode: screen;
}
.mdi-depth-floor {
  position: absolute;
  z-index: 0;
  left: 0;
  right: 0;
  bottom: -9%;
  height: 58%;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(185, 255, 59, .2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(185, 255, 59, .16) 1px, transparent 1px);
  background-size: 52px 52px;
  transform: perspective(480px) rotateX(66deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: radial-gradient(ellipse 58% 78% at 50% 100%, #000 18%, transparent 70%);
  mask-image: radial-gradient(ellipse 58% 78% at 50% 100%, #000 18%, transparent 70%);
  animation: mdi-floor 5s linear infinite;
  opacity: .85;
}
@keyframes mdi-floor { to { background-position: 0 52px, 0 0; } }

.mdi-float-chip {
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 10px;
  border: 1px solid rgba(220, 235, 205, .2);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(40, 50, 34, .82), rgba(16, 20, 14, .9));
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 1px rgba(255, 255, 255, .12);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  color: #eef3e7;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  transform: translate3d(calc(var(--hero-px, 0) * var(--d) * 1px), calc(var(--hero-py, 0) * var(--d) * .7px), 0);
  animation: mdi-bob 6s ease-in-out infinite;
  animation-delay: calc(var(--d) * -90ms);
}
.mdi-float-chip i {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: rgba(185, 255, 59, .14);
  color: var(--mdi-motion-lime);
  font-style: normal;
  font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(185, 255, 59, .3);
}
.mdi-float-chip small { display: block; margin-top: 2px; color: #9faa96; font-size: 10px; font-weight: 500; }
.mdi-chip-a { top: 36%; right: -2%; }
.mdi-chip-b { bottom: 9%; left: -5%; }
.mdi-chip-c { top: 66%; right: -3%; }
@keyframes mdi-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -9px; } }
@media (max-width: 1050px) and (min-width: 651px) {
  /* Single-column hero: keep the handwritten callout clear of the buttons. */
  .workspace-stage { margin-top: 26px; }
  .mdi-chip-a { right: 1%; } .mdi-chip-c { right: 0; } .mdi-chip-b { left: 0; }
}
@media (max-width: 650px) {
  .mdi-float-chip { display: none; }
  .mdi-depth-floor { bottom: -4%; height: 40%; }
}

/* ---- Cards: 3D tilt on hover ---- */
.mdi-tilt {
  transform:
    perspective(1000px)
    rotateX(var(--mdi-tilt-x, 0deg))
    rotateY(var(--mdi-tilt-y, 0deg))
    translateY(var(--mdi-lift, 0px)) !important;
  transition: transform .6s var(--mdi-ease-out), box-shadow .4s ease, border-color .3s ease !important;
}
.mdi-tilt.is-tilting { --mdi-lift: -6px; transition: transform .12s linear, box-shadow .4s ease, border-color .3s ease !important; }
.mdi-tilt.is-tilting:not(.principle-card-lime):not(.principle-card-orange) {
  border-color: rgba(185, 255, 59, .32);
  box-shadow: 0 28px 60px -24px rgba(0, 0, 0, .7), 0 0 0 1px rgba(185, 255, 59, .08), 0 18px 50px -30px rgba(185, 255, 59, .35);
}
.mdi-tilt.principle-card.is-tilting { box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .55); }

/* ---- Home journey: line runs through the stage dots ---- */
.journey-track::before,
.journey-track::after { top: var(--journey-line-y, 29px); }
@media (max-width: 650px) {
  .journey-track::before, .journey-track::after { top: var(--journey-line-y, 20px); }
}

/* ---- Founder Connect journey chart (v2): aligned, round dots, draws on view ---- */
.fc-chart-plot { position: relative; height: 142px; margin-top: 4px; }
.fc-chart-plot .fc-chart-svg { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; overflow: visible; }
.fc-chart-v2 .fc-chart-gridline { stroke: rgba(198, 218, 174, .1); stroke-width: 1; stroke-dasharray: 2 7; }
.fc-chart-stem { fill: none; stroke: rgba(185, 255, 59, .18); stroke-width: 1; stroke-dasharray: 2 4; }
.fc-chart-area2 { fill: url(#journeyArea2); }
.fc-chart-glow { fill: none; stroke: rgba(185, 255, 59, .35); stroke-width: 9; stroke-linecap: round; filter: blur(6px); }
.fc-chart-line { fill: none; stroke: url(#journeyLine2); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.fc-chart-plot .fc-chart-svg { clip-path: inset(-20px -2% -20px 0); animation: fc-plot-wipe 1.6s cubic-bezier(.22, .8, .25, 1) .15s both; }
@keyframes fc-plot-wipe { from { clip-path: inset(-20px 100% -20px 0); } }
.fc-chart-dot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #b9ff3b;
  border-radius: 50%;
  background: #141a10;
  box-shadow: 0 0 0 4px rgba(185, 255, 59, .08), 0 0 14px rgba(185, 255, 59, .35);
  animation: fc-dot-pop .5s cubic-bezier(.34, 1.56, .64, 1) calc(.3s + var(--i) * .32s) both;
}
.fc-chart-dot:first-of-type { background: #b9ff3b; }
.fc-chart-dot.is-goal { width: 18px; height: 18px; margin: -9px 0 0 -9px; background: #d9ff9a; border-color: #efffd2; }
.fc-chart-dot.is-goal::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(185, 255, 59, .55);
  border-radius: 50%;
  animation: fc-goal-ping 2.2s ease-out 1.8s infinite;
}
@keyframes fc-dot-pop { from { opacity: 0; scale: 0; } }
@keyframes fc-goal-ping { from { opacity: 1; scale: .6; } to { opacity: 0; scale: 1.9; } }
.fc-journey-card .fc-chart-stages { margin-top: 12px; }
@media (max-width: 720px) { .fc-chart-plot { height: 120px; } }

@media (prefers-reduced-motion: reduce) {
  .workspace-preview { transform: rotateY(-4deg); }
  .workspace-preview::after, .mdi-float-chip { display: none; }
  .mdi-depth-floor { animation: none; }
  .mdi-tilt { transform: none !important; }
  .fc-chart-plot .fc-chart-svg, .fc-chart-dot, .fc-chart-dot.is-goal::after { animation: none; }
}

/* Journey timeline (desktop/tablet): the dots and their line sit on the section's top green line. */
@media (min-width: 651px) {
  .journey-track { padding-top: 0; }
  .journey-step { display: flex; flex-direction: column; }
  .journey-step .step-node { order: -1; margin: -6px 0 18px; }
  .journey-step .step-index { margin-bottom: 14px; }
  .journey-track::before, .journey-track::after { top: -1px; }
}
