/* ============================================================
   K2 — Scène d'ouverture de l'accueil : « Dimanche, 22 h 47 ».
   Une cliente en panne, prise en charge par l'IA, en deux actes.
   Préfixe op- pour isoler du design system (app.css).
   ============================================================ */

.op {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 24px 70px;
  overflow: hidden;
}

/* ambiance nuit : voile sombre + halo lunaire */
.op-night {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(520px 320px at 78% 12%, rgba(154, 178, 255, .10), transparent 70%),
    radial-gradient(900px 600px at 50% 110%, rgba(255, 79, 216, .07), transparent 70%),
    linear-gradient(180deg, rgba(4, 5, 8, .78), rgba(4, 5, 8, .35) 40%, rgba(4, 5, 8, .82));
}

/* tout élément minuté est masqué tant que le scénario ne l'a pas révélé */
.op [data-t] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .55s ease, transform .55s cubic-bezier(.2,.7,.2,1);
}
.op [data-t].in { opacity: 1; transform: none; }

/* ---------- didascalie d'ouverture ---------- */
.op-context {
  position: relative;
  max-width: 640px;
  margin: 8px 0 16px;
  text-align: center;
  font-size: clamp(15px, 1.9vw, 19px);
  line-height: 1.65;
  color: #b8c1d1;
}
.op-context b { color: var(--txt); }
.op-context .op-time {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--accent);
}

/* ---------- scène centrale ---------- */
.op-stage {
  position: relative;
  width: 100%;
  max-width: 980px;
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 34px;
}

/* ---------- acte 1 : le téléphone de Julie ---------- */
.op-phone {
  width: min(352px, 92vw);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  overflow: hidden;
  position: relative;
  transition: opacity .55s ease, transform .7s cubic-bezier(.2,.7,.2,1);
}
.op-phone::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .8;
}
/* à l'acte 2, le téléphone s'écarte ; sur mobile il s'efface */
.op.act2 .op-phone { transform: translateX(-6%) scale(.96); opacity: .45; }

.op-phone-notch {
  width: 110px; height: 20px;
  margin: 10px auto 4px;
  border-radius: 999px;
  background: #0a0c10;
  border: 1px solid var(--line);
}
.op-phone-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.op-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.op-phone-head .t { font-size: 13.5px; font-weight: 600; }
.op-phone-head .s {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--accent);
}
.op-phone-body {
  padding: 12px 12px 14px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.op-sys {
  text-align: center;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--muted);
}

.op-bubble {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 15px;
  font-size: 12.5px;
  line-height: 1.42;
}
.op-julie {
  justify-self: end;
  background: #1a1f2a;
  border: 1px solid var(--line);
  border-bottom-right-radius: 5px;
}
.op-k2 {
  justify-self: start;
  background: color-mix(in srgb, var(--accent) 11%, #0a0c10 89%);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-bottom-left-radius: 5px;
}
.op-k2 b { color: var(--accent); }

/* suivi de la dépanneuse */
.op-tracker {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #0a0c10;
  padding: 11px 13px;
}
.op-tracker .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
}
.op-tracker .who { font-weight: 600; }
.op-tracker .eta {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--accent);
}
.op-road {
  position: relative;
  height: 4px;
  border-radius: 2px;
  margin-top: 10px;
  background: var(--line);
}
.op-road::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 12%;
  border-radius: 2px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 30%, transparent), var(--accent));
  transition: width 30s linear;
}
.op.play .op-road::before { width: 86%; }
.op-truck {
  position: absolute;
  top: 50%; left: 12%;
  transform: translate(-50%, -50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: #0a0c10;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
  transition: left 30s linear;
}
.op.play .op-truck { left: 86%; }

/* « en train d'écrire » : apparaît puis s'efface tout seul */
.op-typing {
  justify-self: start;
  display: inline-flex;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 15px;
  border-bottom-left-radius: 5px;
  background: color-mix(in srgb, var(--accent) 11%, #0a0c10 89%);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
}
.op-typing.me {
  justify-self: end;
  border-radius: 15px;
  border-bottom-right-radius: 5px;
  background: #1a1f2a;
  border-color: var(--line);
}
.op-typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: op-typing 1.1s ease-in-out infinite;
}
.op-typing.me i { background: var(--muted); }
.op-typing i:nth-child(2) { animation-delay: .18s; }
.op-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes op-typing {
  0%, 100% { opacity: .25; transform: translateY(0); }
  40%      { opacity: 1;   transform: translateY(-3px); }
}
.op-typing.gone { opacity: 0 !important; height: 0; padding: 0; border-width: 0; margin: -9px 0 0; overflow: hidden; }

.op-stamp {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--accent);
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  padding: 5px 12px;
  text-align: center;
}

/* ---------- acte 2 : l'appel de l'assistance ---------- */
/* absent du flux tant que l'acte 2 n'a pas commencé : le téléphone
   reste ainsi centré pendant tout l'acte 1 */
.op-call { display: none; }
.op.act2 .op-call { display: block; }
.op-call {
  width: min(440px, 92vw);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55);
  overflow: hidden;
  align-self: center;
  position: relative;
}
.op-call::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #2fe4ff, transparent);
  opacity: .8;
}
.op-call-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--muted);
}
.op-call-bar .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #2fe4ff;
  animation: con-pulse 1.8s infinite;
}
.op-call-bar .spacer { flex: 1; }
.op-call-bar .live { color: #2fe4ff; }

.op-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 34px;
  padding: 10px 14px 0;
}
.op-wave i {
  flex: 1;
  background: #2fe4ff;
  border-radius: 2px;
  opacity: .85;
  animation: wave 1s ease-in-out infinite;
}
.op-wave i:nth-child(odd) { animation-delay: .15s; }
.op-wave i:nth-child(3n)  { animation-delay: .3s; }
.op-wave i:nth-child(4n)  { animation-delay: .45s; }

.op-script {
  margin: 12px 14px;
  background: #0a0c10;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 15px;
  font-size: 13px;
  line-height: 1.6;
  min-height: 108px;
}
.op-script .who { color: #2fe4ff; font-weight: 600; }
.op-script .caret {
  display: inline-block;
  width: 8px; height: 14px;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: #2fe4ff;
  animation: op-caret .85s steps(1) infinite;
}
@keyframes op-caret { 50% { opacity: 0; } }
.op-call .op-stamp { display: flex; justify-content: center; margin: 0 14px 14px; color: #2fe4ff; border-color: rgba(47,228,255,.45); }

/* ---------- la chute ---------- */
.op-punch {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  text-align: center;
  padding: 24px;
  background: radial-gradient(60% 50% at 50% 45%, rgba(4, 5, 8, .92), rgba(4, 5, 8, .78));
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.op-punch.in { pointer-events: auto; }
.op-punch .big {
  max-width: 780px;
  margin: 0;
  font-size: clamp(26px, 4.6vw, 48px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.02em;
}
.op-punch .big em { font-style: normal; color: var(--accent); }
.op-punch .sub { margin: -10px 0 0; color: var(--muted); font-size: 15px; }

/* ---------- indice de défilement ---------- */
.op-scroll {
  position: absolute;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  width: 26px; height: 42px;
  border: 2px solid color-mix(in srgb, var(--muted) 60%, transparent);
  border-radius: 14px;
  z-index: 3;
}
.op-scroll span {
  position: absolute;
  top: 8px; left: 50%;
  width: 4px; height: 8px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--accent);
  animation: hx-scroll 1.8s ease-in-out infinite;
}

/* retour à zéro entre deux boucles : aucune transition ne doit se voir */
.op.reset [data-t],
.op.reset .op-phone { transition: none !important; }
.op.reset .op-road::before,
.op.reset .op-truck { transition: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .op { padding-bottom: 60px; }
  .op-stage { flex-direction: column; align-items: center; }
  .op-phone-body { min-height: 0; }
  .op.act2 .op-phone { display: none; }
}

/* ---------- mouvement réduit : scène posée, sans chorégraphie ---------- */
@media (prefers-reduced-motion: reduce) {
  .op [data-t] { opacity: 1; transform: none; transition: none; }
  .op-typing { display: none; }
  .op-road::before { width: 60%; transition: none; }
  .op-truck { left: 60%; transition: none; animation: none; }
  .op-wave i, .op-call-bar .dot, .op-scroll span { animation: none; }
  .op-punch { position: relative; inset: auto; background: none; backdrop-filter: none; padding: 34px 24px 0; pointer-events: auto; }
  .op-call { display: block; }
  .op.act2 .op-phone { transform: none; opacity: 1; }
}
