/* ===========================================================================
   AI LEARN — röstcoach · widget-stilar
   Bygger på tokens.css. Lugn paper/purple-estetik som resten av sajten.
   =========================================================================== */

/* ---- Launcher (centrerad, frostad, med pratbubbla) --------------------- */
.coach-launch-wrap {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.coach-launch-wrap.coach-hide { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(12px); }
/* När cookie-bannern visas: lyft launchern ovanför den (annars täcker bannern,
   z-index 9400, knappen och fångar klicken). Höjden mäts i forms.js. */
body.has-cookie-bar .coach-launch-wrap { bottom: calc(var(--cookie-bar-h, 96px) + 16px); transition: bottom .24s var(--ease-standard), opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }

/* pratbubbla med nedåtpil — uppmanar att testa */
.coach-bubble {
  position: relative;
  pointer-events: none;             /* dekorativ — stjäl aldrig knappens klickyta */
  max-width: 340px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.80);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-raised);
  color: var(--ink-700);
  font-size: var(--text-base);
  line-height: 1.45;
  text-align: center;
  animation: coachBubblePulse 2.8s var(--ease-standard) 1s infinite;
}
.coach-bubble b { color: var(--purple-700); font-weight: 600; }
.coach-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 9px solid rgba(255, 255, 255, 0.72);
  filter: drop-shadow(0 2px 1px rgba(26, 26, 31, 0.06));
}
@keyframes coachBubblePulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-3px) scale(1.04); }
}

.coach-launch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px 13px 18px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--purple-700);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-float);
  transition: transform var(--dur-base) var(--ease-out), background var(--dur-fast) var(--ease-standard);
}
.coach-launch:hover { background: var(--purple-800); transform: translateY(-2px); }
.coach-launch:focus-visible { outline: 2px solid var(--purple-300); outline-offset: 3px; }
.coach-launch .cl-pulse {
  width: 9px; height: 9px; border-radius: 50%;
  background: #7bdcb5; box-shadow: 0 0 0 0 rgba(123, 220, 181, 0.7);
  animation: coachPulse 2.4s var(--ease-standard) infinite;
}
.coach-launch .cl-ic { display: inline-flex; }
@keyframes coachPulse {
  0% { box-shadow: 0 0 0 0 rgba(123, 220, 181, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(123, 220, 181, 0); }
  100% { box-shadow: 0 0 0 0 rgba(123, 220, 181, 0); }
}

/* ---- Launcher-flare: större, exklusiv lila glow + roterande ljusstrimma --- */
@property --coach-flare { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.coach-launch {
  position: relative;
  padding: 16px 32px 16px 26px;   /* större — syns tydligare */
  font-size: 16px;
  box-shadow: 0 10px 28px rgba(101, 53, 139, 0.40);
  animation: coachGlow 3.6s var(--ease-standard) infinite;
}
/* roterande gradient-ring (mask → bara den 2px tunna kanten lyser) */
.coach-launch::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(from var(--coach-flare),
    rgba(217, 194, 239, 0) 0deg, rgba(217, 194, 239, 0) 170deg,
    var(--purple-300) 250deg, #ffffff 300deg, var(--purple-200) 332deg,
    rgba(217, 194, 239, 0) 360deg);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  animation: coachFlare 3.6s linear infinite;
}
@keyframes coachFlare { to { --coach-flare: 360deg; } }
@keyframes coachGlow {
  0%, 100% { box-shadow: 0 10px 28px rgba(101, 53, 139, 0.38), 0 0 16px 1px rgba(138, 91, 176, 0.30); }
  50%      { box-shadow: 0 14px 36px rgba(101, 53, 139, 0.55), 0 0 30px 6px rgba(138, 91, 176, 0.55); }
}
@media (prefers-reduced-motion: reduce) {
  .coach-launch { animation: none; }
  .coach-launch::before { animation: none; opacity: 0.6; }
}

/* Klickyta: HELA launchern öppnar coachen (data-coach-launch sitter på wrappen),
   så inget lager — bubbla, flare-ring eller glow — kan stjäla klicket. Wrappen är
   klickbar som vanligt; `.coach-hide` (rad ovan) stänger av den när coachen är öppen. */

/* ---- Dock (kompakt, frostat kort — likt sidans hero-kort) ------------- */
.coach-dock {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px) scale(0.98);
  transform-origin: bottom center;
  z-index: 9001;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.coach-dock.open { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

.coach-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-float);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* identitet */
.coach-card .coach-row { display: flex; align-items: center; gap: 13px; }
.coach-card .coach-av {
  position: relative; width: 44px; height: 44px; flex: 0 0 auto; overflow: hidden;
  display: grid; place-items: center; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-500), var(--purple-800));
  color: #fff; font-family: var(--font-hand); font-size: 24px; font-weight: 700;
}
.coach-card .coach-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.coach-card .coach-id { min-width: 0; }
.coach-card .coach-id .cn { font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); color: var(--ink-900); line-height: 1.1; }
.coach-card .coach-id .cr { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-400); margin-top: 3px; }

.coach-x {
  position: absolute; top: 10px; right: 10px;
  width: 28px; height: 28px; border: none; background: transparent;
  color: var(--ink-400); font-size: 22px; line-height: 1; cursor: pointer; border-radius: var(--radius-md);
}
.coach-x:hover { background: rgba(26, 26, 31, 0.06); color: var(--ink-700); }

/* status-pills: LYSSNAR / TALAR / VÄNTAR */
.coach-pills { display: flex; gap: 7px; }
.coach-pill {
  flex: 1; text-align: center; padding: 8px 0; border-radius: var(--radius-pill);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .12em;
  color: var(--ink-400); background: rgba(255, 255, 255, 0.5); border: 1px solid var(--line);
  transition: all var(--dur-base) var(--ease-standard);
}
.coach-pill.on.p-listen { background: var(--purple-700); color: #fff; border-color: transparent; }
.coach-pill.on.p-talk   { background: var(--forest-500); color: #fff; border-color: transparent; }
.coach-pill.on.p-wait   { background: var(--clay-300); color: var(--ink-900); border-color: transparent; }

/* mic-meter (grön när hon hör dig) */
.coach-meter { display: flex; align-items: flex-end; gap: 3px; height: 24px; }
.coach-meter span { flex: 1; min-height: 4px; border-radius: 2px; background: var(--purple-200); transition: height 90ms linear, background 120ms; }

/* mute-knapp (öppen mic) */
.coach-ptt {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px; border: none; border-radius: var(--radius-pill);
  background: var(--purple-700); color: var(--white);
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 600;
  cursor: pointer; user-select: none;
  transition: background var(--dur-fast) var(--ease-standard);
}
.coach-ptt:hover:not(:disabled) { background: var(--purple-800); }
.coach-ptt:focus-visible { outline: 2px solid var(--purple-300); outline-offset: 3px; }
.coach-ptt.muted { background: var(--ink-300); }
.coach-ptt.muted:hover:not(:disabled) { background: var(--ink-400); }
.coach-ptt:disabled { opacity: 0.5; cursor: default; }
.coach-ptt .ptt-ic { display: inline-flex; }

.coach-err { margin: 0; text-align: center; font-size: var(--text-xs); color: var(--rose-700); }

/* samtyckesgrind (visas innan sessionen startar) */
/* explicit display nedan vinner annars över [hidden] → tvinga bort när dold */
.coach-consent[hidden], .coach-live[hidden] { display: none !important; }
.coach-consent { display: flex; flex-direction: column; gap: 14px; }
.cc-text { margin: 0; font-size: var(--text-sm); line-height: 1.55; color: var(--ink-600); }
.cc-text b { color: var(--ink-900); font-weight: 600; }
.cc-text a { color: var(--purple-700); }
.cc-actions { display: flex; flex-direction: column; gap: 6px; }
.cc-decline { display: block; width: 100%; border: none; background: transparent; color: var(--ink-500); font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 500; cursor: pointer; padding: 13px; min-height: 44px; border-radius: var(--radius-md); }
.cc-decline:hover { color: var(--ink-700); background: rgba(26, 26, 31, 0.05); }

/* ---- Bokningspanel ----------------------------------------------------- */
.coach-booking { position: fixed; inset: 0; z-index: 9500; display: grid; place-items: center; padding: 16px; }
.coach-booking[hidden] { display: none; }
.cb-scrim { position: absolute; inset: 0; background: rgba(26, 26, 31, 0.5); opacity: 0; transition: opacity var(--dur-base) var(--ease-standard); backdrop-filter: blur(2px); }
.coach-booking.open .cb-scrim { opacity: 1; }
.cb-card {
  position: relative; z-index: 1; width: min(720px, 94vw); height: min(760px, 88vh);
  display: flex; flex-direction: column; background: var(--white);
  border-radius: var(--radius-2xl); box-shadow: var(--shadow-float); overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(0.985);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.coach-booking.open .cb-card { opacity: 1; transform: translateY(0) scale(1); }
.cb-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cb-head h3 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); color: var(--ink-900); }
.cb-x { width: 32px; height: 32px; border: none; background: transparent; color: var(--ink-400); font-size: 24px; line-height: 1; cursor: pointer; border-radius: var(--radius-md); }
.cb-x:hover { background: var(--line-soft); color: var(--ink-700); }
.cb-body { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cb-cta { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cb-cta span { font-size: var(--text-xs); color: var(--ink-500); }
.cb-frame { flex: 1 1 auto; width: 100%; height: 100%; border: 0; min-height: 360px; }
.cb-fallback { margin: 0; padding: 10px 18px; text-align: center; font-size: var(--text-xs); color: var(--ink-500); border-top: 1px solid var(--line); }
.cb-fallback a { color: var(--purple-700); }
.cb-soon { margin: auto; padding: 40px; text-align: center; max-width: 42ch; }
.cb-soon p { color: var(--ink-600); line-height: var(--leading-normal); margin-bottom: 18px; }

/* ---- Highlight-puls på scrollade sektioner ----------------------------- */
.coach-target-pulse { animation: coachTarget 1.3s var(--ease-out); }
@keyframes coachTarget {
  0% { box-shadow: inset 0 0 0 9999px rgba(101, 53, 139, 0.07); }
  100% { box-shadow: inset 0 0 0 9999px rgba(101, 53, 139, 0); }
}

/* ---- Mobil ------------------------------------------------------------- */
@media (max-width: 560px) {
  .coach-launch-wrap { bottom: 14px; }
  .coach-bubble { max-width: 80vw; }
  .coach-dock { bottom: 14px; width: calc(100vw - 24px); max-height: calc(100vh - 28px); }
}

/* ---- Reduce motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .coach-launch .cl-pulse, .coach-bubble { animation: none; }
  .coach-dock, .cb-card, .cb-scrim, .coach-meter span { transition: none; }
  .coach-target-pulse { animation: none; }
}
