/* Act 2. The circuit sits beside the content, large and sticky, and the corner
   sections scroll past it. A corner is where a new section starts; the track
   between two corners is that section's contents, so a section with four
   projects simply occupies more of the lap than one with a single item.

   The car's travel and the corner markers are both derived from scroll
   position through this act, so they agree by construction. */

.lap { position: relative; z-index: 1; }



@media (min-width: 900px) {
  .lap {
    display: grid;
    grid-template-columns: minmax(0, 42fr) minmax(0, 58fr);
    gap: clamp(var(--sp-4), 2.5vw, 44px);
    align-items: start;
    padding-inline: clamp(var(--sp-4), 3vw, 48px);
  }
  .lap-track {
    position: sticky;
    top: var(--ses-h);
    height: calc(100svh - var(--ses-h));
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-bottom: var(--strip);
    z-index: 2;
  }
  .lap-body {
    position: sticky;
    top: var(--ses-h);
    height: calc(100svh - var(--ses-h) - var(--strip));
    overflow: hidden;
    display: flex;
    align-items: stretch;
    padding-block: var(--sp-3);
    z-index: 2;
    min-width: 0;
  }
  .placard-runway {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: clamp(var(--sp-4), 2.5vw, 36px);
    height: 100%;
    width: max-content;
    flex-shrink: 0;
    will-change: transform;
  }
  .lap-body .corner {
    flex: 0 0 clamp(520px, 52vw, 760px);
    width: clamp(520px, 52vw, 760px);
    max-width: clamp(520px, 52vw, 760px);
    height: 100%;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }
  .lap-body .corner-inner {
    width: 100%;
    margin-inline: 0;
    padding: clamp(var(--sp-4), 2.5vw, var(--sp-5));
    overflow-y: auto;
    scrollbar-width: thin;
    box-sizing: border-box;
    flex: 1;
  }

  .lap-body .corner::before,
  .lap-body .corner::after { display: none; }

  /* Soft track field over Monaco waters */
  .lap::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(100deg,
      rgba(11, 13, 16, 0) 0%,
      rgba(14, 11, 15, .20) 32%,
      rgba(18, 12, 18, .50) 58%,
      rgba(12, 14, 18, .75) 100%);
  }

  .lap-body .tower {
    grid-template-columns: 1fr;
    gap: clamp(var(--sp-4), 3vh, 36px);
  }
}

/* Narrow & Mobile Viewports: Native Vertical Flow */
@media (max-width: 899px) {
  .lap {
    height: auto !important;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    padding-inline: 0;
    position: relative;
    z-index: 1;
  }
  .lap-track {
    display: contents;
  }
  .tm {
    position: sticky;
    top: var(--ses-h, 28px);
    z-index: 40;
    width: 100%;
    max-width: min(230px, 74vw);
    margin: 0 auto;
    background: rgba(8, 11, 16, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-top: none;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
    padding: 2px 6px 2px;
    box-sizing: border-box;
    pointer-events: none;
  }
  .tm .tm-corner {
    pointer-events: auto;
  }
  .rc {
    width: 100%;
    max-width: min(560px, 94vw);
    margin: var(--sp-3) auto;
    padding-inline: var(--sp-2);
    box-sizing: border-box;
  }
  .lap-body {
    position: relative;
    height: auto;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    padding: var(--sp-2) var(--sp-2) var(--sp-6);
    box-sizing: border-box;
  }
  .placard-runway {
    display: flex;
    flex-direction: column;
    gap: clamp(var(--sp-5), 4vh, var(--sp-6));
    width: 100%;
    max-width: min(560px, 94vw);
    margin: 0 auto;
    transform: none !important;
    padding-inline: 0;
    box-sizing: border-box;
  }
  .lap-body .corner {
    flex: none;
    width: 100%;
    max-width: 100%;
    height: auto;
    overflow: visible;
    padding: 0;
    box-sizing: border-box;
    scroll-margin-top: calc(var(--ses-h, 28px) + 155px) !important;
  }
  .lap-body .corner-inner {
    width: 100%;
    max-width: 100%;
    padding: 0;
    overflow: visible;
    box-sizing: border-box;
  }
  .after-flag {
    width: 100%;
    max-width: min(560px, 94vw);
    margin: 0 auto;
    padding-inline: var(--sp-2);
    box-sizing: border-box;
  }
  .after-flag .corner {
    scroll-margin-top: calc(var(--ses-h, 28px) + 16px);
  }
}
