/* =====================================================================
   About page "How I Teach": the session as a 3D train ride
   (about.html [data-train-ride], js/train-ride.js)
   Without .is-live (no WebGL2, reduced motion, script failure) the six
   stops are ordinary cards in a grid. With .is-live the block becomes a
   tall scroll track with a sticky stage: the canvas fills it and one
   stop card shows at a time.
   ===================================================================== */
.tr-ride { --tr-lime: #c6ff3d; --tr-pink: #ff5ca8; position: relative; margin-top: 1.5rem; }
.tr-canvas, .tr-route, .tr-say, .tr-hint, .tr-loading, .tr-next { display: none; }

/* ---------- The words: one card per stop ---------- */
.tr-stops { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; text-align: left; }
.tr-stop {
  position: relative;
  padding: 1.25rem 1.3rem 1.2rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(16, 19, 34, .94), rgba(9, 11, 20, .96));
  border: 1px solid rgba(124, 77, 255, .45);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .5);
}
.tr-stop--intro, .tr-stop--end { display: none; }
.tr-step {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .7rem;
  padding: .32rem .7rem;
  border-radius: 999px;
  background: var(--tron-cyan, #5ee7ff);
  color: #06111a;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.tr-step i { font-style: normal; font-weight: 600; opacity: .75; }
.tr-stop h4 { margin: 0 0 .5rem; font-size: clamp(1.3rem, 2.4vw, 1.75rem); line-height: 1.15; color: #fff; }
.page-tron .tr-stop p { margin: 0; font-size: 1.02rem; line-height: 1.55; color: #cfd5ee; }
.tr-how { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .5rem; }
.page-tron .tr-how li { position: relative; padding-left: 1.5rem; font-size: .96rem; line-height: 1.45; color: #cfd5ee; }
.tr-how li::before { content: ''; position: absolute; left: 0; top: .32em; width: .8rem; height: .8rem; border-radius: 50%; background: var(--tron-cyan, #5ee7ff); box-shadow: 0 0 8px rgba(94, 231, 255, .6); }
.tr-how b { color: #fff; font-weight: 700; }
.tr-get { margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed rgba(94, 231, 255, .25); font-size: 1.02rem; font-weight: 700; line-height: 1.35; color: #fff; }
.tr-get span { display: block; margin-bottom: .2rem; font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--tr-lime); }
.tr-stop .btn { margin-top: 1rem; }

@media (max-width: 900px) { .tr-stops { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .tr-stops { grid-template-columns: 1fr; } }

/* ---------- Live ride ---------- */
.tr-ride.is-live {
  /* full width of the screen, whatever the section's own width is */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  height: 1300vh; /* 8 scenes x 150vh of scrolling, plus the stage itself */
  margin-top: 0;
}
.is-live .tr-sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
.is-live .tr-canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
/* soften the top and bottom edge of the stage into the page */
.is-live .tr-sticky::before,
.is-live .tr-sticky::after { content: ''; position: absolute; left: 0; right: 0; height: 90px; z-index: 1; pointer-events: none; }
.is-live .tr-sticky::before { top: 0; height: 190px; background: linear-gradient(180deg, var(--tron-bg, #070912) 30%, rgba(7, 9, 18, .82) 65%, transparent); }
.is-live .tr-sticky::after { bottom: 0; background: linear-gradient(0deg, var(--tron-bg, #070912), transparent); }

.is-live .tr-stops { display: block; position: absolute; z-index: 3; left: max(3vw, calc(50vw - 620px)); top: calc(50% + 46px); width: min(430px, 36vw); height: 0; }
.is-live .tr-stop,
.is-live .tr-stop--intro,
.is-live .tr-stop--end {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  transform: translateY(-50%) translateX(-26px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .45s ease, transform .55s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .45s;
  backdrop-filter: blur(6px);
}
.is-live .tr-stop.is-active { opacity: 1; visibility: visible; transform: translateY(-50%); transition-delay: .12s, .12s, 0s; }

/* Route: six stations along the top */
.is-live .tr-route {
  display: flex;
  position: absolute;
  z-index: 3;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  width: min(880px, 92vw);
  justify-content: space-between;
  align-items: flex-start;
}
.tr-route-line { position: absolute; left: 20px; right: 20px; top: 15px; height: 3px; border-radius: 3px; background: rgba(94, 231, 255, .2); }
.tr-route-line i { display: block; height: 100%; border-radius: 3px; background: var(--tr-lime); box-shadow: 0 0 10px rgba(198, 255, 61, .7); transform-origin: left center; transform: scaleX(0); }
.tr-route button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  width: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: #9fb0d6;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.tr-route button b {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0b0e1a;
  border: 2px solid rgba(94, 231, 255, .45);
  color: #cdefff;
  font-size: .9rem;
  transition: background .3s, border-color .3s, color .3s, transform .3s, box-shadow .3s;
}
.tr-route button.is-on b { background: var(--tr-lime); border-color: var(--tr-lime); color: #10131f; }
.tr-route button[aria-current] b { transform: scale(1.2); box-shadow: 0 0 18px rgba(198, 255, 61, .7); }
.tr-route button[aria-current] { color: #fff; }
.tr-route button:focus-visible { outline: 2px solid var(--tr-lime); outline-offset: 4px; border-radius: 8px; }

/* The conductor's speech bubble, pinned above his head by the script */
.is-live .tr-say {
  display: block;
  position: absolute;
  z-index: 2;
  left: 0;
  top: 0;
  margin: 0;
  max-width: min(260px, 60vw);
  padding: .55rem .9rem;
  border-radius: 16px 16px 16px 4px;
  background: #fff;
  color: #1b1f2a !important;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  transform: translate(var(--x, 50vw), max(70px, calc(var(--y, 50vh) - 100% - 6px)));
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
  will-change: transform;
}
.is-live .tr-say.is-in { opacity: 1; }
.is-live .tr-say.is-hidden { opacity: 0; }

.is-live .tr-hint {
  display: flex;
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  align-items: center;
  gap: .5rem;
  padding: .45rem .95rem;
  border-radius: 999px;
  background: rgba(11, 14, 26, .8);
  border: 1px solid rgba(94, 231, 255, .35);
  color: #eaf9ff;
  font-size: .9rem;
  font-weight: 700;
  transition: opacity .4s ease;
}
.tr-hint::after { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--tr-lime); border-bottom: 2px solid var(--tr-lime); transform: rotate(45deg) translateY(-2px); animation: tr-nudge 1.4s ease-in-out infinite; }
@keyframes tr-nudge { 50% { transform: rotate(45deg) translate(3px, 1px); } }
.tr-ride:not([data-stop="0"]) .tr-hint { opacity: 0; }
.is-live.is-loading .tr-loading {
  display: block;
  position: absolute;
  z-index: 3;
  right: 4vw;
  bottom: 26px;
  margin: 0;
  font-size: .85rem;
  font-weight: 600;
  color: #9fb0d6 !important;
}

/* Short laptop screens: tighten the card so it always fits under the route */
@media (min-width: 821px) and (max-height: 780px) {
  .is-live .tr-stop { padding: 1rem 1.1rem; }
  .tr-step { margin-bottom: .5rem; font-size: .72rem; }
  .tr-stop h4 { font-size: 1.3rem; margin-bottom: .35rem; }
  .page-tron .tr-stop p { font-size: .92rem; line-height: 1.45; }
  .tr-how { margin-top: .55rem; gap: .32rem; }
  .page-tron .tr-how li { font-size: .88rem; line-height: 1.38; padding-left: 1.25rem; }
  .tr-how li::before { width: .62rem; height: .62rem; top: .36em; }
  .tr-get { margin-top: .6rem; padding-top: .55rem; font-size: .94rem; }
  .tr-stop .btn { margin-top: .7rem; }
}
@media (min-width: 821px) and (max-height: 600px) {
  .is-live .tr-route { top: 76px; }
  .tr-route button span { display: none; }
  .is-live .tr-stops { top: calc(50% + 34px); }
}

/* Phones: the train rides across the top, the words sit at the bottom */
@media (max-width: 820px) { .tr-ride.is-live { height: 1220vh; } }
@media (max-width: 820px) and (min-height: 521px) {
  .is-live .tr-stops { left: 14px; right: 14px; top: auto; bottom: 14px; width: auto; }
  .is-live .tr-stop,
  .is-live .tr-stop--intro,
  .is-live .tr-stop--end { top: auto; bottom: 0; transform: translateY(20px); padding: 1.2rem 1.4rem 1.3rem; }
  .is-live .tr-stop.is-active { transform: none; }
  .is-live .tr-stop { max-height: 56svh; overflow-y: auto; }
  .tr-stop h4 { font-size: 1.3rem; }
  .page-tron .tr-stop p { font-size: .98rem; line-height: 1.5; }
  .tr-get { margin-top: .7rem; padding-top: .65rem; font-size: .98rem; }
  .tr-how { margin-top: .6rem; gap: .35rem; }
  .page-tron .tr-how li { font-size: .9rem; line-height: 1.38; padding-left: 1.25rem; }
  .tr-how li::before { width: .62rem; height: .62rem; top: .38em; }
  .is-live .tr-route { top: 78px; }
  .tr-route button span { display: none; }
  .tr-route button b { width: 28px; height: 28px; font-size: .82rem; }
  .tr-route-line { top: 13px; }
  .is-live .tr-say { font-size: .92rem; padding: .45rem .75rem; }
  .is-live .tr-hint { bottom: auto; top: 128px; }
  /* "Next" button just above the card (js/train-ride.js keeps --tr-card-h in step with it) */
  .is-live .tr-next {
    display: inline-flex; align-items: center; gap: .4rem;
    position: absolute; z-index: 4; left: 50%;
    bottom: calc(14px + var(--tr-card-h, 0px) + 12px);
    transform: translateX(-50%);
    padding: .6rem 1.05rem; border: 0; border-radius: 999px; cursor: pointer;
    font: 700 .82rem/1 'Satoshi', system-ui, sans-serif; letter-spacing: .04em; white-space: nowrap;
    color: #12141b; background: var(--tr-lime, #D8FF3E);
    box-shadow: 0 8px 22px -8px rgba(0, 0, 0, .6), 0 0 0 4px rgba(216, 255, 62, .18);
    transition: bottom .35s ease, opacity .3s ease;
  }
  .is-live .tr-next span { display: inline-block; animation: tr-next-bob 1.4s ease-in-out infinite; }
  .is-live .tr-next:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
  .is-live.is-loading .tr-next { opacity: 0; pointer-events: none; }
  /* the floating WhatsApp, back-to-top and Pixel step aside while the ride fills the screen */
  html.tr-in-ride .pp-wa,
  html.tr-in-ride .pp-top,
  html.tr-in-ride .pp-mascot { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }
  .is-live.is-loading .tr-loading { right: 12px; bottom: auto; top: 132px; }
}

/* Small and short (a phone on its side, a narrow preview pane): the words
   go in a compact card on the left so the train is never covered */
@media (max-width: 820px) and (max-height: 520px) {
  .is-live .tr-route { top: 74px; width: 94vw; }
  .tr-route button span { display: none; }
  .tr-route button b { width: 26px; height: 26px; font-size: .78rem; }
  .tr-route-line { top: 12px; }
  .is-live .tr-stops { left: 10px; top: auto; bottom: 10px; width: min(46vw, 320px); }
  .is-live .tr-stop,
  .is-live .tr-stop--intro,
  .is-live .tr-stop--end { top: auto; bottom: 0; transform: translateY(16px); padding: .7rem .8rem; max-height: calc(100svh - 122px); overflow-y: auto; }
  .is-live .tr-stop.is-active { transform: none; }
  .tr-step { font-size: .66rem; margin-bottom: .35rem; padding: .22rem .55rem; }
  .tr-stop h4 { font-size: 1.05rem; margin-bottom: .25rem; }
  .page-tron .tr-stop p { font-size: .8rem; line-height: 1.35; }
  .tr-how { margin-top: .4rem; gap: .22rem; }
  .page-tron .tr-how li { font-size: .78rem; line-height: 1.3; padding-left: 1rem; }
  .tr-how li::before { width: .5rem; height: .5rem; top: .36em; }
  .tr-get { margin-top: .4rem; padding-top: .4rem; font-size: .82rem; }
  .is-live .tr-hint { bottom: 8px; left: auto; right: 10px; transform: none; font-size: .78rem; }
  .is-live .tr-say { font-size: .8rem; padding: .35rem .6rem; }
}
@keyframes tr-next-bob { 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .is-live .tr-next span { animation: none; } }

/* Landing spot for "Ride the session train" on the homepage: clear of the fixed menu bar */
#train-ride { scroll-margin-top: 96px; }
