/* =========================================================================
   1AI TRADER — Couche « 21st » de l'accueil (additive, CSS)
     A. Fonctionnalités : cartes « dossiers » en verre dépoli, qui se redressent en 3D
     B. Grille bento (profils, signaux) : bordure lumineuse qui suit le curseur
     C. Aperçu du tableau de bord : cadre 3D qui se redresse au défilement + chandeliers
     D. « 4 étapes » : les cartes jaillissent du fond (tunnel 3D) au défilement
   Tout est posé par algo-21st.js (classes st21-*). Sans JS ou avec « réduire les animations » :
   le contenu reste visible et immobile. Clair / sombre / arabe (RTL, propriétés logiques).
   ========================================================================= */

/* ---------------------------------------------------------------- A. dossiers en verre */
.st21-persp { perspective: 1100px; }
.st21-folder {
  position: relative; isolation: isolate; overflow: visible;
  background: color-mix(in srgb, var(--algo-surface) 62%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  border-color: color-mix(in srgb, var(--algo-accent) 22%, var(--algo-border));
  border-start-start-radius: 6px;               /* coin du dossier côté onglet */
  transform-origin: 50% 100%;
}
.st21-tab {
  position: absolute; inset-block-start: -13px; inset-inline-start: 18px; z-index: -1;
  width: 74px; height: 14px; pointer-events: none;
  background: color-mix(in srgb, var(--algo-surface) 62%, transparent);
  border: 1px solid color-mix(in srgb, var(--algo-accent) 22%, var(--algo-border)); border-bottom: 0;
  border-radius: 10px 10px 0 0;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: background-color .3s ease, border-color .3s ease, transform .4s cubic-bezier(.16,1,.3,1);
}
.st21-sheen {
  position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; overflow: hidden;
}
.st21-sheen::before {
  content: ""; position: absolute; inset-block: -20%; inset-inline-start: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, color-mix(in srgb, #fff 34%, transparent), transparent);
  transform: skewX(-18deg); opacity: 0;
}
@media (hover: hover) {
  .st21-folder:hover .st21-tab {
    background: color-mix(in srgb, var(--algo-accent) 22%, var(--algo-surface));
    border-color: var(--algo-accent); transform: translateY(-3px);
  }
  .st21-folder:hover .st21-sheen::before { animation: st21-sheen 1s cubic-bezier(.16,1,.3,1) both; }
}
@keyframes st21-sheen { from { inset-inline-start: -60%; opacity: .9; } to { inset-inline-start: 130%; opacity: 0; } }

/* le dossier « s'assemble » : il se redresse depuis le bas quand il apparaît (réutilise .fx de algo-fx.js) */
html.fx-on .st21-folder { rotate: x 22deg; transition: opacity .7s cubic-bezier(.16,1,.3,1), transform .7s cubic-bezier(.16,1,.3,1), rotate .9s cubic-bezier(.16,1,.3,1); }
html.fx-on .st21-folder.fx-in { rotate: x 0deg; }

/* ---------------------------------------------------------------- B. bento + bordure lumineuse */
.st21-glow { position: relative; }
.st21-glow::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), var(--algo-accent), transparent 65%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .3s ease;
}
@media (hover: hover) { .st21-glow:hover::after { opacity: 1; } }

@media (min-width: 940px) {
  .st21-bento { grid-template-columns: 1.25fr 1fr; grid-auto-rows: 1fr; }
  .st21-bento > :first-child { grid-row: span 2; display: flex; flex-direction: column; justify-content: center; padding: clamp(28px, 3vw, 44px); }
  .st21-bento > :first-child .algo-card__icon { width: 72px; height: 72px; font-size: 2rem; }
  .st21-bento > :first-child h3 { font-size: 1.4rem; }
  .st21-bento > :first-child p { font-size: 1.05rem; }
}

/* ---------------------------------------------------------------- C. tableau de bord (aperçu illustratif) */
.st21-dash { perspective: 1300px; }
.st21-dash__frame {
  --p: 1;                                          /* 0 = couché, 1 = droit (posé par le JS) */
  position: relative; max-width: 980px; margin-inline: auto;
  border: 1px solid color-mix(in srgb, var(--algo-accent) 28%, var(--algo-border)); border-radius: 18px;
  background: color-mix(in srgb, var(--algo-surface) 88%, transparent);
  box-shadow: var(--algo-shadow-lg), 0 0 0 1px color-mix(in srgb, var(--algo-accent) 10%, transparent), 0 30px 80px -30px color-mix(in srgb, var(--algo-accent) 45%, transparent);
  transform-origin: 50% 0;
  transform: rotateX(calc((1 - var(--p)) * 26deg)) scale(calc(.92 + var(--p) * .08));
  will-change: transform;
}
.st21-dash__bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--algo-border); }
.st21-dash__bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--algo-border); }
.st21-dash__bar i:nth-child(1) { background: #ff5f57; } .st21-dash__bar i:nth-child(2) { background: #febc2e; } .st21-dash__bar i:nth-child(3) { background: #28c840; }
.st21-dash__bar small { margin-inline-start: auto; color: var(--algo-muted); font-size: .78rem; }
.st21-dash__body { display: grid; grid-template-columns: 170px 1fr; min-height: 340px; }
.st21-dash__side { padding: 14px; border-inline-end: 1px solid var(--algo-border); display: flex; flex-direction: column; gap: 6px; }
.st21-dash__side span { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 10px; font-size: .86rem; color: var(--algo-muted); }
.st21-dash__side span.is-on { background: var(--algo-accent-soft); color: var(--algo-accent); font-weight: 600; }
.st21-dash__main { position: relative; padding: 14px 16px 16px; min-width: 0; }
.st21-dash__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.st21-dash__head b { font-family: var(--algo-font-display); }
.st21-dash__ohlc { font-size: .78rem; color: var(--algo-muted); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.st21-dash__ohlc em { font-style: normal; color: var(--algo-ink); margin-inline-end: 8px; }
.st21-dash__plot { position: relative; direction: ltr; }
.st21-dash__plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.st21-up { fill: var(--algo-positive); stroke: var(--algo-positive); }
.st21-dn { fill: var(--algo-negative); stroke: var(--algo-negative); }
.st21-dash__plot line.st21-w { stroke-width: 1.2; }
.st21-lv text { font-size: 9px; fill: currentColor; }
.st21-lv--tp { color: var(--algo-positive); } .st21-lv--sl { color: var(--algo-negative); } .st21-lv--en { color: var(--algo-accent); }
.st21-lv line { stroke: currentColor; stroke-width: 1; stroke-dasharray: 5 4; opacity: .7; }
.st21-cross line { stroke: var(--algo-muted); stroke-width: .8; stroke-dasharray: 3 3; }
.st21-cross { opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.st21-dash__plot:hover .st21-cross { opacity: 1; }
.st21-sig { position: absolute; display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; transform: translate(-50%, -135%); pointer-events: none;
  background: color-mix(in srgb, var(--algo-positive) 18%, var(--algo-surface)); color: var(--algo-positive); border: 1px solid color-mix(in srgb, var(--algo-positive) 45%, transparent); }
.st21-dash__note { margin: 10px 0 0; font-size: .8rem; color: var(--algo-muted); text-align: center; }
/* les bougies se dessinent une à une quand le cadre est visible (JS pose .is-drawn) */
html.st21-js .st21-dash .st21-k { opacity: 0; transform: translateY(8px); transition: opacity .35s ease, transform .35s ease; transition-delay: calc(var(--i) * 22ms); }
html.st21-js .st21-dash.is-drawn .st21-k { opacity: 1; transform: none; }
@media (max-width: 720px) {
  .st21-dash__body { grid-template-columns: 1fr; }
  .st21-dash__side { flex-direction: row; overflow-x: auto; scrollbar-width: none; border-inline-end: 0; border-bottom: 1px solid var(--algo-border); }
  .st21-dash__side::-webkit-scrollbar { display: none; }
  .st21-lv text { font-size: 16px; }
  .st21-dash__note { margin-top: 30px; }
  .st21-dash__side span { white-space: nowrap; }
  .st21-dash__frame { transform: rotateX(calc((1 - var(--p)) * 14deg)); }
}

/* ---------------------------------------------------------------- D. tunnel 3D pour « 4 étapes » */
.st21-tunnel { position: relative; isolation: isolate; }
.st21-tunnel::before {                              /* anneaux qui convergent vers le fond */
  content: ""; position: absolute; inset: -10% 0; z-index: -1; pointer-events: none;
  background: repeating-radial-gradient(ellipse at 50% 55%, transparent 0 54px, color-mix(in srgb, var(--algo-accent) 14%, transparent) 55px 56px);
  -webkit-mask-image: radial-gradient(ellipse at 50% 55%, #000 0%, transparent 68%); mask-image: radial-gradient(ellipse at 50% 55%, #000 0%, transparent 68%);
  opacity: var(--tun, 0); transform: scale(calc(1.5 - var(--tun, 0) * .5));
}
.st21-tunnel .neo-steps { perspective: 1000px; }
.st21-tunnel .neo-step {
  translate: calc(var(--sx, 0) * (1 - var(--sp, 1)) * 1px) 0 calc(-520px * (1 - var(--sp, 1)));
  will-change: translate;
}
@media (max-width: 939px) { .st21-tunnel .neo-step { translate: 0 0 calc(-220px * (1 - var(--sp, 1))); } }

/* ---------------------------------------------------------------- réduire les animations */
@media (prefers-reduced-motion: reduce) {
  html.fx-on .st21-folder, html.fx-on .st21-folder.fx-in { rotate: none; transition: none; }
  .st21-sheen::before { animation: none !important; }
  .st21-tab { transition: none; }
  .st21-dash__frame { transform: none !important; }
  html.st21-js .st21-dash .st21-k { opacity: 1; transform: none; transition: none; }
  .st21-tunnel::before { transform: none; opacity: .5; }
  .st21-tunnel .neo-step { translate: none; }
}
