/* ==========================================================
   BEARING AI — Motion sections (homepage)
   Two self-contained pieces. To remove either one, delete its
   block below, its markup in index.html and its JS file.
     1. Compass rose (hero)     -> js/motion-rose.js
     2. "No loose ends" thread  -> js/motion-thread.js
   ========================================================== */


/* ----------------------------------------------------------
   1. COMPASS ROSE (hero photo)
   A large, faint rose centred on the hero photo, behind the
   text card. Absolutely positioned, so it takes no space and
   causes no layout shift.

   To make it stronger, fainter, bigger or move it, change these:
---------------------------------------------------------- */
.hero {
  --rose-line:          #FFFFFF;
  --rose-line-opacity:  0.30;
  --rose-north:         var(--c-accent);  /* the one hint of colour */
  --rose-north-opacity: 0.45;
  --rose-size:          115%;             /* of the photo's width */
  --rose-x:             50%;              /* centre, across the photo */
  --rose-y:             50%;              /* centre, down the photo */

  overflow: hidden;
}

/* The frame covers the photo and crops the rose to it. */
.hero-rose {
  position: absolute;
  inset: 0;
  z-index: 0;                 /* the text card (z-index 1) sits above it */
  overflow: hidden;
  pointer-events: none;
}

.hero-rose__svg {
  position: absolute;
  left: var(--rose-x);
  top: var(--rose-y);
  width: var(--rose-size);
  height: auto;
  aspect-ratio: 1;
  max-width: none;
  /* Percentage margins are measured against the frame's width, as is the
     size, so these centre the rose on its x/y point. */
  margin-left: calc(var(--rose-size) / -2);
  margin-top:  calc(var(--rose-size) / -2);
  overflow: visible;
  transform: rotate(-30deg);          /* load position; script swings it to north */
  will-change: transform;
}

.hero-rose__lines {
  fill: none;
  stroke: var(--rose-line);
  stroke-opacity: var(--rose-line-opacity);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.hero-rose__lines * { vector-effect: non-scaling-stroke; }

.hero-rose__north {
  fill: var(--rose-north);
  fill-opacity: var(--rose-north-opacity);
  stroke: none;
}

/* Mobile: the photo becomes a 220px strip above the text (set in the
   homepage's inline styles), so the frame matches that strip. */
@media (max-width: 768px) {
  .hero { --rose-line-opacity: 0.38; }
  .hero-rose { bottom: auto; height: 220px; }
}

/* Reduced motion: settled on north, no movement. */
@media (prefers-reduced-motion: reduce) {
  .hero-rose__svg { transform: none !important; will-change: auto; }
}


/* ----------------------------------------------------------
   2. "NO LOOSE ENDS" THREAD (stages, problem cards, why cards)
   One row of boxes: the thread runs along a rail above them.
   Several rows: it runs along each row, turning down the side.
   One column (mobile): it runs down the left.
   The rail space is reserved in CSS, not added by script.
---------------------------------------------------------- */
/* Reserve the rail. Above the boxes while they sit in rows,
   down the left once they stack into one column. Each group stacks
   at a different width, so each has its own breakpoint below. */
.has-thread {
  position: relative;
  padding-top: 1.75rem;
}

.thread {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  overflow: visible;
  pointer-events: none;
}

.thread__line {
  fill: none;
  stroke: var(--c-accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thread__marker {
  fill: var(--c-bg-alt);
  stroke: var(--c-accent);
  stroke-width: 1.5;
  stroke-opacity: 0.45;
  transition: fill 0.3s ease, stroke-opacity 0.3s ease;
}

/* Hollow markers match the section behind them. */
.has-thread--why .thread__marker { fill: var(--c-bg); }

.thread__marker.is-reached,
.has-thread--why .thread__marker.is-reached {
  fill: var(--c-accent);
  stroke-opacity: 1;
}

/* The final solid dot, centred on the end of the line. Grows in on arrival. */
.thread__end {
  fill: var(--c-accent);
  stroke: none;
  opacity: 0;
  transform: scale(0.3);
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.25s ease, transform 0.3s ease;
}
.thread__end.is-reached,
.has-thread--why .thread__end.is-reached { fill: var(--c-accent); opacity: 1; transform: scale(1); }

@media (max-width: 768px) {
  .has-thread--stages,
  .has-thread--why {
    padding-top: 0;
    padding-left: 1.75rem;
  }
}

/* The three problem cards go to two columns at tablet width and
   one column only below 480px. */
@media (max-width: 479px) {
  .has-thread--problems {
    padding-top: 0;
    padding-left: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thread__marker,
  .thread__end { transition: none; }
  .thread__end { transform: none; }
}
