/* ============================================================
   ENROLL LANDING — CARD LOOPS (home only, driven by feature-loops.js)
   ------------------------------------------------------------
   Method after Stageshow by Benji Taylor (https://benji.org/stageshow).
   .loop is a scene. Its parts carry data-part and turn .is-on when
   the script reaches them; the cursor aims at data-at elements.
   .lp parts start hidden once the script runs (.is-live), so without
   JS or with reduced motion every card reads as its final frame.

   1. Engine: scene, parts, cursor, shared states
   2. Platform: chat, requests, letter, knowledge base
   3. Guardrails and How it works
   ============================================================ */

:root {
  --done-ink: #15803d;
  --done-bg: #ecfdf3;
  --done-border: #c9f0d6;
  --placeholder: #efece7;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── 1. Engine ─────────────────────────────────────────────── */
.loop {
  transition: opacity 0.4s ease;
}

.loop.is-resetting {
  opacity: 0;
}

/* Anything the script or the cursor changes eases between states */
.loop [data-at],
.loop [data-part] {
  transition:
    background 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease,
    opacity 0.3s ease,
    transform 0.12s ease;
}

.loop.is-live .lp {
  transition:
    opacity 0.35s ease,
    transform 0.35s var(--ease-out);
}

.loop.is-live .lp:not(.is-on) {
  opacity: 0;
  transform: translateY(8px);
}

.is-pressed {
  transform: scale(0.95);
}

.loop-cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  width: 24px;
  height: 24px;
  opacity: 0;
  pointer-events: none;
  transform-origin: 5px 3px;
  transition: opacity 0.25s ease;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

.loop-cursor path {
  fill: #fff;
  stroke: var(--black);
}

.loop-cursor.is-on {
  opacity: 1;
}

/* Two labels in one place: the second replaces the first when its owner turns .is-on */
.swap {
  display: inline-grid;
}

.swap > span {
  grid-area: 1 / 1;
  transition: opacity 0.3s ease;
}

.swap > span + span,
.is-on > .swap > span:first-child {
  opacity: 0;
}

.is-on > .swap > span + span {
  opacity: 1;
}

/* A number that rolls: the old value leaves upward, the new one comes from below */
.roll {
  display: inline-grid;
  overflow: hidden;
  font-weight: 600;
}

.roll > span {
  grid-area: 1 / 1;
  transition:
    transform 0.5s var(--ease-out),
    opacity 0.3s ease;
}

.roll > span + span,
.roll.is-on > span:first-child {
  opacity: 0;
  transform: translateY(100%);
}

.roll.is-on > span:first-child {
  transform: translateY(-100%);
}

.roll.is-on > span + span {
  opacity: 1;
  transform: none;
}

.count {
  font-variant-numeric: tabular-nums;
}

/* Button the cursor presses; .is-on is its done state */
.loop-btn {
  flex: none;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--black);
}

/* Done: one green state shared by buttons, tags and badges */
.loop-btn.is-on,
.gi-btn--yes.is-on,
.ib-policy-tag.is-on,
.ib-live.is-on {
  color: var(--done-ink);
  background: var(--done-bg);
  border-color: var(--done-border);
}

.loop-btn--muted.is-on {
  color: var(--ink-soft);
  background: var(--grey);
}

/* White product surface floating on the dark panel */
.inbox,
.kb-page {
  background: #fff;
  border: 1px solid var(--border);
  box-shadow:
    0 18px 44px rgba(11, 11, 11, 0.08),
    0 1px 3px rgba(11, 11, 11, 0.04);
}

/* Placeholder line: text the story does not need */
.ph {
  display: block;
  width: 92%;
  height: 7px;
  border-radius: 4px;
  background: var(--placeholder);
}

.ph--short {
  width: 58%;
}

.ph--mid {
  width: 74%;
}

/* ── 2. Platform ───────────────────────────────────────────── */

/* 01 chat: feed on top, composer at the bottom */
.feature-ui--chat.loop {
  min-height: 360px;
  justify-content: space-between;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  font-size: 13.5px;
  color: var(--black);
}

.chat-status-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.chat-composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  border: 1px solid #e7e4df;
  border-radius: 12px;
  font-size: 14px;
}

.chat-draft {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #a19c95;
}

.chat-draft.is-on {
  color: var(--black);
}

.chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #fff;
  background: var(--black);
}

.chat-send svg {
  width: 14px;
  height: 14px;
}

/* 02 requests: new rows push in from the top, the oldest slide out below */
.inbox {
  max-width: 460px;
  height: 330px;
  padding: 14px 14px 0;
  gap: 0;
  border-radius: 16px;
  overflow: hidden;
}

.inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 12px;
  border-bottom: 1px solid #ece9e4;
}

.inbox-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
}

.inbox-tab {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--grey);
}

.inbox-list {
  flex: 1;
  overflow: hidden;
  mask-image: linear-gradient(180deg, #000 70%, transparent);
}

.inbox-row {
  display: grid;
  grid-template-rows: 1fr;
  transition:
    grid-template-rows 0.5s var(--ease-out),
    opacity 0.4s ease;
}

.inbox.is-live .inbox-row:not(.is-on) {
  grid-template-rows: 0fr;
  opacity: 0;
}

.inbox-row-in {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  padding: 0 4px;
  border-bottom: 1px solid #f1eee9;
}

.inbox-row-in > * {
  margin: 11px 0;
}

.inbox-src {
  flex: none;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.inbox-q {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  color: var(--black);
}

/* Spinner and result share one cell; the row's .is-done swaps them */
.inbox-status {
  flex: none;
  display: grid;
  justify-items: end;
  font-size: 12px;
}

.inbox-status > span {
  grid-area: 1 / 1;
  transition: opacity 0.3s ease;
}

.inbox-pending {
  align-self: center;
  width: 14px;
  height: 14px;
  border: 1.6px solid #d6d2cc;
  border-top-color: var(--black);
  border-radius: 50%;
  opacity: 0;
  animation: inbox-spin 0.8s linear infinite;
}

.inbox.is-live .inbox-row:not(.is-done) .inbox-pending {
  opacity: 1;
}

.inbox.is-live .inbox-row:not(.is-done) .inbox-done {
  opacity: 0;
}

.inbox-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 4px;
  border-radius: var(--radius-pill);
  color: var(--done-ink);
  background: var(--done-bg);
  white-space: nowrap;
}

.inbox-done img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
}

.inbox-done--routed {
  color: var(--black);
  background: var(--lin-mid);
}

.inbox-done--routed img {
  border-radius: 50%;
  object-fit: cover;
}

@keyframes inbox-spin {
  to {
    transform: rotate(360deg);
  }
}

/* 03 letter: written line by line, then a toast under it */
.loop.is-live .letter:not(.is-writing) .letter-line {
  clip-path: inset(0 100% 0 0);
}

.feature-ui--letter.loop {
  gap: 14px;
}

.loop-toast {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--black);
  background: #fff;
  box-shadow: 0 8px 24px rgba(11, 11, 11, 0.12);
}

.loop-toast img {
  width: 16px;
  height: 16px;
}

/* 04 knowledge base: a policy page; the HR reply and Enroll's suggestion straddle it */
.kb {
  max-width: 440px;
  padding: 44px 0 64px;
}

.kb-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
  border-radius: 12px;
}

.kb-page-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--black);
}

.kb-page-head img {
  width: 18px;
  height: 18px;
}

.kb-line {
  margin: 2px 0;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.kb-old {
  transition:
    color 0.3s ease,
    text-decoration-color 0.3s ease;
  color: var(--black);
  font-weight: 600;
  text-decoration: line-through transparent;
}

.kb-line:has(.kb-new.is-on) .kb-old {
  color: #a19c95;
  font-weight: 400;
  text-decoration-color: currentcolor;
}

.kb-new {
  display: inline-block;
  padding: 0 5px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--black);
  background: var(--celadon);
}

.kb-stamp {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}

.kb-stamp img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.kb-reply,
.kb-suggest {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e7e4df;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--black);
  box-shadow: 0 12px 32px rgba(11, 11, 11, 0.14);
}

.kb-reply {
  top: 0;
  right: -12px;
  width: 80%;
}

.kb-suggest {
  bottom: 0;
  left: -16px;
  width: 86%;
}

.kb-avatar {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.kb-reply-body,
.kb-suggest-body {
  flex: 1;
  min-width: 0;
}

.kb-reply-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.kb-reply-name img {
  width: 12px;
  height: 12px;
}

/* ── 3. Guardrails and How it works ────────────────────────── */

/* Approvals: once approved, Deny steps aside and the HRIS line turns green */
.gi-approval-btns.is-on .gi-btn:not(.gi-btn--yes) {
  opacity: 0;
}

.gi-then.is-on {
  color: var(--done-ink);
  font-weight: 500;
}

/* Escalations: the employee's question on top of the flow */
.gi-chip--ask {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

.gi-chip--ask img {
  width: 14px;
  height: 14px;
}

/* Permissioning: the row under the cursor shows its scope */
.gi-access-scope {
  transition: color 0.3s ease;
}

.gi-access li.is-on {
  background: var(--section-bg);
}

.gi-access li.is-on .gi-access-scope {
  color: var(--black);
}

/* How it works: the status dot follows the done state */
.ib-policy-tag::before,
.ib-live::before {
  transition: background 0.3s ease;
}

.ib-policy-tag.is-on::before,
.ib-live.is-on::before {
  background: #2f9e57;
}

/* How it works: a ticket in the customer's tool, then Enroll's own requests view */
.tk,
.rq {
  position: relative;
  box-sizing: border-box;
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  padding: 16px 16px 20px;
  border-radius: 14px 14px 0 0;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow:
    0 18px 44px rgba(11, 11, 11, 0.1),
    0 1px 3px rgba(11, 11, 11, 0.04);
}

.tk-head,
.rq-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid #ece9e4;
  font-size: 13px;
}

.tk-tool,
.rq-head img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 4px;
}

.tk-tool-name,
.rq-title {
  flex: 1;
  font-weight: 600;
  color: var(--black);
}

.tk-id,
.rq-tab {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--grey);
}

.tk-title {
  margin: 14px 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--black);
}

.tk-meta {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.tk-meta div {
  display: flex;
  align-items: center;
}

.tk-meta dt {
  width: 92px;
  color: var(--muted);
}

.tk-meta dd {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--black);
}

.tk-meta dd img {
  width: 16px;
  height: 16px;
}

.tk-status,
.rq-status {
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--grey);
  white-space: nowrap;
}

.tk-status.is-on,
.rq-status.is-on,
.rq-status--done {
  color: var(--done-ink);
  background: var(--done-bg);
  border-color: var(--done-border);
}

.tk-reply {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 10px;
  background: var(--section-bg);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--black);
}

.tk-avatar {
  flex: none;
  width: 22px;
  height: 22px;
}

.tk-reply-name {
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}

.rq-row {
  display: flex;
  align-items: center;
  gap: 10px;
  max-height: 60px;
  padding: 11px 4px;
  border-bottom: 1px solid #f1eee9;
  font-size: 13px;
  transition:
    max-height 0.5s var(--ease-out),
    padding 0.5s var(--ease-out),
    opacity 0.4s ease;
}

.rq.is-live .rq-row--new:not(.is-on) {
  max-height: 0;
  padding-block: 0;
  opacity: 0;
  overflow: hidden;
}

.rq-src {
  flex: none;
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.rq-q {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--black);
}

.rq-owner {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 72px;
  font-size: 12px;
  color: var(--ink-soft);
}

.rq-owner img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: cover;
}

@media (max-width: 480px) {
  .rq-owner {
    display: none;
  }

  .inbox-q {
    white-space: normal;
  }

  .kb {
    padding: 72px 0 80px;
  }

  .kb-reply {
    right: -6px;
    width: 88%;
  }

  .kb-suggest {
    left: -6px;
    width: 94%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .inbox-pending {
    animation: none;
  }
}
