/* ==========================================================================
   FinRadar — home-story.css
   Visuels du récit (constat, signaux, étapes). Tokens only.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Constat — 400 contrats, un point chacun. Le balayage passe, sept
   s'allument : les signaux de la semaine. Visuel conceptuel, donc sombre.
   -------------------------------------------------------------------------- */
.portfolio {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: var(--portfolio-max);
  margin-inline: auto;
  padding: var(--space-5);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-xl);
  background-color: var(--c-bg-raised);
  background-image: var(--g-card);
  box-shadow: var(--shadow-inset), var(--shadow-lg);
}

.portfolio__head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  max-width: none;
  font-size: var(--fs-ui-sm);
  color: var(--c-text-muted);
}

.portfolio__head strong {
  color: var(--c-text);
}

.portfolio__grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  grid-template-rows: repeat(20, 1fr);
  aspect-ratio: 1;
  overflow: hidden;
  background-image: radial-gradient(circle, rgb(var(--rgb-text) / 0.22) 1.5px, transparent 2px);
  background-size: 5% 5%;
}

/* Le balayage : visible seulement pendant son passage. */
.portfolio__grid::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 18%;
  border-bottom: 1px solid var(--c-mint);
  background-image: linear-gradient(transparent, rgb(var(--rgb-accent) / 0.22));
  opacity: 0;
}

.portfolio__dot {
  width: 8px;
  height: 8px;
  place-self: center;
  border-radius: var(--radius-pill);
  background-color: var(--c-accent-light);
  box-shadow: 0 0 0 4px rgb(var(--rgb-accent) / 0.2), 0 0 16px var(--c-accent);
}

.portfolio__dot:nth-child(1) { grid-area: 3 / 4; }
.portfolio__dot:nth-child(2) { grid-area: 5 / 15; }
.portfolio__dot:nth-child(3) { grid-area: 8 / 9; }
.portfolio__dot:nth-child(4) { grid-area: 11 / 18; }
.portfolio__dot:nth-child(5) { grid-area: 14 / 3; }
.portfolio__dot:nth-child(6) { grid-area: 16 / 12; }
.portfolio__dot:nth-child(7) { grid-area: 19 / 7; }

/* Le risque de la semaine : le seul point ambre. */
.portfolio__dot--warn {
  background-color: var(--c-warn);
  box-shadow: 0 0 0 4px rgb(var(--rgb-warn) / 0.2), 0 0 16px var(--c-warn);
}

.portfolio__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  font-size: var(--fs-ui-sm);
  color: var(--c-text-muted);
}

.portfolio__key {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.portfolio__key::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background-color: var(--c-accent-light);
  box-shadow: 0 0 8px var(--c-accent);
}

.portfolio__key--warn::before {
  background-color: var(--c-warn);
  box-shadow: 0 0 8px var(--c-warn);
}

/* --------------------------------------------------------------------------
   Opportunité — le client, puis l'établissement qui pousse en dessous
   -------------------------------------------------------------------------- */
.tree {
  gap: var(--space-5);
}

/* Retrait = marge de ligne + demi-avatar + coude : le coude part du centre
   de l'avatar parent, quelle que soit la densité. */
.tree__new {
  position: relative;
  margin-left: calc(var(--ui-gap) + var(--space-6));
}

/* Le coude qui relie l'établissement à sa maison mère. */
.tree__new::before {
  content: '';
  position: absolute;
  top: calc(-1 * var(--space-5) - 1px);
  left: calc(-1 * var(--space-4) - 1px);
  width: var(--space-4);
  height: calc(50% + var(--space-5));
  border-bottom: 2px solid var(--c-accent);
  border-left: 2px solid var(--c-accent);
  border-bottom-left-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Risque — l'annonce BODACC tamponnée, et ce qu'elle expose
   -------------------------------------------------------------------------- */
.notice {
  position: relative;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.notice__head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--fs-ui-xs);
  color: var(--c-ink-muted);
}

.notice__src {
  font-weight: var(--fw-heavy);
  letter-spacing: 0.06em;
  color: var(--c-ink);
}

.notice__lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notice__lines span {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background-color: var(--c-panel-line);
}

.notice__lines span:nth-child(2) {
  width: 80%;
}

.notice__lines span:nth-child(3) {
  width: 52%;
}

/* Incliné par rotate, que l'animation (transform) ne touche pas. */
.notice__stamp {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-3);
  padding: var(--space-1) var(--space-2);
  border: 2px solid var(--c-warn-ink);
  border-radius: var(--radius-xs);
  background-color: var(--c-panel-raised);
  color: var(--c-warn-ink);
  font-size: var(--fs-ui-xs);
  font-weight: var(--fw-heavy);
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  rotate: -7deg;
}

/* --------------------------------------------------------------------------
   Étape 1 — les comptes se branchent, interrupteur par interrupteur.
   État final : branché ; l'animation part d'un interrupteur éteint.
   -------------------------------------------------------------------------- */
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  border-radius: var(--radius-pill);
  background-color: var(--c-accent);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-pill);
  background-color: var(--c-panel-raised);
  box-shadow: 0 1px 3px rgb(var(--rgb-bg) / 0.3);
  transform: translateX(14px);
}

/* --------------------------------------------------------------------------
   Étape 2 — la ligne de relevé brute devient un contrat
   -------------------------------------------------------------------------- */
.raw {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  overflow: hidden;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background-color: var(--c-ink);
  color: rgb(var(--rgb-panel) / 0.85);
  font-family: var(--ff-mono);
  font-size: var(--fs-ui-xs);
  white-space: nowrap;
}

.raw__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.raw__amount {
  color: var(--c-mint);
}

/* Le faisceau de lecture, rangé hors champ une fois la ligne lue. */
.raw::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(90deg, transparent, rgb(var(--rgb-mint) / 0.4), transparent);
  transform: translateX(100%);
}

.extract__arrow {
  align-self: center;
  color: var(--c-ink-faint);
}

.contract {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.contract__field {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-2) var(--ui-gap);
  border: 1px solid var(--c-panel-line);
  border-radius: var(--radius-sm);
  background-color: var(--c-panel-raised);
  box-shadow: var(--shadow-ui);
}

.contract__key {
  font-size: var(--fs-ui-xs);
  color: var(--c-ink-muted);
}

.contract__value {
  overflow: hidden;
  font-size: var(--fs-ui-sm);
  font-weight: var(--fw-bold);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.contract__field--accent {
  border-color: var(--c-accent);
}

.contract__field--accent .contract__value {
  color: var(--c-ink-accent);
}

/* --------------------------------------------------------------------------
   Trois colonnes — le visuel déborde sur la marge de la carte, le texte la
   garde : les lignes gardent la place de leurs noms.
   -------------------------------------------------------------------------- */
@media (min-width: 1080px) {
  .feature .mockup {
    margin: calc(var(--space-3) - var(--card-pad)) calc(var(--space-3) - var(--card-pad)) 0;
  }
}

/* --------------------------------------------------------------------------
   Mouvement — les gestes propres à ces scènes, joués une fois quand la
   carte apparaît. Chaque délai place l'élément dans le récit de sa scène.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .portfolio__grid::after {
    animation: scan-y 3.2s linear 0.3s both;
  }

  .portfolio__dot {
    animation: dot-lit var(--dur-in) var(--ease-out) both;
  }

  .portfolio__dot:nth-child(1) { animation-delay: 0.6s; }
  .portfolio__dot:nth-child(2) { animation-delay: 0.85s; }
  .portfolio__dot:nth-child(3) { animation-delay: 1.25s; }
  .portfolio__dot:nth-child(4) { animation-delay: 1.65s; }
  .portfolio__dot:nth-child(5) { animation-delay: 2.05s; }
  .portfolio__dot:nth-child(6) { animation-delay: 2.3s; }
  .portfolio__dot:nth-child(7) { animation-delay: 2.7s; }

  .notice__stamp {
    animation: stamp 0.5s var(--ease-out) 0.7s both;
  }

  .switch {
    animation: switch-on 0.4s var(--ease-out) 0.6s both;
  }

  .row:nth-child(2) .switch {
    animation-delay: 1s;
  }

  .row:nth-child(3) .switch {
    animation-delay: 1.4s;
  }

  .switch::after {
    animation: knob-on 0.4s var(--ease-out) both;
    animation-delay: inherit;
  }

  .raw::after {
    animation: scan-x 0.9s var(--ease-out) 0.4s both;
  }
}

/* Le balayage descend une fois la grille, puis s'efface. */
@keyframes scan-y {
  0% { opacity: 1; transform: translateY(-100%); }
  90% { opacity: 1; transform: translateY(555%); }
  100% { opacity: 0; transform: translateY(555%); }
}

@keyframes dot-lit {
  0% { opacity: 0; transform: scale(0.4); }
  50% { opacity: 1; transform: scale(1.6); }
}

/* Le tampon tombe de haut et s'écrase sur l'annonce. */
@keyframes stamp {
  from { opacity: 0; transform: scale(1.8); }
}

@keyframes switch-on {
  from { background-color: var(--c-panel-line); }
}

@keyframes knob-on {
  from { transform: none; }
}

@keyframes scan-x {
  from { transform: translateX(-100%); }
}
