/* =========================================================
   ZAR WORKSPACE TUTORIAL
   Owns:
   - Empty left-workspace guidance
   - Tutorial card presentation
   - Separation from the right chat lane

   Does not own:
   - Chat output
   - MARSS dock
   - Floating scientific tools
========================================================= */

/* =========================================================
   WORKSPACE POSITIONING
========================================================= */

.sanity-guard-workspace {
  position: relative;
  isolation: isolate;
}

/*
  Keep the chat panel in its original position and size.
  The tutorial is absolutely positioned and therefore does
  not participate in this flex layout.
*/
.sanity-guard-workspace > .genebean_guard_panel {
  position: relative;
  z-index: 2;

  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* =========================================================
   TUTORIAL CARD
========================================================= */

.zar-workspace-tutorial {
  position: absolute;
  z-index: 3;

  /*
    Reserve the rightmost 920px for the chat lane.
    The left offset leaves room for the MARSS launcher.
  */
  left: clamp(100px, 8vw, 160px);
  right: calc(920px + 48px);
  top: 50%;

  width: min(520px, calc(100% - 40px));
  margin-inline: auto;
  padding: 28px 30px 26px;

  transform: translateY(-50%);

  border: 1px solid rgba(143, 212, 189, 0.15);
  border-radius: 24px;

  background:
    radial-gradient(
      circle at 16% 0%,
      rgba(143, 212, 189, 0.11),
      transparent 42%
    ),
    radial-gradient(
      circle at 92% 100%,
      rgba(104, 137, 235, 0.09),
      transparent 45%
    ),
    linear-gradient(
      155deg,
      rgba(14, 22, 35, 0.88),
      rgba(7, 11, 21, 0.94)
    );

  color: rgba(239, 245, 255, 0.94);

  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.30),
    0 0 45px rgba(98, 133, 225, 0.045),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);

  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);

  box-sizing: border-box;

  transition:
    opacity 220ms ease,
    visibility 220ms ease,
    transform 220ms ease;
}

/* Faint workspace illumination behind the card */
.zar-workspace-tutorial::before {
  content: "";
  position: absolute;
  z-index: -1;

  left: 50%;
  top: 50%;

  width: 135%;
  height: 145%;

  transform: translate(-50%, -50%);

  background:
    radial-gradient(
      ellipse at center,
      rgba(74, 105, 190, 0.075),
      transparent 66%
    );

  pointer-events: none;
}

/* =========================================================
   DISMISS BUTTON
========================================================= */

.zar-workspace-tutorial__dismiss {
  position: absolute;
  top: 14px;
  right: 14px;

  width: 30px;
  height: 30px;

  display: grid;
  place-items: center;

  padding: 0;

  border: 1px solid rgba(145, 164, 220, 0.15);
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.035);
  color: rgba(211, 222, 246, 0.68);

  font-size: 18px;
  line-height: 1;

  cursor: pointer;

  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.zar-workspace-tutorial__dismiss:hover {
  color: #ffffff;
  background: rgba(127, 181, 255, 0.10);
  border-color: rgba(127, 181, 255, 0.30);
  transform: rotate(4deg);
}

.zar-workspace-tutorial__dismiss:focus-visible {
  outline: 2px solid rgba(127, 181, 255, 0.72);
  outline-offset: 3px;
}

/* =========================================================
   CONTENT
========================================================= */

.zar-workspace-tutorial__eyebrow {
  margin: 0 42px 10px 0;

  color: rgba(143, 212, 189, 0.86);

  font-size: 0.68rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.zar-workspace-tutorial__title {
  margin: 0 42px 12px 0;

  color: rgba(242, 246, 255, 0.97);

  font-size: clamp(1.25rem, 1.6vw, 1.65rem);
  line-height: 1.18;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.zar-workspace-tutorial__description {
  max-width: 45ch;
  margin: 0 0 18px;

  color: rgba(201, 212, 236, 0.76);

  font-size: 0.9rem;
  line-height: 1.65;
}

/* =========================================================
   STEPS
========================================================= */

.zar-workspace-tutorial__steps {
  display: grid;
  gap: 10px;

  margin: 0 0 22px;
  padding: 0;

  list-style: none;
  counter-reset: zar-workspace-step;
}

.zar-workspace-tutorial__steps li {
  position: relative;

  min-height: 28px;
  padding-left: 40px;

  color: rgba(221, 229, 247, 0.84);

  font-size: 0.82rem;
  line-height: 1.55;

  counter-increment: zar-workspace-step;
}

.zar-workspace-tutorial__steps li::before {
  content: counter(zar-workspace-step);

  position: absolute;
  left: 0;
  top: 0;

  width: 27px;
  height: 27px;

  display: grid;
  place-items: center;

  border: 1px solid rgba(143, 212, 189, 0.20);
  border-radius: 9px;

  background:
    linear-gradient(
      180deg,
      rgba(31, 59, 68, 0.70),
      rgba(11, 24, 35, 0.82)
    );

  color: rgba(164, 225, 205, 0.92);

  font-size: 0.68rem;
  line-height: 1;
  font-weight: 800;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* =========================================================
   ACTIONS
========================================================= */

.zar-workspace-tutorial__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.zar-workspace-tutorial__action {
  min-height: 40px;
  padding: 10px 16px;

  border: 1px solid rgba(143, 212, 189, 0.25);
  border-radius: 13px;

  background:
    radial-gradient(
      circle at 50% 0%,
      rgba(143, 212, 189, 0.16),
      transparent 70%
    ),
    linear-gradient(
      180deg,
      rgba(27, 54, 63, 0.92),
      rgba(10, 24, 35, 0.96)
    );

  color: rgba(232, 249, 243, 0.96);

  font: inherit;
  font-size: 0.78rem;
  line-height: 1.2;
  font-weight: 750;

  cursor: pointer;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 10px 22px rgba(0, 0, 0, 0.20);

  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.zar-workspace-tutorial__action:hover {
  transform: translateY(-1px);
  border-color: rgba(143, 212, 189, 0.45);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 13px 27px rgba(0, 0, 0, 0.25),
    0 0 20px rgba(143, 212, 189, 0.09);
}

.zar-workspace-tutorial__action:focus-visible {
  outline: 2px solid rgba(143, 212, 189, 0.72);
  outline-offset: 3px;
}

.zar-workspace-tutorial__action--secondary {
  border-color: rgba(127, 181, 255, 0.19);

  background:
    linear-gradient(
      180deg,
      rgba(27, 38, 69, 0.76),
      rgba(10, 17, 34, 0.88)
    );

  color: rgba(209, 222, 252, 0.90);
}

.zar-workspace-tutorial__action--secondary:hover {
  border-color: rgba(127, 181, 255, 0.38);
}

/* =========================================================
   VISIBILITY STATES
========================================================= */

/* JavaScript can add this class after dismissal */
.zar-workspace-tutorial.is-dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(calc(-50% + 10px));
}

/*
  Hide the tutorial while any MARSS tool is active.
  This works with the existing dock state.
*/
body:has(.gb-marss-tool-btn.is-active)
.zar-workspace-tutorial {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(calc(-50% + 10px));
}

/* Do not allow the tutorial to block floating tools */
.gb-marss-dock-wrapper,
.gb-marss-slide-panel,
.file-reader-draggable,
.row-namer-draggable {
  position: fixed;
  z-index: 99970;
}

/* =========================================================
   RESPONSIVE SAFETY
========================================================= */

/*
  Below this width there is not enough separation between
  the left application workspace and the 920px chat lane.
*/
@media (max-width: 1380px) {
  .zar-workspace-tutorial {
    display: none;
  }
}

@media (max-height: 720px) {
  .zar-workspace-tutorial {
    top: 48%;
    padding: 20px 22px;
  }

  .zar-workspace-tutorial__description {
    margin-bottom: 12px;
  }

  .zar-workspace-tutorial__steps {
    gap: 6px;
    margin-bottom: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zar-workspace-tutorial,
  .zar-workspace-tutorial__dismiss,
  .zar-workspace-tutorial__action {
    transition: none;
  }
}

/* =========================================================
   ZAR WORKSPACE GUIDE — DRAGGABLE WRAPPER
========================================================= */

@media (min-width: 1381px) {
  .zar-workspace-guide {
    --zar-workspace-guide-drag-x: 0px;
    --zar-workspace-guide-drag-y: 0px;

    position: absolute;
    z-index: 3;

    left: clamp(100px, 8vw, 160px);
    right: calc(920px + 48px);
    top: 50%;

    width: min(520px, calc(100% - 40px));
    margin-inline: auto;

    transform:
      translate(
        var(--zar-workspace-guide-drag-x),
        calc(
          -50% +
          var(--zar-workspace-guide-drag-y)
        )
      );

    box-sizing: border-box;
    pointer-events: none;
    will-change: transform;
  }

  .zar-workspace-guide > * {
    pointer-events: auto;
  }

  /*
   * Position now belongs to the wrapper.
   * The card becomes ordinary content inside it.
   */
  .zar-workspace-guide .zar-workspace-tutorial {
    position: relative;

    left: auto;
    right: auto;
    top: auto;

    width: 100%;
    margin: 0;

    transform: none;
  }

  .zar-workspace-guide.is-collapsed {
    right: auto;
    width: 72px;
  }
}

/* =========================================================
   EXPANDED DRAG HANDLE
========================================================= */

.zar-workspace-tutorial__header {
  position: relative;
}

.zar-workspace-guide.is-draggable-ready
.zar-workspace-tutorial__header {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.zar-workspace-guide.is-dragging
.zar-workspace-tutorial__header {
  cursor: grabbing;
}

/* =========================================================
   COLLAPSED LAUNCHER
========================================================= */

.zar-workspace-guide__launcher[hidden],
.zar-workspace-tutorial[hidden] {
  display: none !important;
}

.zar-workspace-guide__launcher {
  width: 72px;
  min-height: 72px;

  display: grid;
  place-items: center;
  gap: 4px;

  padding: 10px 8px 8px;

  border: 1px solid rgba(143, 212, 189, 0.24);
  border-radius: 22px;

  background:
    radial-gradient(
      circle at 30% 10%,
      rgba(143, 212, 189, 0.18),
      transparent 52%
    ),
    radial-gradient(
      circle at 85% 90%,
      rgba(104, 137, 235, 0.15),
      transparent 48%
    ),
    linear-gradient(
      155deg,
      rgba(18, 30, 45, 0.97),
      rgba(7, 11, 22, 0.985)
    );

  color: rgba(155, 222, 202, 0.95);

  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.38),
    0 0 28px rgba(104, 137, 235, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);

  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);

  cursor: pointer;

  transition:
    color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.zar-workspace-guide__launcher:hover {
  color: #ffffff;
  border-color: rgba(143, 212, 189, 0.48);

  box-shadow:
    0 21px 48px rgba(0, 0, 0, 0.42),
    0 0 34px rgba(104, 137, 235, 0.17),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);

  transform: translateY(-1px);
}

.zar-workspace-guide__launcher:focus-visible {
  outline: 2px solid rgba(143, 212, 189, 0.75);
  outline-offset: 4px;
}

.zar-workspace-guide__launcher svg {
  display: block;
  filter:
    drop-shadow(
      0 0 8px rgba(143, 212, 189, 0.28)
    );
}

.zar-workspace-guide__launcher-label {
  color: rgba(211, 228, 238, 0.78);

  font-size: 0.58rem;
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-align: center;
}

/* =========================================================
   DRAG STATES
========================================================= */

.zar-workspace-guide-drag-handle {
  touch-action: none;
  user-select: none;
}

.zar-workspace-guide.is-dragging,
.zar-workspace-guide.is-dragging * {
  cursor: var(--zar-cursor-grabbing) !important;
}

.zar-workspace-guide.is-dragging {
  transition: none !important;
}

.zar-workspace-guide-drag-perimeter {
  position: absolute;
  inset: 0;

  display: block;

  pointer-events: none;
  z-index: 20;
}

.zar-workspace-guide-drag-perimeter__edge {
  position: absolute;

  pointer-events: auto;
  touch-action: none;

  background: transparent;
}

.zar-workspace-guide-drag-perimeter__edge--top {
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
}

.zar-workspace-guide-drag-perimeter__edge--right {
  top: 0;
  right: 0;
  bottom: 0;
  width: 10px;
}

.zar-workspace-guide-drag-perimeter__edge--bottom {
  right: 0;
  bottom: 0;
  left: 0;
  height: 10px;
}

.zar-workspace-guide-drag-perimeter__edge--left {
  top: 0;
  bottom: 0;
  left: 0;
  width: 10px;
}

/* Hide the entire guide during the active spotlight tour */
body.zar-workspace-tour-active
.zar-workspace-guide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Current mobile/tablet policy remains unchanged */
@media (max-width: 1380px) {
  .zar-workspace-guide {
    display: none;
  }
}