/* ────────────────────────────────────────────────────────────────
 *  SIERA Avatar Widget styles
 * ──────────────────────────────────────────────────────────────── */

#siera-avatar-container { position: fixed; z-index: 99999; }

/* Width of the docked lesson rail. siera-avatar.js sets the live value from the
   tutor's mode, the viewport and the curriculum sidebar; this is a fallback. */
:root { --siera-dock-width: 400px; }

/* ── Floating launcher pill ──────────────────────────────────── */
#siera-avatar-toggle {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px 11px 12px;
  background: linear-gradient(135deg, #1e7a6e, #00b4a0);
  color: #fff;
  border: none;
  border-radius: 40px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s;
  z-index: 100000;
}
#siera-avatar-toggle:hover  { transform: translateY(-2px); box-shadow: 0 9px 28px rgba(0,0,0,0.34); }
#siera-avatar-toggle:active { transform: translateY(0); }
#siera-avatar-toggle .siera-toggle-icon {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.18);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 15px;
}
/* Hide the launcher while the panel is open */
#siera-avatar-container.siera-open #siera-avatar-toggle { opacity: 0; pointer-events: none; }

/* ── Avatar panel ────────────────────────────────────────────── */
#siera-avatar-panel {
  box-sizing: border-box;
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 400px;
  height: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 40px);
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease, width 0.28s ease, height 0.28s ease;
}
#siera-avatar-container.siera-open #siera-avatar-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Give conversation mode enough height before dividing it into internal rows. */
#siera-avatar-container.siera-conversation-open #siera-avatar-panel {
  height: min(840px, calc(100dvh - 40px));
}
/* Conversation open: use a wider panel where space permits. */
#siera-avatar-container.siera-wide #siera-avatar-panel {
  width: 740px;
  max-width: calc(100vw - 32px);
}
#siera-avatar-container.siera-transcript-expanded #siera-avatar-panel {
  width: 1008px;
  height: calc(100dvh - 40px);
  max-width: calc((100vw - 64px) * .9);
  max-height: calc(100dvh - 40px);
}

/* With room to spare, SIERA docks as a rail at the right edge and the page
   gives up exactly that width instead of being covered. Full height on an
   ordinary page; below the lesson popup's own header inside a lesson. */
#siera-avatar-container.siera-docked #siera-avatar-panel {
  /* siera-avatar.js measures whatever is pinned above (the lesson popup's own
     header, the admin bar) so the rail starts exactly at its lower edge —
     a hard-coded offset left a sliver of page showing above the panel. */
  top: var(--siera-dock-top, 0px);
  right: 0;
  bottom: 0;
  width: var(--siera-dock-width);
  height: auto;
  max-width: none;
  max-height: none;
  border-radius: 0;
  border-width: 0 0 0 1px;
  box-shadow: -18px 0 44px rgba(0, 0, 0, 0.34);
}

/* The page element that yields the rail's width (siera-avatar.js picks it:
   the lesson columns in a lesson, the block layout everywhere else). */
.siera-dock-host {
  transition: margin-right .28s ease;
}
body.siera-widget-docked .siera-dock-host,
/* The lesson theme sets `#popup-content { margin: 0 !important }`, which an id
   selector wins on specificity — name the ids too or the lesson ignores the
   rail and runs underneath it. */
body.siera-widget-docked #popup-content.siera-dock-host,
body.siera-widget-docked #popup-footer.siera-dock-host {
  margin-right: var(--siera-dock-width) !important;
}
/* Animate the lesson both when SIERA docks and when she leaves, and keep the
   column auto-width so the margin narrows it instead of pushing it off-screen. */
body.viewing-course-item #popup-content,
body.viewing-course-item #popup-footer {
  transition: margin-left .3s ease, margin-right .28s ease, max-width .3s ease !important;
}
body.siera-widget-docked #popup-content,
body.siera-widget-docked #popup-footer {
  width: auto !important;
}

#siera-avatar-frame-host { flex: 1 1 auto; min-height: 0; }
#siera-avatar-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Before the conversation opens, a full-height rail would stretch SIERA down
   the whole column. Bound the tutor and centre it in the rail instead — the
   panel and the tutor share a background, so the rail still reads as one piece. */
#siera-avatar-container.siera-docked:not(.siera-conversation-open) #siera-avatar-frame-host {
  display: flex;
  align-items: center;
}
#siera-avatar-container.siera-docked:not(.siera-conversation-open) #siera-avatar-iframe {
  /* The tutor's chrome is a fixed ~210px, so the portrait absorbs this bound:
     525px frames her about 10% smaller than the 560px this started at. */
  max-height: 525px;
}

/* ── Reading marker while SIERA tutors a passage ──────────────────
   A rail down the passage she is reading (positioned by siera-avatar.js),
   with the rest of the lesson dimmed so the eye lands in the right place.
   Both are dropped the moment the walkthrough stops. */
#siera-reading-marker {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  border-left: 4px solid #00F2FF;
  border-radius: 4px 12px 12px 4px;
  background: linear-gradient(90deg, rgba(0, 242, 255, 0.10), rgba(0, 242, 255, 0.02) 45%, transparent 75%);
  box-shadow: -2px 0 20px rgba(0, 242, 255, 0.35);
  animation: siera-marker-in 0.35s ease;
  transition: top 0.3s ease, left 0.3s ease, width 0.3s ease, height 0.3s ease;
}
.siera-reading-marker__cap {
  position: absolute;
  top: -9px;
  left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #0B1322;
  box-shadow: 0 0 0 1px rgba(0, 242, 255, 0.35);
  color: #7FECFF;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}
@keyframes siera-marker-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: none; }
}
body.siera-reading [data-siera-dim] {
  opacity: 0.3 !important;
  transition: opacity 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  #siera-reading-marker { animation: none; transition: none; }
  body.siera-reading [data-siera-dim] { transition: none; }
}

/* ── Inline lesson launcher ──────────────────────────────────── */
.siera-inline-toggle { margin: 0 0 14px; }
#siera-inline-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: linear-gradient(135deg, #1e7a6e, #00b4a0);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
#siera-inline-toggle-btn:hover { opacity: 0.9; }

/* ── Mobile: panel fills the screen ──────────────────────────── */
@media (max-width: 520px) {
  #siera-avatar-panel,
  #siera-avatar-container.siera-conversation-open #siera-avatar-panel,
  #siera-avatar-container.siera-transcript-expanded #siera-avatar-panel {
    right: 0; bottom: 0; top: 0; left: 0;
    width: 100vw; height: 100dvh;
    max-width: 100vw; max-height: 100dvh;
    border-radius: 0;
  }
  #siera-avatar-toggle { right: 16px; bottom: 16px; }
}

/* "Help me solve this" on practice problems: only where SIERA is on the page. */
.sls-siera-help { display: none; }
.siera-available .sls-siera-help {
  display: inline-flex; align-items: center; gap: .35rem;
  margin: .45rem 0 .2rem; padding: .32rem .8rem;
  font: 600 .82rem/1.2 inherit; letter-spacing: .01em;
  color: #0b1220; background: #5eead4; border: 0; border-radius: 999px; cursor: pointer;
}
.siera-available .sls-siera-help:hover,
.siera-available .sls-siera-help:focus-visible { background: #99f6e4; outline: 2px solid #99f6e4; outline-offset: 2px; }
